aboutsummaryrefslogtreecommitdiffstats
path: root/arch/frv/kernel/irq-mb93493.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/frv/kernel/irq-mb93493.c')
-rw-r--r--arch/frv/kernel/irq-mb93493.c167
1 files changed, 108 insertions, 59 deletions
diff --git a/arch/frv/kernel/irq-mb93493.c b/arch/frv/kernel/irq-mb93493.c
index 988d035640e1..8ad9abfc7c13 100644
--- a/arch/frv/kernel/irq-mb93493.c
+++ b/arch/frv/kernel/irq-mb93493.c
@@ -1,6 +1,6 @@
1/* irq-mb93493.c: MB93493 companion chip interrupt handler 1/* irq-mb93493.c: MB93493 companion chip interrupt handler
2 * 2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. 3 * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com) 4 * Written by David Howells (dhowells@redhat.com)
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
@@ -24,84 +24,133 @@
24#include <asm/delay.h> 24#include <asm/delay.h>
25#include <asm/irq.h> 25#include <asm/irq.h>
26#include <asm/irc-regs.h> 26#include <asm/irc-regs.h>
27#include <asm/irq-routing.h>
28#include <asm/mb93493-irqs.h> 27#include <asm/mb93493-irqs.h>
28#include <asm/mb93493-regs.h>
29 29
30static void frv_mb93493_doirq(struct irq_source *source); 30#define IRQ_ROUTE_ONE(X) (X##_ROUTE << (X - IRQ_BASE_MB93493))
31
32#define IRQ_ROUTING \
33 (IRQ_ROUTE_ONE(IRQ_MB93493_VDC) | \
34 IRQ_ROUTE_ONE(IRQ_MB93493_VCC) | \
35 IRQ_ROUTE_ONE(IRQ_MB93493_AUDIO_OUT) | \
36 IRQ_ROUTE_ONE(IRQ_MB93493_I2C_0) | \
37 IRQ_ROUTE_ONE(IRQ_MB93493_I2C_1) | \
38 IRQ_ROUTE_ONE(IRQ_MB93493_USB) | \
39 IRQ_ROUTE_ONE(IRQ_MB93493_LOCAL_BUS) | \
40 IRQ_ROUTE_ONE(IRQ_MB93493_PCMCIA) | \
41 IRQ_ROUTE_ONE(IRQ_MB93493_GPIO) | \
42 IRQ_ROUTE_ONE(IRQ_MB93493_AUDIO_IN))
31 43
32/*****************************************************************************/
33/* 44/*
34 * MB93493 companion chip IRQ multiplexor 45 * daughter board PIC operations
35 */ 46 */
36static struct irq_source frv_mb93493[2] = { 47static void frv_mb93493_enable(unsigned int irq)
37 [0] = {
38 .muxname = "mb93493.0",
39 .muxdata = __region_CS3 + 0x3d0,
40 .doirq = frv_mb93493_doirq,
41 .irqmask = 0x0000,
42 },
43 [1] = {
44 .muxname = "mb93493.1",
45 .muxdata = __region_CS3 + 0x3d4,
46 .doirq = frv_mb93493_doirq,
47 .irqmask = 0x0000,
48 },
49};
50
51static void frv_mb93493_control(struct irq_group *group, int index, int on)
52{ 48{
53 struct irq_source *source;
54 uint32_t iqsr; 49 uint32_t iqsr;
50 volatile void *piqsr;
55 51
56 if ((frv_mb93493[0].irqmask & (1 << index))) 52 if (IRQ_ROUTING & (1 << (irq - IRQ_BASE_MB93493)))
57 source = &frv_mb93493[0]; 53 piqsr = __addr_MB93493_IQSR(1);
58 else 54 else
59 source = &frv_mb93493[1]; 55 piqsr = __addr_MB93493_IQSR(0);
60 56
61 iqsr = readl(source->muxdata); 57 iqsr = readl(piqsr);
62 if (on) 58 iqsr |= 1 << (irq - IRQ_BASE_MB93493 + 16);
63 iqsr |= 1 << (index + 16); 59 writel(iqsr, piqsr);
60}
61
62static void frv_mb93493_disable(unsigned int irq)
63{
64 uint32_t iqsr;
65 volatile void *piqsr;
66
67 if (IRQ_ROUTING & (1 << (irq - IRQ_BASE_MB93493)))
68 piqsr = __addr_MB93493_IQSR(1);
64 else 69 else
65 iqsr &= ~(1 << (index + 16)); 70 piqsr = __addr_MB93493_IQSR(0);
66 71
67 writel(iqsr, source->muxdata); 72 iqsr = readl(piqsr);
73 iqsr &= ~(1 << (irq - IRQ_BASE_MB93493 + 16));
74 writel(iqsr, piqsr);
68} 75}
69 76
70static struct irq_group frv_mb93493_irqs = { 77static void frv_mb93493_ack(unsigned int irq)
71 .first_irq = IRQ_BASE_MB93493,
72 .control = frv_mb93493_control,
73};
74
75static void frv_mb93493_doirq(struct irq_source *source)
76{ 78{
77 uint32_t mask = readl(source->muxdata); 79}
78 mask = mask & (mask >> 16) & 0xffff;
79 80
80 if (mask) 81static void frv_mb93493_end(unsigned int irq)
81 distribute_irqs(&frv_mb93493_irqs, mask); 82{
82} 83}
83 84
84static void __init mb93493_irq_route(int irq, int source) 85static struct irq_chip frv_mb93493_pic = {
86 .name = "mb93093",
87 .enable = frv_mb93493_enable,
88 .disable = frv_mb93493_disable,
89 .ack = frv_mb93493_ack,
90 .mask = frv_mb93493_disable,
91 .unmask = frv_mb93493_enable,
92 .end = frv_mb93493_end,
93};
94
95/*
96 * MB93493 PIC interrupt handler
97 */
98static irqreturn_t mb93493_interrupt(int irq, void *_piqsr, struct pt_regs *regs)
85{ 99{
86 frv_mb93493[source].irqmask |= 1 << (irq - IRQ_BASE_MB93493); 100 volatile void *piqsr = _piqsr;
87 frv_mb93493_irqs.sources[irq - IRQ_BASE_MB93493] = &frv_mb93493[source]; 101 irqreturn_t iret = 0;
102 uint32_t iqsr;
103
104 iqsr = readl(piqsr);
105 iqsr = iqsr & (iqsr >> 16) & 0xffff;
106
107 /* poll all the triggered IRQs */
108 while (iqsr) {
109 int irq;
110
111 asm("scan %1,gr0,%0" : "=r"(irq) : "r"(iqsr));
112 irq = 31 - irq;
113 iqsr &= ~(1 << irq);
114
115 if (__do_IRQ(IRQ_BASE_MB93493 + irq, regs))
116 iret |= IRQ_HANDLED;
117 }
118
119 return iret;
88} 120}
89 121
90void __init route_mb93493_irqs(void) 122/*
123 * define an interrupt action for each MB93493 PIC output
124 * - use dev_id to indicate the MB93493 PIC input to output mappings
125 */
126static struct irqaction mb93493_irq[2] = {
127 [0] = {
128 .handler = mb93493_interrupt,
129 .flags = IRQF_DISABLED | IRQF_SHARED,
130 .mask = CPU_MASK_NONE,
131 .name = "mb93493.0",
132 .dev_id = (void *) __addr_MB93493_IQSR(0),
133 },
134 [1] = {
135 .handler = mb93493_interrupt,
136 .flags = IRQF_DISABLED | IRQF_SHARED,
137 .mask = CPU_MASK_NONE,
138 .name = "mb93493.1",
139 .dev_id = (void *) __addr_MB93493_IQSR(1),
140 }
141};
142
143/*
144 * initialise the motherboard MB93493's PIC
145 */
146void __init mb93493_init(void)
91{ 147{
92 frv_irq_route_external(&frv_mb93493[0], IRQ_CPU_MB93493_0); 148 int irq;
93 frv_irq_route_external(&frv_mb93493[1], IRQ_CPU_MB93493_1); 149
94 150 for (irq = IRQ_BASE_MB93493 + 0; irq <= IRQ_BASE_MB93493 + 10; irq++)
95 frv_irq_set_group(&frv_mb93493_irqs); 151 set_irq_chip_and_handler(irq, &frv_mb93493_pic, handle_edge_irq);
96 152
97 mb93493_irq_route(IRQ_MB93493_VDC, IRQ_MB93493_VDC_ROUTE); 153 /* the MB93493 drives external IRQ inputs on the CPU PIC */
98 mb93493_irq_route(IRQ_MB93493_VCC, IRQ_MB93493_VCC_ROUTE); 154 setup_irq(IRQ_CPU_MB93493_0, &mb93493_irq[0]);
99 mb93493_irq_route(IRQ_MB93493_AUDIO_IN, IRQ_MB93493_AUDIO_IN_ROUTE); 155 setup_irq(IRQ_CPU_MB93493_1, &mb93493_irq[1]);
100 mb93493_irq_route(IRQ_MB93493_I2C_0, IRQ_MB93493_I2C_0_ROUTE);
101 mb93493_irq_route(IRQ_MB93493_I2C_1, IRQ_MB93493_I2C_1_ROUTE);
102 mb93493_irq_route(IRQ_MB93493_USB, IRQ_MB93493_USB_ROUTE);
103 mb93493_irq_route(IRQ_MB93493_LOCAL_BUS, IRQ_MB93493_LOCAL_BUS_ROUTE);
104 mb93493_irq_route(IRQ_MB93493_PCMCIA, IRQ_MB93493_PCMCIA_ROUTE);
105 mb93493_irq_route(IRQ_MB93493_GPIO, IRQ_MB93493_GPIO_ROUTE);
106 mb93493_irq_route(IRQ_MB93493_AUDIO_OUT, IRQ_MB93493_AUDIO_OUT_ROUTE);
107} 156}