blob: 7d21befb8932c5ba36df028cb74b1c66e61c652d [file] [log] [blame]
Ralf Baechle23fbee92005-07-25 22:45:45 +00001/*
Ralf Baechle23fbee92005-07-25 22:45:45 +00002 * 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/*
Atsushi Nemotobb72f1f2008-07-24 00:25:21 +090014 * MIPS_CPU_IRQ_BASE+00 Software 0
15 * MIPS_CPU_IRQ_BASE+01 Software 1
16 * MIPS_CPU_IRQ_BASE+02 Cascade TX4938-CP0
17 * MIPS_CPU_IRQ_BASE+03 Multiplexed -- do not use
18 * MIPS_CPU_IRQ_BASE+04 Multiplexed -- do not use
19 * MIPS_CPU_IRQ_BASE+05 Multiplexed -- do not use
20 * MIPS_CPU_IRQ_BASE+06 Multiplexed -- do not use
21 * MIPS_CPU_IRQ_BASE+07 CPU TIMER
22 *
23 * TXX9_IRQ_BASE+00
24 * TXX9_IRQ_BASE+01
25 * TXX9_IRQ_BASE+02 Cascade RBTX4938-IOC
26 * TXX9_IRQ_BASE+03 RBTX4938 RTL-8019AS Ethernet
27 * TXX9_IRQ_BASE+04
28 * TXX9_IRQ_BASE+05 TX4938 ETH1
29 * TXX9_IRQ_BASE+06 TX4938 ETH0
30 * TXX9_IRQ_BASE+07
31 * TXX9_IRQ_BASE+08 TX4938 SIO 0
32 * TXX9_IRQ_BASE+09 TX4938 SIO 1
33 * TXX9_IRQ_BASE+10 TX4938 DMA0
34 * TXX9_IRQ_BASE+11 TX4938 DMA1
35 * TXX9_IRQ_BASE+12 TX4938 DMA2
36 * TXX9_IRQ_BASE+13 TX4938 DMA3
37 * TXX9_IRQ_BASE+14
38 * TXX9_IRQ_BASE+15
39 * TXX9_IRQ_BASE+16 TX4938 PCIC
40 * TXX9_IRQ_BASE+17 TX4938 TMR0
41 * TXX9_IRQ_BASE+18 TX4938 TMR1
42 * TXX9_IRQ_BASE+19 TX4938 TMR2
43 * TXX9_IRQ_BASE+20
44 * TXX9_IRQ_BASE+21
45 * TXX9_IRQ_BASE+22 TX4938 PCIERR
46 * TXX9_IRQ_BASE+23
47 * TXX9_IRQ_BASE+24
48 * TXX9_IRQ_BASE+25
49 * TXX9_IRQ_BASE+26
50 * TXX9_IRQ_BASE+27
51 * TXX9_IRQ_BASE+28
52 * TXX9_IRQ_BASE+29
53 * TXX9_IRQ_BASE+30
54 * TXX9_IRQ_BASE+31 TX4938 SPI
55 *
56 * RBTX4938_IRQ_IOC+00 PCI-D
57 * RBTX4938_IRQ_IOC+01 PCI-C
58 * RBTX4938_IRQ_IOC+02 PCI-B
59 * RBTX4938_IRQ_IOC+03 PCI-A
60 * RBTX4938_IRQ_IOC+04 RTC
61 * RBTX4938_IRQ_IOC+05 ATA
62 * RBTX4938_IRQ_IOC+06 MODEM
63 * RBTX4938_IRQ_IOC+07 SWINT
64 */
Ralf Baechle23fbee92005-07-25 22:45:45 +000065#include <linux/init.h>
Ralf Baechle23fbee92005-07-25 22:45:45 +000066#include <linux/interrupt.h>
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +090067#include <asm/mipsregs.h>
68#include <asm/txx9/generic.h>
Atsushi Nemoto22b1d702008-07-11 00:31:36 +090069#include <asm/txx9/rbtx4938.h>
Ralf Baechle23fbee92005-07-25 22:45:45 +000070
Ralf Baechle23fbee92005-07-25 22:45:45 +000071static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq);
72static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq);
Ralf Baechle23fbee92005-07-25 22:45:45 +000073
Ralf Baechle23fbee92005-07-25 22:45:45 +000074#define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC"
Ralf Baechle94dee172006-07-02 14:41:42 +010075static struct irq_chip toshiba_rbtx4938_irq_ioc_type = {
Atsushi Nemoto70d21cd2007-01-15 00:07:25 +090076 .name = TOSHIBA_RBTX4938_IOC_NAME,
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090077 .ack = toshiba_rbtx4938_irq_ioc_disable,
78 .mask = toshiba_rbtx4938_irq_ioc_disable,
79 .mask_ack = toshiba_rbtx4938_irq_ioc_disable,
80 .unmask = toshiba_rbtx4938_irq_ioc_enable,
Ralf Baechle23fbee92005-07-25 22:45:45 +000081};
82
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +090083static int toshiba_rbtx4938_irq_nested(int sw_irq)
Ralf Baechle23fbee92005-07-25 22:45:45 +000084{
85 u8 level3;
86
Atsushi Nemoto66140c82008-04-14 21:49:07 +090087 level3 = readb(rbtx4938_imstat_addr);
Atsushi Nemoto21e77df2008-09-01 22:22:37 +090088 if (unlikely(!level3))
89 return -1;
90 /* must use fls so onboard ATA has priority */
91 return RBTX4938_IRQ_IOC + __fls8(level3);
Ralf Baechle23fbee92005-07-25 22:45:45 +000092}
93
Ralf Baechle23fbee92005-07-25 22:45:45 +000094static void __init
95toshiba_rbtx4938_irq_ioc_init(void)
96{
97 int i;
98
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +090099 for (i = RBTX4938_IRQ_IOC;
100 i < RBTX4938_IRQ_IOC + RBTX4938_NR_IRQ_IOC; i++)
Atsushi Nemoto14178362006-11-14 01:13:18 +0900101 set_irq_chip_and_handler(i, &toshiba_rbtx4938_irq_ioc_type,
102 handle_level_irq);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000103
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900104 set_irq_chained_handler(RBTX4938_IRQ_IOCINT, handle_simple_irq);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000105}
106
Ralf Baechle23fbee92005-07-25 22:45:45 +0000107static void
108toshiba_rbtx4938_irq_ioc_enable(unsigned int irq)
109{
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900110 unsigned char v;
Ralf Baechle23fbee92005-07-25 22:45:45 +0000111
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900112 v = readb(rbtx4938_imask_addr);
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900113 v |= (1 << (irq - RBTX4938_IRQ_IOC));
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900114 writeb(v, rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000115 mmiowb();
Ralf Baechle23fbee92005-07-25 22:45:45 +0000116}
117
118static void
119toshiba_rbtx4938_irq_ioc_disable(unsigned int irq)
120{
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900121 unsigned char v;
Ralf Baechle23fbee92005-07-25 22:45:45 +0000122
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900123 v = readb(rbtx4938_imask_addr);
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900124 v &= ~(1 << (irq - RBTX4938_IRQ_IOC));
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900125 writeb(v, rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000126 mmiowb();
Ralf Baechle23fbee92005-07-25 22:45:45 +0000127}
128
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900129static int rbtx4938_irq_dispatch(int pending)
Ralf Baechle23fbee92005-07-25 22:45:45 +0000130{
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900131 int irq;
Ralf Baechle23fbee92005-07-25 22:45:45 +0000132
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900133 if (pending & STATUSF_IP7)
134 irq = MIPS_CPU_IRQ_BASE + 7;
135 else if (pending & STATUSF_IP2) {
136 irq = txx9_irq();
137 if (irq == RBTX4938_IRQ_IOCINT)
138 irq = toshiba_rbtx4938_irq_nested(irq);
139 } else if (pending & STATUSF_IP1)
140 irq = MIPS_CPU_IRQ_BASE + 0;
141 else if (pending & STATUSF_IP0)
142 irq = MIPS_CPU_IRQ_BASE + 1;
143 else
144 irq = -1;
145 return irq;
146}
147
148void __init rbtx4938_irq_setup(void)
149{
150 txx9_irq_dispatch = rbtx4938_irq_dispatch;
Ralf Baechle23fbee92005-07-25 22:45:45 +0000151 /* Now, interrupt control disabled, */
152 /* all IRC interrupts are masked, */
153 /* all IRC interrupt mode are Low Active. */
154
155 /* mask all IOC interrupts */
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900156 writeb(0, rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000157
158 /* clear SoftInt interrupts */
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900159 writeb(0, rbtx4938_softint_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000160 tx4938_irq_init();
161 toshiba_rbtx4938_irq_ioc_init();
162 /* Onboard 10M Ether: High Active */
Atsushi Nemotoc87abd72007-08-02 23:36:02 +0900163 set_irq_type(RBTX4938_IRQ_ETHER, IRQF_TRIGGER_HIGH);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000164}