kn02-irq.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * linux/arch/mips/dec/kn02-irq.c
  3. *
  4. * DECstation 5000/200 (KN02) Control and Status Register
  5. * interrupts.
  6. *
  7. * Copyright (c) 2002, 2003, 2005 Maciej W. Rozycki
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/irq.h>
  16. #include <linux/types.h>
  17. #include <asm/dec/kn02.h>
  18. /*
  19. * Bits 7:0 of the Control Register are write-only -- the
  20. * corresponding bits of the Status Register have a different
  21. * meaning. Hence we use a cache. It speeds up things a bit
  22. * as well.
  23. *
  24. * There is no default value -- it has to be initialized.
  25. */
  26. u32 cached_kn02_csr;
  27. static int kn02_irq_base;
  28. static inline void unmask_kn02_irq(unsigned int irq)
  29. {
  30. volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
  31. KN02_CSR);
  32. cached_kn02_csr |= (1 << (irq - kn02_irq_base + 16));
  33. *csr = cached_kn02_csr;
  34. }
  35. static inline void mask_kn02_irq(unsigned int irq)
  36. {
  37. volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
  38. KN02_CSR);
  39. cached_kn02_csr &= ~(1 << (irq - kn02_irq_base + 16));
  40. *csr = cached_kn02_csr;
  41. }
  42. static void ack_kn02_irq(unsigned int irq)
  43. {
  44. mask_kn02_irq(irq);
  45. iob();
  46. }
  47. static void end_kn02_irq(unsigned int irq)
  48. {
  49. if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  50. unmask_kn02_irq(irq);
  51. }
  52. static struct irq_chip kn02_irq_type = {
  53. .typename = "KN02-CSR",
  54. .ack = ack_kn02_irq,
  55. .mask = mask_kn02_irq,
  56. .mask_ack = ack_kn02_irq,
  57. .unmask = unmask_kn02_irq,
  58. .end = end_kn02_irq,
  59. };
  60. void __init init_kn02_irqs(int base)
  61. {
  62. volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
  63. KN02_CSR);
  64. int i;
  65. /* Mask interrupts. */
  66. cached_kn02_csr &= ~KN02_CSR_IOINTEN;
  67. *csr = cached_kn02_csr;
  68. iob();
  69. for (i = base; i < base + KN02_IRQ_LINES; i++)
  70. set_irq_chip_and_handler(i, &kn02_irq_type, handle_level_irq);
  71. kn02_irq_base = base;
  72. }