summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-single.c
diff options
context:
space:
mode:
authorSherman Yin <syin@broadcom.com>2013-08-27 14:32:12 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-08-28 07:34:41 -0400
commit03b054e9696c3cbd3d5905ec96da15acd0a2fe8d (patch)
tree7123b780c194d350b3e5134c267e17262effb385 /drivers/pinctrl/pinctrl-single.c
parentf5ba9c52bf1e236c4698c240955e5f119db62a28 (diff)
pinctrl: Pass all configs to driver on pin_config_set()
When setting pin configuration in the pinctrl framework, pin_config_set() or pin_config_group_set() is called in a loop to set one configuration at a time for the specified pin or group. This patch 1) removes the loop and 2) changes the API to pass the whole pin config array to the driver. It is now up to the driver to loop through the configs. This allows the driver to potentially combine configs and reduce the number of writes to pin config registers. All c files changed have been build-tested to verify the change compiles and that the corresponding .o is successfully generated. Signed-off-by: Sherman Yin <syin@broadcom.com> Reviewed-by: Christian Daudt <csd@broadcom.com> Reviewed-by: Matt Porter <matt.porter@linaro.org> Tested-by: Stephen Warren <swarren@nvidia.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-single.c')
-rw-r--r--drivers/pinctrl/pinctrl-single.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 6866548fab31..8f31768c665d 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -209,7 +209,7 @@ struct pcs_device {
209static int pcs_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin, 209static int pcs_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin,
210 unsigned long *config); 210 unsigned long *config);
211static int pcs_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin, 211static int pcs_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin,
212 unsigned long config); 212 unsigned long *configs, unsigned num_configs);
213 213
214static enum pin_config_param pcs_bias[] = { 214static enum pin_config_param pcs_bias[] = {
215 PIN_CONFIG_BIAS_PULL_DOWN, 215 PIN_CONFIG_BIAS_PULL_DOWN,
@@ -536,7 +536,7 @@ static void pcs_pinconf_clear_bias(struct pinctrl_dev *pctldev, unsigned pin)
536 int i; 536 int i;
537 for (i = 0; i < ARRAY_SIZE(pcs_bias); i++) { 537 for (i = 0; i < ARRAY_SIZE(pcs_bias); i++) {
538 config = pinconf_to_config_packed(pcs_bias[i], 0); 538 config = pinconf_to_config_packed(pcs_bias[i], 0);
539 pcs_pinconf_set(pctldev, pin, config); 539 pcs_pinconf_set(pctldev, pin, &config, 1);
540 } 540 }
541} 541}
542 542
@@ -622,22 +622,28 @@ static int pcs_pinconf_get(struct pinctrl_dev *pctldev,
622} 622}
623 623
624static int pcs_pinconf_set(struct pinctrl_dev *pctldev, 624static int pcs_pinconf_set(struct pinctrl_dev *pctldev,
625 unsigned pin, unsigned long config) 625 unsigned pin, unsigned long *configs,
626 unsigned num_configs)
626{ 627{
627 struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev); 628 struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev);
628 struct pcs_function *func; 629 struct pcs_function *func;
629 unsigned offset = 0, shift = 0, i, data, ret; 630 unsigned offset = 0, shift = 0, i, data, ret;
630 u16 arg; 631 u16 arg;
632 int j;
631 633
632 ret = pcs_get_function(pctldev, pin, &func); 634 ret = pcs_get_function(pctldev, pin, &func);
633 if (ret) 635 if (ret)
634 return ret; 636 return ret;
635 637
636 for (i = 0; i < func->nconfs; i++) { 638 for (j = 0; j < num_configs; j++) {
637 if (pinconf_to_config_param(config) == func->conf[i].param) { 639 for (i = 0; i < func->nconfs; i++) {
640 if (pinconf_to_config_param(configs[j])
641 != func->conf[i].param)
642 continue;
643
638 offset = pin * (pcs->width / BITS_PER_BYTE); 644 offset = pin * (pcs->width / BITS_PER_BYTE);
639 data = pcs->read(pcs->base + offset); 645 data = pcs->read(pcs->base + offset);
640 arg = pinconf_to_config_argument(config); 646 arg = pinconf_to_config_argument(configs[j]);
641 switch (func->conf[i].param) { 647 switch (func->conf[i].param) {
642 /* 2 parameters */ 648 /* 2 parameters */
643 case PIN_CONFIG_INPUT_SCHMITT: 649 case PIN_CONFIG_INPUT_SCHMITT:
@@ -667,10 +673,14 @@ static int pcs_pinconf_set(struct pinctrl_dev *pctldev,
667 return -ENOTSUPP; 673 return -ENOTSUPP;
668 } 674 }
669 pcs->write(data, pcs->base + offset); 675 pcs->write(data, pcs->base + offset);
670 return 0; 676
677 break;
671 } 678 }
672 } 679 if (i >= func->nconfs)
673 return -ENOTSUPP; 680 return -ENOTSUPP;
681 } /* for each config */
682
683 return 0;
674} 684}
675 685
676static int pcs_pinconf_group_get(struct pinctrl_dev *pctldev, 686static int pcs_pinconf_group_get(struct pinctrl_dev *pctldev,
@@ -695,7 +705,8 @@ static int pcs_pinconf_group_get(struct pinctrl_dev *pctldev,
695} 705}
696 706
697static int pcs_pinconf_group_set(struct pinctrl_dev *pctldev, 707static int pcs_pinconf_group_set(struct pinctrl_dev *pctldev,
698 unsigned group, unsigned long config) 708 unsigned group, unsigned long *configs,
709 unsigned num_configs)
699{ 710{
700 const unsigned *pins; 711 const unsigned *pins;
701 unsigned npins; 712 unsigned npins;
@@ -705,7 +716,7 @@ static int pcs_pinconf_group_set(struct pinctrl_dev *pctldev,
705 if (ret) 716 if (ret)
706 return ret; 717 return ret;
707 for (i = 0; i < npins; i++) { 718 for (i = 0; i < npins; i++) {
708 if (pcs_pinconf_set(pctldev, pins[i], config)) 719 if (pcs_pinconf_set(pctldev, pins[i], configs, num_configs))
709 return -ENOTSUPP; 720 return -ENOTSUPP;
710 } 721 }
711 return 0; 722 return 0;