blob: 3c720551ac12e5ff5e0e975403d80192fc2b11ce [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Lennert Buytenhek3f7e5812006-09-18 23:10:26 +01002 * linux/arch/arm/mach-iop33x/irq.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Generic IOP331 IRQ handling functionality
5 *
6 * Author: Dave Jiang <dave.jiang@intel.com>
7 * Copyright (C) 2003 Intel Corp.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 *
14 */
15#include <linux/init.h>
16#include <linux/interrupt.h>
17#include <linux/list.h>
18
19#include <asm/mach/irq.h>
20#include <asm/irq.h>
21#include <asm/hardware.h>
22
23#include <asm/mach-types.h>
24
25static u32 iop331_mask0 = 0;
26static u32 iop331_mask1 = 0;
27
28static inline void intctl_write0(u32 val)
29{
30 // INTCTL0
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010031 iop3xx_cp6_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 asm volatile("mcr p6,0,%0,c0,c0,0"::"r" (val));
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010033 iop3xx_cp6_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070034}
35
36static inline void intctl_write1(u32 val)
37{
38 // INTCTL1
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010039 iop3xx_cp6_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 asm volatile("mcr p6,0,%0,c1,c0,0"::"r" (val));
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010041 iop3xx_cp6_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070042}
43
44static inline void intstr_write0(u32 val)
45{
46 // INTSTR0
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010047 iop3xx_cp6_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 asm volatile("mcr p6,0,%0,c2,c0,0"::"r" (val));
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010049 iop3xx_cp6_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
52static inline void intstr_write1(u32 val)
53{
54 // INTSTR1
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010055 iop3xx_cp6_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 asm volatile("mcr p6,0,%0,c3,c0,0"::"r" (val));
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010057 iop3xx_cp6_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070058}
59
Lennert Buytenhek7412b102006-09-18 23:24:10 +010060static inline void intbase_write(u32 val)
61{
62 iop3xx_cp6_enable();
63 asm volatile("mcr p6, 0, %0, c12, c0, 0" : : "r" (val));
64 iop3xx_cp6_disable();
65}
66
67static inline void intsize_write(u32 val)
68{
69 iop3xx_cp6_enable();
70 asm volatile("mcr p6, 0, %0, c13, c0, 0" : : "r" (val));
71 iop3xx_cp6_disable();
72}
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074static void
75iop331_irq_mask1 (unsigned int irq)
76{
Lennert Buytenhek610300e2006-09-18 23:22:24 +010077 iop331_mask0 &= ~(1 << irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 intctl_write0(iop331_mask0);
79}
80
81static void
82iop331_irq_mask2 (unsigned int irq)
83{
Lennert Buytenhek610300e2006-09-18 23:22:24 +010084 iop331_mask1 &= ~(1 << (irq - 32));
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 intctl_write1(iop331_mask1);
86}
87
88static void
89iop331_irq_unmask1(unsigned int irq)
90{
Lennert Buytenhek610300e2006-09-18 23:22:24 +010091 iop331_mask0 |= (1 << irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 intctl_write0(iop331_mask0);
93}
94
95static void
96iop331_irq_unmask2(unsigned int irq)
97{
Lennert Buytenhek610300e2006-09-18 23:22:24 +010098 iop331_mask1 |= (1 << (irq - 32));
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 intctl_write1(iop331_mask1);
100}
101
David Brownell38c677c2006-08-01 22:26:25 +0100102struct irq_chip iop331_irqchip1 = {
103 .name = "IOP-1",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 .ack = iop331_irq_mask1,
105 .mask = iop331_irq_mask1,
106 .unmask = iop331_irq_unmask1,
107};
108
David Brownell38c677c2006-08-01 22:26:25 +0100109struct irq_chip iop331_irqchip2 = {
110 .name = "IOP-2",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 .ack = iop331_irq_mask2,
112 .mask = iop331_irq_mask2,
113 .unmask = iop331_irq_unmask2,
114};
115
116void __init iop331_init_irq(void)
117{
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +0100118 unsigned int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
120 intctl_write0(0); // disable all interrupts
121 intctl_write1(0);
122 intstr_write0(0); // treat all as IRQ
123 intstr_write1(0);
Lennert Buytenhek7412b102006-09-18 23:24:10 +0100124 intbase_write(0);
125 intsize_write(1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 if(machine_is_iq80331()) // all interrupts are inputs to chip
Lennert Buytenhek7e9740b2006-09-18 23:17:36 +0100127 *IOP3XX_PCIIRSR = 0x0f;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
Lennert Buytenhek610300e2006-09-18 23:22:24 +0100129 for(i = 0; i < NR_IRQS; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 {
131 set_irq_chip(i, (i < 32) ? &iop331_irqchip1 : &iop331_irqchip2);
132 set_irq_handler(i, do_level_IRQ);
133 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
134 }
135}
136