pinctrl: stm32: use new generic GPIO chip API

Convert the driver to using the new generic GPIO chip interfaces from
linux/gpio/generic.h.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/20250811-gpio-mmio-pinctrl-conv-v1-1-a84c5da2be20@linaro.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Bartosz Golaszewski 2025-08-11 17:02:00 +02:00 committed by Linus Walleij
parent 8f5ae30d69
commit 4bcff9c05b
1 changed files with 19 additions and 13 deletions

View File

@ -6,6 +6,7 @@
#include <linux/bits.h>
#include <linux/clk.h>
#include <linux/gpio/driver.h>
#include <linux/gpio/generic.h>
#include <linux/io.h>
#include <linux/of.h>
#include <linux/of_device.h>
@ -45,7 +46,7 @@ struct stm32_hdp {
void __iomem *base;
struct clk *clk;
struct pinctrl_dev *pctl_dev;
struct gpio_chip gpio_chip;
struct gpio_generic_chip gpio_chip;
u32 mux_conf;
u32 gposet_conf;
const char * const *func_name;
@ -603,6 +604,7 @@ MODULE_DEVICE_TABLE(of, stm32_hdp_of_match);
static int stm32_hdp_probe(struct platform_device *pdev)
{
struct gpio_generic_chip_config config;
struct device *dev = &pdev->dev;
struct stm32_hdp *hdp;
u8 version;
@ -635,21 +637,25 @@ static int stm32_hdp_probe(struct platform_device *pdev)
if (err)
return dev_err_probe(dev, err, "Failed to enable pinctrl\n");
hdp->gpio_chip.get_direction = stm32_hdp_gpio_get_direction;
hdp->gpio_chip.ngpio = ARRAY_SIZE(stm32_hdp_pins);
hdp->gpio_chip.can_sleep = true;
hdp->gpio_chip.names = stm32_hdp_pins_group;
hdp->gpio_chip.gc.get_direction = stm32_hdp_gpio_get_direction;
hdp->gpio_chip.gc.ngpio = ARRAY_SIZE(stm32_hdp_pins);
hdp->gpio_chip.gc.can_sleep = true;
hdp->gpio_chip.gc.names = stm32_hdp_pins_group;
err = bgpio_init(&hdp->gpio_chip, dev, 4,
hdp->base + HDP_GPOVAL,
hdp->base + HDP_GPOSET,
hdp->base + HDP_GPOCLR,
NULL, NULL, BGPIOF_NO_INPUT);
config = (typeof(config)){
.dev = dev,
.sz = 4,
.dat = hdp->base + HDP_GPOVAL,
.set = hdp->base + HDP_GPOSET,
.clr = hdp->base + HDP_GPOCLR,
.flags = BGPIOF_NO_INPUT,
};
err = gpio_generic_chip_init(&hdp->gpio_chip, &config);
if (err)
return dev_err_probe(dev, err, "Failed to init bgpio\n");
return dev_err_probe(dev, err, "Failed to init the generic GPIO chip\n");
err = devm_gpiochip_add_data(dev, &hdp->gpio_chip, hdp);
err = devm_gpiochip_add_data(dev, &hdp->gpio_chip.gc, hdp);
if (err)
return dev_err_probe(dev, err, "Failed to add gpiochip\n");