mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 11:03:43 +02:00
gpio: rda: use new generic GPIO chip API
Convert the driver to using the new generic GPIO chip interfaces from linux/gpio/generic.h. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20250825-gpio-mmio-gpio-conv-v1-11-356b4b1d5110@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
728e0ca4e1
commit
ebd63ab0f2
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/gpio/driver.h>
|
||||
#include <linux/gpio/generic.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
|
@ -35,7 +36,7 @@
|
|||
#define RDA_GPIO_BANK_NR 32
|
||||
|
||||
struct rda_gpio {
|
||||
struct gpio_chip chip;
|
||||
struct gpio_generic_chip chip;
|
||||
void __iomem *base;
|
||||
spinlock_t lock;
|
||||
int irq;
|
||||
|
|
@ -208,6 +209,7 @@ static const struct irq_chip rda_gpio_irq_chip = {
|
|||
|
||||
static int rda_gpio_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct gpio_generic_chip_config config;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct gpio_irq_chip *girq;
|
||||
struct rda_gpio *rda_gpio;
|
||||
|
|
@ -235,24 +237,29 @@ static int rda_gpio_probe(struct platform_device *pdev)
|
|||
|
||||
spin_lock_init(&rda_gpio->lock);
|
||||
|
||||
ret = bgpio_init(&rda_gpio->chip, dev, 4,
|
||||
rda_gpio->base + RDA_GPIO_VAL,
|
||||
rda_gpio->base + RDA_GPIO_SET,
|
||||
rda_gpio->base + RDA_GPIO_CLR,
|
||||
rda_gpio->base + RDA_GPIO_OEN_SET_OUT,
|
||||
rda_gpio->base + RDA_GPIO_OEN_SET_IN,
|
||||
BGPIOF_READ_OUTPUT_REG_SET);
|
||||
config = (typeof(config)){
|
||||
.dev = dev,
|
||||
.sz = 4,
|
||||
.dat = rda_gpio->base + RDA_GPIO_VAL,
|
||||
.set = rda_gpio->base + RDA_GPIO_SET,
|
||||
.clr = rda_gpio->base + RDA_GPIO_CLR,
|
||||
.dirout = rda_gpio->base + RDA_GPIO_OEN_SET_OUT,
|
||||
.dirin = rda_gpio->base + RDA_GPIO_OEN_SET_IN,
|
||||
.flags = BGPIOF_READ_OUTPUT_REG_SET,
|
||||
};
|
||||
|
||||
ret = gpio_generic_chip_init(&rda_gpio->chip, &config);
|
||||
if (ret) {
|
||||
dev_err(dev, "bgpio_init failed\n");
|
||||
dev_err(dev, "failed to initialize the generic GPIO chip\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
rda_gpio->chip.label = dev_name(dev);
|
||||
rda_gpio->chip.ngpio = ngpios;
|
||||
rda_gpio->chip.base = -1;
|
||||
rda_gpio->chip.gc.label = dev_name(dev);
|
||||
rda_gpio->chip.gc.ngpio = ngpios;
|
||||
rda_gpio->chip.gc.base = -1;
|
||||
|
||||
if (rda_gpio->irq >= 0) {
|
||||
girq = &rda_gpio->chip.irq;
|
||||
girq = &rda_gpio->chip.gc.irq;
|
||||
gpio_irq_chip_set_chip(girq, &rda_gpio_irq_chip);
|
||||
girq->handler = handle_bad_irq;
|
||||
girq->default_type = IRQ_TYPE_NONE;
|
||||
|
|
@ -269,7 +276,7 @@ static int rda_gpio_probe(struct platform_device *pdev)
|
|||
|
||||
platform_set_drvdata(pdev, rda_gpio);
|
||||
|
||||
return devm_gpiochip_add_data(dev, &rda_gpio->chip, rda_gpio);
|
||||
return devm_gpiochip_add_data(dev, &rda_gpio->chip.gc, rda_gpio);
|
||||
}
|
||||
|
||||
static const struct of_device_id rda_gpio_of_match[] = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user