irq.c 5.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*
 * iop13xx IRQ handling / support functions
 * Copyright (c) 2005-2006, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307 USA.
 *
 */
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/sysctl.h>
#include <asm/uaccess.h>
#include <asm/mach/irq.h>
#include <asm/irq.h>
#include <asm/hardware.h>
#include <asm/mach-types.h>
#include <asm/arch/irqs.h>
D
Daniel Wolstenholme 已提交
29
#include <asm/arch/msi.h>
30 31 32

/* INTCTL0 CP6 R0 Page 4
 */
33
static u32 read_intctl_0(void)
34 35 36 37 38
{
	u32 val;
	asm volatile("mrc p6, 0, %0, c0, c4, 0":"=r" (val));
	return val;
}
39
static void write_intctl_0(u32 val)
40 41 42 43 44 45
{
	asm volatile("mcr p6, 0, %0, c0, c4, 0"::"r" (val));
}

/* INTCTL1 CP6 R1 Page 4
 */
46
static u32 read_intctl_1(void)
47 48 49 50 51
{
	u32 val;
	asm volatile("mrc p6, 0, %0, c1, c4, 0":"=r" (val));
	return val;
}
52
static void write_intctl_1(u32 val)
53 54 55 56 57 58
{
	asm volatile("mcr p6, 0, %0, c1, c4, 0"::"r" (val));
}

/* INTCTL2 CP6 R2 Page 4
 */
59
static u32 read_intctl_2(void)
60 61 62 63 64
{
	u32 val;
	asm volatile("mrc p6, 0, %0, c2, c4, 0":"=r" (val));
	return val;
}
65
static void write_intctl_2(u32 val)
66 67 68 69 70 71
{
	asm volatile("mcr p6, 0, %0, c2, c4, 0"::"r" (val));
}

/* INTCTL3 CP6 R3 Page 4
 */
72
static u32 read_intctl_3(void)
73 74 75 76 77
{
	u32 val;
	asm volatile("mrc p6, 0, %0, c3, c4, 0":"=r" (val));
	return val;
}
78
static void write_intctl_3(u32 val)
79 80 81 82 83 84
{
	asm volatile("mcr p6, 0, %0, c3, c4, 0"::"r" (val));
}

/* INTSTR0 CP6 R0 Page 5
 */
85
static void write_intstr_0(u32 val)
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
{
	asm volatile("mcr p6, 0, %0, c0, c5, 0"::"r" (val));
}

/* INTSTR1 CP6 R1 Page 5
 */
static void write_intstr_1(u32 val)
{
	asm volatile("mcr p6, 0, %0, c1, c5, 0"::"r" (val));
}

/* INTSTR2 CP6 R2 Page 5
 */
static void write_intstr_2(u32 val)
{
	asm volatile("mcr p6, 0, %0, c2, c5, 0"::"r" (val));
}

/* INTSTR3 CP6 R3 Page 5
 */
static void write_intstr_3(u32 val)
{
	asm volatile("mcr p6, 0, %0, c3, c5, 0"::"r" (val));
}

/* INTBASE CP6 R0 Page 2
 */
static void write_intbase(u32 val)
{
	asm volatile("mcr p6, 0, %0, c0, c2, 0"::"r" (val));
}

/* INTSIZE CP6 R2 Page 2
 */
static void write_intsize(u32 val)
{
	asm volatile("mcr p6, 0, %0, c2, c2, 0"::"r" (val));
}

/* 0 = Interrupt Masked and 1 = Interrupt not masked */
static void
iop13xx_irq_mask0 (unsigned int irq)
{
	write_intctl_0(read_intctl_0() & ~(1 << (irq - 0)));
}

static void
iop13xx_irq_mask1 (unsigned int irq)
{
	write_intctl_1(read_intctl_1() & ~(1 << (irq - 32)));
}

static void
iop13xx_irq_mask2 (unsigned int irq)
{
	write_intctl_2(read_intctl_2() & ~(1 << (irq - 64)));
}

static void
iop13xx_irq_mask3 (unsigned int irq)
{
	write_intctl_3(read_intctl_3() & ~(1 << (irq - 96)));
}

static void
iop13xx_irq_unmask0(unsigned int irq)
{
	write_intctl_0(read_intctl_0() | (1 << (irq - 0)));
}

static void
iop13xx_irq_unmask1(unsigned int irq)
{
	write_intctl_1(read_intctl_1() | (1 << (irq - 32)));
}

static void
iop13xx_irq_unmask2(unsigned int irq)
{
	write_intctl_2(read_intctl_2() | (1 << (irq - 64)));
}

static void
iop13xx_irq_unmask3(unsigned int irq)
{
	write_intctl_3(read_intctl_3() | (1 << (irq - 96)));
}

174 175
static struct irq_chip iop13xx_irqchip1 = {
	.name	= "IOP13xx-1",
176 177 178 179 180
	.ack    = iop13xx_irq_mask0,
	.mask   = iop13xx_irq_mask0,
	.unmask = iop13xx_irq_unmask0,
};

181 182
static struct irq_chip iop13xx_irqchip2 = {
	.name	= "IOP13xx-2",
183 184 185 186 187
	.ack    = iop13xx_irq_mask1,
	.mask   = iop13xx_irq_mask1,
	.unmask = iop13xx_irq_unmask1,
};

188 189
static struct irq_chip iop13xx_irqchip3 = {
	.name	= "IOP13xx-3",
190 191 192 193 194
	.ack    = iop13xx_irq_mask2,
	.mask   = iop13xx_irq_mask2,
	.unmask = iop13xx_irq_unmask2,
};

195 196
static struct irq_chip iop13xx_irqchip4 = {
	.name	= "IOP13xx-4",
197 198 199 200 201
	.ack    = iop13xx_irq_mask3,
	.mask   = iop13xx_irq_mask3,
	.unmask = iop13xx_irq_unmask3,
};

202 203
extern void iop_init_cp6_handler(void);

204 205 206 207
void __init iop13xx_init_irq(void)
{
	unsigned int i;

208
	iop_init_cp6_handler();
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225

	/* disable all interrupts */
	write_intctl_0(0);
	write_intctl_1(0);
	write_intctl_2(0);
	write_intctl_3(0);

	/* treat all as IRQ */
	write_intstr_0(0);
	write_intstr_1(0);
	write_intstr_2(0);
	write_intstr_3(0);

	/* initialize the interrupt vector generator */
	write_intbase(INTBASE);
	write_intsize(INTSIZE_4);

D
Daniel Wolstenholme 已提交
226
	for(i = 0; i <= IRQ_IOP13XX_HPI; i++) {
227 228
		if (i < 32)
			set_irq_chip(i, &iop13xx_irqchip1);
229
		else if (i < 64)
230
			set_irq_chip(i, &iop13xx_irqchip2);
231
		else if (i < 96)
232
			set_irq_chip(i, &iop13xx_irqchip3);
233 234
		else
			set_irq_chip(i, &iop13xx_irqchip4);
235

236
		set_irq_handler(i, handle_level_irq);
237 238
		set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
	}
D
Daniel Wolstenholme 已提交
239 240

	iop13xx_msi_init();
241
}