irq.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 short val;
  37. unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
  38. /* Set the priority in IPR to 0 */
  39. val = ctrl_inw(IRLCNTR1);
  40. val &= mask;
  41. ctrl_outw(val, IRLCNTR1);
  42. }
  43. static void enable_rts7751r2d_irq(unsigned int irq)
  44. {
  45. unsigned short val;
  46. unsigned short value = (0x0001 << mask_pos[irq]);
  47. /* Set priority in IPR back to original value */
  48. val = ctrl_inw(IRLCNTR1);
  49. val |= value;
  50. ctrl_outw(val, IRLCNTR1);
  51. }
  52. int rts7751r2d_irq_demux(int irq)
  53. {
  54. int demux_irq;
  55. demux_irq = voyagergx_irq_demux(irq);
  56. return demux_irq;
  57. }
  58. static void ack_rts7751r2d_irq(unsigned int irq)
  59. {
  60. disable_rts7751r2d_irq(irq);
  61. }
  62. static void end_rts7751r2d_irq(unsigned int irq)
  63. {
  64. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  65. enable_rts7751r2d_irq(irq);
  66. }
  67. static struct hw_interrupt_type rts7751r2d_irq_type = {
  68. .typename = "RTS7751R2D IRQ",
  69. .startup = startup_rts7751r2d_irq,
  70. .shutdown = shutdown_rts7751r2d_irq,
  71. .enable = enable_rts7751r2d_irq,
  72. .disable = disable_rts7751r2d_irq,
  73. .ack = ack_rts7751r2d_irq,
  74. .end = end_rts7751r2d_irq,
  75. };
  76. static void make_rts7751r2d_irq(unsigned int irq)
  77. {
  78. disable_irq_nosync(irq);
  79. irq_desc[irq].chip = &rts7751r2d_irq_type;
  80. disable_rts7751r2d_irq(irq);
  81. }
  82. /*
  83. * Initialize IRQ setting
  84. */
  85. void __init init_rts7751r2d_IRQ(void)
  86. {
  87. int i;
  88. /* IRL0=KEY Input
  89. * IRL1=Ethernet
  90. * IRL2=CF Card
  91. * IRL3=CF Card Insert
  92. * IRL4=PCMCIA
  93. * IRL5=VOYAGER
  94. * IRL6=RTC Alarm
  95. * IRL7=RTC Timer
  96. * IRL8=SD Card
  97. * IRL9=PCI Slot #1
  98. * IRL10=PCI Slot #2
  99. * IRL11=Extention #0
  100. * IRL12=Extention #1
  101. * IRL13=Extention #2
  102. * IRL14=Extention #3
  103. */
  104. for (i=0; i<15; i++)
  105. make_rts7751r2d_irq(i);
  106. setup_voyagergx_irq();
  107. }