blob: 8c87a35f30682405abea6261152916000ec50d46 [file] [log] [blame]
Ralf Baechle23fbee92005-07-25 22:45:45 +00001/*
2 * linux/arch/mips/tx4938/toshiba_rbtx4938/irq.c
3 *
4 * Toshiba RBTX4938 specific interrupt handlers
5 * Copyright (C) 2000-2001 Toshiba Corporation
6 *
7 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
8 * terms of the GNU General Public License version 2. This program is
9 * licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 *
12 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
13 */
14
15/*
16IRQ Device
17
1816 TX4938-CP0/00 Software 0
1917 TX4938-CP0/01 Software 1
2018 TX4938-CP0/02 Cascade TX4938-CP0
2119 TX4938-CP0/03 Multiplexed -- do not use
2220 TX4938-CP0/04 Multiplexed -- do not use
2321 TX4938-CP0/05 Multiplexed -- do not use
2422 TX4938-CP0/06 Multiplexed -- do not use
2523 TX4938-CP0/07 CPU TIMER
26
2724 TX4938-PIC/00
2825 TX4938-PIC/01
2926 TX4938-PIC/02 Cascade RBTX4938-IOC
3027 TX4938-PIC/03 RBTX4938 RTL-8019AS Ethernet
3128 TX4938-PIC/04
3229 TX4938-PIC/05 TX4938 ETH1
3330 TX4938-PIC/06 TX4938 ETH0
3431 TX4938-PIC/07
3532 TX4938-PIC/08 TX4938 SIO 0
3633 TX4938-PIC/09 TX4938 SIO 1
3734 TX4938-PIC/10 TX4938 DMA0
3835 TX4938-PIC/11 TX4938 DMA1
3936 TX4938-PIC/12 TX4938 DMA2
4037 TX4938-PIC/13 TX4938 DMA3
4138 TX4938-PIC/14
4239 TX4938-PIC/15
4340 TX4938-PIC/16 TX4938 PCIC
4441 TX4938-PIC/17 TX4938 TMR0
4542 TX4938-PIC/18 TX4938 TMR1
4643 TX4938-PIC/19 TX4938 TMR2
4744 TX4938-PIC/20
4845 TX4938-PIC/21
4946 TX4938-PIC/22 TX4938 PCIERR
5047 TX4938-PIC/23
5148 TX4938-PIC/24
5249 TX4938-PIC/25
5350 TX4938-PIC/26
5451 TX4938-PIC/27
5552 TX4938-PIC/28
5653 TX4938-PIC/29
5754 TX4938-PIC/30
5855 TX4938-PIC/31 TX4938 SPI
59
6056 RBTX4938-IOC/00 PCI-D
6157 RBTX4938-IOC/01 PCI-C
6258 RBTX4938-IOC/02 PCI-B
6359 RBTX4938-IOC/03 PCI-A
6460 RBTX4938-IOC/04 RTC
6561 RBTX4938-IOC/05 ATA
6662 RBTX4938-IOC/06 MODEM
6763 RBTX4938-IOC/07 SWINT
68*/
69#include <linux/init.h>
70#include <linux/kernel.h>
71#include <linux/types.h>
72#include <linux/mm.h>
73#include <linux/swap.h>
74#include <linux/ioport.h>
75#include <linux/sched.h>
76#include <linux/interrupt.h>
77#include <linux/pci.h>
78#include <linux/timex.h>
79#include <asm/bootinfo.h>
80#include <asm/page.h>
81#include <asm/io.h>
82#include <asm/irq.h>
83#include <asm/processor.h>
Ralf Baechle23fbee92005-07-25 22:45:45 +000084#include <asm/reboot.h>
85#include <asm/time.h>
Atsushi Nemotof5c70dd2006-08-20 22:55:52 +090086#include <asm/wbflush.h>
Ralf Baechle23fbee92005-07-25 22:45:45 +000087#include <linux/bootmem.h>
88#include <asm/tx4938/rbtx4938.h>
89
Ralf Baechle23fbee92005-07-25 22:45:45 +000090static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq);
91static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq);
Ralf Baechle23fbee92005-07-25 22:45:45 +000092static void toshiba_rbtx4938_irq_ioc_end(unsigned int irq);
93
Ralf Baechle23fbee92005-07-25 22:45:45 +000094#define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC"
Ralf Baechle94dee172006-07-02 14:41:42 +010095static struct irq_chip toshiba_rbtx4938_irq_ioc_type = {
Ralf Baechle23fbee92005-07-25 22:45:45 +000096 .typename = TOSHIBA_RBTX4938_IOC_NAME,
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090097 .ack = toshiba_rbtx4938_irq_ioc_disable,
98 .mask = toshiba_rbtx4938_irq_ioc_disable,
99 .mask_ack = toshiba_rbtx4938_irq_ioc_disable,
100 .unmask = toshiba_rbtx4938_irq_ioc_enable,
Ralf Baechle23fbee92005-07-25 22:45:45 +0000101 .end = toshiba_rbtx4938_irq_ioc_end,
Ralf Baechle23fbee92005-07-25 22:45:45 +0000102};
103
104#define TOSHIBA_RBTX4938_IOC_INTR_ENAB 0xb7f02000
105#define TOSHIBA_RBTX4938_IOC_INTR_STAT 0xb7f0200a
106
107int
108toshiba_rbtx4938_irq_nested(int sw_irq)
109{
110 u8 level3;
111
112 level3 = reg_rd08(TOSHIBA_RBTX4938_IOC_INTR_STAT) & 0xff;
113 if (level3) {
114 /* must use fls so onboard ATA has priority */
115 sw_irq = TOSHIBA_RBTX4938_IRQ_IOC_BEG + fls(level3) - 1;
116 }
117
118 wbflush();
119 return sw_irq;
120}
121
122static struct irqaction toshiba_rbtx4938_irq_ioc_action = {
123 .handler = no_action,
124 .flags = 0,
125 .mask = CPU_MASK_NONE,
126 .name = TOSHIBA_RBTX4938_IOC_NAME,
127};
128
129/**********************************************************************************/
130/* Functions for ioc */
131/**********************************************************************************/
132static void __init
133toshiba_rbtx4938_irq_ioc_init(void)
134{
135 int i;
136
137 for (i = TOSHIBA_RBTX4938_IRQ_IOC_BEG;
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +0900138 i <= TOSHIBA_RBTX4938_IRQ_IOC_END; i++)
Atsushi Nemoto14178362006-11-14 01:13:18 +0900139 set_irq_chip_and_handler(i, &toshiba_rbtx4938_irq_ioc_type,
140 handle_level_irq);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000141
142 setup_irq(RBTX4938_IRQ_IOCINT,
143 &toshiba_rbtx4938_irq_ioc_action);
144}
145
Ralf Baechle23fbee92005-07-25 22:45:45 +0000146static void
147toshiba_rbtx4938_irq_ioc_enable(unsigned int irq)
148{
Ralf Baechle23fbee92005-07-25 22:45:45 +0000149 volatile unsigned char v;
150
Ralf Baechle23fbee92005-07-25 22:45:45 +0000151 v = TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);
152 v |= (1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG));
153 TX4938_WR08(TOSHIBA_RBTX4938_IOC_INTR_ENAB, v);
154 mmiowb();
155 TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000156}
157
158static void
159toshiba_rbtx4938_irq_ioc_disable(unsigned int irq)
160{
Ralf Baechle23fbee92005-07-25 22:45:45 +0000161 volatile unsigned char v;
162
Ralf Baechle23fbee92005-07-25 22:45:45 +0000163 v = TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);
164 v &= ~(1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG));
165 TX4938_WR08(TOSHIBA_RBTX4938_IOC_INTR_ENAB, v);
166 mmiowb();
167 TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000168}
169
170static void
171toshiba_rbtx4938_irq_ioc_end(unsigned int irq)
172{
173 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
174 toshiba_rbtx4938_irq_ioc_enable(irq);
175 }
176}
177
178extern void __init txx9_spi_irqinit(int irc_irq);
179
180void __init arch_init_irq(void)
181{
182 extern void tx4938_irq_init(void);
183
184 /* Now, interrupt control disabled, */
185 /* all IRC interrupts are masked, */
186 /* all IRC interrupt mode are Low Active. */
187
188 /* mask all IOC interrupts */
189 *rbtx4938_imask_ptr = 0;
190
191 /* clear SoftInt interrupts */
192 *rbtx4938_softint_ptr = 0;
193 tx4938_irq_init();
194 toshiba_rbtx4938_irq_ioc_init();
195 /* Onboard 10M Ether: High Active */
196 TX4938_WR(TX4938_MKA(TX4938_IRC_IRDM0), 0x00000040);
197
198 if (tx4938_ccfgptr->pcfg & TX4938_PCFG_SPI_SEL) {
199 txx9_spi_irqinit(RBTX4938_IRQ_IRC_SPI);
200 }
201
202 wbflush();
203}