blob: d667439c85733d76050141c7b8d301c49a58b1f9 [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
60static void
61iop331_irq_mask1 (unsigned int irq)
62{
63 iop331_mask0 &= ~(1 << (irq - IOP331_IRQ_OFS));
64 intctl_write0(iop331_mask0);
65}
66
67static void
68iop331_irq_mask2 (unsigned int irq)
69{
70 iop331_mask1 &= ~(1 << (irq - IOP331_IRQ_OFS - 32));
71 intctl_write1(iop331_mask1);
72}
73
74static void
75iop331_irq_unmask1(unsigned int irq)
76{
77 iop331_mask0 |= (1 << (irq - IOP331_IRQ_OFS));
78 intctl_write0(iop331_mask0);
79}
80
81static void
82iop331_irq_unmask2(unsigned int irq)
83{
84 iop331_mask1 |= (1 << (irq - IOP331_IRQ_OFS - 32));
85 intctl_write1(iop331_mask1);
86}
87
David Brownell38c677c2006-08-01 22:26:25 +010088struct irq_chip iop331_irqchip1 = {
89 .name = "IOP-1",
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 .ack = iop331_irq_mask1,
91 .mask = iop331_irq_mask1,
92 .unmask = iop331_irq_unmask1,
93};
94
David Brownell38c677c2006-08-01 22:26:25 +010095struct irq_chip iop331_irqchip2 = {
96 .name = "IOP-2",
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 .ack = iop331_irq_mask2,
98 .mask = iop331_irq_mask2,
99 .unmask = iop331_irq_unmask2,
100};
101
102void __init iop331_init_irq(void)
103{
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +0100104 unsigned int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
106 intctl_write0(0); // disable all interrupts
107 intctl_write1(0);
108 intstr_write0(0); // treat all as IRQ
109 intstr_write1(0);
110 if(machine_is_iq80331()) // all interrupts are inputs to chip
Lennert Buytenhek7e9740b2006-09-18 23:17:36 +0100111 *IOP3XX_PCIIRSR = 0x0f;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Lennert Buytenhek3f7e5812006-09-18 23:10:26 +0100113 for(i = IOP331_IRQ_OFS; i < NR_IRQS; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 {
115 set_irq_chip(i, (i < 32) ? &iop331_irqchip1 : &iop331_irqchip2);
116 set_irq_handler(i, do_level_IRQ);
117 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
118 }
119}
120