kn02-irq.c 1.8 KB

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