diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2017-01-23 15:34:34 +0300 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-01-26 15:27:37 +0100 |
commit | 2956b5d94a76b596fa5057c2b3ca915cb27d7652 (patch) | |
tree | 3a1dbce1201ef4923a4124f63eb209026e8fba7e /drivers/gpio/gpio-f7188x.c | |
parent | 15381bc7c7f52d56f87c56dd7c948ad78704b852 (diff) |
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>
Diffstat (limited to 'drivers/gpio/gpio-f7188x.c')
-rw-r--r-- | drivers/gpio/gpio-f7188x.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c index e8accde62aa7..56bd76c33767 100644 --- a/drivers/gpio/gpio-f7188x.c +++ b/drivers/gpio/gpio-f7188x.c @@ -131,9 +131,8 @@ static int f7188x_gpio_get(struct gpio_chip *chip, unsigned offset); static int f7188x_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value); static void f7188x_gpio_set(struct gpio_chip *chip, unsigned offset, int value); -static int f7188x_gpio_set_single_ended(struct gpio_chip *gc, - unsigned offset, - enum single_ended_mode mode); +static int f7188x_gpio_set_config(struct gpio_chip *chip, unsigned offset, + unsigned long config); #define F7188X_GPIO_BANK(_base, _ngpio, _regbase) \ { \ @@ -145,7 +144,7 @@ static int f7188x_gpio_set_single_ended(struct gpio_chip *gc, .get = f7188x_gpio_get, \ .direction_output = f7188x_gpio_direction_out, \ .set = f7188x_gpio_set, \ - .set_single_ended = f7188x_gpio_set_single_ended, \ + .set_config = f7188x_gpio_set_config, \ .base = _base, \ .ngpio = _ngpio, \ .can_sleep = true, \ @@ -326,17 +325,17 @@ static void f7188x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) superio_exit(sio->addr); } -static int f7188x_gpio_set_single_ended(struct gpio_chip *chip, - unsigned offset, - enum single_ended_mode mode) +static int f7188x_gpio_set_config(struct gpio_chip *chip, unsigned offset, + unsigned long config) { int err; + enum pin_config_param param = pinconf_to_config_param(config); struct f7188x_gpio_bank *bank = gpiochip_get_data(chip); struct f7188x_sio *sio = bank->data->sio; u8 data; - if (mode != LINE_MODE_OPEN_DRAIN && - mode != LINE_MODE_PUSH_PULL) + if (param != PIN_CONFIG_DRIVE_OPEN_DRAIN && + param != PIN_CONFIG_DRIVE_PUSH_PULL) return -ENOTSUPP; err = superio_enter(sio->addr); @@ -345,7 +344,7 @@ static int f7188x_gpio_set_single_ended(struct gpio_chip *chip, superio_select(sio->addr, SIO_LD_GPIO); data = superio_inb(sio->addr, gpio_out_mode(bank->regbase)); - if (mode == LINE_MODE_OPEN_DRAIN) + if (param == PIN_CONFIG_DRIVE_OPEN_DRAIN) data &= ~BIT(offset); else data |= BIT(offset); |