irq-mb93091.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* irq-mb93091.c: MB93091 FPGA interrupt handling
  2. *
  3. * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/ptrace.h>
  12. #include <linux/errno.h>
  13. #include <linux/signal.h>
  14. #include <linux/sched.h>
  15. #include <linux/ioport.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/init.h>
  18. #include <linux/irq.h>
  19. #include <asm/io.h>
  20. #include <asm/system.h>
  21. #include <asm/bitops.h>
  22. #include <asm/delay.h>
  23. #include <asm/irq.h>
  24. #include <asm/irc-regs.h>
  25. #include <asm/irq-routing.h>
  26. #define __reg16(ADDR) (*(volatile unsigned short *)(ADDR))
  27. #define __get_IMR() ({ __reg16(0xffc00004); })
  28. #define __set_IMR(M) do { __reg16(0xffc00004) = (M); wmb(); } while(0)
  29. #define __get_IFR() ({ __reg16(0xffc0000c); })
  30. #define __clr_IFR(M) do { __reg16(0xffc0000c) = ~(M); wmb(); } while(0)
  31. static void frv_fpga_doirq(struct irq_source *source);
  32. static void frv_fpga_control(struct irq_group *group, int irq, int on);
  33. /*****************************************************************************/
  34. /*
  35. * FPGA IRQ multiplexor
  36. */
  37. static struct irq_source frv_fpga[4] = {
  38. #define __FPGA(X, M) \
  39. [X] = { \
  40. .muxname = "fpga."#X, \
  41. .irqmask = M, \
  42. .doirq = frv_fpga_doirq, \
  43. }
  44. __FPGA(0, 0x0028),
  45. __FPGA(1, 0x0050),
  46. __FPGA(2, 0x1c00),
  47. __FPGA(3, 0x6386),
  48. };
  49. static struct irq_group frv_fpga_irqs = {
  50. .first_irq = IRQ_BASE_FPGA,
  51. .control = frv_fpga_control,
  52. .sources = {
  53. [ 1] = &frv_fpga[3],
  54. [ 2] = &frv_fpga[3],
  55. [ 3] = &frv_fpga[0],
  56. [ 4] = &frv_fpga[1],
  57. [ 5] = &frv_fpga[0],
  58. [ 6] = &frv_fpga[1],
  59. [ 7] = &frv_fpga[3],
  60. [ 8] = &frv_fpga[3],
  61. [ 9] = &frv_fpga[3],
  62. [10] = &frv_fpga[2],
  63. [11] = &frv_fpga[2],
  64. [12] = &frv_fpga[2],
  65. [13] = &frv_fpga[3],
  66. [14] = &frv_fpga[3],
  67. },
  68. };
  69. static void frv_fpga_control(struct irq_group *group, int index, int on)
  70. {
  71. uint16_t imr = __get_IMR();
  72. if (on)
  73. imr &= ~(1 << index);
  74. else
  75. imr |= 1 << index;
  76. __set_IMR(imr);
  77. }
  78. static void frv_fpga_doirq(struct irq_source *source)
  79. {
  80. uint16_t mask, imr;
  81. imr = __get_IMR();
  82. mask = source->irqmask & ~imr & __get_IFR();
  83. if (mask) {
  84. __set_IMR(imr | mask);
  85. __clr_IFR(mask);
  86. distribute_irqs(&frv_fpga_irqs, mask);
  87. __set_IMR(imr);
  88. }
  89. }
  90. void __init fpga_init(void)
  91. {
  92. __set_IMR(0x7ffe);
  93. __clr_IFR(0x0000);
  94. frv_irq_route_external(&frv_fpga[0], IRQ_CPU_EXTERNAL0);
  95. frv_irq_route_external(&frv_fpga[1], IRQ_CPU_EXTERNAL1);
  96. frv_irq_route_external(&frv_fpga[2], IRQ_CPU_EXTERNAL2);
  97. frv_irq_route_external(&frv_fpga[3], IRQ_CPU_EXTERNAL3);
  98. frv_irq_set_group(&frv_fpga_irqs);
  99. }