irq.c 4.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * Toshiba RBTX4938 specific interrupt handlers
 * Copyright (C) 2000-2001 Toshiba Corporation
 *
 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
 * terms of the GNU General Public License version 2. This program is
 * licensed "as is" without any warranty of any kind, whether express
 * or implied.
 *
 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
 */

/*
A
Atsushi Nemoto 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
 * MIPS_CPU_IRQ_BASE+00 Software 0
 * MIPS_CPU_IRQ_BASE+01 Software 1
 * MIPS_CPU_IRQ_BASE+02 Cascade TX4938-CP0
 * MIPS_CPU_IRQ_BASE+03 Multiplexed -- do not use
 * MIPS_CPU_IRQ_BASE+04 Multiplexed -- do not use
 * MIPS_CPU_IRQ_BASE+05 Multiplexed -- do not use
 * MIPS_CPU_IRQ_BASE+06 Multiplexed -- do not use
 * MIPS_CPU_IRQ_BASE+07 CPU TIMER
 *
 * TXX9_IRQ_BASE+00
 * TXX9_IRQ_BASE+01
 * TXX9_IRQ_BASE+02 Cascade RBTX4938-IOC
 * TXX9_IRQ_BASE+03 RBTX4938 RTL-8019AS Ethernet
 * TXX9_IRQ_BASE+04
 * TXX9_IRQ_BASE+05 TX4938 ETH1
 * TXX9_IRQ_BASE+06 TX4938 ETH0
 * TXX9_IRQ_BASE+07
 * TXX9_IRQ_BASE+08 TX4938 SIO 0
 * TXX9_IRQ_BASE+09 TX4938 SIO 1
 * TXX9_IRQ_BASE+10 TX4938 DMA0
 * TXX9_IRQ_BASE+11 TX4938 DMA1
 * TXX9_IRQ_BASE+12 TX4938 DMA2
 * TXX9_IRQ_BASE+13 TX4938 DMA3
 * TXX9_IRQ_BASE+14
 * TXX9_IRQ_BASE+15
 * TXX9_IRQ_BASE+16 TX4938 PCIC
 * TXX9_IRQ_BASE+17 TX4938 TMR0
 * TXX9_IRQ_BASE+18 TX4938 TMR1
 * TXX9_IRQ_BASE+19 TX4938 TMR2
 * TXX9_IRQ_BASE+20
 * TXX9_IRQ_BASE+21
 * TXX9_IRQ_BASE+22 TX4938 PCIERR
 * TXX9_IRQ_BASE+23
 * TXX9_IRQ_BASE+24
 * TXX9_IRQ_BASE+25
 * TXX9_IRQ_BASE+26
 * TXX9_IRQ_BASE+27
 * TXX9_IRQ_BASE+28
 * TXX9_IRQ_BASE+29
 * TXX9_IRQ_BASE+30
 * TXX9_IRQ_BASE+31 TX4938 SPI
 *
 * RBTX4938_IRQ_IOC+00 PCI-D
 * RBTX4938_IRQ_IOC+01 PCI-C
 * RBTX4938_IRQ_IOC+02 PCI-B
 * RBTX4938_IRQ_IOC+03 PCI-A
 * RBTX4938_IRQ_IOC+04 RTC
 * RBTX4938_IRQ_IOC+05 ATA
 * RBTX4938_IRQ_IOC+06 MODEM
 * RBTX4938_IRQ_IOC+07 SWINT
 */
65 66
#include <linux/init.h>
#include <linux/interrupt.h>
67 68
#include <asm/mipsregs.h>
#include <asm/txx9/generic.h>
A
Atsushi Nemoto 已提交
69
#include <asm/txx9/rbtx4938.h>
70 71 72 73 74

static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq);
static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq);

#define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC"
75
static struct irq_chip toshiba_rbtx4938_irq_ioc_type = {
76
	.name = TOSHIBA_RBTX4938_IOC_NAME,
A
Atsushi Nemoto 已提交
77 78 79 80
	.ack = toshiba_rbtx4938_irq_ioc_disable,
	.mask = toshiba_rbtx4938_irq_ioc_disable,
	.mask_ack = toshiba_rbtx4938_irq_ioc_disable,
	.unmask = toshiba_rbtx4938_irq_ioc_enable,
81 82
};

83
static int toshiba_rbtx4938_irq_nested(int sw_irq)
84 85 86
{
	u8 level3;

A
Atsushi Nemoto 已提交
87 88
	level3 = readb(rbtx4938_imstat_addr);
	if (level3)
89
		/* must use fls so onboard ATA has priority */
90
		sw_irq = RBTX4938_IRQ_IOC + fls(level3) - 1;
91 92 93 94 95 96 97 98
	return sw_irq;
}

static void __init
toshiba_rbtx4938_irq_ioc_init(void)
{
	int i;

99 100
	for (i = RBTX4938_IRQ_IOC;
	     i < RBTX4938_IRQ_IOC + RBTX4938_NR_IRQ_IOC; i++)
101 102
		set_irq_chip_and_handler(i, &toshiba_rbtx4938_irq_ioc_type,
					 handle_level_irq);
103

104
	set_irq_chained_handler(RBTX4938_IRQ_IOCINT, handle_simple_irq);
105 106 107 108 109
}

static void
toshiba_rbtx4938_irq_ioc_enable(unsigned int irq)
{
A
Atsushi Nemoto 已提交
110
	unsigned char v;
111

A
Atsushi Nemoto 已提交
112
	v = readb(rbtx4938_imask_addr);
113
	v |= (1 << (irq - RBTX4938_IRQ_IOC));
A
Atsushi Nemoto 已提交
114
	writeb(v, rbtx4938_imask_addr);
115 116 117 118 119 120
	mmiowb();
}

static void
toshiba_rbtx4938_irq_ioc_disable(unsigned int irq)
{
A
Atsushi Nemoto 已提交
121
	unsigned char v;
122

A
Atsushi Nemoto 已提交
123
	v = readb(rbtx4938_imask_addr);
124
	v &= ~(1 << (irq - RBTX4938_IRQ_IOC));
A
Atsushi Nemoto 已提交
125
	writeb(v, rbtx4938_imask_addr);
126 127 128
	mmiowb();
}

129
static int rbtx4938_irq_dispatch(int pending)
130
{
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
	int irq;

	if (pending & STATUSF_IP7)
		irq = MIPS_CPU_IRQ_BASE + 7;
	else if (pending & STATUSF_IP2) {
		irq = txx9_irq();
		if (irq == RBTX4938_IRQ_IOCINT)
			irq = toshiba_rbtx4938_irq_nested(irq);
	} else if (pending & STATUSF_IP1)
		irq = MIPS_CPU_IRQ_BASE + 0;
	else if (pending & STATUSF_IP0)
		irq = MIPS_CPU_IRQ_BASE + 1;
	else
		irq = -1;
	return irq;
}
147

148 149 150
void __init rbtx4938_irq_setup(void)
{
	txx9_irq_dispatch = rbtx4938_irq_dispatch;
151 152 153 154 155
	/* Now, interrupt control disabled, */
	/* all IRC interrupts are masked, */
	/* all IRC interrupt mode are Low Active. */

	/* mask all IOC interrupts */
A
Atsushi Nemoto 已提交
156
	writeb(0, rbtx4938_imask_addr);
157 158

	/* clear SoftInt interrupts */
A
Atsushi Nemoto 已提交
159
	writeb(0, rbtx4938_softint_addr);
160 161 162
	tx4938_irq_init();
	toshiba_rbtx4938_irq_ioc_init();
	/* Onboard 10M Ether: High Active */
163
	set_irq_type(RBTX4938_IRQ_ETHER, IRQF_TRIGGER_HIGH);
164
}