mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-16 15:45:45 +00:00
gpio: pca953x: Improve bias setting
commit55a9968c7e
upstream. The commit15add06841
("gpio: pca953x: add ->set_config implementation") introduced support for bias setting. However this, due to being half-baked, brought potential issues: - the turning bias via disabling makes the pin floating for a while; - once enabled, bias can't be disabled. Fix all these by adding support for bias disabling and move the disabling part under the corresponding conditional. While at it, add support for default setting, since it's cheap to add. Fixes:15add06841
("gpio: pca953x: add ->set_config implementation") Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d84a69ac41
commit
17a027aafd
1 changed files with 9 additions and 7 deletions
|
@ -558,21 +558,21 @@ static int pca953x_gpio_set_pull_up_down(struct pca953x_chip *chip,
|
||||||
|
|
||||||
mutex_lock(&chip->i2c_lock);
|
mutex_lock(&chip->i2c_lock);
|
||||||
|
|
||||||
/* Disable pull-up/pull-down */
|
|
||||||
ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, 0);
|
|
||||||
if (ret)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
/* Configure pull-up/pull-down */
|
/* Configure pull-up/pull-down */
|
||||||
if (config == PIN_CONFIG_BIAS_PULL_UP)
|
if (config == PIN_CONFIG_BIAS_PULL_UP)
|
||||||
ret = regmap_write_bits(chip->regmap, pull_sel_reg, bit, bit);
|
ret = regmap_write_bits(chip->regmap, pull_sel_reg, bit, bit);
|
||||||
else if (config == PIN_CONFIG_BIAS_PULL_DOWN)
|
else if (config == PIN_CONFIG_BIAS_PULL_DOWN)
|
||||||
ret = regmap_write_bits(chip->regmap, pull_sel_reg, bit, 0);
|
ret = regmap_write_bits(chip->regmap, pull_sel_reg, bit, 0);
|
||||||
|
else
|
||||||
|
ret = 0;
|
||||||
if (ret)
|
if (ret)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
/* Enable pull-up/pull-down */
|
/* Disable/Enable pull-up/pull-down */
|
||||||
ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, bit);
|
if (config == PIN_CONFIG_BIAS_DISABLE)
|
||||||
|
ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, 0);
|
||||||
|
else
|
||||||
|
ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, bit);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
mutex_unlock(&chip->i2c_lock);
|
mutex_unlock(&chip->i2c_lock);
|
||||||
|
@ -586,7 +586,9 @@ static int pca953x_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
|
||||||
|
|
||||||
switch (pinconf_to_config_param(config)) {
|
switch (pinconf_to_config_param(config)) {
|
||||||
case PIN_CONFIG_BIAS_PULL_UP:
|
case PIN_CONFIG_BIAS_PULL_UP:
|
||||||
|
case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
|
||||||
case PIN_CONFIG_BIAS_PULL_DOWN:
|
case PIN_CONFIG_BIAS_PULL_DOWN:
|
||||||
|
case PIN_CONFIG_BIAS_DISABLE:
|
||||||
return pca953x_gpio_set_pull_up_down(chip, offset, config);
|
return pca953x_gpio_set_pull_up_down(chip, offset, config);
|
||||||
default:
|
default:
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
|
|
Loading…
Reference in a new issue