Skip to content

Commit 38a700e

Browse files
Asmaa MnebhiBartosz Golaszewski
authored andcommitted
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: cd33f21 ("gpio: mlxbf3: Add gpio driver support") Signed-off-by: Asmaa Mnebhi <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 9e0fa5d commit 38a700e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/gpio/gpio-mlxbf3.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* gpio[1]: HOST_GPIO32->HOST_GPIO55
2020
*/
2121
#define MLXBF3_GPIO_MAX_PINS_PER_BLOCK 32
22+
#define MLXBF3_GPIO_MAX_PINS_BLOCK0 32
23+
#define MLXBF3_GPIO_MAX_PINS_BLOCK1 24
2224

2325
/*
2426
* fw_gpio[x] block registers and their offset
@@ -158,6 +160,26 @@ static const struct irq_chip gpio_mlxbf3_irqchip = {
158160
GPIOCHIP_IRQ_RESOURCE_HELPERS,
159161
};
160162

163+
static int mlxbf3_gpio_add_pin_ranges(struct gpio_chip *chip)
164+
{
165+
unsigned int id;
166+
167+
switch(chip->ngpio) {
168+
case MLXBF3_GPIO_MAX_PINS_BLOCK0:
169+
id = 0;
170+
break;
171+
case MLXBF3_GPIO_MAX_PINS_BLOCK1:
172+
id = 1;
173+
break;
174+
default:
175+
return -EINVAL;
176+
}
177+
178+
return gpiochip_add_pin_range(chip, "MLNXBF34:00",
179+
chip->base, id * MLXBF3_GPIO_MAX_PINS_PER_BLOCK,
180+
chip->ngpio);
181+
}
182+
161183
static int mlxbf3_gpio_probe(struct platform_device *pdev)
162184
{
163185
struct device *dev = &pdev->dev;
@@ -197,6 +219,7 @@ static int mlxbf3_gpio_probe(struct platform_device *pdev)
197219
gc->request = gpiochip_generic_request;
198220
gc->free = gpiochip_generic_free;
199221
gc->owner = THIS_MODULE;
222+
gc->add_pin_ranges = mlxbf3_gpio_add_pin_ranges;
200223

201224
irq = platform_get_irq(pdev, 0);
202225
if (irq >= 0) {
@@ -243,6 +266,7 @@ static struct platform_driver mlxbf3_gpio_driver = {
243266
};
244267
module_platform_driver(mlxbf3_gpio_driver);
245268

269+
MODULE_SOFTDEP("pre: pinctrl-mlxbf3");
246270
MODULE_DESCRIPTION("NVIDIA BlueField-3 GPIO Driver");
247271
MODULE_AUTHOR("Asmaa Mnebhi <[email protected]>");
248272
MODULE_LICENSE("Dual BSD/GPL");

0 commit comments

Comments
 (0)