[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230816135839.24011-3-asmaa@nvidia.com>
Date: Wed, 16 Aug 2023 09:58:39 -0400
From: Asmaa Mnebhi <asmaa@...dia.com>
To: <andy.shevchenko@...il.com>, <linux-gpio@...r.kernel.org>,
<linus.walleij@...aro.org>, <bgolaszewski@...libre.com>,
<brgl@...ev.pl>, <linux-kernel@...r.kernel.org>
CC: Asmaa Mnebhi <asmaa@...dia.com>
Subject: [PATCH v1 2/2] gpio: mlxbf3: Support add_pin_ranges()
Support add_pin_ranges() so that pinctrl_gpio_request() can be called.
The GPIO value is not modified when the user runs the "gpioset" tool.
This is because when gpiochip_generic_request is invoked by the gpio-mlxbf3
driver, "pin_ranges" is empty so it skips "pinctrl_gpio_request()".
pinctrl_gpio_request() is essential in the code flow because it changes the
mux value so that software has control over modifying the GPIO value.
Adding add_pin_ranges() creates a dependency on the pinctrl-mlxbf3.c driver.
Fixes: cd33f216d24 ("gpio: mlxbf3: Add gpio driver support")
Signed-off-by: Asmaa Mnebhi <asmaa@...dia.com>
---
drivers/gpio/gpio-mlxbf3.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/gpio/gpio-mlxbf3.c b/drivers/gpio/gpio-mlxbf3.c
index e30cee108986..3828f5282b17 100644
--- a/drivers/gpio/gpio-mlxbf3.c
+++ b/drivers/gpio/gpio-mlxbf3.c
@@ -158,6 +158,24 @@ static const struct irq_chip gpio_mlxbf3_irqchip = {
GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
+static int mlxbf3_gpio_add_pin_ranges(struct gpio_chip *chip)
+{
+ int ret;
+ int id = 0;
+
+ id = !!(chip->ngpio % MLXBF3_GPIO_MAX_PINS_PER_BLOCK);
+
+ ret = gpiochip_add_pin_range(chip,
+ "MLNXBF34:00",
+ chip->base,
+ id * MLXBF3_GPIO_MAX_PINS_PER_BLOCK,
+ chip->ngpio);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
static int mlxbf3_gpio_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -197,6 +215,7 @@ static int mlxbf3_gpio_probe(struct platform_device *pdev)
gc->request = gpiochip_generic_request;
gc->free = gpiochip_generic_free;
gc->owner = THIS_MODULE;
+ gc->add_pin_ranges = mlxbf3_gpio_add_pin_ranges;
irq = platform_get_irq(pdev, 0);
if (irq >= 0) {
@@ -243,6 +262,7 @@ static struct platform_driver mlxbf3_gpio_driver = {
};
module_platform_driver(mlxbf3_gpio_driver);
+MODULE_SOFTDEP("pre: pinctrl-mlxbf3");
MODULE_DESCRIPTION("NVIDIA BlueField-3 GPIO Driver");
MODULE_AUTHOR("Asmaa Mnebhi <asmaa@...dia.com>");
MODULE_LICENSE("Dual BSD/GPL");
--
2.30.1
Powered by blists - more mailing lists