12
12
#include <linux/init.h>
13
13
#include <linux/module.h>
14
14
#include <linux/platform_device.h>
15
+ #include <linux/interrupt.h>
15
16
#include <linux/io.h>
16
17
#include <linux/irq.h>
17
18
#include <linux/slab.h>
18
19
#include <linux/gpio/driver.h>
19
20
#include <linux/bitops.h>
20
21
#include <linux/seq_file.h>
21
- #include <linux/interrupt.h>
22
22
23
23
struct ep93xx_gpio_irq_chip {
24
24
void __iomem * base ;
@@ -138,7 +138,8 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d)
138
138
{
139
139
struct gpio_chip * gc = irq_data_get_irq_chip_data (d );
140
140
struct ep93xx_gpio_irq_chip * eic = to_ep93xx_gpio_irq_chip (gc );
141
- int port_mask = BIT (irqd_to_hwirq (d ));
141
+ irq_hw_number_t hwirq = irqd_to_hwirq (d );
142
+ int port_mask = BIT (hwirq );
142
143
143
144
if (irqd_get_trigger_type (d ) == IRQ_TYPE_EDGE_BOTH )
144
145
eic -> int_type2 ^= port_mask ; /* switch edge direction */
@@ -147,26 +148,28 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d)
147
148
ep93xx_gpio_update_int_params (eic );
148
149
149
150
writeb (port_mask , eic -> base + EP93XX_INT_EOI_OFFSET );
150
- gpiochip_disable_irq (gc , irqd_to_hwirq ( d ) );
151
+ gpiochip_disable_irq (gc , hwirq );
151
152
}
152
153
153
154
static void ep93xx_gpio_irq_mask (struct irq_data * d )
154
155
{
155
156
struct gpio_chip * gc = irq_data_get_irq_chip_data (d );
156
157
struct ep93xx_gpio_irq_chip * eic = to_ep93xx_gpio_irq_chip (gc );
158
+ irq_hw_number_t hwirq = irqd_to_hwirq (d );
157
159
158
- eic -> int_unmasked &= ~BIT (irqd_to_hwirq ( d ) );
160
+ eic -> int_unmasked &= ~BIT (hwirq );
159
161
ep93xx_gpio_update_int_params (eic );
160
- gpiochip_disable_irq (gc , irqd_to_hwirq ( d ) );
162
+ gpiochip_disable_irq (gc , hwirq );
161
163
}
162
164
163
165
static void ep93xx_gpio_irq_unmask (struct irq_data * d )
164
166
{
165
167
struct gpio_chip * gc = irq_data_get_irq_chip_data (d );
166
168
struct ep93xx_gpio_irq_chip * eic = to_ep93xx_gpio_irq_chip (gc );
169
+ irq_hw_number_t hwirq = irqd_to_hwirq (d );
167
170
168
- gpiochip_enable_irq (gc , irqd_to_hwirq ( d ) );
169
- eic -> int_unmasked |= BIT (irqd_to_hwirq ( d ) );
171
+ gpiochip_enable_irq (gc , hwirq );
172
+ eic -> int_unmasked |= BIT (hwirq );
170
173
ep93xx_gpio_update_int_params (eic );
171
174
}
172
175
@@ -179,11 +182,11 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
179
182
{
180
183
struct gpio_chip * gc = irq_data_get_irq_chip_data (d );
181
184
struct ep93xx_gpio_irq_chip * eic = to_ep93xx_gpio_irq_chip (gc );
182
- irq_hw_number_t offset = irqd_to_hwirq (d );
183
- int port_mask = BIT (offset );
185
+ irq_hw_number_t hwirq = irqd_to_hwirq (d );
186
+ int port_mask = BIT (hwirq );
184
187
irq_flow_handler_t handler ;
185
188
186
- gc -> direction_input (gc , offset );
189
+ gc -> direction_input (gc , hwirq );
187
190
188
191
switch (type ) {
189
192
case IRQ_TYPE_EDGE_RISING :
@@ -209,7 +212,7 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
209
212
case IRQ_TYPE_EDGE_BOTH :
210
213
eic -> int_type1 |= port_mask ;
211
214
/* set initial polarity based on current input level */
212
- if (gc -> get (gc , offset ))
215
+ if (gc -> get (gc , hwirq ))
213
216
eic -> int_type2 &= ~port_mask ; /* falling */
214
217
else
215
218
eic -> int_type2 |= port_mask ; /* rising */
@@ -285,9 +288,8 @@ static int ep93xx_setup_irqs(struct platform_device *pdev,
285
288
if (girq -> num_parents == 0 )
286
289
return - EINVAL ;
287
290
288
- girq -> parents = devm_kcalloc (dev , girq -> num_parents ,
289
- sizeof (* girq -> parents ),
290
- GFP_KERNEL );
291
+ girq -> parents = devm_kcalloc (dev , girq -> num_parents , sizeof (* girq -> parents ),
292
+ GFP_KERNEL );
291
293
if (!girq -> parents )
292
294
return - ENOMEM ;
293
295
@@ -306,7 +308,7 @@ static int ep93xx_setup_irqs(struct platform_device *pdev,
306
308
girq -> parent_handler = ep93xx_gpio_f_irq_handler ;
307
309
308
310
for (i = 0 ; i < girq -> num_parents ; i ++ ) {
309
- irq = platform_get_irq (pdev , i );
311
+ irq = platform_get_irq_optional (pdev , i );
310
312
if (irq < 0 )
311
313
continue ;
312
314
@@ -359,9 +361,15 @@ static int ep93xx_gpio_probe(struct platform_device *pdev)
359
361
return devm_gpiochip_add_data (& pdev -> dev , gc , egc );
360
362
}
361
363
364
+ static const struct of_device_id ep93xx_gpio_match [] = {
365
+ { .compatible = "cirrus,ep9301-gpio" },
366
+ { /* sentinel */ }
367
+ };
368
+
362
369
static struct platform_driver ep93xx_gpio_driver = {
363
370
.driver = {
364
371
.name = "gpio-ep93xx" ,
372
+ .of_match_table = ep93xx_gpio_match ,
365
373
},
366
374
.probe = ep93xx_gpio_probe ,
367
375
};
0 commit comments