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