Skip to content

Commit 8f67b1f

Browse files
maquefelarndb
authored andcommitted
gpio: ep93xx: add DT support for gpio-ep93xx
Add OF ID match table. Signed-off-by: Nikita Shubin <[email protected]> Tested-by: Alexander Sverdlin <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Reviewed-by: Mark Brown <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Acked-by: Bartosz Golaszewski <[email protected]> Acked-by: Miquel Raynal <[email protected]> Acked-by: Vinod Koul <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 177c20d commit 8f67b1f

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

drivers/gpio/gpio-ep93xx.c

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
#include <linux/init.h>
1313
#include <linux/module.h>
1414
#include <linux/platform_device.h>
15+
#include <linux/interrupt.h>
1516
#include <linux/io.h>
1617
#include <linux/irq.h>
1718
#include <linux/slab.h>
1819
#include <linux/gpio/driver.h>
1920
#include <linux/bitops.h>
2021
#include <linux/seq_file.h>
21-
#include <linux/interrupt.h>
2222

2323
struct ep93xx_gpio_irq_chip {
2424
void __iomem *base;
@@ -138,7 +138,8 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d)
138138
{
139139
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
140140
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);
142143

143144
if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH)
144145
eic->int_type2 ^= port_mask; /* switch edge direction */
@@ -147,26 +148,28 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d)
147148
ep93xx_gpio_update_int_params(eic);
148149

149150
writeb(port_mask, eic->base + EP93XX_INT_EOI_OFFSET);
150-
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
151+
gpiochip_disable_irq(gc, hwirq);
151152
}
152153

153154
static void ep93xx_gpio_irq_mask(struct irq_data *d)
154155
{
155156
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
156157
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
158+
irq_hw_number_t hwirq = irqd_to_hwirq(d);
157159

158-
eic->int_unmasked &= ~BIT(irqd_to_hwirq(d));
160+
eic->int_unmasked &= ~BIT(hwirq);
159161
ep93xx_gpio_update_int_params(eic);
160-
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
162+
gpiochip_disable_irq(gc, hwirq);
161163
}
162164

163165
static void ep93xx_gpio_irq_unmask(struct irq_data *d)
164166
{
165167
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
166168
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
169+
irq_hw_number_t hwirq = irqd_to_hwirq(d);
167170

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);
170173
ep93xx_gpio_update_int_params(eic);
171174
}
172175

@@ -179,11 +182,11 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
179182
{
180183
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
181184
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);
184187
irq_flow_handler_t handler;
185188

186-
gc->direction_input(gc, offset);
189+
gc->direction_input(gc, hwirq);
187190

188191
switch (type) {
189192
case IRQ_TYPE_EDGE_RISING:
@@ -209,7 +212,7 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
209212
case IRQ_TYPE_EDGE_BOTH:
210213
eic->int_type1 |= port_mask;
211214
/* set initial polarity based on current input level */
212-
if (gc->get(gc, offset))
215+
if (gc->get(gc, hwirq))
213216
eic->int_type2 &= ~port_mask; /* falling */
214217
else
215218
eic->int_type2 |= port_mask; /* rising */
@@ -285,9 +288,8 @@ static int ep93xx_setup_irqs(struct platform_device *pdev,
285288
if (girq->num_parents == 0)
286289
return -EINVAL;
287290

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);
291293
if (!girq->parents)
292294
return -ENOMEM;
293295

@@ -306,7 +308,7 @@ static int ep93xx_setup_irqs(struct platform_device *pdev,
306308
girq->parent_handler = ep93xx_gpio_f_irq_handler;
307309

308310
for (i = 0; i < girq->num_parents; i++) {
309-
irq = platform_get_irq(pdev, i);
311+
irq = platform_get_irq_optional(pdev, i);
310312
if (irq < 0)
311313
continue;
312314

@@ -359,9 +361,15 @@ static int ep93xx_gpio_probe(struct platform_device *pdev)
359361
return devm_gpiochip_add_data(&pdev->dev, gc, egc);
360362
}
361363

364+
static const struct of_device_id ep93xx_gpio_match[] = {
365+
{ .compatible = "cirrus,ep9301-gpio" },
366+
{ /* sentinel */ }
367+
};
368+
362369
static struct platform_driver ep93xx_gpio_driver = {
363370
.driver = {
364371
.name = "gpio-ep93xx",
372+
.of_match_table = ep93xx_gpio_match,
365373
},
366374
.probe = ep93xx_gpio_probe,
367375
};

0 commit comments

Comments
 (0)