blob: f4984820251a9e3177c62e8e77b121578b9a52e6 [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/*
14IRQ Device
15
1616 TX4938-CP0/00 Software 0
1717 TX4938-CP0/01 Software 1
1818 TX4938-CP0/02 Cascade TX4938-CP0
1919 TX4938-CP0/03 Multiplexed -- do not use
2020 TX4938-CP0/04 Multiplexed -- do not use
2121 TX4938-CP0/05 Multiplexed -- do not use
2222 TX4938-CP0/06 Multiplexed -- do not use
2323 TX4938-CP0/07 CPU TIMER
24
2524 TX4938-PIC/00
2625 TX4938-PIC/01
2726 TX4938-PIC/02 Cascade RBTX4938-IOC
2827 TX4938-PIC/03 RBTX4938 RTL-8019AS Ethernet
2928 TX4938-PIC/04
3029 TX4938-PIC/05 TX4938 ETH1
3130 TX4938-PIC/06 TX4938 ETH0
3231 TX4938-PIC/07
3332 TX4938-PIC/08 TX4938 SIO 0
3433 TX4938-PIC/09 TX4938 SIO 1
3534 TX4938-PIC/10 TX4938 DMA0
3635 TX4938-PIC/11 TX4938 DMA1
3736 TX4938-PIC/12 TX4938 DMA2
3837 TX4938-PIC/13 TX4938 DMA3
3938 TX4938-PIC/14
4039 TX4938-PIC/15
4140 TX4938-PIC/16 TX4938 PCIC
4241 TX4938-PIC/17 TX4938 TMR0
4342 TX4938-PIC/18 TX4938 TMR1
4443 TX4938-PIC/19 TX4938 TMR2
4544 TX4938-PIC/20
4645 TX4938-PIC/21
4746 TX4938-PIC/22 TX4938 PCIERR
4847 TX4938-PIC/23
4948 TX4938-PIC/24
5049 TX4938-PIC/25
5150 TX4938-PIC/26
5251 TX4938-PIC/27
5352 TX4938-PIC/28
5453 TX4938-PIC/29
5554 TX4938-PIC/30
5655 TX4938-PIC/31 TX4938 SPI
57
5856 RBTX4938-IOC/00 PCI-D
5957 RBTX4938-IOC/01 PCI-C
6058 RBTX4938-IOC/02 PCI-B
6159 RBTX4938-IOC/03 PCI-A
6260 RBTX4938-IOC/04 RTC
6361 RBTX4938-IOC/05 ATA
6462 RBTX4938-IOC/06 MODEM
6563 RBTX4938-IOC/07 SWINT
66*/
67#include <linux/init.h>
Ralf Baechle23fbee92005-07-25 22:45:45 +000068#include <linux/interrupt.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
Ralf Baechle23fbee92005-07-25 22:45:45 +000083int
84toshiba_rbtx4938_irq_nested(int sw_irq)
85{
86 u8 level3;
87
Atsushi Nemoto66140c82008-04-14 21:49:07 +090088 level3 = readb(rbtx4938_imstat_addr);
89 if (level3)
Ralf Baechle23fbee92005-07-25 22:45:45 +000090 /* must use fls so onboard ATA has priority */
91 sw_irq = TOSHIBA_RBTX4938_IRQ_IOC_BEG + fls(level3) - 1;
Ralf Baechle23fbee92005-07-25 22:45:45 +000092
Ralf Baechle23fbee92005-07-25 22:45:45 +000093 return sw_irq;
94}
95
96static struct irqaction toshiba_rbtx4938_irq_ioc_action = {
97 .handler = no_action,
98 .flags = 0,
99 .mask = CPU_MASK_NONE,
100 .name = TOSHIBA_RBTX4938_IOC_NAME,
101};
102
103/**********************************************************************************/
104/* Functions for ioc */
105/**********************************************************************************/
106static void __init
107toshiba_rbtx4938_irq_ioc_init(void)
108{
109 int i;
110
111 for (i = TOSHIBA_RBTX4938_IRQ_IOC_BEG;
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +0900112 i <= TOSHIBA_RBTX4938_IRQ_IOC_END; i++)
Atsushi Nemoto14178362006-11-14 01:13:18 +0900113 set_irq_chip_and_handler(i, &toshiba_rbtx4938_irq_ioc_type,
114 handle_level_irq);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000115
116 setup_irq(RBTX4938_IRQ_IOCINT,
117 &toshiba_rbtx4938_irq_ioc_action);
118}
119
Ralf Baechle23fbee92005-07-25 22:45:45 +0000120static void
121toshiba_rbtx4938_irq_ioc_enable(unsigned int irq)
122{
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900123 unsigned char v;
Ralf Baechle23fbee92005-07-25 22:45:45 +0000124
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900125 v = readb(rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000126 v |= (1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG));
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900127 writeb(v, rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000128 mmiowb();
Ralf Baechle23fbee92005-07-25 22:45:45 +0000129}
130
131static void
132toshiba_rbtx4938_irq_ioc_disable(unsigned int irq)
133{
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900134 unsigned char v;
Ralf Baechle23fbee92005-07-25 22:45:45 +0000135
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900136 v = readb(rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000137 v &= ~(1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG));
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900138 writeb(v, rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000139 mmiowb();
Ralf Baechle23fbee92005-07-25 22:45:45 +0000140}
141
Ralf Baechle23fbee92005-07-25 22:45:45 +0000142void __init arch_init_irq(void)
143{
144 extern void tx4938_irq_init(void);
145
146 /* Now, interrupt control disabled, */
147 /* all IRC interrupts are masked, */
148 /* all IRC interrupt mode are Low Active. */
149
150 /* mask all IOC interrupts */
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900151 writeb(0, rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000152
153 /* clear SoftInt interrupts */
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900154 writeb(0, rbtx4938_softint_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000155 tx4938_irq_init();
156 toshiba_rbtx4938_irq_ioc_init();
157 /* Onboard 10M Ether: High Active */
Atsushi Nemotoc87abd72007-08-02 23:36:02 +0900158 set_irq_type(RBTX4938_IRQ_ETHER, IRQF_TRIGGER_HIGH);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000159}