summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2022-09-02 20:26:40 +0200
committerLinus Walleij <linus.walleij@linaro.org>2022-09-08 10:05:43 +0200
commitd86e0344852eb65688c31227ee5a1e081f49e1bd (patch)
tree21fe223c246c53c1bd54e87d6439754b58bd150c /drivers/pinctrl
parentpinctrl: cy8c95x0: Drop unneeded npins assignment (diff)
downloadlinux-d86e0344852eb65688c31227ee5a1e081f49e1bd.tar.xz
linux-d86e0344852eb65688c31227ee5a1e081f49e1bd.zip
pinctrl: cy8c95x0: Enable GPIO range
Since it's a pin control, GPIO counterpart needs to know the mapping between pin numbering and GPIO numbering. Enable this by calling gpiochip_add_pin_range() at the chip addition time. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Patrick Rudolph <patrick.rudolph@9elements.com> Link: https://lore.kernel.org/r/20220902182650.83098-7-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/pinctrl-cy8c95x0.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/pinctrl/pinctrl-cy8c95x0.c b/drivers/pinctrl/pinctrl-cy8c95x0.c
index a511044ea60a..2e05585c88db 100644
--- a/drivers/pinctrl/pinctrl-cy8c95x0.c
+++ b/drivers/pinctrl/pinctrl-cy8c95x0.c
@@ -812,7 +812,20 @@ static void cy8c95x0_gpio_set_multiple(struct gpio_chip *gc,
cy8c95x0_write_regs_mask(chip, CY8C95X0_OUTPUT, bits, mask);
}
-static int cy8c95x0_setup_gpiochip(struct cy8c95x0_pinctrl *chip, int ngpio)
+static int cy8c95x0_add_pin_ranges(struct gpio_chip *gc)
+{
+ struct cy8c95x0_pinctrl *chip = gpiochip_get_data(gc);
+ struct device *dev = chip->dev;
+ int ret;
+
+ ret = gpiochip_add_pin_range(gc, dev_name(dev), 0, 0, chip->tpin);
+ if (ret)
+ dev_err(dev, "failed to add GPIO pin range\n");
+
+ return ret;
+}
+
+static int cy8c95x0_setup_gpiochip(struct cy8c95x0_pinctrl *chip)
{
struct gpio_chip *gc = &chip->gpio_chip;
@@ -825,9 +838,10 @@ static int cy8c95x0_setup_gpiochip(struct cy8c95x0_pinctrl *chip, int ngpio)
gc->set_multiple = cy8c95x0_gpio_set_multiple;
gc->set_config = cy8c95x0_gpio_set_config;
gc->can_sleep = true;
+ gc->add_pin_ranges = cy8c95x0_add_pin_ranges;
gc->base = -1;
- gc->ngpio = ngpio;
+ gc->ngpio = chip->tpin;
gc->parent = chip->dev;
gc->owner = THIS_MODULE;
@@ -1339,11 +1353,11 @@ static int cy8c95x0_probe(struct i2c_client *client)
goto err_exit;
}
- ret = cy8c95x0_setup_gpiochip(chip, chip->tpin);
+ ret = cy8c95x0_setup_pinctrl(chip);
if (ret)
goto err_exit;
- ret = cy8c95x0_setup_pinctrl(chip);
+ ret = cy8c95x0_setup_gpiochip(chip);
if (ret)
goto err_exit;