aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-at91.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-at91.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-at91.c')
-rw-r--r--drivers/pinctrl/pinctrl-at91.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 7cce066c71b6..9685ff6c8b01 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -736,30 +736,40 @@ static int at91_pinconf_get(struct pinctrl_dev *pctldev,
736} 736}
737 737
738static int at91_pinconf_set(struct pinctrl_dev *pctldev, 738static int at91_pinconf_set(struct pinctrl_dev *pctldev,
739 unsigned pin_id, unsigned long config) 739 unsigned pin_id, unsigned long *configs,
740 unsigned num_configs)
740{ 741{
741 struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 742 struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
742 unsigned mask; 743 unsigned mask;
743 void __iomem *pio; 744 void __iomem *pio;
744 745 int i;
745 dev_dbg(info->dev, "%s:%d, pin_id=%d, config=0x%lx", __func__, __LINE__, pin_id, config); 746 unsigned long config;
746 pio = pin_to_controller(info, pin_to_bank(pin_id)); 747
747 mask = pin_to_mask(pin_id % MAX_NB_GPIO_PER_BANK); 748 for (i = 0; i < num_configs; i++) {
748 749 config = configs[i];
749 if (config & PULL_UP && config & PULL_DOWN) 750
750 return -EINVAL; 751 dev_dbg(info->dev,
751 752 "%s:%d, pin_id=%d, config=0x%lx",
752 at91_mux_set_pullup(pio, mask, config & PULL_UP); 753 __func__, __LINE__, pin_id, config);
753 at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE); 754 pio = pin_to_controller(info, pin_to_bank(pin_id));
754 if (info->ops->set_deglitch) 755 mask = pin_to_mask(pin_id % MAX_NB_GPIO_PER_BANK);
755 info->ops->set_deglitch(pio, mask, config & DEGLITCH); 756
756 if (info->ops->set_debounce) 757 if (config & PULL_UP && config & PULL_DOWN)
757 info->ops->set_debounce(pio, mask, config & DEBOUNCE, 758 return -EINVAL;
759
760 at91_mux_set_pullup(pio, mask, config & PULL_UP);
761 at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE);
762 if (info->ops->set_deglitch)
763 info->ops->set_deglitch(pio, mask, config & DEGLITCH);
764 if (info->ops->set_debounce)
765 info->ops->set_debounce(pio, mask, config & DEBOUNCE,
758 (config & DEBOUNCE_VAL) >> DEBOUNCE_VAL_SHIFT); 766 (config & DEBOUNCE_VAL) >> DEBOUNCE_VAL_SHIFT);
759 if (info->ops->set_pulldown) 767 if (info->ops->set_pulldown)
760 info->ops->set_pulldown(pio, mask, config & PULL_DOWN); 768 info->ops->set_pulldown(pio, mask, config & PULL_DOWN);
761 if (info->ops->disable_schmitt_trig && config & DIS_SCHMIT) 769 if (info->ops->disable_schmitt_trig && config & DIS_SCHMIT)
762 info->ops->disable_schmitt_trig(pio, mask); 770 info->ops->disable_schmitt_trig(pio, mask);
771
772 } /* for each config */
763 773
764 return 0; 774 return 0;
765} 775}