aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/sh-pfc/pinctrl.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/sh-pfc/pinctrl.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/sh-pfc/pinctrl.c')
-rw-r--r--drivers/pinctrl/sh-pfc/pinctrl.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index 8649ec3910a3..e758af95c209 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -529,38 +529,44 @@ static int sh_pfc_pinconf_get(struct pinctrl_dev *pctldev, unsigned _pin,
529} 529}
530 530
531static int sh_pfc_pinconf_set(struct pinctrl_dev *pctldev, unsigned _pin, 531static int sh_pfc_pinconf_set(struct pinctrl_dev *pctldev, unsigned _pin,
532 unsigned long config) 532 unsigned long *configs, unsigned num_configs)
533{ 533{
534 struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); 534 struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
535 struct sh_pfc *pfc = pmx->pfc; 535 struct sh_pfc *pfc = pmx->pfc;
536 enum pin_config_param param = pinconf_to_config_param(config); 536 enum pin_config_param param;
537 unsigned long flags; 537 unsigned long flags;
538 unsigned int i;
538 539
539 if (!sh_pfc_pinconf_validate(pfc, _pin, param)) 540 for (i = 0; i < num_configs; i++) {
540 return -ENOTSUPP; 541 param = pinconf_to_config_param(configs[i]);
541 542
542 switch (param) { 543 if (!sh_pfc_pinconf_validate(pfc, _pin, param))
543 case PIN_CONFIG_BIAS_PULL_UP:
544 case PIN_CONFIG_BIAS_PULL_DOWN:
545 case PIN_CONFIG_BIAS_DISABLE:
546 if (!pfc->info->ops || !pfc->info->ops->set_bias)
547 return -ENOTSUPP; 544 return -ENOTSUPP;
548 545
549 spin_lock_irqsave(&pfc->lock, flags); 546 switch (param) {
550 pfc->info->ops->set_bias(pfc, _pin, param); 547 case PIN_CONFIG_BIAS_PULL_UP:
551 spin_unlock_irqrestore(&pfc->lock, flags); 548 case PIN_CONFIG_BIAS_PULL_DOWN:
549 case PIN_CONFIG_BIAS_DISABLE:
550 if (!pfc->info->ops || !pfc->info->ops->set_bias)
551 return -ENOTSUPP;
552 552
553 break; 553 spin_lock_irqsave(&pfc->lock, flags);
554 pfc->info->ops->set_bias(pfc, _pin, param);
555 spin_unlock_irqrestore(&pfc->lock, flags);
554 556
555 default: 557 break;
556 return -ENOTSUPP; 558
557 } 559 default:
560 return -ENOTSUPP;
561 }
562 } /* for each config */
558 563
559 return 0; 564 return 0;
560} 565}
561 566
562static int sh_pfc_pinconf_group_set(struct pinctrl_dev *pctldev, unsigned group, 567static int sh_pfc_pinconf_group_set(struct pinctrl_dev *pctldev, unsigned group,
563 unsigned long config) 568 unsigned long *configs,
569 unsigned num_configs)
564{ 570{
565 struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); 571 struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
566 const unsigned int *pins; 572 const unsigned int *pins;
@@ -571,7 +577,7 @@ static int sh_pfc_pinconf_group_set(struct pinctrl_dev *pctldev, unsigned group,
571 num_pins = pmx->pfc->info->groups[group].nr_pins; 577 num_pins = pmx->pfc->info->groups[group].nr_pins;
572 578
573 for (i = 0; i < num_pins; ++i) 579 for (i = 0; i < num_pins; ++i)
574 sh_pfc_pinconf_set(pctldev, pins[i], config); 580 sh_pfc_pinconf_set(pctldev, pins[i], configs, num_configs);
575 581
576 return 0; 582 return 0;
577} 583}