blob: 4d6a8dc46c76eb963e7c5a0df6acd0d882976180 [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>
Ralf Baechle23fbee92005-07-25 22:45:45 +000070#include <linux/interrupt.h>
Ralf Baechle23fbee92005-07-25 22:45:45 +000071#include <asm/tx4938/rbtx4938.h>
72
Ralf Baechle23fbee92005-07-25 22:45:45 +000073static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq);
74static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq);
Ralf Baechle23fbee92005-07-25 22:45:45 +000075
Ralf Baechle23fbee92005-07-25 22:45:45 +000076#define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC"
Ralf Baechle94dee172006-07-02 14:41:42 +010077static struct irq_chip toshiba_rbtx4938_irq_ioc_type = {
Atsushi Nemoto70d21cd2007-01-15 00:07:25 +090078 .name = TOSHIBA_RBTX4938_IOC_NAME,
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +090079 .ack = toshiba_rbtx4938_irq_ioc_disable,
80 .mask = toshiba_rbtx4938_irq_ioc_disable,
81 .mask_ack = toshiba_rbtx4938_irq_ioc_disable,
82 .unmask = toshiba_rbtx4938_irq_ioc_enable,
Ralf Baechle23fbee92005-07-25 22:45:45 +000083};
84
Ralf Baechle23fbee92005-07-25 22:45:45 +000085int
86toshiba_rbtx4938_irq_nested(int sw_irq)
87{
88 u8 level3;
89
Atsushi Nemoto66140c82008-04-14 21:49:07 +090090 level3 = readb(rbtx4938_imstat_addr);
91 if (level3)
Ralf Baechle23fbee92005-07-25 22:45:45 +000092 /* must use fls so onboard ATA has priority */
93 sw_irq = TOSHIBA_RBTX4938_IRQ_IOC_BEG + fls(level3) - 1;
Ralf Baechle23fbee92005-07-25 22:45:45 +000094
Ralf Baechle23fbee92005-07-25 22:45:45 +000095 return sw_irq;
96}
97
98static struct irqaction toshiba_rbtx4938_irq_ioc_action = {
99 .handler = no_action,
100 .flags = 0,
101 .mask = CPU_MASK_NONE,
102 .name = TOSHIBA_RBTX4938_IOC_NAME,
103};
104
105/**********************************************************************************/
106/* Functions for ioc */
107/**********************************************************************************/
108static void __init
109toshiba_rbtx4938_irq_ioc_init(void)
110{
111 int i;
112
113 for (i = TOSHIBA_RBTX4938_IRQ_IOC_BEG;
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +0900114 i <= TOSHIBA_RBTX4938_IRQ_IOC_END; i++)
Atsushi Nemoto14178362006-11-14 01:13:18 +0900115 set_irq_chip_and_handler(i, &toshiba_rbtx4938_irq_ioc_type,
116 handle_level_irq);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000117
118 setup_irq(RBTX4938_IRQ_IOCINT,
119 &toshiba_rbtx4938_irq_ioc_action);
120}
121
Ralf Baechle23fbee92005-07-25 22:45:45 +0000122static void
123toshiba_rbtx4938_irq_ioc_enable(unsigned int irq)
124{
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900125 unsigned char v;
Ralf Baechle23fbee92005-07-25 22:45:45 +0000126
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900127 v = readb(rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000128 v |= (1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG));
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900129 writeb(v, rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000130 mmiowb();
Ralf Baechle23fbee92005-07-25 22:45:45 +0000131}
132
133static void
134toshiba_rbtx4938_irq_ioc_disable(unsigned int irq)
135{
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900136 unsigned char v;
Ralf Baechle23fbee92005-07-25 22:45:45 +0000137
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900138 v = readb(rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000139 v &= ~(1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG));
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900140 writeb(v, rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000141 mmiowb();
Ralf Baechle23fbee92005-07-25 22:45:45 +0000142}
143
Ralf Baechle23fbee92005-07-25 22:45:45 +0000144void __init arch_init_irq(void)
145{
146 extern void tx4938_irq_init(void);
147
148 /* Now, interrupt control disabled, */
149 /* all IRC interrupts are masked, */
150 /* all IRC interrupt mode are Low Active. */
151
152 /* mask all IOC interrupts */
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900153 writeb(0, rbtx4938_imask_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000154
155 /* clear SoftInt interrupts */
Atsushi Nemoto66140c82008-04-14 21:49:07 +0900156 writeb(0, rbtx4938_softint_addr);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000157 tx4938_irq_init();
158 toshiba_rbtx4938_irq_ioc_init();
159 /* Onboard 10M Ether: High Active */
Atsushi Nemotoc87abd72007-08-02 23:36:02 +0900160 set_irq_type(RBTX4938_IRQ_ETHER, IRQF_TRIGGER_HIGH);
Ralf Baechle23fbee92005-07-25 22:45:45 +0000161}