aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorHeiko Stübner <heiko@sntech.de>2013-06-16 11:41:16 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-06-17 12:18:34 -0400
commit44b6d93043ab6775cb8e190a82ae79afd121e944 (patch)
tree57955b50c5b015e1a17bf77ef2ab44eec83bbec0 /drivers/pinctrl
parent0f9bc4bcdf4fd8fe768a47e25efdf709192e4de1 (diff)
pinctrl: rockchip: correctly handle arguments of pinconf options
Change the rockchip pinctrl driver to handle the arguments to the pull pinconfig options correctly. So only accept non-0 values for the pull options as the rockchip pin-controller can only turn pulls on and off (this via BIAS_DISABLE). Signed-off-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/pinctrl-rockchip.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index c605b63b5a6b..427564f552b4 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -563,6 +563,25 @@ static const struct pinmux_ops rockchip_pmx_ops = {
563 * Pinconf_ops handling 563 * Pinconf_ops handling
564 */ 564 */
565 565
566static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl,
567 enum pin_config_param pull)
568{
569 /* rk3066b does support any pulls */
570 if (!ctrl->pull_offset)
571 return pull ? false : true;
572
573 if (ctrl->pull_auto) {
574 if (pull != PIN_CONFIG_BIAS_PULL_PIN_DEFAULT &&
575 pull != PIN_CONFIG_BIAS_DISABLE)
576 return false;
577 } else {
578 if (pull == PIN_CONFIG_BIAS_PULL_PIN_DEFAULT)
579 return false;
580 }
581
582 return true;
583}
584
566/* set the pin config settings for a specified pin */ 585/* set the pin config settings for a specified pin */
567static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, 586static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
568 unsigned long config) 587 unsigned long config)
@@ -570,12 +589,21 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
570 struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 589 struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
571 struct rockchip_pin_bank *bank = pin_to_bank(info, pin); 590 struct rockchip_pin_bank *bank = pin_to_bank(info, pin);
572 enum pin_config_param param = pinconf_to_config_param(config); 591 enum pin_config_param param = pinconf_to_config_param(config);
592 u16 arg = pinconf_to_config_argument(config);
573 593
574 switch (param) { 594 switch (param) {
575 case PIN_CONFIG_BIAS_DISABLE: 595 case PIN_CONFIG_BIAS_DISABLE:
596 return rockchip_set_pull(bank, pin - bank->pin_base, param);
597 break;
576 case PIN_CONFIG_BIAS_PULL_UP: 598 case PIN_CONFIG_BIAS_PULL_UP:
577 case PIN_CONFIG_BIAS_PULL_DOWN: 599 case PIN_CONFIG_BIAS_PULL_DOWN:
578 case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: 600 case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
601 if (!rockchip_pinconf_pull_valid(info->ctrl, param))
602 return -ENOTSUPP;
603
604 if (!arg)
605 return -EINVAL;
606
579 return rockchip_set_pull(bank, pin - bank->pin_base, param); 607 return rockchip_set_pull(bank, pin - bank->pin_base, param);
580 break; 608 break;
581 default: 609 default:
@@ -593,19 +621,24 @@ static int rockchip_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
593 struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 621 struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
594 struct rockchip_pin_bank *bank = pin_to_bank(info, pin); 622 struct rockchip_pin_bank *bank = pin_to_bank(info, pin);
595 enum pin_config_param param = pinconf_to_config_param(*config); 623 enum pin_config_param param = pinconf_to_config_param(*config);
596 unsigned int pull;
597 624
598 switch (param) { 625 switch (param) {
599 case PIN_CONFIG_BIAS_DISABLE: 626 case PIN_CONFIG_BIAS_DISABLE:
627 if (rockchip_get_pull(bank, pin - bank->pin_base) != param)
628 return -EINVAL;
629
630 *config = 0;
631 break;
600 case PIN_CONFIG_BIAS_PULL_UP: 632 case PIN_CONFIG_BIAS_PULL_UP:
601 case PIN_CONFIG_BIAS_PULL_DOWN: 633 case PIN_CONFIG_BIAS_PULL_DOWN:
602 case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: 634 case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
603 pull = rockchip_get_pull(bank, pin - bank->pin_base); 635 if (!rockchip_pinconf_pull_valid(info->ctrl, param))
636 return -ENOTSUPP;
604 637
605 if (pull != param) 638 if (rockchip_get_pull(bank, pin - bank->pin_base) != param)
606 return -EINVAL; 639 return -EINVAL;
607 640
608 *config = 0; 641 *config = 1;
609 break; 642 break;
610 default: 643 default:
611 return -ENOTSUPP; 644 return -ENOTSUPP;