diff options
author | Doug Anderson <dianders@chromium.org> | 2014-10-21 13:47:33 -0400 |
---|---|---|
committer | Heiko Stuebner <heiko@sntech.de> | 2014-10-29 16:06:21 -0400 |
commit | e5c2c9db0a2cff4d4df4b94f91146b26a0f0adc7 (patch) | |
tree | de56d37cd83b68cce00ad1c0e45bfec59194bfe6 /drivers/pinctrl | |
parent | 876d716ba9af205f46b7e911d39482e627aea0e8 (diff) |
pinctrl: rockchip: Don't call pinctrl_gpio_direction_output() in pin_config_set()
The Rockchip pinctrl driver was calling
rockchip_gpio_direction_output() in the pin_config_set() callback.
This was just a shortcut for:
* rockchip_gpio_set()
* pinctrl_gpio_direction_output()
Unfortunately it's not so good to call pinctrl_gpio_direction_output()
from pin_config_set(). Specifically when initting hogs you'll get an
error.
Let's refactor a little so we can call
_rockchip_pmx_gpio_set_direction() directly.
Signed-off-by: Doug Anderson <dianders@chromium.org>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/pinctrl-rockchip.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 230d8f379129..8a3c582108c5 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c | |||
@@ -856,22 +856,14 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, | |||
856 | * leads to this function call (via the pinctrl_gpio_direction_{input|output}() | 856 | * leads to this function call (via the pinctrl_gpio_direction_{input|output}() |
857 | * function called from the gpiolib interface). | 857 | * function called from the gpiolib interface). |
858 | */ | 858 | */ |
859 | static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, | 859 | static int _rockchip_pmx_gpio_set_direction(struct gpio_chip *chip, |
860 | struct pinctrl_gpio_range *range, | 860 | int pin, bool input) |
861 | unsigned offset, bool input) | ||
862 | { | 861 | { |
863 | struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); | ||
864 | struct rockchip_pin_bank *bank; | 862 | struct rockchip_pin_bank *bank; |
865 | struct gpio_chip *chip; | 863 | int ret; |
866 | int pin, ret; | ||
867 | u32 data; | 864 | u32 data; |
868 | 865 | ||
869 | chip = range->gc; | ||
870 | bank = gc_to_pin_bank(chip); | 866 | bank = gc_to_pin_bank(chip); |
871 | pin = offset - chip->base; | ||
872 | |||
873 | dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n", | ||
874 | offset, range->name, pin, input ? "input" : "output"); | ||
875 | 867 | ||
876 | ret = rockchip_set_mux(bank, pin, RK_FUNC_GPIO); | 868 | ret = rockchip_set_mux(bank, pin, RK_FUNC_GPIO); |
877 | if (ret < 0) | 869 | if (ret < 0) |
@@ -888,6 +880,23 @@ static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, | |||
888 | return 0; | 880 | return 0; |
889 | } | 881 | } |
890 | 882 | ||
883 | static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, | ||
884 | struct pinctrl_gpio_range *range, | ||
885 | unsigned offset, bool input) | ||
886 | { | ||
887 | struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); | ||
888 | struct gpio_chip *chip; | ||
889 | int pin; | ||
890 | |||
891 | chip = range->gc; | ||
892 | pin = offset - chip->base; | ||
893 | dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n", | ||
894 | offset, range->name, pin, input ? "input" : "output"); | ||
895 | |||
896 | return _rockchip_pmx_gpio_set_direction(chip, offset - chip->base, | ||
897 | input); | ||
898 | } | ||
899 | |||
891 | static const struct pinmux_ops rockchip_pmx_ops = { | 900 | static const struct pinmux_ops rockchip_pmx_ops = { |
892 | .get_functions_count = rockchip_pmx_get_funcs_count, | 901 | .get_functions_count = rockchip_pmx_get_funcs_count, |
893 | .get_function_name = rockchip_pmx_get_func_name, | 902 | .get_function_name = rockchip_pmx_get_func_name, |
@@ -917,8 +926,7 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl, | |||
917 | return false; | 926 | return false; |
918 | } | 927 | } |
919 | 928 | ||
920 | static int rockchip_gpio_direction_output(struct gpio_chip *gc, | 929 | static void rockchip_gpio_set(struct gpio_chip *gc, unsigned offset, int value); |
921 | unsigned offset, int value); | ||
922 | static int rockchip_gpio_get(struct gpio_chip *gc, unsigned offset); | 930 | static int rockchip_gpio_get(struct gpio_chip *gc, unsigned offset); |
923 | 931 | ||
924 | /* set the pin config settings for a specified pin */ | 932 | /* set the pin config settings for a specified pin */ |
@@ -959,9 +967,10 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, | |||
959 | return rc; | 967 | return rc; |
960 | break; | 968 | break; |
961 | case PIN_CONFIG_OUTPUT: | 969 | case PIN_CONFIG_OUTPUT: |
962 | rc = rockchip_gpio_direction_output(&bank->gpio_chip, | 970 | rockchip_gpio_set(&bank->gpio_chip, |
963 | pin - bank->pin_base, | 971 | pin - bank->pin_base, arg); |
964 | arg); | 972 | rc = _rockchip_pmx_gpio_set_direction(&bank->gpio_chip, |
973 | pin - bank->pin_base, false); | ||
965 | if (rc) | 974 | if (rc) |
966 | return rc; | 975 | return rc; |
967 | break; | 976 | break; |