irq.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * linux/arch/sh/boards/se/7722/irq.c
  3. *
  4. * Copyright (C) 2007 Nobuhiro Iwamatsu
  5. *
  6. * Hitachi UL SolutionEngine 7722 Support.
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/irq.h>
  14. #include <linux/interrupt.h>
  15. #include <asm/irq.h>
  16. #include <asm/io.h>
  17. #include <mach-se/mach/se7722.h>
  18. static void disable_se7722_irq(unsigned int irq)
  19. {
  20. unsigned int bit = irq - SE7722_FPGA_IRQ_BASE;
  21. ctrl_outw(ctrl_inw(IRQ01_MASK) | 1 << bit, IRQ01_MASK);
  22. }
  23. static void enable_se7722_irq(unsigned int irq)
  24. {
  25. unsigned int bit = irq - SE7722_FPGA_IRQ_BASE;
  26. ctrl_outw(ctrl_inw(IRQ01_MASK) & ~(1 << bit), IRQ01_MASK);
  27. }
  28. static struct irq_chip se7722_irq_chip __read_mostly = {
  29. .name = "SE7722-FPGA",
  30. .mask = disable_se7722_irq,
  31. .unmask = enable_se7722_irq,
  32. .mask_ack = disable_se7722_irq,
  33. };
  34. static void se7722_irq_demux(unsigned int irq, struct irq_desc *desc)
  35. {
  36. unsigned short intv = ctrl_inw(IRQ01_STS);
  37. struct irq_desc *ext_desc;
  38. unsigned int ext_irq = SE7722_FPGA_IRQ_BASE;
  39. intv &= (1 << SE7722_FPGA_IRQ_NR) - 1;
  40. while (intv) {
  41. if (intv & 1) {
  42. ext_desc = irq_desc + ext_irq;
  43. handle_level_irq(ext_irq, ext_desc);
  44. }
  45. intv >>= 1;
  46. ext_irq++;
  47. }
  48. }
  49. /*
  50. * Initialize IRQ setting
  51. */
  52. void __init init_se7722_IRQ(void)
  53. {
  54. int i;
  55. ctrl_outw(0, IRQ01_MASK); /* disable all irqs */
  56. ctrl_outw(0x2000, 0xb03fffec); /* mrshpc irq enable */
  57. for (i = 0; i < SE7722_FPGA_IRQ_NR; i++)
  58. set_irq_chip_and_handler_name(SE7722_FPGA_IRQ_BASE + i,
  59. &se7722_irq_chip,
  60. handle_level_irq, "level");
  61. set_irq_chained_handler(IRQ0_IRQ, se7722_irq_demux);
  62. set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW);
  63. set_irq_chained_handler(IRQ1_IRQ, se7722_irq_demux);
  64. set_irq_type(IRQ1_IRQ, IRQ_TYPE_LEVEL_LOW);
  65. }