intc2.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Interrupt handling for INTC2-based IRQ.
  3. *
  4. * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
  5. * Copyright (C) 2005, 2006 Paul Mundt (lethal@linux-sh.org)
  6. *
  7. * May be copied or modified under the terms of the GNU General Public
  8. * License. See linux/COPYING for more information.
  9. *
  10. * These are the "new Hitachi style" interrupts, as present on the
  11. * Hitachi 7751, the STM ST40 STB1, SH7760, and SH7780.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/irq.h>
  15. #include <linux/io.h>
  16. #include <asm/system.h>
  17. static void disable_intc2_irq(unsigned int irq)
  18. {
  19. struct intc2_data *p = get_irq_chip_data(irq);
  20. ctrl_outl(1 << p->msk_shift,
  21. INTC2_BASE + INTC2_INTMSK_OFFSET + p->msk_offset);
  22. }
  23. static void enable_intc2_irq(unsigned int irq)
  24. {
  25. struct intc2_data *p = get_irq_chip_data(irq);
  26. ctrl_outl(1 << p->msk_shift,
  27. INTC2_BASE + INTC2_INTMSKCLR_OFFSET + p->msk_offset);
  28. }
  29. static struct irq_chip intc2_irq_chip = {
  30. .name = "INTC2",
  31. .mask = disable_intc2_irq,
  32. .unmask = enable_intc2_irq,
  33. .mask_ack = disable_intc2_irq,
  34. };
  35. /*
  36. * Setup an INTC2 style interrupt.
  37. * NOTE: Unlike IPR interrupts, parameters are not shifted by this code,
  38. * allowing the use of the numbers straight out of the datasheet.
  39. * For example:
  40. * PIO1 which is INTPRI00[19,16] and INTMSK00[13]
  41. * would be: ^ ^ ^ ^
  42. * | | | |
  43. * { 84, 0, 16, 0, 13 },
  44. *
  45. * in the intc2_data table.
  46. */
  47. void make_intc2_irq(struct intc2_data *table, unsigned int nr_irqs)
  48. {
  49. int i;
  50. for (i = 0; i < nr_irqs; i++) {
  51. unsigned long ipr, flags;
  52. struct intc2_data *p = table + i;
  53. disable_irq_nosync(p->irq);
  54. /* Set the priority level */
  55. local_irq_save(flags);
  56. ipr = ctrl_inl(INTC2_BASE + INTC2_INTPRI_OFFSET +
  57. p->ipr_offset);
  58. ipr &= ~(0xf << p->ipr_shift);
  59. ipr |= p->priority << p->ipr_shift;
  60. ctrl_outl(ipr, INTC2_BASE + INTC2_INTPRI_OFFSET +
  61. p->ipr_offset);
  62. local_irq_restore(flags);
  63. set_irq_chip_and_handler_name(p->irq, &intc2_irq_chip,
  64. handle_level_irq, "level");
  65. set_irq_chip_data(p->irq, p);
  66. enable_intc2_irq(p->irq);
  67. }
  68. }