Commit 4bcff9c0 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Linus Walleij
Browse files

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: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/20250811-gpio-mmio-pinctrl-conv-v1-1-a84c5da2be20@linaro.org


Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 8f5ae30d
Loading
Loading
Loading
Loading
+20 −14
Original line number Diff line number Diff line
@@ -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;

	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 = bgpio_init(&hdp->gpio_chip, dev, 4,
			 hdp->base + HDP_GPOVAL,
			 hdp->base + HDP_GPOSET,
			 hdp->base + HDP_GPOCLR,
			 NULL, NULL, 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");