irq.c 2.9 KB

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