aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/irq.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa/irq.c')
-rw-r--r--arch/arm/mach-pxa/irq.c83
1 files changed, 35 insertions, 48 deletions
diff --git a/arch/arm/mach-pxa/irq.c b/arch/arm/mach-pxa/irq.c
index 54e91c9e71c8..2693e3c3776f 100644
--- a/arch/arm/mach-pxa/irq.c
+++ b/arch/arm/mach-pxa/irq.c
@@ -53,37 +53,48 @@ static inline int cpu_has_ipr(void)
53 return !cpu_is_pxa25x(); 53 return !cpu_is_pxa25x();
54} 54}
55 55
56static void pxa_mask_irq(unsigned int irq) 56static inline void __iomem *irq_base(int i)
57{
58 static unsigned long phys_base[] = {
59 0x40d00000,
60 0x40d0009c,
61 0x40d00130,
62 };
63
64 return (void __iomem *)io_p2v(phys_base[i]);
65}
66
67static void pxa_mask_irq(struct irq_data *d)
57{ 68{
58 void __iomem *base = get_irq_chip_data(irq); 69 void __iomem *base = irq_data_get_irq_chip_data(d);
59 uint32_t icmr = __raw_readl(base + ICMR); 70 uint32_t icmr = __raw_readl(base + ICMR);
60 71
61 icmr &= ~(1 << IRQ_BIT(irq)); 72 icmr &= ~(1 << IRQ_BIT(d->irq));
62 __raw_writel(icmr, base + ICMR); 73 __raw_writel(icmr, base + ICMR);
63} 74}
64 75
65static void pxa_unmask_irq(unsigned int irq) 76static void pxa_unmask_irq(struct irq_data *d)
66{ 77{
67 void __iomem *base = get_irq_chip_data(irq); 78 void __iomem *base = irq_data_get_irq_chip_data(d);
68 uint32_t icmr = __raw_readl(base + ICMR); 79 uint32_t icmr = __raw_readl(base + ICMR);
69 80
70 icmr |= 1 << IRQ_BIT(irq); 81 icmr |= 1 << IRQ_BIT(d->irq);
71 __raw_writel(icmr, base + ICMR); 82 __raw_writel(icmr, base + ICMR);
72} 83}
73 84
74static struct irq_chip pxa_internal_irq_chip = { 85static struct irq_chip pxa_internal_irq_chip = {
75 .name = "SC", 86 .name = "SC",
76 .ack = pxa_mask_irq, 87 .irq_ack = pxa_mask_irq,
77 .mask = pxa_mask_irq, 88 .irq_mask = pxa_mask_irq,
78 .unmask = pxa_unmask_irq, 89 .irq_unmask = pxa_unmask_irq,
79}; 90};
80 91
81/* 92/*
82 * GPIO IRQs for GPIO 0 and 1 93 * GPIO IRQs for GPIO 0 and 1
83 */ 94 */
84static int pxa_set_low_gpio_type(unsigned int irq, unsigned int type) 95static int pxa_set_low_gpio_type(struct irq_data *d, unsigned int type)
85{ 96{
86 int gpio = irq - IRQ_GPIO0; 97 int gpio = d->irq - IRQ_GPIO0;
87 98
88 if (__gpio_is_occupied(gpio)) { 99 if (__gpio_is_occupied(gpio)) {
89 pr_err("%s failed: GPIO is configured\n", __func__); 100 pr_err("%s failed: GPIO is configured\n", __func__);
@@ -103,31 +114,17 @@ static int pxa_set_low_gpio_type(unsigned int irq, unsigned int type)
103 return 0; 114 return 0;
104} 115}
105 116
106static void pxa_ack_low_gpio(unsigned int irq) 117static void pxa_ack_low_gpio(struct irq_data *d)
107{
108 GEDR0 = (1 << (irq - IRQ_GPIO0));
109}
110
111static void pxa_mask_low_gpio(unsigned int irq)
112{
113 struct irq_desc *desc = irq_to_desc(irq);
114
115 desc->chip->mask(irq);
116}
117
118static void pxa_unmask_low_gpio(unsigned int irq)
119{ 118{
120 struct irq_desc *desc = irq_to_desc(irq); 119 GEDR0 = (1 << (d->irq - IRQ_GPIO0));
121
122 desc->chip->unmask(irq);
123} 120}
124 121
125static struct irq_chip pxa_low_gpio_chip = { 122static struct irq_chip pxa_low_gpio_chip = {
126 .name = "GPIO-l", 123 .name = "GPIO-l",
127 .ack = pxa_ack_low_gpio, 124 .irq_ack = pxa_ack_low_gpio,
128 .mask = pxa_mask_low_gpio, 125 .irq_mask = pxa_mask_irq,
129 .unmask = pxa_unmask_low_gpio, 126 .irq_unmask = pxa_unmask_irq,
130 .set_type = pxa_set_low_gpio_type, 127 .irq_set_type = pxa_set_low_gpio_type,
131}; 128};
132 129
133static void __init pxa_init_low_gpio_irq(set_wake_t fn) 130static void __init pxa_init_low_gpio_irq(set_wake_t fn)
@@ -141,22 +138,12 @@ static void __init pxa_init_low_gpio_irq(set_wake_t fn)
141 138
142 for (irq = IRQ_GPIO0; irq <= IRQ_GPIO1; irq++) { 139 for (irq = IRQ_GPIO0; irq <= IRQ_GPIO1; irq++) {
143 set_irq_chip(irq, &pxa_low_gpio_chip); 140 set_irq_chip(irq, &pxa_low_gpio_chip);
141 set_irq_chip_data(irq, irq_base(0));
144 set_irq_handler(irq, handle_edge_irq); 142 set_irq_handler(irq, handle_edge_irq);
145 set_irq_flags(irq, IRQF_VALID); 143 set_irq_flags(irq, IRQF_VALID);
146 } 144 }
147 145
148 pxa_low_gpio_chip.set_wake = fn; 146 pxa_low_gpio_chip.irq_set_wake = fn;
149}
150
151static inline void __iomem *irq_base(int i)
152{
153 static unsigned long phys_base[] = {
154 0x40d00000,
155 0x40d0009c,
156 0x40d00130,
157 };
158
159 return (void __iomem *)io_p2v(phys_base[i >> 5]);
160} 147}
161 148
162void __init pxa_init_irq(int irq_nr, set_wake_t fn) 149void __init pxa_init_irq(int irq_nr, set_wake_t fn)
@@ -168,7 +155,7 @@ void __init pxa_init_irq(int irq_nr, set_wake_t fn)
168 pxa_internal_irq_nr = irq_nr; 155 pxa_internal_irq_nr = irq_nr;
169 156
170 for (n = 0; n < irq_nr; n += 32) { 157 for (n = 0; n < irq_nr; n += 32) {
171 void __iomem *base = irq_base(n); 158 void __iomem *base = irq_base(n >> 5);
172 159
173 __raw_writel(0, base + ICMR); /* disable all IRQs */ 160 __raw_writel(0, base + ICMR); /* disable all IRQs */
174 __raw_writel(0, base + ICLR); /* all IRQs are IRQ, not FIQ */ 161 __raw_writel(0, base + ICLR); /* all IRQs are IRQ, not FIQ */
@@ -188,7 +175,7 @@ void __init pxa_init_irq(int irq_nr, set_wake_t fn)
188 /* only unmasked interrupts kick us out of idle */ 175 /* only unmasked interrupts kick us out of idle */
189 __raw_writel(1, irq_base(0) + ICCR); 176 __raw_writel(1, irq_base(0) + ICCR);
190 177
191 pxa_internal_irq_chip.set_wake = fn; 178 pxa_internal_irq_chip.irq_set_wake = fn;
192 pxa_init_low_gpio_irq(fn); 179 pxa_init_low_gpio_irq(fn);
193} 180}
194 181
@@ -200,7 +187,7 @@ static int pxa_irq_suspend(struct sys_device *dev, pm_message_t state)
200{ 187{
201 int i; 188 int i;
202 189
203 for (i = 0; i < pxa_internal_irq_nr; i += 32) { 190 for (i = 0; i < pxa_internal_irq_nr / 32; i++) {
204 void __iomem *base = irq_base(i); 191 void __iomem *base = irq_base(i);
205 192
206 saved_icmr[i] = __raw_readl(base + ICMR); 193 saved_icmr[i] = __raw_readl(base + ICMR);
@@ -219,14 +206,14 @@ static int pxa_irq_resume(struct sys_device *dev)
219{ 206{
220 int i; 207 int i;
221 208
222 for (i = 0; i < pxa_internal_irq_nr; i += 32) { 209 for (i = 0; i < pxa_internal_irq_nr / 32; i++) {
223 void __iomem *base = irq_base(i); 210 void __iomem *base = irq_base(i);
224 211
225 __raw_writel(saved_icmr[i], base + ICMR); 212 __raw_writel(saved_icmr[i], base + ICMR);
226 __raw_writel(0, base + ICLR); 213 __raw_writel(0, base + ICLR);
227 } 214 }
228 215
229 if (!cpu_is_pxa25x()) 216 if (cpu_has_ipr())
230 for (i = 0; i < pxa_internal_irq_nr; i++) 217 for (i = 0; i < pxa_internal_irq_nr; i++)
231 __raw_writel(saved_ipr[i], IRQ_BASE + IPR(i)); 218 __raw_writel(saved_ipr[i], IRQ_BASE + IPR(i));
232 219