irq.c 2.7 KB

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