irq.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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/io.h>
  17. #include <mach-se/mach/se7343.h>
  18. static void disable_se7343_irq(unsigned int irq)
  19. {
  20. unsigned int bit = irq - SE7343_FPGA_IRQ_BASE;
  21. ctrl_outw(ctrl_inw(PA_CPLD_IMSK) | 1 << bit, PA_CPLD_IMSK);
  22. }
  23. static void enable_se7343_irq(unsigned int irq)
  24. {
  25. unsigned int bit = irq - SE7343_FPGA_IRQ_BASE;
  26. ctrl_outw(ctrl_inw(PA_CPLD_IMSK) & ~(1 << bit), PA_CPLD_IMSK);
  27. }
  28. static struct irq_chip se7343_irq_chip __read_mostly = {
  29. .name = "SE7343-FPGA",
  30. .mask = disable_se7343_irq,
  31. .unmask = enable_se7343_irq,
  32. .mask_ack = disable_se7343_irq,
  33. };
  34. static void se7343_irq_demux(unsigned int irq, struct irq_desc *desc)
  35. {
  36. unsigned short intv = ctrl_inw(PA_CPLD_ST);
  37. struct irq_desc *ext_desc;
  38. unsigned int ext_irq = SE7343_FPGA_IRQ_BASE;
  39. intv &= (1 << SE7343_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_7343se_IRQ(void)
  53. {
  54. int i;
  55. ctrl_outw(0, PA_CPLD_IMSK); /* disable all irqs */
  56. ctrl_outw(0x2000, 0xb03fffec); /* mrshpc irq enable */
  57. for (i = 0; i < SE7343_FPGA_IRQ_NR; i++)
  58. set_irq_chip_and_handler_name(SE7343_FPGA_IRQ_BASE + i,
  59. &se7343_irq_chip,
  60. handle_level_irq, "level");
  61. set_irq_chained_handler(IRQ0_IRQ, se7343_irq_demux);
  62. set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW);
  63. set_irq_chained_handler(IRQ1_IRQ, se7343_irq_demux);
  64. set_irq_type(IRQ1_IRQ, IRQ_TYPE_LEVEL_LOW);
  65. set_irq_chained_handler(IRQ4_IRQ, se7343_irq_demux);
  66. set_irq_type(IRQ4_IRQ, IRQ_TYPE_LEVEL_LOW);
  67. set_irq_chained_handler(IRQ5_IRQ, se7343_irq_demux);
  68. set_irq_type(IRQ5_IRQ, IRQ_TYPE_LEVEL_LOW);
  69. }