diff options
author | Patrice Chotard <patrice.chotard@st.com> | 2013-06-20 10:05:00 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-06-24 07:29:59 -0400 |
commit | 61ce135679d2b0b38f55edc7833b4b1f32c890ed (patch) | |
tree | 6e148f631eeacbf8a15d4e2326a9d333c913c72c | |
parent | 64a45c986349a00f0d4c96c0daeecdea76e31a96 (diff) |
pinctrl: abx500: fix abx500_pin_config_set()
- Update abx500_pin_config_set() in order to take in
account PIN_CONFIG_BIAS_DISABLE state to disable
pull up or pull down.
- Rework error path.
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/pinctrl/pinctrl-abx500.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c index f13a57b13b05..caa7ab6811d1 100644 --- a/drivers/pinctrl/pinctrl-abx500.c +++ b/drivers/pinctrl/pinctrl-abx500.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/pinctrl/machine.h> | 33 | #include <linux/pinctrl/machine.h> |
34 | 34 | ||
35 | #include "pinctrl-abx500.h" | 35 | #include "pinctrl-abx500.h" |
36 | #include "core.h" | ||
36 | #include "pinconf.h" | 37 | #include "pinconf.h" |
37 | 38 | ||
38 | /* | 39 | /* |
@@ -963,7 +964,7 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev, | |||
963 | struct pullud *pullud = pct->soc->pullud; | 964 | struct pullud *pullud = pct->soc->pullud; |
964 | struct gpio_chip *chip = &pct->chip; | 965 | struct gpio_chip *chip = &pct->chip; |
965 | unsigned offset; | 966 | unsigned offset; |
966 | int ret = 0; | 967 | int ret = -EINVAL; |
967 | enum pin_config_param param = pinconf_to_config_param(config); | 968 | enum pin_config_param param = pinconf_to_config_param(config); |
968 | enum pin_config_param argument = pinconf_to_config_argument(config); | 969 | enum pin_config_param argument = pinconf_to_config_argument(config); |
969 | 970 | ||
@@ -976,13 +977,32 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev, | |||
976 | offset = pin - 1; | 977 | offset = pin - 1; |
977 | 978 | ||
978 | switch (param) { | 979 | switch (param) { |
979 | case PIN_CONFIG_BIAS_PULL_DOWN: | 980 | case PIN_CONFIG_BIAS_DISABLE: |
981 | ret = abx500_gpio_direction_input(chip, offset); | ||
980 | /* | 982 | /* |
981 | * if argument = 1 set the pull down | 983 | * Some chips only support pull down, while some actually |
982 | * else clear the pull down | 984 | * support both pull up and pull down. Such chips have |
985 | * a "pullud" range specified for the pins that support | ||
986 | * both features. If the pin is not within that range, we | ||
987 | * fall back to the old bit set that only support pull down. | ||
983 | */ | 988 | */ |
989 | if (pullud && | ||
990 | pin >= pullud->first_pin && | ||
991 | pin <= pullud->last_pin) | ||
992 | ret = abx500_set_pull_updown(pct, | ||
993 | pin, | ||
994 | ABX500_GPIO_PULL_NONE); | ||
995 | else | ||
996 | /* Chip only supports pull down */ | ||
997 | ret = abx500_gpio_set_bits(chip, AB8500_GPIO_PUD1_REG, | ||
998 | offset, ABX500_GPIO_PULL_NONE); | ||
999 | break; | ||
1000 | |||
1001 | case PIN_CONFIG_BIAS_PULL_DOWN: | ||
984 | ret = abx500_gpio_direction_input(chip, offset); | 1002 | ret = abx500_gpio_direction_input(chip, offset); |
985 | /* | 1003 | /* |
1004 | * if argument = 1 set the pull down | ||
1005 | * else clear the pull down | ||
986 | * Some chips only support pull down, while some actually | 1006 | * Some chips only support pull down, while some actually |
987 | * support both pull up and pull down. Such chips have | 1007 | * support both pull up and pull down. Such chips have |
988 | * a "pullud" range specified for the pins that support | 1008 | * a "pullud" range specified for the pins that support |
@@ -1002,6 +1022,7 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev, | |||
1002 | break; | 1022 | break; |
1003 | 1023 | ||
1004 | case PIN_CONFIG_BIAS_PULL_UP: | 1024 | case PIN_CONFIG_BIAS_PULL_UP: |
1025 | ret = abx500_gpio_direction_input(chip, offset); | ||
1005 | /* | 1026 | /* |
1006 | * if argument = 1 set the pull up | 1027 | * if argument = 1 set the pull up |
1007 | * else clear the pull up | 1028 | * else clear the pull up |
@@ -1030,8 +1051,6 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev, | |||
1030 | 1051 | ||
1031 | default: | 1052 | default: |
1032 | dev_err(chip->dev, "illegal configuration requested\n"); | 1053 | dev_err(chip->dev, "illegal configuration requested\n"); |
1033 | |||
1034 | return -EINVAL; | ||
1035 | } | 1054 | } |
1036 | 1055 | ||
1037 | return ret; | 1056 | return ret; |