irq.c 2.1 KB

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