irq-mb93093.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* irq-mb93093.c: MB93093 FPGA interrupt handling
  2. *
  3. * Copyright (C) 2004 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/config.h>
  12. #include <linux/ptrace.h>
  13. #include <linux/errno.h>
  14. #include <linux/signal.h>
  15. #include <linux/sched.h>
  16. #include <linux/ioport.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/init.h>
  19. #include <linux/irq.h>
  20. #include <asm/io.h>
  21. #include <asm/system.h>
  22. #include <asm/bitops.h>
  23. #include <asm/delay.h>
  24. #include <asm/irq.h>
  25. #include <asm/irc-regs.h>
  26. #include <asm/irq-routing.h>
  27. #define __reg16(ADDR) (*(volatile unsigned short *)(__region_CS2 + (ADDR)))
  28. #define __get_IMR() ({ __reg16(0x0a); })
  29. #define __set_IMR(M) do { __reg16(0x0a) = (M); wmb(); } while(0)
  30. #define __get_IFR() ({ __reg16(0x02); })
  31. #define __clr_IFR(M) do { __reg16(0x02) = ~(M); wmb(); } while(0)
  32. static void frv_fpga_doirq(struct irq_source *source);
  33. static void frv_fpga_control(struct irq_group *group, int irq, int on);
  34. /*****************************************************************************/
  35. /*
  36. * FPGA IRQ multiplexor
  37. */
  38. static struct irq_source frv_fpga[4] = {
  39. #define __FPGA(X, M) \
  40. [X] = { \
  41. .muxname = "fpga."#X, \
  42. .irqmask = M, \
  43. .doirq = frv_fpga_doirq, \
  44. }
  45. __FPGA(0, 0x0700),
  46. };
  47. static struct irq_group frv_fpga_irqs = {
  48. .first_irq = IRQ_BASE_FPGA,
  49. .control = frv_fpga_control,
  50. .sources = {
  51. [ 8] = &frv_fpga[0],
  52. [ 9] = &frv_fpga[0],
  53. [10] = &frv_fpga[0],
  54. },
  55. };
  56. static void frv_fpga_control(struct irq_group *group, int index, int on)
  57. {
  58. uint16_t imr = __get_IMR();
  59. if (on)
  60. imr &= ~(1 << index);
  61. else
  62. imr |= 1 << index;
  63. __set_IMR(imr);
  64. }
  65. static void frv_fpga_doirq(struct irq_source *source)
  66. {
  67. uint16_t mask, imr;
  68. imr = __get_IMR();
  69. mask = source->irqmask & ~imr & __get_IFR();
  70. if (mask) {
  71. __set_IMR(imr | mask);
  72. __clr_IFR(mask);
  73. distribute_irqs(&frv_fpga_irqs, mask);
  74. __set_IMR(imr);
  75. }
  76. }
  77. void __init fpga_init(void)
  78. {
  79. __set_IMR(0x0700);
  80. __clr_IFR(0x0000);
  81. frv_irq_route_external(&frv_fpga[0], IRQ_CPU_EXTERNAL2);
  82. frv_irq_set_group(&frv_fpga_irqs);
  83. }