irq.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * linux/arch/sh/boards/renesas/rts7751r2d/irq.c
  3. *
  4. * Copyright (C) 2000 Kazumoto Kojima
  5. *
  6. * Renesas Technology Sales RTS7751R2D Support.
  7. *
  8. * Modified for RTS7751R2D by
  9. * Atom Create Engineering Co., Ltd. 2002.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/irq.h>
  13. #include <asm/io.h>
  14. #include <asm/irq.h>
  15. #include <asm/rts7751r2d/rts7751r2d.h>
  16. #if defined(CONFIG_RTS7751R2D_REV11)
  17. static int mask_pos[] = {11, 9, 8, 12, 10, 6, 5, 4, 7, 14, 13, 0, 0, 0, 0};
  18. #else
  19. static int mask_pos[] = {6, 11, 9, 8, 12, 10, 5, 4, 7, 14, 13, 0, 0, 0, 0};
  20. #endif
  21. extern int voyagergx_irq_demux(int irq);
  22. extern void setup_voyagergx_irq(void);
  23. static void enable_rts7751r2d_irq(unsigned int irq);
  24. static void disable_rts7751r2d_irq(unsigned int irq);
  25. /* shutdown is same as "disable" */
  26. #define shutdown_rts7751r2d_irq disable_rts7751r2d_irq
  27. static void ack_rts7751r2d_irq(unsigned int irq);
  28. static void end_rts7751r2d_irq(unsigned int irq);
  29. static unsigned int startup_rts7751r2d_irq(unsigned int irq)
  30. {
  31. enable_rts7751r2d_irq(irq);
  32. return 0; /* never anything pending */
  33. }
  34. static void disable_rts7751r2d_irq(unsigned int irq)
  35. {
  36. unsigned long flags;
  37. unsigned short val;
  38. unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
  39. /* Set the priority in IPR to 0 */
  40. local_irq_save(flags);
  41. val = ctrl_inw(IRLCNTR1);
  42. val &= mask;
  43. ctrl_outw(val, IRLCNTR1);
  44. local_irq_restore(flags);
  45. }
  46. static void enable_rts7751r2d_irq(unsigned int irq)
  47. {
  48. unsigned long flags;
  49. unsigned short val;
  50. unsigned short value = (0x0001 << mask_pos[irq]);
  51. /* Set priority in IPR back to original value */
  52. local_irq_save(flags);
  53. val = ctrl_inw(IRLCNTR1);
  54. val |= value;
  55. ctrl_outw(val, IRLCNTR1);
  56. local_irq_restore(flags);
  57. }
  58. int rts7751r2d_irq_demux(int irq)
  59. {
  60. int demux_irq;
  61. demux_irq = voyagergx_irq_demux(irq);
  62. return demux_irq;
  63. }
  64. static void ack_rts7751r2d_irq(unsigned int irq)
  65. {
  66. disable_rts7751r2d_irq(irq);
  67. }
  68. static void end_rts7751r2d_irq(unsigned int irq)
  69. {
  70. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  71. enable_rts7751r2d_irq(irq);
  72. }
  73. static struct hw_interrupt_type rts7751r2d_irq_type = {
  74. .typename = "RTS7751R2D IRQ",
  75. .startup = startup_rts7751r2d_irq,
  76. .shutdown = shutdown_rts7751r2d_irq,
  77. .enable = enable_rts7751r2d_irq,
  78. .disable = disable_rts7751r2d_irq,
  79. .ack = ack_rts7751r2d_irq,
  80. .end = end_rts7751r2d_irq,
  81. };
  82. static void make_rts7751r2d_irq(unsigned int irq)
  83. {
  84. disable_irq_nosync(irq);
  85. irq_desc[irq].chip = &rts7751r2d_irq_type;
  86. disable_rts7751r2d_irq(irq);
  87. }
  88. /*
  89. * Initialize IRQ setting
  90. */
  91. void __init init_rts7751r2d_IRQ(void)
  92. {
  93. int i;
  94. /* IRL0=KEY Input
  95. * IRL1=Ethernet
  96. * IRL2=CF Card
  97. * IRL3=CF Card Insert
  98. * IRL4=PCMCIA
  99. * IRL5=VOYAGER
  100. * IRL6=RTC Alarm
  101. * IRL7=RTC Timer
  102. * IRL8=SD Card
  103. * IRL9=PCI Slot #1
  104. * IRL10=PCI Slot #2
  105. * IRL11=Extention #0
  106. * IRL12=Extention #1
  107. * IRL13=Extention #2
  108. * IRL14=Extention #3
  109. */
  110. for (i=0; i<15; i++)
  111. make_rts7751r2d_irq(i);
  112. setup_voyagergx_irq();
  113. }