irq.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Toshiba RBTX4938 specific interrupt handlers
  3. * Copyright (C) 2000-2001 Toshiba Corporation
  4. *
  5. * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
  6. * terms of the GNU General Public License version 2. This program is
  7. * licensed "as is" without any warranty of any kind, whether express
  8. * or implied.
  9. *
  10. * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
  11. */
  12. /*
  13. IRQ Device
  14. 16 TX4938-CP0/00 Software 0
  15. 17 TX4938-CP0/01 Software 1
  16. 18 TX4938-CP0/02 Cascade TX4938-CP0
  17. 19 TX4938-CP0/03 Multiplexed -- do not use
  18. 20 TX4938-CP0/04 Multiplexed -- do not use
  19. 21 TX4938-CP0/05 Multiplexed -- do not use
  20. 22 TX4938-CP0/06 Multiplexed -- do not use
  21. 23 TX4938-CP0/07 CPU TIMER
  22. 24 TX4938-PIC/00
  23. 25 TX4938-PIC/01
  24. 26 TX4938-PIC/02 Cascade RBTX4938-IOC
  25. 27 TX4938-PIC/03 RBTX4938 RTL-8019AS Ethernet
  26. 28 TX4938-PIC/04
  27. 29 TX4938-PIC/05 TX4938 ETH1
  28. 30 TX4938-PIC/06 TX4938 ETH0
  29. 31 TX4938-PIC/07
  30. 32 TX4938-PIC/08 TX4938 SIO 0
  31. 33 TX4938-PIC/09 TX4938 SIO 1
  32. 34 TX4938-PIC/10 TX4938 DMA0
  33. 35 TX4938-PIC/11 TX4938 DMA1
  34. 36 TX4938-PIC/12 TX4938 DMA2
  35. 37 TX4938-PIC/13 TX4938 DMA3
  36. 38 TX4938-PIC/14
  37. 39 TX4938-PIC/15
  38. 40 TX4938-PIC/16 TX4938 PCIC
  39. 41 TX4938-PIC/17 TX4938 TMR0
  40. 42 TX4938-PIC/18 TX4938 TMR1
  41. 43 TX4938-PIC/19 TX4938 TMR2
  42. 44 TX4938-PIC/20
  43. 45 TX4938-PIC/21
  44. 46 TX4938-PIC/22 TX4938 PCIERR
  45. 47 TX4938-PIC/23
  46. 48 TX4938-PIC/24
  47. 49 TX4938-PIC/25
  48. 50 TX4938-PIC/26
  49. 51 TX4938-PIC/27
  50. 52 TX4938-PIC/28
  51. 53 TX4938-PIC/29
  52. 54 TX4938-PIC/30
  53. 55 TX4938-PIC/31 TX4938 SPI
  54. 56 RBTX4938-IOC/00 PCI-D
  55. 57 RBTX4938-IOC/01 PCI-C
  56. 58 RBTX4938-IOC/02 PCI-B
  57. 59 RBTX4938-IOC/03 PCI-A
  58. 60 RBTX4938-IOC/04 RTC
  59. 61 RBTX4938-IOC/05 ATA
  60. 62 RBTX4938-IOC/06 MODEM
  61. 63 RBTX4938-IOC/07 SWINT
  62. */
  63. #include <linux/init.h>
  64. #include <linux/interrupt.h>
  65. #include <asm/mipsregs.h>
  66. #include <asm/txx9/generic.h>
  67. #include <asm/txx9/rbtx4938.h>
  68. static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq);
  69. static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq);
  70. #define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC"
  71. static struct irq_chip toshiba_rbtx4938_irq_ioc_type = {
  72. .name = TOSHIBA_RBTX4938_IOC_NAME,
  73. .ack = toshiba_rbtx4938_irq_ioc_disable,
  74. .mask = toshiba_rbtx4938_irq_ioc_disable,
  75. .mask_ack = toshiba_rbtx4938_irq_ioc_disable,
  76. .unmask = toshiba_rbtx4938_irq_ioc_enable,
  77. };
  78. static int toshiba_rbtx4938_irq_nested(int sw_irq)
  79. {
  80. u8 level3;
  81. level3 = readb(rbtx4938_imstat_addr);
  82. if (level3)
  83. /* must use fls so onboard ATA has priority */
  84. sw_irq = RBTX4938_IRQ_IOC + fls(level3) - 1;
  85. return sw_irq;
  86. }
  87. /**********************************************************************************/
  88. /* Functions for ioc */
  89. /**********************************************************************************/
  90. static void __init
  91. toshiba_rbtx4938_irq_ioc_init(void)
  92. {
  93. int i;
  94. for (i = RBTX4938_IRQ_IOC;
  95. i < RBTX4938_IRQ_IOC + RBTX4938_NR_IRQ_IOC; i++)
  96. set_irq_chip_and_handler(i, &toshiba_rbtx4938_irq_ioc_type,
  97. handle_level_irq);
  98. set_irq_chained_handler(RBTX4938_IRQ_IOCINT, handle_simple_irq);
  99. }
  100. static void
  101. toshiba_rbtx4938_irq_ioc_enable(unsigned int irq)
  102. {
  103. unsigned char v;
  104. v = readb(rbtx4938_imask_addr);
  105. v |= (1 << (irq - RBTX4938_IRQ_IOC));
  106. writeb(v, rbtx4938_imask_addr);
  107. mmiowb();
  108. }
  109. static void
  110. toshiba_rbtx4938_irq_ioc_disable(unsigned int irq)
  111. {
  112. unsigned char v;
  113. v = readb(rbtx4938_imask_addr);
  114. v &= ~(1 << (irq - RBTX4938_IRQ_IOC));
  115. writeb(v, rbtx4938_imask_addr);
  116. mmiowb();
  117. }
  118. static int rbtx4938_irq_dispatch(int pending)
  119. {
  120. int irq;
  121. if (pending & STATUSF_IP7)
  122. irq = MIPS_CPU_IRQ_BASE + 7;
  123. else if (pending & STATUSF_IP2) {
  124. irq = txx9_irq();
  125. if (irq == RBTX4938_IRQ_IOCINT)
  126. irq = toshiba_rbtx4938_irq_nested(irq);
  127. } else if (pending & STATUSF_IP1)
  128. irq = MIPS_CPU_IRQ_BASE + 0;
  129. else if (pending & STATUSF_IP0)
  130. irq = MIPS_CPU_IRQ_BASE + 1;
  131. else
  132. irq = -1;
  133. return irq;
  134. }
  135. void __init rbtx4938_irq_setup(void)
  136. {
  137. txx9_irq_dispatch = rbtx4938_irq_dispatch;
  138. /* Now, interrupt control disabled, */
  139. /* all IRC interrupts are masked, */
  140. /* all IRC interrupt mode are Low Active. */
  141. /* mask all IOC interrupts */
  142. writeb(0, rbtx4938_imask_addr);
  143. /* clear SoftInt interrupts */
  144. writeb(0, rbtx4938_softint_addr);
  145. tx4938_irq_init();
  146. toshiba_rbtx4938_irq_ioc_init();
  147. /* Onboard 10M Ether: High Active */
  148. set_irq_type(RBTX4938_IRQ_ETHER, IRQF_TRIGGER_HIGH);
  149. }