pinctrl / gpio: Introduce .set_config() callback for GPIO chips
Currently we already have two pin configuration related callbacks available for GPIO chips .set_single_ended() and .set_debounce(). In future we expect to have even more, which does not scale well if we need to add yet another callback to the GPIO chip structure for each possible configuration parameter. Better solution is to reuse what we already have available in the generic pinconf. To support this, we introduce a new .set_config() callback for GPIO chips. The callback takes a single packed pin configuration value as parameter. This can then be extended easily beyond what is currently supported by just adding new types to the generic pinconf enum. If the GPIO driver is backed up by a pinctrl driver the GPIO driver can just assign gpiochip_generic_config() (introduced in this patch) to .set_config and that will take care configuration requests are directed to the pinctrl driver. We then convert the existing drivers over .set_config() and finally remove the .set_single_ended() and .set_debounce() callbacks. Suggested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:

committed by
Linus Walleij

parent
15381bc7c7
commit
2956b5d94a
@@ -974,6 +974,18 @@ static int omap_gpio_debounce(struct gpio_chip *chip, unsigned offset,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int omap_gpio_set_config(struct gpio_chip *chip, unsigned offset,
|
||||
unsigned long config)
|
||||
{
|
||||
u32 debounce;
|
||||
|
||||
if (pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE)
|
||||
return -ENOTSUPP;
|
||||
|
||||
debounce = pinconf_to_config_argument(config);
|
||||
return omap_gpio_debounce(chip, offset, debounce);
|
||||
}
|
||||
|
||||
static void omap_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||
{
|
||||
struct gpio_bank *bank;
|
||||
@@ -1045,7 +1057,7 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
|
||||
bank->chip.direction_input = omap_gpio_input;
|
||||
bank->chip.get = omap_gpio_get;
|
||||
bank->chip.direction_output = omap_gpio_output;
|
||||
bank->chip.set_debounce = omap_gpio_debounce;
|
||||
bank->chip.set_config = omap_gpio_set_config;
|
||||
bank->chip.set = omap_gpio_set;
|
||||
if (bank->is_mpuio) {
|
||||
bank->chip.label = "mpuio";
|
||||
|
Reference in New Issue
Block a user