Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: ep93xx: add DT support for gpio-ep93xx

Add OF ID match table.

Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Tested-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Nikita Shubin and committed by
Arnd Bergmann
8f67b1f0 177c20d7

+23 -15
+23 -15
drivers/gpio/gpio-ep93xx.c
··· 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 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 */ ··· 148 147 ep93xx_gpio_update_int_params(eic); 149 148 150 149 writeb(port_mask, eic->base + EP93XX_INT_EOI_OFFSET); 151 - gpiochip_disable_irq(gc, irqd_to_hwirq(d)); 150 + gpiochip_disable_irq(gc, hwirq); 152 151 } 153 152 154 153 static void ep93xx_gpio_irq_mask(struct irq_data *d) 155 154 { 156 155 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 157 156 struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); 157 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 158 158 159 - eic->int_unmasked &= ~BIT(irqd_to_hwirq(d)); 159 + eic->int_unmasked &= ~BIT(hwirq); 160 160 ep93xx_gpio_update_int_params(eic); 161 - gpiochip_disable_irq(gc, irqd_to_hwirq(d)); 161 + gpiochip_disable_irq(gc, hwirq); 162 162 } 163 163 164 164 static void ep93xx_gpio_irq_unmask(struct irq_data *d) 165 165 { 166 166 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 167 167 struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); 168 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 168 169 169 - gpiochip_enable_irq(gc, irqd_to_hwirq(d)); 170 - eic->int_unmasked |= BIT(irqd_to_hwirq(d)); 170 + gpiochip_enable_irq(gc, hwirq); 171 + eic->int_unmasked |= BIT(hwirq); 171 172 ep93xx_gpio_update_int_params(eic); 172 173 } 173 174 ··· 182 179 { 183 180 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 184 181 struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); 185 - irq_hw_number_t offset = irqd_to_hwirq(d); 186 - int port_mask = BIT(offset); 182 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 183 + int port_mask = BIT(hwirq); 187 184 irq_flow_handler_t handler; 188 185 189 - gc->direction_input(gc, offset); 186 + gc->direction_input(gc, hwirq); 190 187 191 188 switch (type) { 192 189 case IRQ_TYPE_EDGE_RISING: ··· 212 209 case IRQ_TYPE_EDGE_BOTH: 213 210 eic->int_type1 |= port_mask; 214 211 /* set initial polarity based on current input level */ 215 - if (gc->get(gc, offset)) 212 + if (gc->get(gc, hwirq)) 216 213 eic->int_type2 &= ~port_mask; /* falling */ 217 214 else 218 215 eic->int_type2 |= port_mask; /* rising */ ··· 288 285 if (girq->num_parents == 0) 289 286 return -EINVAL; 290 287 291 - girq->parents = devm_kcalloc(dev, girq->num_parents, 292 - sizeof(*girq->parents), 293 - GFP_KERNEL); 288 + girq->parents = devm_kcalloc(dev, girq->num_parents, sizeof(*girq->parents), 289 + GFP_KERNEL); 294 290 if (!girq->parents) 295 291 return -ENOMEM; 296 292 ··· 308 306 girq->parent_handler = ep93xx_gpio_f_irq_handler; 309 307 310 308 for (i = 0; i < girq->num_parents; i++) { 311 - irq = platform_get_irq(pdev, i); 309 + irq = platform_get_irq_optional(pdev, i); 312 310 if (irq < 0) 313 311 continue; 314 312 ··· 361 359 return devm_gpiochip_add_data(&pdev->dev, gc, egc); 362 360 } 363 361 362 + static const struct of_device_id ep93xx_gpio_match[] = { 363 + { .compatible = "cirrus,ep9301-gpio" }, 364 + { /* sentinel */ } 365 + }; 366 + 364 367 static struct platform_driver ep93xx_gpio_driver = { 365 368 .driver = { 366 369 .name = "gpio-ep93xx", 370 + .of_match_table = ep93xx_gpio_match, 367 371 }, 368 372 .probe = ep93xx_gpio_probe, 369 373 };