irq.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. unsigned int se7722_fpga_irq[SE7722_FPGA_IRQ_NR] = { 0, };
  19. static void disable_se7722_irq(unsigned int irq)
  20. {
  21. unsigned int bit = (unsigned int)get_irq_chip_data(irq);
  22. ctrl_outw(ctrl_inw(IRQ01_MASK) | 1 << bit, IRQ01_MASK);
  23. }
  24. static void enable_se7722_irq(unsigned int irq)
  25. {
  26. unsigned int bit = (unsigned int)get_irq_chip_data(irq);
  27. ctrl_outw(ctrl_inw(IRQ01_MASK) & ~(1 << bit), IRQ01_MASK);
  28. }
  29. static struct irq_chip se7722_irq_chip __read_mostly = {
  30. .name = "SE7722-FPGA",
  31. .mask = disable_se7722_irq,
  32. .unmask = enable_se7722_irq,
  33. .mask_ack = disable_se7722_irq,
  34. };
  35. static void se7722_irq_demux(unsigned int irq, struct irq_desc *desc)
  36. {
  37. unsigned short intv = ctrl_inw(IRQ01_STS);
  38. unsigned int ext_irq = 0;
  39. intv &= (1 << SE7722_FPGA_IRQ_NR) - 1;
  40. for (; intv; intv >>= 1, ext_irq++) {
  41. if (!(intv & 1))
  42. continue;
  43. generic_handle_irq(se7722_fpga_irq[ext_irq]);
  44. }
  45. }
  46. /*
  47. * Initialize IRQ setting
  48. */
  49. void __init init_se7722_IRQ(void)
  50. {
  51. int i, irq;
  52. ctrl_outw(0, IRQ01_MASK); /* disable all irqs */
  53. ctrl_outw(0x2000, 0xb03fffec); /* mrshpc irq enable */
  54. for (i = 0; i < SE7722_FPGA_IRQ_NR; i++) {
  55. irq = create_irq();
  56. if (irq < 0)
  57. return;
  58. se7722_fpga_irq[i] = irq;
  59. set_irq_chip_and_handler_name(se7722_fpga_irq[i],
  60. &se7722_irq_chip,
  61. handle_level_irq, "level");
  62. set_irq_chip_data(se7722_fpga_irq[i], (void *)i);
  63. }
  64. set_irq_chained_handler(IRQ0_IRQ, se7722_irq_demux);
  65. set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW);
  66. set_irq_chained_handler(IRQ1_IRQ, se7722_irq_demux);
  67. set_irq_type(IRQ1_IRQ, IRQ_TYPE_LEVEL_LOW);
  68. }