irq-mb93093.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/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 *)(__region_CS2 + (ADDR)))
  27. #define __get_IMR() ({ __reg16(0x0a); })
  28. #define __set_IMR(M) do { __reg16(0x0a) = (M); wmb(); } while(0)
  29. #define __get_IFR() ({ __reg16(0x02); })
  30. #define __clr_IFR(M) do { __reg16(0x02) = ~(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, 0x0700),
  45. };
  46. static struct irq_group frv_fpga_irqs = {
  47. .first_irq = IRQ_BASE_FPGA,
  48. .control = frv_fpga_control,
  49. .sources = {
  50. [ 8] = &frv_fpga[0],
  51. [ 9] = &frv_fpga[0],
  52. [10] = &frv_fpga[0],
  53. },
  54. };
  55. static void frv_fpga_control(struct irq_group *group, int index, int on)
  56. {
  57. uint16_t imr = __get_IMR();
  58. if (on)
  59. imr &= ~(1 << index);
  60. else
  61. imr |= 1 << index;
  62. __set_IMR(imr);
  63. }
  64. static void frv_fpga_doirq(struct irq_source *source)
  65. {
  66. uint16_t mask, imr;
  67. imr = __get_IMR();
  68. mask = source->irqmask & ~imr & __get_IFR();
  69. if (mask) {
  70. __set_IMR(imr | mask);
  71. __clr_IFR(mask);
  72. distribute_irqs(&frv_fpga_irqs, mask);
  73. __set_IMR(imr);
  74. }
  75. }
  76. void __init fpga_init(void)
  77. {
  78. __set_IMR(0x0700);
  79. __clr_IFR(0x0000);
  80. frv_irq_route_external(&frv_fpga[0], IRQ_CPU_EXTERNAL2);
  81. frv_irq_set_group(&frv_fpga_irqs);
  82. }