aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-wcove.c
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2017-01-23 07:34:34 -0500
committerLinus Walleij <linus.walleij@linaro.org>2017-01-26 09:27:37 -0500
commit2956b5d94a76b596fa5057c2b3ca915cb27d7652 (patch)
tree3a1dbce1201ef4923a4124f63eb209026e8fba7e /drivers/gpio/gpio-wcove.c
parent15381bc7c7f52d56f87c56dd7c948ad78704b852 (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-wcove.c')
-rw-r--r--drivers/gpio/gpio-wcove.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
index 34baee5b1dd6..97613de5304e 100644
--- a/drivers/gpio/gpio-wcove.c
+++ b/drivers/gpio/gpio-wcove.c
@@ -202,17 +202,16 @@ static void wcove_gpio_set(struct gpio_chip *chip,
202 regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 1, 0); 202 regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 1, 0);
203} 203}
204 204
205static int wcove_gpio_set_single_ended(struct gpio_chip *chip, 205static int wcove_gpio_set_config(struct gpio_chip *chip, unsigned int gpio,
206 unsigned int gpio, 206 unsigned long config)
207 enum single_ended_mode mode)
208{ 207{
209 struct wcove_gpio *wg = gpiochip_get_data(chip); 208 struct wcove_gpio *wg = gpiochip_get_data(chip);
210 209
211 switch (mode) { 210 switch (pinconf_to_config_param(config)) {
212 case LINE_MODE_OPEN_DRAIN: 211 case PIN_CONFIG_DRIVE_OPEN_DRAIN:
213 return regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 212 return regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT),
214 CTLO_DRV_MASK, CTLO_DRV_OD); 213 CTLO_DRV_MASK, CTLO_DRV_OD);
215 case LINE_MODE_PUSH_PULL: 214 case PIN_CONFIG_DRIVE_PUSH_PULL:
216 return regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 215 return regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT),
217 CTLO_DRV_MASK, CTLO_DRV_CMOS); 216 CTLO_DRV_MASK, CTLO_DRV_CMOS);
218 default: 217 default:
@@ -411,7 +410,7 @@ static int wcove_gpio_probe(struct platform_device *pdev)
411 wg->chip.get_direction = wcove_gpio_get_direction; 410 wg->chip.get_direction = wcove_gpio_get_direction;
412 wg->chip.get = wcove_gpio_get; 411 wg->chip.get = wcove_gpio_get;
413 wg->chip.set = wcove_gpio_set; 412 wg->chip.set = wcove_gpio_set;
414 wg->chip.set_single_ended = wcove_gpio_set_single_ended, 413 wg->chip.set_config = wcove_gpio_set_config,
415 wg->chip.base = -1; 414 wg->chip.base = -1;
416 wg->chip.ngpio = WCOVE_VGPIO_NUM; 415 wg->chip.ngpio = WCOVE_VGPIO_NUM;
417 wg->chip.can_sleep = true; 416 wg->chip.can_sleep = true;