aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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
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')
-rw-r--r--drivers/pinctrl/mvebu/pinctrl-mvebu.c26
-rw-r--r--drivers/pinctrl/pinconf.c42
-rw-r--r--drivers/pinctrl/pinctrl-abx500.c187
-rw-r--r--drivers/pinctrl/pinctrl-at91.c48
-rw-r--r--drivers/pinctrl/pinctrl-bcm2835.c43
-rw-r--r--drivers/pinctrl/pinctrl-exynos5440.c113
-rw-r--r--drivers/pinctrl/pinctrl-falcon.c63
-rw-r--r--drivers/pinctrl/pinctrl-imx.c28
-rw-r--r--drivers/pinctrl/pinctrl-mxs.c91
-rw-r--r--drivers/pinctrl/pinctrl-nomadik.c125
-rw-r--r--drivers/pinctrl/pinctrl-palmas.c134
-rw-r--r--drivers/pinctrl/pinctrl-rockchip.c57
-rw-r--r--drivers/pinctrl/pinctrl-samsung.c17
-rw-r--r--drivers/pinctrl/pinctrl-single.c33
-rw-r--r--drivers/pinctrl/pinctrl-st.c11
-rw-r--r--drivers/pinctrl/pinctrl-sunxi.c77
-rw-r--r--drivers/pinctrl/pinctrl-tegra.c69
-rw-r--r--drivers/pinctrl/pinctrl-tz1090-pdc.c135
-rw-r--r--drivers/pinctrl/pinctrl-tz1090.c140
-rw-r--r--drivers/pinctrl/pinctrl-u300.c18
-rw-r--r--drivers/pinctrl/pinctrl-xway.c119
-rw-r--r--drivers/pinctrl/sh-pfc/pinctrl.c42
-rw-r--r--drivers/pinctrl/vt8500/pinctrl-wmt.c54
23 files changed, 948 insertions, 724 deletions
diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
index bb7ddb1bc89f..e78c041c3c73 100644
--- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c
+++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
@@ -191,18 +191,27 @@ static int mvebu_pinconf_group_get(struct pinctrl_dev *pctldev,
191} 191}
192 192
193static int mvebu_pinconf_group_set(struct pinctrl_dev *pctldev, 193static int mvebu_pinconf_group_set(struct pinctrl_dev *pctldev,
194 unsigned gid, unsigned long config) 194 unsigned gid, unsigned long *configs,
195 unsigned num_configs)
195{ 196{
196 struct mvebu_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 197 struct mvebu_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
197 struct mvebu_pinctrl_group *grp = &pctl->groups[gid]; 198 struct mvebu_pinctrl_group *grp = &pctl->groups[gid];
199 int i, ret;
198 200
199 if (!grp->ctrl) 201 if (!grp->ctrl)
200 return -EINVAL; 202 return -EINVAL;
201 203
202 if (grp->ctrl->mpp_set) 204 for (i = 0; i < num_configs; i++) {
203 return grp->ctrl->mpp_set(grp->ctrl, config); 205 if (grp->ctrl->mpp_set)
206 ret = grp->ctrl->mpp_set(grp->ctrl, configs[i]);
207 else
208 ret = mvebu_common_mpp_set(pctl, grp, configs[i]);
204 209
205 return mvebu_common_mpp_set(pctl, grp, config); 210 if (ret)
211 return ret;
212 } /* for each config */
213
214 return 0;
206} 215}
207 216
208static void mvebu_pinconf_group_dbg_show(struct pinctrl_dev *pctldev, 217static void mvebu_pinconf_group_dbg_show(struct pinctrl_dev *pctldev,
@@ -303,6 +312,7 @@ static int mvebu_pinmux_enable(struct pinctrl_dev *pctldev, unsigned fid,
303 struct mvebu_pinctrl_group *grp = &pctl->groups[gid]; 312 struct mvebu_pinctrl_group *grp = &pctl->groups[gid];
304 struct mvebu_mpp_ctrl_setting *setting; 313 struct mvebu_mpp_ctrl_setting *setting;
305 int ret; 314 int ret;
315 unsigned long config;
306 316
307 setting = mvebu_pinctrl_find_setting_by_name(pctl, grp, 317 setting = mvebu_pinctrl_find_setting_by_name(pctl, grp,
308 func->name); 318 func->name);
@@ -313,7 +323,8 @@ static int mvebu_pinmux_enable(struct pinctrl_dev *pctldev, unsigned fid,
313 return -EINVAL; 323 return -EINVAL;
314 } 324 }
315 325
316 ret = mvebu_pinconf_group_set(pctldev, grp->gid, setting->val); 326 config = setting->val;
327 ret = mvebu_pinconf_group_set(pctldev, grp->gid, &config, 1);
317 if (ret) { 328 if (ret) {
318 dev_err(pctl->dev, "cannot set group %s to %s\n", 329 dev_err(pctl->dev, "cannot set group %s to %s\n",
319 func->groups[gid], func->name); 330 func->groups[gid], func->name);
@@ -329,6 +340,7 @@ static int mvebu_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev,
329 struct mvebu_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 340 struct mvebu_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
330 struct mvebu_pinctrl_group *grp; 341 struct mvebu_pinctrl_group *grp;
331 struct mvebu_mpp_ctrl_setting *setting; 342 struct mvebu_mpp_ctrl_setting *setting;
343 unsigned long config;
332 344
333 grp = mvebu_pinctrl_find_group_by_pid(pctl, offset); 345 grp = mvebu_pinctrl_find_group_by_pid(pctl, offset);
334 if (!grp) 346 if (!grp)
@@ -341,7 +353,9 @@ static int mvebu_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev,
341 if (!setting) 353 if (!setting)
342 return -ENOTSUPP; 354 return -ENOTSUPP;
343 355
344 return mvebu_pinconf_group_set(pctldev, grp->gid, setting->val); 356 config = setting->val;
357
358 return mvebu_pinconf_group_set(pctldev, grp->gid, &config, 1);
345} 359}
346 360
347static int mvebu_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev, 361static int mvebu_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
index 8da2d6db228c..a138965c01cb 100644
--- a/drivers/pinctrl/pinconf.c
+++ b/drivers/pinctrl/pinconf.c
@@ -158,7 +158,7 @@ int pinconf_apply_setting(struct pinctrl_setting const *setting)
158{ 158{
159 struct pinctrl_dev *pctldev = setting->pctldev; 159 struct pinctrl_dev *pctldev = setting->pctldev;
160 const struct pinconf_ops *ops = pctldev->desc->confops; 160 const struct pinconf_ops *ops = pctldev->desc->confops;
161 int i, ret; 161 int ret;
162 162
163 if (!ops) { 163 if (!ops) {
164 dev_err(pctldev->dev, "missing confops\n"); 164 dev_err(pctldev->dev, "missing confops\n");
@@ -171,17 +171,15 @@ int pinconf_apply_setting(struct pinctrl_setting const *setting)
171 dev_err(pctldev->dev, "missing pin_config_set op\n"); 171 dev_err(pctldev->dev, "missing pin_config_set op\n");
172 return -EINVAL; 172 return -EINVAL;
173 } 173 }
174 for (i = 0; i < setting->data.configs.num_configs; i++) { 174 ret = ops->pin_config_set(pctldev,
175 ret = ops->pin_config_set(pctldev, 175 setting->data.configs.group_or_pin,
176 setting->data.configs.group_or_pin, 176 setting->data.configs.configs,
177 setting->data.configs.configs[i]); 177 setting->data.configs.num_configs);
178 if (ret < 0) { 178 if (ret < 0) {
179 dev_err(pctldev->dev, 179 dev_err(pctldev->dev,
180 "pin_config_set op failed for pin %d config %08lx\n", 180 "pin_config_set op failed for pin %d\n",
181 setting->data.configs.group_or_pin, 181 setting->data.configs.group_or_pin);
182 setting->data.configs.configs[i]); 182 return ret;
183 return ret;
184 }
185 } 183 }
186 break; 184 break;
187 case PIN_MAP_TYPE_CONFIGS_GROUP: 185 case PIN_MAP_TYPE_CONFIGS_GROUP:
@@ -190,17 +188,15 @@ int pinconf_apply_setting(struct pinctrl_setting const *setting)
190 "missing pin_config_group_set op\n"); 188 "missing pin_config_group_set op\n");
191 return -EINVAL; 189 return -EINVAL;
192 } 190 }
193 for (i = 0; i < setting->data.configs.num_configs; i++) { 191 ret = ops->pin_config_group_set(pctldev,
194 ret = ops->pin_config_group_set(pctldev, 192 setting->data.configs.group_or_pin,
195 setting->data.configs.group_or_pin, 193 setting->data.configs.configs,
196 setting->data.configs.configs[i]); 194 setting->data.configs.num_configs);
197 if (ret < 0) { 195 if (ret < 0) {
198 dev_err(pctldev->dev, 196 dev_err(pctldev->dev,
199 "pin_config_group_set op failed for group %d config %08lx\n", 197 "pin_config_group_set op failed for group %d\n",
200 setting->data.configs.group_or_pin, 198 setting->data.configs.group_or_pin);
201 setting->data.configs.configs[i]); 199 return ret;
202 return ret;
203 }
204 } 200 }
205 break; 201 break;
206 default: 202 default:
diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c
index 1d3f988c2c8b..8f25df06bc6b 100644
--- a/drivers/pinctrl/pinctrl-abx500.c
+++ b/drivers/pinctrl/pinctrl-abx500.c
@@ -1041,98 +1041,115 @@ static int abx500_pin_config_get(struct pinctrl_dev *pctldev,
1041 1041
1042static int abx500_pin_config_set(struct pinctrl_dev *pctldev, 1042static int abx500_pin_config_set(struct pinctrl_dev *pctldev,
1043 unsigned pin, 1043 unsigned pin,
1044 unsigned long config) 1044 unsigned long *configs,
1045 unsigned num_configs)
1045{ 1046{
1046 struct abx500_pinctrl *pct = pinctrl_dev_get_drvdata(pctldev); 1047 struct abx500_pinctrl *pct = pinctrl_dev_get_drvdata(pctldev);
1047 struct gpio_chip *chip = &pct->chip; 1048 struct gpio_chip *chip = &pct->chip;
1048 unsigned offset; 1049 unsigned offset;
1049 int ret = -EINVAL; 1050 int ret = -EINVAL;
1050 enum pin_config_param param = pinconf_to_config_param(config); 1051 int i;
1051 enum pin_config_param argument = pinconf_to_config_argument(config); 1052 enum pin_config_param param;
1052 1053 enum pin_config_param argument;
1053 dev_dbg(chip->dev, "pin %d [%#lx]: %s %s\n", 1054
1054 pin, config, (param == PIN_CONFIG_OUTPUT) ? "output " : "input", 1055 for (i = 0; i < num_configs; i++) {
1055 (param == PIN_CONFIG_OUTPUT) ? (argument ? "high" : "low") : 1056 param = pinconf_to_config_param(configs[i]);
1056 (argument ? "pull up" : "pull down")); 1057 argument = pinconf_to_config_argument(configs[i]);
1057 1058
1058 /* on ABx500, there is no GPIO0, so adjust the offset */ 1059 dev_dbg(chip->dev, "pin %d [%#lx]: %s %s\n",
1059 offset = pin - 1; 1060 pin, configs[i],
1060 1061 (param == PIN_CONFIG_OUTPUT) ? "output " : "input",
1061 switch (param) { 1062 (param == PIN_CONFIG_OUTPUT) ?
1062 case PIN_CONFIG_BIAS_DISABLE: 1063 (argument ? "high" : "low") :
1063 ret = abx500_gpio_direction_input(chip, offset); 1064 (argument ? "pull up" : "pull down"));
1064 if (ret < 0) 1065
1065 goto out; 1066 /* on ABx500, there is no GPIO0, so adjust the offset */
1066 /* 1067 offset = pin - 1;
1067 * Some chips only support pull down, while some actually 1068
1068 * support both pull up and pull down. Such chips have 1069 switch (param) {
1069 * a "pullud" range specified for the pins that support 1070 case PIN_CONFIG_BIAS_DISABLE:
1070 * both features. If the pin is not within that range, we 1071 ret = abx500_gpio_direction_input(chip, offset);
1071 * fall back to the old bit set that only support pull down. 1072 if (ret < 0)
1072 */ 1073 goto out;
1073 if (abx500_pullud_supported(chip, pin)) 1074 /*
1074 ret = abx500_set_pull_updown(pct, 1075 * Some chips only support pull down, while some
1075 pin, 1076 * actually support both pull up and pull down. Such
1076 ABX500_GPIO_PULL_NONE); 1077 * chips have a "pullud" range specified for the pins
1077 else 1078 * that support both features. If the pin is not
1078 /* Chip only supports pull down */ 1079 * within that range, we fall back to the old bit set
1079 ret = abx500_gpio_set_bits(chip, AB8500_GPIO_PUD1_REG, 1080 * that only support pull down.
1080 offset, ABX500_GPIO_PULL_NONE); 1081 */
1081 break; 1082 if (abx500_pullud_supported(chip, pin))
1082 1083 ret = abx500_set_pull_updown(pct,
1083 case PIN_CONFIG_BIAS_PULL_DOWN: 1084 pin,
1084 ret = abx500_gpio_direction_input(chip, offset); 1085 ABX500_GPIO_PULL_NONE);
1085 if (ret < 0) 1086 else
1086 goto out; 1087 /* Chip only supports pull down */
1087 /* 1088 ret = abx500_gpio_set_bits(chip,
1088 * if argument = 1 set the pull down 1089 AB8500_GPIO_PUD1_REG, offset,
1089 * else clear the pull down 1090 ABX500_GPIO_PULL_NONE);
1090 * Some chips only support pull down, while some actually 1091 break;
1091 * support both pull up and pull down. Such chips have
1092 * a "pullud" range specified for the pins that support
1093 * both features. If the pin is not within that range, we
1094 * fall back to the old bit set that only support pull down.
1095 */
1096 if (abx500_pullud_supported(chip, pin))
1097 ret = abx500_set_pull_updown(pct,
1098 pin,
1099 argument ? ABX500_GPIO_PULL_DOWN : ABX500_GPIO_PULL_NONE);
1100 else
1101 /* Chip only supports pull down */
1102 ret = abx500_gpio_set_bits(chip, AB8500_GPIO_PUD1_REG,
1103 offset,
1104 argument ? ABX500_GPIO_PULL_DOWN : ABX500_GPIO_PULL_NONE);
1105 break;
1106
1107 case PIN_CONFIG_BIAS_PULL_UP:
1108 ret = abx500_gpio_direction_input(chip, offset);
1109 if (ret < 0)
1110 goto out;
1111 /*
1112 * if argument = 1 set the pull up
1113 * else clear the pull up
1114 */
1115 ret = abx500_gpio_direction_input(chip, offset);
1116 /*
1117 * Some chips only support pull down, while some actually
1118 * support both pull up and pull down. Such chips have
1119 * a "pullud" range specified for the pins that support
1120 * both features. If the pin is not within that range, do
1121 * nothing
1122 */
1123 if (abx500_pullud_supported(chip, pin))
1124 ret = abx500_set_pull_updown(pct,
1125 pin,
1126 argument ? ABX500_GPIO_PULL_UP : ABX500_GPIO_PULL_NONE);
1127 break;
1128 1092
1129 case PIN_CONFIG_OUTPUT: 1093 case PIN_CONFIG_BIAS_PULL_DOWN:
1130 ret = abx500_gpio_direction_output(chip, offset, argument); 1094 ret = abx500_gpio_direction_input(chip, offset);
1131 break; 1095 if (ret < 0)
1096 goto out;
1097 /*
1098 * if argument = 1 set the pull down
1099 * else clear the pull down
1100 * Some chips only support pull down, while some
1101 * actually support both pull up and pull down. Such
1102 * chips have a "pullud" range specified for the pins
1103 * that support both features. If the pin is not
1104 * within that range, we fall back to the old bit set
1105 * that only support pull down.
1106 */
1107 if (abx500_pullud_supported(chip, pin))
1108 ret = abx500_set_pull_updown(pct,
1109 pin,
1110 argument ? ABX500_GPIO_PULL_DOWN :
1111 ABX500_GPIO_PULL_NONE);
1112 else
1113 /* Chip only supports pull down */
1114 ret = abx500_gpio_set_bits(chip,
1115 AB8500_GPIO_PUD1_REG,
1116 offset,
1117 argument ? ABX500_GPIO_PULL_DOWN :
1118 ABX500_GPIO_PULL_NONE);
1119 break;
1132 1120
1133 default: 1121 case PIN_CONFIG_BIAS_PULL_UP:
1134 dev_err(chip->dev, "illegal configuration requested\n"); 1122 ret = abx500_gpio_direction_input(chip, offset);
1135 } 1123 if (ret < 0)
1124 goto out;
1125 /*
1126 * if argument = 1 set the pull up
1127 * else clear the pull up
1128 */
1129 ret = abx500_gpio_direction_input(chip, offset);
1130 /*
1131 * Some chips only support pull down, while some
1132 * actually support both pull up and pull down. Such
1133 * chips have a "pullud" range specified for the pins
1134 * that support both features. If the pin is not
1135 * within that range, do nothing
1136 */
1137 if (abx500_pullud_supported(chip, pin))
1138 ret = abx500_set_pull_updown(pct,
1139 pin,
1140 argument ? ABX500_GPIO_PULL_UP :
1141 ABX500_GPIO_PULL_NONE);
1142 break;
1143
1144 case PIN_CONFIG_OUTPUT:
1145 ret = abx500_gpio_direction_output(chip, offset,
1146 argument);
1147 break;
1148
1149 default:
1150 dev_err(chip->dev, "illegal configuration requested\n");
1151 }
1152 } /* for each config */
1136out: 1153out:
1137 if (ret < 0) 1154 if (ret < 0)
1138 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); 1155 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret);
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}
diff --git a/drivers/pinctrl/pinctrl-bcm2835.c b/drivers/pinctrl/pinctrl-bcm2835.c
index a1c88b30f71f..c05c1ef2cc3c 100644
--- a/drivers/pinctrl/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/pinctrl-bcm2835.c
@@ -893,28 +893,35 @@ static int bcm2835_pinconf_get(struct pinctrl_dev *pctldev,
893} 893}
894 894
895static int bcm2835_pinconf_set(struct pinctrl_dev *pctldev, 895static int bcm2835_pinconf_set(struct pinctrl_dev *pctldev,
896 unsigned pin, unsigned long config) 896 unsigned pin, unsigned long *configs,
897 unsigned num_configs)
897{ 898{
898 struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev); 899 struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
899 enum bcm2835_pinconf_param param = BCM2835_PINCONF_UNPACK_PARAM(config); 900 enum bcm2835_pinconf_param param;
900 u16 arg = BCM2835_PINCONF_UNPACK_ARG(config); 901 u16 arg;
901 u32 off, bit; 902 u32 off, bit;
903 int i;
902 904
903 if (param != BCM2835_PINCONF_PARAM_PULL) 905 for (i = 0; i < num_configs; i++) {
904 return -EINVAL; 906 param = BCM2835_PINCONF_UNPACK_PARAM(configs[i]);
905 907 arg = BCM2835_PINCONF_UNPACK_ARG(configs[i]);
906 off = GPIO_REG_OFFSET(pin); 908
907 bit = GPIO_REG_SHIFT(pin); 909 if (param != BCM2835_PINCONF_PARAM_PULL)
908 910 return -EINVAL;
909 bcm2835_gpio_wr(pc, GPPUD, arg & 3); 911
910 /* 912 off = GPIO_REG_OFFSET(pin);
911 * Docs say to wait 150 cycles, but not of what. We assume a 913 bit = GPIO_REG_SHIFT(pin);
912 * 1 MHz clock here, which is pretty slow... 914
913 */ 915 bcm2835_gpio_wr(pc, GPPUD, arg & 3);
914 udelay(150); 916 /*
915 bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), BIT(bit)); 917 * Docs say to wait 150 cycles, but not of what. We assume a
916 udelay(150); 918 * 1 MHz clock here, which is pretty slow...
917 bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), 0); 919 */
920 udelay(150);
921 bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), BIT(bit));
922 udelay(150);
923 bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), 0);
924 } /* for each config */
918 925
919 return 0; 926 return 0;
920} 927}
diff --git a/drivers/pinctrl/pinctrl-exynos5440.c b/drivers/pinctrl/pinctrl-exynos5440.c
index 3b283fd898ff..544d469c5a7b 100644
--- a/drivers/pinctrl/pinctrl-exynos5440.c
+++ b/drivers/pinctrl/pinctrl-exynos5440.c
@@ -401,64 +401,71 @@ static const struct pinmux_ops exynos5440_pinmux_ops = {
401 401
402/* set the pin config settings for a specified pin */ 402/* set the pin config settings for a specified pin */
403static int exynos5440_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, 403static int exynos5440_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
404 unsigned long config) 404 unsigned long *configs,
405 unsigned num_configs)
405{ 406{
406 struct exynos5440_pinctrl_priv_data *priv; 407 struct exynos5440_pinctrl_priv_data *priv;
407 void __iomem *base; 408 void __iomem *base;
408 enum pincfg_type cfg_type = PINCFG_UNPACK_TYPE(config); 409 enum pincfg_type cfg_type;
409 u32 cfg_value = PINCFG_UNPACK_VALUE(config); 410 u32 cfg_value;
410 u32 data; 411 u32 data;
412 int i;
411 413
412 priv = pinctrl_dev_get_drvdata(pctldev); 414 priv = pinctrl_dev_get_drvdata(pctldev);
413 base = priv->reg_base; 415 base = priv->reg_base;
414 416
415 switch (cfg_type) { 417 for (i = 0; i < num_configs; i++) {
416 case PINCFG_TYPE_PUD: 418 cfg_type = PINCFG_UNPACK_TYPE(configs[i]);
417 /* first set pull enable/disable bit */ 419 cfg_value = PINCFG_UNPACK_VALUE(configs[i]);
418 data = readl(base + GPIO_PE); 420
419 data &= ~(1 << pin); 421 switch (cfg_type) {
420 if (cfg_value) 422 case PINCFG_TYPE_PUD:
421 data |= (1 << pin); 423 /* first set pull enable/disable bit */
422 writel(data, base + GPIO_PE); 424 data = readl(base + GPIO_PE);
423 425 data &= ~(1 << pin);
424 /* then set pull up/down bit */ 426 if (cfg_value)
425 data = readl(base + GPIO_PS); 427 data |= (1 << pin);
426 data &= ~(1 << pin); 428 writel(data, base + GPIO_PE);
427 if (cfg_value == 2) 429
428 data |= (1 << pin); 430 /* then set pull up/down bit */
429 writel(data, base + GPIO_PS); 431 data = readl(base + GPIO_PS);
430 break; 432 data &= ~(1 << pin);
431 433 if (cfg_value == 2)
432 case PINCFG_TYPE_DRV: 434 data |= (1 << pin);
433 /* set the first bit of the drive strength */ 435 writel(data, base + GPIO_PS);
434 data = readl(base + GPIO_DS0); 436 break;
435 data &= ~(1 << pin); 437
436 data |= ((cfg_value & 1) << pin); 438 case PINCFG_TYPE_DRV:
437 writel(data, base + GPIO_DS0); 439 /* set the first bit of the drive strength */
438 cfg_value >>= 1; 440 data = readl(base + GPIO_DS0);
439 441 data &= ~(1 << pin);
440 /* set the second bit of the driver strength */ 442 data |= ((cfg_value & 1) << pin);
441 data = readl(base + GPIO_DS1); 443 writel(data, base + GPIO_DS0);
442 data &= ~(1 << pin); 444 cfg_value >>= 1;
443 data |= ((cfg_value & 1) << pin); 445
444 writel(data, base + GPIO_DS1); 446 /* set the second bit of the driver strength */
445 break; 447 data = readl(base + GPIO_DS1);
446 case PINCFG_TYPE_SKEW_RATE: 448 data &= ~(1 << pin);
447 data = readl(base + GPIO_SR); 449 data |= ((cfg_value & 1) << pin);
448 data &= ~(1 << pin); 450 writel(data, base + GPIO_DS1);
449 data |= ((cfg_value & 1) << pin); 451 break;
450 writel(data, base + GPIO_SR); 452 case PINCFG_TYPE_SKEW_RATE:
451 break; 453 data = readl(base + GPIO_SR);
452 case PINCFG_TYPE_INPUT_TYPE: 454 data &= ~(1 << pin);
453 data = readl(base + GPIO_TYPE); 455 data |= ((cfg_value & 1) << pin);
454 data &= ~(1 << pin); 456 writel(data, base + GPIO_SR);
455 data |= ((cfg_value & 1) << pin); 457 break;
456 writel(data, base + GPIO_TYPE); 458 case PINCFG_TYPE_INPUT_TYPE:
457 break; 459 data = readl(base + GPIO_TYPE);
458 default: 460 data &= ~(1 << pin);
459 WARN_ON(1); 461 data |= ((cfg_value & 1) << pin);
460 return -EINVAL; 462 writel(data, base + GPIO_TYPE);
461 } 463 break;
464 default:
465 WARN_ON(1);
466 return -EINVAL;
467 }
468 } /* for each config */
462 469
463 return 0; 470 return 0;
464} 471}
@@ -510,7 +517,8 @@ static int exynos5440_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
510 517
511/* set the pin config settings for a specified pin group */ 518/* set the pin config settings for a specified pin group */
512static int exynos5440_pinconf_group_set(struct pinctrl_dev *pctldev, 519static int exynos5440_pinconf_group_set(struct pinctrl_dev *pctldev,
513 unsigned group, unsigned long config) 520 unsigned group, unsigned long *configs,
521 unsigned num_configs)
514{ 522{
515 struct exynos5440_pinctrl_priv_data *priv; 523 struct exynos5440_pinctrl_priv_data *priv;
516 const unsigned int *pins; 524 const unsigned int *pins;
@@ -520,7 +528,8 @@ static int exynos5440_pinconf_group_set(struct pinctrl_dev *pctldev,
520 pins = priv->pin_groups[group].pins; 528 pins = priv->pin_groups[group].pins;
521 529
522 for (cnt = 0; cnt < priv->pin_groups[group].num_pins; cnt++) 530 for (cnt = 0; cnt < priv->pin_groups[group].num_pins; cnt++)
523 exynos5440_pinconf_set(pctldev, pins[cnt], config); 531 exynos5440_pinconf_set(pctldev, pins[cnt], configs,
532 num_configs);
524 533
525 return 0; 534 return 0;
526} 535}
diff --git a/drivers/pinctrl/pinctrl-falcon.c b/drivers/pinctrl/pinctrl-falcon.c
index 4e731f24df85..2e62689b5e9f 100644
--- a/drivers/pinctrl/pinctrl-falcon.c
+++ b/drivers/pinctrl/pinctrl-falcon.c
@@ -238,7 +238,8 @@ static int falcon_pinconf_group_get(struct pinctrl_dev *pctrldev,
238} 238}
239 239
240static int falcon_pinconf_group_set(struct pinctrl_dev *pctrldev, 240static int falcon_pinconf_group_set(struct pinctrl_dev *pctrldev,
241 unsigned group, unsigned long config) 241 unsigned group, unsigned long *configs,
242 unsigned num_configs)
242{ 243{
243 return -ENOTSUPP; 244 return -ENOTSUPP;
244} 245}
@@ -279,39 +280,47 @@ static int falcon_pinconf_get(struct pinctrl_dev *pctrldev,
279} 280}
280 281
281static int falcon_pinconf_set(struct pinctrl_dev *pctrldev, 282static int falcon_pinconf_set(struct pinctrl_dev *pctrldev,
282 unsigned pin, unsigned long config) 283 unsigned pin, unsigned long *configs,
284 unsigned num_configs)
283{ 285{
284 enum ltq_pinconf_param param = LTQ_PINCONF_UNPACK_PARAM(config); 286 enum ltq_pinconf_param param;
285 int arg = LTQ_PINCONF_UNPACK_ARG(config); 287 int arg;
286 struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); 288 struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
287 void __iomem *mem = info->membase[PORT(pin)]; 289 void __iomem *mem = info->membase[PORT(pin)];
288 u32 reg; 290 u32 reg;
291 int i;
289 292
290 switch (param) { 293 for (i = 0; i < num_configs; i++) {
291 case LTQ_PINCONF_PARAM_DRIVE_CURRENT: 294 param = LTQ_PINCONF_UNPACK_PARAM(configs[i]);
292 reg = LTQ_PADC_DCC; 295 arg = LTQ_PINCONF_UNPACK_ARG(configs[i]);
293 break; 296
294 297 switch (param) {
295 case LTQ_PINCONF_PARAM_SLEW_RATE: 298 case LTQ_PINCONF_PARAM_DRIVE_CURRENT:
296 reg = LTQ_PADC_SRC; 299 reg = LTQ_PADC_DCC;
297 break; 300 break;
298 301
299 case LTQ_PINCONF_PARAM_PULL: 302 case LTQ_PINCONF_PARAM_SLEW_RATE:
300 if (arg == 1) 303 reg = LTQ_PADC_SRC;
301 reg = LTQ_PADC_PDEN; 304 break;
302 else 305
303 reg = LTQ_PADC_PUEN; 306 case LTQ_PINCONF_PARAM_PULL:
304 break; 307 if (arg == 1)
308 reg = LTQ_PADC_PDEN;
309 else
310 reg = LTQ_PADC_PUEN;
311 break;
312
313 default:
314 pr_err("%s: Invalid config param %04x\n",
315 pinctrl_dev_get_name(pctrldev), param);
316 return -ENOTSUPP;
317 }
305 318
306 default: 319 pad_w32(mem, BIT(PORT_PIN(pin)), reg);
307 pr_err("%s: Invalid config param %04x\n", 320 if (!(pad_r32(mem, reg) & BIT(PORT_PIN(pin))))
308 pinctrl_dev_get_name(pctrldev), param); 321 return -ENOTSUPP;
309 return -ENOTSUPP; 322 } /* for each config */
310 }
311 323
312 pad_w32(mem, BIT(PORT_PIN(pin)), reg);
313 if (!(pad_r32(mem, reg) & BIT(PORT_PIN(pin))))
314 return -ENOTSUPP;
315 return 0; 324 return 0;
316} 325}
317 326
diff --git a/drivers/pinctrl/pinctrl-imx.c b/drivers/pinctrl/pinctrl-imx.c
index 360249301315..d78dd813bff9 100644
--- a/drivers/pinctrl/pinctrl-imx.c
+++ b/drivers/pinctrl/pinctrl-imx.c
@@ -323,11 +323,13 @@ static int imx_pinconf_get(struct pinctrl_dev *pctldev,
323} 323}
324 324
325static int imx_pinconf_set(struct pinctrl_dev *pctldev, 325static int imx_pinconf_set(struct pinctrl_dev *pctldev,
326 unsigned pin_id, unsigned long config) 326 unsigned pin_id, unsigned long *configs,
327 unsigned num_configs)
327{ 328{
328 struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 329 struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
329 const struct imx_pinctrl_soc_info *info = ipctl->info; 330 const struct imx_pinctrl_soc_info *info = ipctl->info;
330 const struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id]; 331 const struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id];
332 int i;
331 333
332 if (!(info->flags & ZERO_OFFSET_VALID) && !pin_reg->conf_reg) { 334 if (!(info->flags & ZERO_OFFSET_VALID) && !pin_reg->conf_reg) {
333 dev_err(info->dev, "Pin(%s) does not support config function\n", 335 dev_err(info->dev, "Pin(%s) does not support config function\n",
@@ -338,17 +340,19 @@ static int imx_pinconf_set(struct pinctrl_dev *pctldev,
338 dev_dbg(ipctl->dev, "pinconf set pin %s\n", 340 dev_dbg(ipctl->dev, "pinconf set pin %s\n",
339 info->pins[pin_id].name); 341 info->pins[pin_id].name);
340 342
341 if (info->flags & SHARE_MUX_CONF_REG) { 343 for (i = 0; i < num_configs; i++) {
342 u32 reg; 344 if (info->flags & SHARE_MUX_CONF_REG) {
343 reg = readl(ipctl->base + pin_reg->conf_reg); 345 u32 reg;
344 reg &= ~0xffff; 346 reg = readl(ipctl->base + pin_reg->conf_reg);
345 reg |= config; 347 reg &= ~0xffff;
346 writel(reg, ipctl->base + pin_reg->conf_reg); 348 reg |= configs[i];
347 } else { 349 writel(reg, ipctl->base + pin_reg->conf_reg);
348 writel(config, ipctl->base + pin_reg->conf_reg); 350 } else {
349 } 351 writel(configs[i], ipctl->base + pin_reg->conf_reg);
350 dev_dbg(ipctl->dev, "write: offset 0x%x val 0x%lx\n", 352 }
351 pin_reg->conf_reg, config); 353 dev_dbg(ipctl->dev, "write: offset 0x%x val 0x%lx\n",
354 pin_reg->conf_reg, configs[i]);
355 } /* for each config */
352 356
353 return 0; 357 return 0;
354} 358}
diff --git a/drivers/pinctrl/pinctrl-mxs.c b/drivers/pinctrl/pinctrl-mxs.c
index f5d56436ba7f..40c76f26998c 100644
--- a/drivers/pinctrl/pinctrl-mxs.c
+++ b/drivers/pinctrl/pinctrl-mxs.c
@@ -233,7 +233,8 @@ static int mxs_pinconf_get(struct pinctrl_dev *pctldev,
233} 233}
234 234
235static int mxs_pinconf_set(struct pinctrl_dev *pctldev, 235static int mxs_pinconf_set(struct pinctrl_dev *pctldev,
236 unsigned pin, unsigned long config) 236 unsigned pin, unsigned long *configs,
237 unsigned num_configs)
237{ 238{
238 return -ENOTSUPP; 239 return -ENOTSUPP;
239} 240}
@@ -249,7 +250,8 @@ static int mxs_pinconf_group_get(struct pinctrl_dev *pctldev,
249} 250}
250 251
251static int mxs_pinconf_group_set(struct pinctrl_dev *pctldev, 252static int mxs_pinconf_group_set(struct pinctrl_dev *pctldev,
252 unsigned group, unsigned long config) 253 unsigned group, unsigned long *configs,
254 unsigned num_configs)
253{ 255{
254 struct mxs_pinctrl_data *d = pinctrl_dev_get_drvdata(pctldev); 256 struct mxs_pinctrl_data *d = pinctrl_dev_get_drvdata(pctldev);
255 struct mxs_group *g = &d->soc->groups[group]; 257 struct mxs_group *g = &d->soc->groups[group];
@@ -257,49 +259,56 @@ static int mxs_pinconf_group_set(struct pinctrl_dev *pctldev,
257 u8 ma, vol, pull, bank, shift; 259 u8 ma, vol, pull, bank, shift;
258 u16 pin; 260 u16 pin;
259 u32 i; 261 u32 i;
262 int n;
263 unsigned long config;
260 264
261 ma = CONFIG_TO_MA(config); 265 for (n = 0; n < num_configs; n++) {
262 vol = CONFIG_TO_VOL(config); 266 config = configs[n];
263 pull = CONFIG_TO_PULL(config); 267
264 268 ma = CONFIG_TO_MA(config);
265 for (i = 0; i < g->npins; i++) { 269 vol = CONFIG_TO_VOL(config);
266 bank = PINID_TO_BANK(g->pins[i]); 270 pull = CONFIG_TO_PULL(config);
267 pin = PINID_TO_PIN(g->pins[i]); 271
268 272 for (i = 0; i < g->npins; i++) {
269 /* drive */ 273 bank = PINID_TO_BANK(g->pins[i]);
270 reg = d->base + d->soc->regs->drive; 274 pin = PINID_TO_PIN(g->pins[i]);
271 reg += bank * 0x40 + pin / 8 * 0x10; 275
272 276 /* drive */
273 /* mA */ 277 reg = d->base + d->soc->regs->drive;
274 if (config & MA_PRESENT) { 278 reg += bank * 0x40 + pin / 8 * 0x10;
275 shift = pin % 8 * 4; 279
276 writel(0x3 << shift, reg + CLR); 280 /* mA */
277 writel(ma << shift, reg + SET); 281 if (config & MA_PRESENT) {
278 } 282 shift = pin % 8 * 4;
279 283 writel(0x3 << shift, reg + CLR);
280 /* vol */ 284 writel(ma << shift, reg + SET);
281 if (config & VOL_PRESENT) { 285 }
282 shift = pin % 8 * 4 + 2; 286
283 if (vol) 287 /* vol */
284 writel(1 << shift, reg + SET); 288 if (config & VOL_PRESENT) {
285 else 289 shift = pin % 8 * 4 + 2;
286 writel(1 << shift, reg + CLR); 290 if (vol)
291 writel(1 << shift, reg + SET);
292 else
293 writel(1 << shift, reg + CLR);
294 }
295
296 /* pull */
297 if (config & PULL_PRESENT) {
298 reg = d->base + d->soc->regs->pull;
299 reg += bank * 0x10;
300 shift = pin;
301 if (pull)
302 writel(1 << shift, reg + SET);
303 else
304 writel(1 << shift, reg + CLR);
305 }
287 } 306 }
288 307
289 /* pull */ 308 /* cache the config value for mxs_pinconf_group_get() */
290 if (config & PULL_PRESENT) { 309 g->config = config;
291 reg = d->base + d->soc->regs->pull;
292 reg += bank * 0x10;
293 shift = pin;
294 if (pull)
295 writel(1 << shift, reg + SET);
296 else
297 writel(1 << shift, reg + CLR);
298 }
299 }
300 310
301 /* cache the config value for mxs_pinconf_group_get() */ 311 } /* for each config */
302 g->config = config;
303 312
304 return 0; 313 return 0;
305} 314}
diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c
index f7c7279d081a..d7c3ae300fa7 100644
--- a/drivers/pinctrl/pinctrl-nomadik.c
+++ b/drivers/pinctrl/pinctrl-nomadik.c
@@ -1695,7 +1695,7 @@ static int nmk_pin_config_get(struct pinctrl_dev *pctldev, unsigned pin,
1695} 1695}
1696 1696
1697static int nmk_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin, 1697static int nmk_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin,
1698 unsigned long config) 1698 unsigned long *configs, unsigned num_configs)
1699{ 1699{
1700 static const char *pullnames[] = { 1700 static const char *pullnames[] = {
1701 [NMK_GPIO_PULL_NONE] = "none", 1701 [NMK_GPIO_PULL_NONE] = "none",
@@ -1712,20 +1712,9 @@ static int nmk_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin,
1712 struct pinctrl_gpio_range *range; 1712 struct pinctrl_gpio_range *range;
1713 struct gpio_chip *chip; 1713 struct gpio_chip *chip;
1714 unsigned bit; 1714 unsigned bit;
1715 1715 pin_cfg_t cfg;
1716 /* 1716 int pull, slpm, output, val, i;
1717 * The pin config contains pin number and altfunction fields, here 1717 bool lowemi, gpiomode, sleep;
1718 * we just ignore that part. It's being handled by the framework and
1719 * pinmux callback respectively.
1720 */
1721 pin_cfg_t cfg = (pin_cfg_t) config;
1722 int pull = PIN_PULL(cfg);
1723 int slpm = PIN_SLPM(cfg);
1724 int output = PIN_DIR(cfg);
1725 int val = PIN_VAL(cfg);
1726 bool lowemi = PIN_LOWEMI(cfg);
1727 bool gpiomode = PIN_GPIOMODE(cfg);
1728 bool sleep = PIN_SLEEPMODE(cfg);
1729 1718
1730 range = nmk_match_gpio_range(pctldev, pin); 1719 range = nmk_match_gpio_range(pctldev, pin);
1731 if (!range) { 1720 if (!range) {
@@ -1740,54 +1729,74 @@ static int nmk_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin,
1740 chip = range->gc; 1729 chip = range->gc;
1741 nmk_chip = container_of(chip, struct nmk_gpio_chip, chip); 1730 nmk_chip = container_of(chip, struct nmk_gpio_chip, chip);
1742 1731
1743 if (sleep) { 1732 for (i = 0; i < num_configs; i++) {
1744 int slpm_pull = PIN_SLPM_PULL(cfg);
1745 int slpm_output = PIN_SLPM_DIR(cfg);
1746 int slpm_val = PIN_SLPM_VAL(cfg);
1747
1748 /* All pins go into GPIO mode at sleep */
1749 gpiomode = true;
1750
1751 /* 1733 /*
1752 * The SLPM_* values are normal values + 1 to allow zero to 1734 * The pin config contains pin number and altfunction fields,
1753 * mean "same as normal". 1735 * here we just ignore that part. It's being handled by the
1736 * framework and pinmux callback respectively.
1754 */ 1737 */
1755 if (slpm_pull) 1738 cfg = (pin_cfg_t) configs[i];
1756 pull = slpm_pull - 1; 1739 pull = PIN_PULL(cfg);
1757 if (slpm_output) 1740 slpm = PIN_SLPM(cfg);
1758 output = slpm_output - 1; 1741 output = PIN_DIR(cfg);
1759 if (slpm_val) 1742 val = PIN_VAL(cfg);
1760 val = slpm_val - 1; 1743 lowemi = PIN_LOWEMI(cfg);
1761 1744 gpiomode = PIN_GPIOMODE(cfg);
1762 dev_dbg(nmk_chip->chip.dev, "pin %d: sleep pull %s, dir %s, val %s\n", 1745 sleep = PIN_SLEEPMODE(cfg);
1763 pin, 1746
1764 slpm_pull ? pullnames[pull] : "same", 1747 if (sleep) {
1765 slpm_output ? (output ? "output" : "input") : "same", 1748 int slpm_pull = PIN_SLPM_PULL(cfg);
1766 slpm_val ? (val ? "high" : "low") : "same"); 1749 int slpm_output = PIN_SLPM_DIR(cfg);
1767 } 1750 int slpm_val = PIN_SLPM_VAL(cfg);
1751
1752 /* All pins go into GPIO mode at sleep */
1753 gpiomode = true;
1754
1755 /*
1756 * The SLPM_* values are normal values + 1 to allow zero
1757 * to mean "same as normal".
1758 */
1759 if (slpm_pull)
1760 pull = slpm_pull - 1;
1761 if (slpm_output)
1762 output = slpm_output - 1;
1763 if (slpm_val)
1764 val = slpm_val - 1;
1765
1766 dev_dbg(nmk_chip->chip.dev,
1767 "pin %d: sleep pull %s, dir %s, val %s\n",
1768 pin,
1769 slpm_pull ? pullnames[pull] : "same",
1770 slpm_output ? (output ? "output" : "input")
1771 : "same",
1772 slpm_val ? (val ? "high" : "low") : "same");
1773 }
1768 1774
1769 dev_dbg(nmk_chip->chip.dev, "pin %d [%#lx]: pull %s, slpm %s (%s%s), lowemi %s\n", 1775 dev_dbg(nmk_chip->chip.dev,
1770 pin, cfg, pullnames[pull], slpmnames[slpm], 1776 "pin %d [%#lx]: pull %s, slpm %s (%s%s), lowemi %s\n",
1771 output ? "output " : "input", 1777 pin, cfg, pullnames[pull], slpmnames[slpm],
1772 output ? (val ? "high" : "low") : "", 1778 output ? "output " : "input",
1773 lowemi ? "on" : "off"); 1779 output ? (val ? "high" : "low") : "",
1780 lowemi ? "on" : "off");
1774 1781
1775 clk_enable(nmk_chip->clk); 1782 clk_enable(nmk_chip->clk);
1776 bit = pin % NMK_GPIO_PER_CHIP; 1783 bit = pin % NMK_GPIO_PER_CHIP;
1777 if (gpiomode) 1784 if (gpiomode)
1778 /* No glitch when going to GPIO mode */ 1785 /* No glitch when going to GPIO mode */
1779 __nmk_gpio_set_mode(nmk_chip, bit, NMK_GPIO_ALT_GPIO); 1786 __nmk_gpio_set_mode(nmk_chip, bit, NMK_GPIO_ALT_GPIO);
1780 if (output) 1787 if (output)
1781 __nmk_gpio_make_output(nmk_chip, bit, val); 1788 __nmk_gpio_make_output(nmk_chip, bit, val);
1782 else { 1789 else {
1783 __nmk_gpio_make_input(nmk_chip, bit); 1790 __nmk_gpio_make_input(nmk_chip, bit);
1784 __nmk_gpio_set_pull(nmk_chip, bit, pull); 1791 __nmk_gpio_set_pull(nmk_chip, bit, pull);
1785 } 1792 }
1786 /* TODO: isn't this only applicable on output pins? */ 1793 /* TODO: isn't this only applicable on output pins? */
1787 __nmk_gpio_set_lowemi(nmk_chip, bit, lowemi); 1794 __nmk_gpio_set_lowemi(nmk_chip, bit, lowemi);
1795
1796 __nmk_gpio_set_slpm(nmk_chip, bit, slpm);
1797 clk_disable(nmk_chip->clk);
1798 } /* for each config */
1788 1799
1789 __nmk_gpio_set_slpm(nmk_chip, bit, slpm);
1790 clk_disable(nmk_chip->clk);
1791 return 0; 1800 return 0;
1792} 1801}
1793 1802
diff --git a/drivers/pinctrl/pinctrl-palmas.c b/drivers/pinctrl/pinctrl-palmas.c
index 9550c33b2544..82638fac3cfa 100644
--- a/drivers/pinctrl/pinctrl-palmas.c
+++ b/drivers/pinctrl/pinctrl-palmas.c
@@ -854,17 +854,19 @@ static int palmas_pinconf_get(struct pinctrl_dev *pctldev,
854} 854}
855 855
856static int palmas_pinconf_set(struct pinctrl_dev *pctldev, 856static int palmas_pinconf_set(struct pinctrl_dev *pctldev,
857 unsigned pin, unsigned long config) 857 unsigned pin, unsigned long *configs,
858 unsigned num_configs)
858{ 859{
859 struct palmas_pctrl_chip_info *pci = pinctrl_dev_get_drvdata(pctldev); 860 struct palmas_pctrl_chip_info *pci = pinctrl_dev_get_drvdata(pctldev);
860 enum pin_config_param param = pinconf_to_config_param(config); 861 enum pin_config_param param;
861 u16 param_val = pinconf_to_config_argument(config); 862 u16 param_val;
862 const struct palmas_pingroup *g; 863 const struct palmas_pingroup *g;
863 const struct palmas_pin_info *opt; 864 const struct palmas_pin_info *opt;
864 int ret; 865 int ret;
865 int base, add, mask; 866 int base, add, mask;
866 int rval; 867 int rval;
867 int group_nr; 868 int group_nr;
869 int i;
868 870
869 for (group_nr = 0; group_nr < pci->num_pin_groups; ++group_nr) { 871 for (group_nr = 0; group_nr < pci->num_pin_groups; ++group_nr) {
870 if (pci->pin_groups[group_nr].pins[0] == pin) 872 if (pci->pin_groups[group_nr].pins[0] == pin)
@@ -885,70 +887,77 @@ static int palmas_pinconf_set(struct pinctrl_dev *pctldev,
885 return -ENOTSUPP; 887 return -ENOTSUPP;
886 } 888 }
887 889
888 switch (param) { 890 for (i = 0; i < num_configs; i++) {
889 case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: 891 param = pinconf_to_config_param(configs[i]);
890 return 0; 892 param_val = pinconf_to_config_argument(configs[i]);
891 case PIN_CONFIG_BIAS_DISABLE: 893
892 case PIN_CONFIG_BIAS_PULL_UP: 894 switch (param) {
893 case PIN_CONFIG_BIAS_PULL_DOWN: 895 case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
894 if (!opt->pud_info) { 896 return 0;
895 dev_err(pci->dev, 897 case PIN_CONFIG_BIAS_DISABLE:
896 "PULL control not supported for pin %s\n", 898 case PIN_CONFIG_BIAS_PULL_UP:
897 g->name); 899 case PIN_CONFIG_BIAS_PULL_DOWN:
898 return -ENOTSUPP; 900 if (!opt->pud_info) {
899 } 901 dev_err(pci->dev,
900 base = opt->pud_info->pullup_dn_reg_base; 902 "PULL control not supported for pin %s\n",
901 add = opt->pud_info->pullup_dn_reg_add; 903 g->name);
902 mask = opt->pud_info->pullup_dn_mask; 904 return -ENOTSUPP;
903 905 }
904 if (param == PIN_CONFIG_BIAS_DISABLE) 906 base = opt->pud_info->pullup_dn_reg_base;
905 rval = opt->pud_info->normal_val; 907 add = opt->pud_info->pullup_dn_reg_add;
906 else if (param == PIN_CONFIG_BIAS_PULL_UP) 908 mask = opt->pud_info->pullup_dn_mask;
907 rval = opt->pud_info->pull_up_val; 909
908 else 910 if (param == PIN_CONFIG_BIAS_DISABLE)
909 rval = opt->pud_info->pull_dn_val; 911 rval = opt->pud_info->normal_val;
912 else if (param == PIN_CONFIG_BIAS_PULL_UP)
913 rval = opt->pud_info->pull_up_val;
914 else
915 rval = opt->pud_info->pull_dn_val;
916
917 if (rval < 0) {
918 dev_err(pci->dev,
919 "PULL control not supported for pin %s\n",
920 g->name);
921 return -ENOTSUPP;
922 }
923 break;
910 924
911 if (rval < 0) { 925 case PIN_CONFIG_DRIVE_OPEN_DRAIN:
912 dev_err(pci->dev, 926 if (!opt->od_info) {
913 "PULL control not supported for pin %s\n", 927 dev_err(pci->dev,
914 g->name); 928 "OD control not supported for pin %s\n",
929 g->name);
930 return -ENOTSUPP;
931 }
932 base = opt->od_info->od_reg_base;
933 add = opt->od_info->od_reg_add;
934 mask = opt->od_info->od_mask;
935 if (param_val == 0)
936 rval = opt->od_info->od_disable;
937 else
938 rval = opt->od_info->od_enable;
939 if (rval < 0) {
940 dev_err(pci->dev,
941 "OD control not supported for pin %s\n",
942 g->name);
943 return -ENOTSUPP;
944 }
945 break;
946 default:
947 dev_err(pci->dev, "Properties not supported\n");
915 return -ENOTSUPP; 948 return -ENOTSUPP;
916 } 949 }
917 break;
918 950
919 case PIN_CONFIG_DRIVE_OPEN_DRAIN: 951 dev_dbg(pci->dev, "%s(): Add0x%02x:0x%02x:0x%02x:0x%02x\n",
920 if (!opt->od_info) { 952 __func__, base, add, mask, rval);
921 dev_err(pci->dev, 953 ret = palmas_update_bits(pci->palmas, base, add, mask, rval);
922 "OD control not supported for pin %s\n", 954 if (ret < 0) {
923 g->name); 955 dev_err(pci->dev, "Reg 0x%02x update failed: %d\n",
924 return -ENOTSUPP; 956 add, ret);
925 } 957 return ret;
926 base = opt->od_info->od_reg_base;
927 add = opt->od_info->od_reg_add;
928 mask = opt->od_info->od_mask;
929 if (param_val == 0)
930 rval = opt->od_info->od_disable;
931 else
932 rval = opt->od_info->od_enable;
933 if (rval < 0) {
934 dev_err(pci->dev,
935 "OD control not supported for pin %s\n",
936 g->name);
937 return -ENOTSUPP;
938 } 958 }
939 break; 959 } /* for each config */
940 default:
941 dev_err(pci->dev, "Properties not supported\n");
942 return -ENOTSUPP;
943 }
944 960
945 dev_dbg(pci->dev, "%s(): Add0x%02x:0x%02x:0x%02x:0x%02x\n",
946 __func__, base, add, mask, rval);
947 ret = palmas_update_bits(pci->palmas, base, add, mask, rval);
948 if (ret < 0) {
949 dev_err(pci->dev, "Reg 0x%02x update failed: %d\n", add, ret);
950 return ret;
951 }
952 return 0; 961 return 0;
953} 962}
954 963
@@ -960,7 +969,8 @@ static int palmas_pinconf_group_get(struct pinctrl_dev *pctldev,
960} 969}
961 970
962static int palmas_pinconf_group_set(struct pinctrl_dev *pctldev, 971static int palmas_pinconf_group_set(struct pinctrl_dev *pctldev,
963 unsigned group, unsigned long config) 972 unsigned group, unsigned long *configs,
973 unsigned num_configs)
964{ 974{
965 dev_err(pctldev->dev, "palmas_pinconf_group_set op not supported\n"); 975 dev_err(pctldev->dev, "palmas_pinconf_group_set op not supported\n");
966 return -ENOTSUPP; 976 return -ENOTSUPP;
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 51a7c24981d1..abff5895e81f 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -574,32 +574,45 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl,
574 574
575/* set the pin config settings for a specified pin */ 575/* set the pin config settings for a specified pin */
576static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, 576static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
577 unsigned long config) 577 unsigned long *configs, unsigned num_configs)
578{ 578{
579 struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 579 struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
580 struct rockchip_pin_bank *bank = pin_to_bank(info, pin); 580 struct rockchip_pin_bank *bank = pin_to_bank(info, pin);
581 enum pin_config_param param = pinconf_to_config_param(config); 581 enum pin_config_param param;
582 u16 arg = pinconf_to_config_argument(config); 582 u16 arg;
583 583 int i;
584 switch (param) { 584 int rc;
585 case PIN_CONFIG_BIAS_DISABLE: 585
586 return rockchip_set_pull(bank, pin - bank->pin_base, param); 586 for (i = 0; i < num_configs; i++) {
587 break; 587 param = pinconf_to_config_param(configs[i]);
588 case PIN_CONFIG_BIAS_PULL_UP: 588 arg = pinconf_to_config_argument(configs[i]);
589 case PIN_CONFIG_BIAS_PULL_DOWN: 589
590 case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: 590 switch (param) {
591 if (!rockchip_pinconf_pull_valid(info->ctrl, param)) 591 case PIN_CONFIG_BIAS_DISABLE:
592 rc = rockchip_set_pull(bank, pin - bank->pin_base,
593 param);
594 if (rc)
595 return rc;
596 break;
597 case PIN_CONFIG_BIAS_PULL_UP:
598 case PIN_CONFIG_BIAS_PULL_DOWN:
599 case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
600 if (!rockchip_pinconf_pull_valid(info->ctrl, param))
601 return -ENOTSUPP;
602
603 if (!arg)
604 return -EINVAL;
605
606 rc = rockchip_set_pull(bank, pin - bank->pin_base,
607 param);
608 if (rc)
609 return rc;
610 break;
611 default:
592 return -ENOTSUPP; 612 return -ENOTSUPP;
593 613 break;
594 if (!arg) 614 }
595 return -EINVAL; 615 } /* for each config */
596
597 return rockchip_set_pull(bank, pin - bank->pin_base, param);
598 break;
599 default:
600 return -ENOTSUPP;
601 break;
602 }
603 616
604 return 0; 617 return 0;
605} 618}
diff --git a/drivers/pinctrl/pinctrl-samsung.c b/drivers/pinctrl/pinctrl-samsung.c
index 439f2ef680df..222648d69f25 100644
--- a/drivers/pinctrl/pinctrl-samsung.c
+++ b/drivers/pinctrl/pinctrl-samsung.c
@@ -442,9 +442,17 @@ static int samsung_pinconf_rw(struct pinctrl_dev *pctldev, unsigned int pin,
442 442
443/* set the pin config settings for a specified pin */ 443/* set the pin config settings for a specified pin */
444static int samsung_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, 444static int samsung_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
445 unsigned long config) 445 unsigned long *configs, unsigned num_configs)
446{ 446{
447 return samsung_pinconf_rw(pctldev, pin, &config, true); 447 int i, ret;
448
449 for (i = 0; i < num_configs; i++) {
450 ret = samsung_pinconf_rw(pctldev, pin, &configs[i], true);
451 if (ret < 0)
452 return ret;
453 } /* for each config */
454
455 return 0;
448} 456}
449 457
450/* get the pin config settings for a specified pin */ 458/* get the pin config settings for a specified pin */
@@ -456,7 +464,8 @@ static int samsung_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
456 464
457/* set the pin config settings for a specified pin group */ 465/* set the pin config settings for a specified pin group */
458static int samsung_pinconf_group_set(struct pinctrl_dev *pctldev, 466static int samsung_pinconf_group_set(struct pinctrl_dev *pctldev,
459 unsigned group, unsigned long config) 467 unsigned group, unsigned long *configs,
468 unsigned num_configs)
460{ 469{
461 struct samsung_pinctrl_drv_data *drvdata; 470 struct samsung_pinctrl_drv_data *drvdata;
462 const unsigned int *pins; 471 const unsigned int *pins;
@@ -466,7 +475,7 @@ static int samsung_pinconf_group_set(struct pinctrl_dev *pctldev,
466 pins = drvdata->pin_groups[group].pins; 475 pins = drvdata->pin_groups[group].pins;
467 476
468 for (cnt = 0; cnt < drvdata->pin_groups[group].num_pins; cnt++) 477 for (cnt = 0; cnt < drvdata->pin_groups[group].num_pins; cnt++)
469 samsung_pinconf_set(pctldev, pins[cnt], config); 478 samsung_pinconf_set(pctldev, pins[cnt], configs, num_configs);
470 479
471 return 0; 480 return 0;
472} 481}
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;
diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
index 2a10a318b648..9cadc68ee572 100644
--- a/drivers/pinctrl/pinctrl-st.c
+++ b/drivers/pinctrl/pinctrl-st.c
@@ -909,15 +909,18 @@ static void st_pinconf_set_retime(struct st_pinctrl *info,
909 config, pin); 909 config, pin);
910} 910}
911 911
912static int st_pinconf_set(struct pinctrl_dev *pctldev, 912static int st_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin_id,
913 unsigned pin_id, unsigned long config) 913 unsigned long *configs, unsigned num_configs)
914{ 914{
915 int pin = st_gpio_pin(pin_id); 915 int pin = st_gpio_pin(pin_id);
916 struct st_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 916 struct st_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
917 struct st_pio_control *pc = st_get_pio_control(pctldev, pin_id); 917 struct st_pio_control *pc = st_get_pio_control(pctldev, pin_id);
918 int i;
918 919
919 st_pinconf_set_config(pc, pin, config); 920 for (i = 0; i < num_configs; i++) {
920 st_pinconf_set_retime(info, pc, pin, config); 921 st_pinconf_set_config(pc, pin, configs[i]);
922 st_pinconf_set_retime(info, pc, pin, configs[i]);
923 } /* for each config */
921 924
922 return 0; 925 return 0;
923} 926}
diff --git a/drivers/pinctrl/pinctrl-sunxi.c b/drivers/pinctrl/pinctrl-sunxi.c
index d251c76c2e62..8dbd465b01d3 100644
--- a/drivers/pinctrl/pinctrl-sunxi.c
+++ b/drivers/pinctrl/pinctrl-sunxi.c
@@ -274,50 +274,55 @@ static int sunxi_pconf_group_get(struct pinctrl_dev *pctldev,
274 274
275static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev, 275static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev,
276 unsigned group, 276 unsigned group,
277 unsigned long config) 277 unsigned long *configs,
278 unsigned num_configs)
278{ 279{
279 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 280 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
280 struct sunxi_pinctrl_group *g = &pctl->groups[group]; 281 struct sunxi_pinctrl_group *g = &pctl->groups[group];
281 u32 val, mask; 282 u32 val, mask;
282 u16 strength; 283 u16 strength;
283 u8 dlevel; 284 u8 dlevel;
285 int i;
284 286
285 switch (pinconf_to_config_param(config)) { 287 for (i = 0; i < num_configs; i++) {
286 case PIN_CONFIG_DRIVE_STRENGTH: 288 switch (pinconf_to_config_param(configs[i])) {
287 strength = pinconf_to_config_argument(config); 289 case PIN_CONFIG_DRIVE_STRENGTH:
288 if (strength > 40) 290 strength = pinconf_to_config_argument(configs[i]);
289 return -EINVAL; 291 if (strength > 40)
290 /* 292 return -EINVAL;
291 * We convert from mA to what the register expects: 293 /*
292 * 0: 10mA 294 * We convert from mA to what the register expects:
293 * 1: 20mA 295 * 0: 10mA
294 * 2: 30mA 296 * 1: 20mA
295 * 3: 40mA 297 * 2: 30mA
296 */ 298 * 3: 40mA
297 dlevel = strength / 10 - 1; 299 */
298 val = readl(pctl->membase + sunxi_dlevel_reg(g->pin)); 300 dlevel = strength / 10 - 1;
299 mask = DLEVEL_PINS_MASK << sunxi_dlevel_offset(g->pin); 301 val = readl(pctl->membase + sunxi_dlevel_reg(g->pin));
300 writel((val & ~mask) | dlevel << sunxi_dlevel_offset(g->pin), 302 mask = DLEVEL_PINS_MASK << sunxi_dlevel_offset(g->pin);
301 pctl->membase + sunxi_dlevel_reg(g->pin)); 303 writel((val & ~mask)
302 break; 304 | dlevel << sunxi_dlevel_offset(g->pin),
303 case PIN_CONFIG_BIAS_PULL_UP: 305 pctl->membase + sunxi_dlevel_reg(g->pin));
304 val = readl(pctl->membase + sunxi_pull_reg(g->pin)); 306 break;
305 mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin); 307 case PIN_CONFIG_BIAS_PULL_UP:
306 writel((val & ~mask) | 1 << sunxi_pull_offset(g->pin), 308 val = readl(pctl->membase + sunxi_pull_reg(g->pin));
307 pctl->membase + sunxi_pull_reg(g->pin)); 309 mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin);
308 break; 310 writel((val & ~mask) | 1 << sunxi_pull_offset(g->pin),
309 case PIN_CONFIG_BIAS_PULL_DOWN: 311 pctl->membase + sunxi_pull_reg(g->pin));
310 val = readl(pctl->membase + sunxi_pull_reg(g->pin)); 312 break;
311 mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin); 313 case PIN_CONFIG_BIAS_PULL_DOWN:
312 writel((val & ~mask) | 2 << sunxi_pull_offset(g->pin), 314 val = readl(pctl->membase + sunxi_pull_reg(g->pin));
313 pctl->membase + sunxi_pull_reg(g->pin)); 315 mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin);
314 break; 316 writel((val & ~mask) | 2 << sunxi_pull_offset(g->pin),
315 default: 317 pctl->membase + sunxi_pull_reg(g->pin));
316 break; 318 break;
317 } 319 default:
320 break;
321 }
318 322
319 /* cache the config value */ 323 /* cache the config value */
320 g->config = config; 324 g->config = configs[i];
325 } /* for each config */
321 326
322 return 0; 327 return 0;
323} 328}
diff --git a/drivers/pinctrl/pinctrl-tegra.c b/drivers/pinctrl/pinctrl-tegra.c
index be7e900fb298..a2e93a2b5ff4 100644
--- a/drivers/pinctrl/pinctrl-tegra.c
+++ b/drivers/pinctrl/pinctrl-tegra.c
@@ -436,7 +436,8 @@ static int tegra_pinconf_get(struct pinctrl_dev *pctldev,
436} 436}
437 437
438static int tegra_pinconf_set(struct pinctrl_dev *pctldev, 438static int tegra_pinconf_set(struct pinctrl_dev *pctldev,
439 unsigned pin, unsigned long config) 439 unsigned pin, unsigned long *configs,
440 unsigned num_configs)
440{ 441{
441 dev_err(pctldev->dev, "pin_config_set op not supported\n"); 442 dev_err(pctldev->dev, "pin_config_set op not supported\n");
442 return -ENOTSUPP; 443 return -ENOTSUPP;
@@ -471,51 +472,57 @@ static int tegra_pinconf_group_get(struct pinctrl_dev *pctldev,
471} 472}
472 473
473static int tegra_pinconf_group_set(struct pinctrl_dev *pctldev, 474static int tegra_pinconf_group_set(struct pinctrl_dev *pctldev,
474 unsigned group, unsigned long config) 475 unsigned group, unsigned long *configs,
476 unsigned num_configs)
475{ 477{
476 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 478 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
477 enum tegra_pinconf_param param = TEGRA_PINCONF_UNPACK_PARAM(config); 479 enum tegra_pinconf_param param;
478 u16 arg = TEGRA_PINCONF_UNPACK_ARG(config); 480 u16 arg;
479 const struct tegra_pingroup *g; 481 const struct tegra_pingroup *g;
480 int ret; 482 int ret, i;
481 s8 bank, bit, width; 483 s8 bank, bit, width;
482 s16 reg; 484 s16 reg;
483 u32 val, mask; 485 u32 val, mask;
484 486
485 g = &pmx->soc->groups[group]; 487 g = &pmx->soc->groups[group];
486 488
487 ret = tegra_pinconf_reg(pmx, g, param, true, &bank, &reg, &bit, 489 for (i = 0; i < num_configs; i++) {
488 &width); 490 param = TEGRA_PINCONF_UNPACK_PARAM(configs[i]);
489 if (ret < 0) 491 arg = TEGRA_PINCONF_UNPACK_ARG(configs[i]);
490 return ret;
491 492
492 val = pmx_readl(pmx, bank, reg); 493 ret = tegra_pinconf_reg(pmx, g, param, true, &bank, &reg, &bit,
494 &width);
495 if (ret < 0)
496 return ret;
493 497
494 /* LOCK can't be cleared */ 498 val = pmx_readl(pmx, bank, reg);
495 if (param == TEGRA_PINCONF_PARAM_LOCK) { 499
496 if ((val & BIT(bit)) && !arg) { 500 /* LOCK can't be cleared */
497 dev_err(pctldev->dev, "LOCK bit cannot be cleared\n"); 501 if (param == TEGRA_PINCONF_PARAM_LOCK) {
498 return -EINVAL; 502 if ((val & BIT(bit)) && !arg) {
503 dev_err(pctldev->dev, "LOCK bit cannot be cleared\n");
504 return -EINVAL;
505 }
499 } 506 }
500 }
501 507
502 /* Special-case Boolean values; allow any non-zero as true */ 508 /* Special-case Boolean values; allow any non-zero as true */
503 if (width == 1) 509 if (width == 1)
504 arg = !!arg; 510 arg = !!arg;
505 511
506 /* Range-check user-supplied value */ 512 /* Range-check user-supplied value */
507 mask = (1 << width) - 1; 513 mask = (1 << width) - 1;
508 if (arg & ~mask) { 514 if (arg & ~mask) {
509 dev_err(pctldev->dev, 515 dev_err(pctldev->dev,
510 "config %lx: %x too big for %d bit register\n", 516 "config %lx: %x too big for %d bit register\n",
511 config, arg, width); 517 configs[i], arg, width);
512 return -EINVAL; 518 return -EINVAL;
513 } 519 }
514 520
515 /* Update register */ 521 /* Update register */
516 val &= ~(mask << bit); 522 val &= ~(mask << bit);
517 val |= arg << bit; 523 val |= arg << bit;
518 pmx_writel(pmx, val, bank, reg); 524 pmx_writel(pmx, val, bank, reg);
525 } /* for each config */
519 526
520 return 0; 527 return 0;
521} 528}
diff --git a/drivers/pinctrl/pinctrl-tz1090-pdc.c b/drivers/pinctrl/pinctrl-tz1090-pdc.c
index 494ad4b83264..5bf01c28925e 100644
--- a/drivers/pinctrl/pinctrl-tz1090-pdc.c
+++ b/drivers/pinctrl/pinctrl-tz1090-pdc.c
@@ -737,39 +737,46 @@ static int tz1090_pdc_pinconf_get(struct pinctrl_dev *pctldev,
737} 737}
738 738
739static int tz1090_pdc_pinconf_set(struct pinctrl_dev *pctldev, 739static int tz1090_pdc_pinconf_set(struct pinctrl_dev *pctldev,
740 unsigned int pin, unsigned long config) 740 unsigned int pin, unsigned long *configs,
741 unsigned num_configs)
741{ 742{
742 struct tz1090_pdc_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 743 struct tz1090_pdc_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
743 enum pin_config_param param = pinconf_to_config_param(config); 744 enum pin_config_param param;
744 unsigned int arg = pinconf_to_config_argument(config); 745 unsigned int arg;
745 int ret; 746 int ret;
746 u32 reg, width, mask, shift, val, tmp; 747 u32 reg, width, mask, shift, val, tmp;
747 unsigned long flags; 748 unsigned long flags;
749 int i;
748 750
749 dev_dbg(pctldev->dev, "%s(pin=%s, config=%#lx)\n", 751 for (i = 0; i < num_configs; i++) {
750 __func__, tz1090_pdc_pins[pin].name, config); 752 param = pinconf_to_config_param(configs[i]);
753 arg = pinconf_to_config_argument(configs[i]);
751 754
752 /* Get register information */ 755 dev_dbg(pctldev->dev, "%s(pin=%s, config=%#lx)\n",
753 ret = tz1090_pdc_pinconf_reg(pctldev, pin, param, true, 756 __func__, tz1090_pdc_pins[pin].name, configs[i]);
754 &reg, &width, &mask, &shift, &val);
755 if (ret < 0)
756 return ret;
757 757
758 /* Unpack argument and range check it */ 758 /* Get register information */
759 if (arg > 1) { 759 ret = tz1090_pdc_pinconf_reg(pctldev, pin, param, true,
760 dev_dbg(pctldev->dev, "%s: arg %u out of range\n", 760 &reg, &width, &mask, &shift, &val);
761 __func__, arg); 761 if (ret < 0)
762 return -EINVAL; 762 return ret;
763 }
764 763
765 /* Write register field */ 764 /* Unpack argument and range check it */
766 __global_lock2(flags); 765 if (arg > 1) {
767 tmp = pmx_read(pmx, reg); 766 dev_dbg(pctldev->dev, "%s: arg %u out of range\n",
768 tmp &= ~mask; 767 __func__, arg);
769 if (arg) 768 return -EINVAL;
770 tmp |= val << shift; 769 }
771 pmx_write(pmx, tmp, reg); 770
772 __global_unlock2(flags); 771 /* Write register field */
772 __global_lock2(flags);
773 tmp = pmx_read(pmx, reg);
774 tmp &= ~mask;
775 if (arg)
776 tmp |= val << shift;
777 pmx_write(pmx, tmp, reg);
778 __global_unlock2(flags);
779 } /* for each config */
773 780
774 return 0; 781 return 0;
775} 782}
@@ -860,54 +867,68 @@ static int tz1090_pdc_pinconf_group_get(struct pinctrl_dev *pctldev,
860 867
861static int tz1090_pdc_pinconf_group_set(struct pinctrl_dev *pctldev, 868static int tz1090_pdc_pinconf_group_set(struct pinctrl_dev *pctldev,
862 unsigned int group, 869 unsigned int group,
863 unsigned long config) 870 unsigned long *configs,
871 unsigned num_configs)
864{ 872{
865 struct tz1090_pdc_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 873 struct tz1090_pdc_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
866 const struct tz1090_pdc_pingroup *g = &tz1090_pdc_groups[group]; 874 const struct tz1090_pdc_pingroup *g = &tz1090_pdc_groups[group];
867 enum pin_config_param param = pinconf_to_config_param(config); 875 enum pin_config_param param;
868 const unsigned int *pit; 876 const unsigned int *pit;
869 unsigned int i; 877 unsigned int i;
870 int ret, arg; 878 int ret, arg;
871 u32 reg, width, mask, shift, val; 879 u32 reg, width, mask, shift, val;
872 unsigned long flags; 880 unsigned long flags;
873 const int *map; 881 const int *map;
882 int j;
874 883
875 dev_dbg(pctldev->dev, "%s(group=%s, config=%#lx)\n", 884 for (j = 0; j < num_configs; j++) {
876 __func__, g->name, config); 885 param = pinconf_to_config_param(configs[j]);
877 886
878 /* Get register information */ 887 dev_dbg(pctldev->dev, "%s(group=%s, config=%#lx)\n",
879 ret = tz1090_pdc_pinconf_group_reg(pctldev, g, param, true, 888 __func__, g->name, configs[j]);
880 &reg, &width, &mask, &shift, &map);
881 if (ret < 0) {
882 /*
883 * Maybe we're trying to set a per-pin configuration of a group,
884 * so do the pins one by one. This is mainly as a convenience.
885 */
886 for (i = 0, pit = g->pins; i < g->npins; ++i, ++pit) {
887 ret = tz1090_pdc_pinconf_set(pctldev, *pit, config);
888 if (ret)
889 return ret;
890 }
891 return 0;
892 }
893 889
894 /* Unpack argument and map it to register value */ 890 /* Get register information */
895 arg = pinconf_to_config_argument(config); 891 ret = tz1090_pdc_pinconf_group_reg(pctldev, g, param, true,
896 for (i = 0; i < BIT(width); ++i) { 892 &reg, &width, &mask, &shift,
897 if (map[i] == arg || (map[i] == -EINVAL && !arg)) { 893 &map);
898 /* Write register field */ 894 if (ret < 0) {
899 __global_lock2(flags); 895 /*
900 val = pmx_read(pmx, reg); 896 * Maybe we're trying to set a per-pin configuration
901 val &= ~mask; 897 * of a group, so do the pins one by one. This is
902 val |= i << shift; 898 * mainly as a convenience.
903 pmx_write(pmx, val, reg); 899 */
904 __global_unlock2(flags); 900 for (i = 0, pit = g->pins; i < g->npins; ++i, ++pit) {
901 ret = tz1090_pdc_pinconf_set(pctldev, *pit,
902 configs, num_configs);
903 if (ret)
904 return ret;
905 }
905 return 0; 906 return 0;
906 } 907 }
907 }
908 908
909 dev_dbg(pctldev->dev, "%s: arg %u not supported\n", 909 /* Unpack argument and map it to register value */
910 __func__, arg); 910 arg = pinconf_to_config_argument(configs[j]);
911 for (i = 0; i < BIT(width); ++i) {
912 if (map[i] == arg || (map[i] == -EINVAL && !arg)) {
913 /* Write register field */
914 __global_lock2(flags);
915 val = pmx_read(pmx, reg);
916 val &= ~mask;
917 val |= i << shift;
918 pmx_write(pmx, val, reg);
919 __global_unlock2(flags);
920 goto next_config;
921 }
922 }
923
924 dev_dbg(pctldev->dev, "%s: arg %u not supported\n",
925 __func__, arg);
926 return 0;
927
928next_config:
929 ;
930 } /* for each config */
931
911 return 0; 932 return 0;
912} 933}
913 934
diff --git a/drivers/pinctrl/pinctrl-tz1090.c b/drivers/pinctrl/pinctrl-tz1090.c
index 72d955252e41..bc9cd7a7602e 100644
--- a/drivers/pinctrl/pinctrl-tz1090.c
+++ b/drivers/pinctrl/pinctrl-tz1090.c
@@ -1762,39 +1762,46 @@ static int tz1090_pinconf_get(struct pinctrl_dev *pctldev,
1762} 1762}
1763 1763
1764static int tz1090_pinconf_set(struct pinctrl_dev *pctldev, 1764static int tz1090_pinconf_set(struct pinctrl_dev *pctldev,
1765 unsigned int pin, unsigned long config) 1765 unsigned int pin, unsigned long *configs,
1766 unsigned num_configs)
1766{ 1767{
1767 struct tz1090_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 1768 struct tz1090_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
1768 enum pin_config_param param = pinconf_to_config_param(config); 1769 enum pin_config_param param;
1769 unsigned int arg = pinconf_to_config_argument(config); 1770 unsigned int arg;
1770 int ret; 1771 int ret;
1771 u32 reg, width, mask, shift, val, tmp; 1772 u32 reg, width, mask, shift, val, tmp;
1772 unsigned long flags; 1773 unsigned long flags;
1774 int i;
1773 1775
1774 dev_dbg(pctldev->dev, "%s(pin=%s, config=%#lx)\n", 1776 for (i = 0; i < num_configs; i++) {
1775 __func__, tz1090_pins[pin].name, config); 1777 param = pinconf_to_config_param(configs[i]);
1778 arg = pinconf_to_config_argument(configs[i]);
1776 1779
1777 /* Get register information */ 1780 dev_dbg(pctldev->dev, "%s(pin=%s, config=%#lx)\n",
1778 ret = tz1090_pinconf_reg(pctldev, pin, param, true, 1781 __func__, tz1090_pins[pin].name, configs[i]);
1779 &reg, &width, &mask, &shift, &val);
1780 if (ret < 0)
1781 return ret;
1782 1782
1783 /* Unpack argument and range check it */ 1783 /* Get register information */
1784 if (arg > 1) { 1784 ret = tz1090_pinconf_reg(pctldev, pin, param, true,
1785 dev_dbg(pctldev->dev, "%s: arg %u out of range\n", 1785 &reg, &width, &mask, &shift, &val);
1786 __func__, arg); 1786 if (ret < 0)
1787 return -EINVAL; 1787 return ret;
1788 }
1789 1788
1790 /* Write register field */ 1789 /* Unpack argument and range check it */
1791 __global_lock2(flags); 1790 if (arg > 1) {
1792 tmp = pmx_read(pmx, reg); 1791 dev_dbg(pctldev->dev, "%s: arg %u out of range\n",
1793 tmp &= ~mask; 1792 __func__, arg);
1794 if (arg) 1793 return -EINVAL;
1795 tmp |= val << shift; 1794 }
1796 pmx_write(pmx, tmp, reg); 1795
1797 __global_unlock2(flags); 1796 /* Write register field */
1797 __global_lock2(flags);
1798 tmp = pmx_read(pmx, reg);
1799 tmp &= ~mask;
1800 if (arg)
1801 tmp |= val << shift;
1802 pmx_write(pmx, tmp, reg);
1803 __global_unlock2(flags);
1804 } /* for each config */
1798 1805
1799 return 0; 1806 return 0;
1800} 1807}
@@ -1894,68 +1901,81 @@ static int tz1090_pinconf_group_get(struct pinctrl_dev *pctldev,
1894} 1901}
1895 1902
1896static int tz1090_pinconf_group_set(struct pinctrl_dev *pctldev, 1903static int tz1090_pinconf_group_set(struct pinctrl_dev *pctldev,
1897 unsigned int group, unsigned long config) 1904 unsigned int group, unsigned long *configs,
1905 unsigned num_configs)
1898{ 1906{
1899 struct tz1090_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 1907 struct tz1090_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
1900 const struct tz1090_pingroup *g; 1908 const struct tz1090_pingroup *g;
1901 enum pin_config_param param = pinconf_to_config_param(config); 1909 enum pin_config_param param;
1902 unsigned int arg, pin, i; 1910 unsigned int arg, pin, i;
1903 const unsigned int *pit; 1911 const unsigned int *pit;
1904 int ret; 1912 int ret;
1905 u32 reg, width, mask, shift, val; 1913 u32 reg, width, mask, shift, val;
1906 unsigned long flags; 1914 unsigned long flags;
1907 const int *map; 1915 const int *map;
1916 int j;
1908 1917
1909 if (group >= ARRAY_SIZE(tz1090_groups)) { 1918 if (group >= ARRAY_SIZE(tz1090_groups)) {
1910 pin = group - ARRAY_SIZE(tz1090_groups); 1919 pin = group - ARRAY_SIZE(tz1090_groups);
1911 return tz1090_pinconf_set(pctldev, pin, config); 1920 return tz1090_pinconf_set(pctldev, pin, configs, num_configs);
1912 } 1921 }
1913 1922
1914 g = &tz1090_groups[group]; 1923 g = &tz1090_groups[group];
1915 if (g->npins == 1) { 1924 if (g->npins == 1) {
1916 pin = g->pins[0]; 1925 pin = g->pins[0];
1917 ret = tz1090_pinconf_set(pctldev, pin, config); 1926 ret = tz1090_pinconf_set(pctldev, pin, configs, num_configs);
1918 if (ret != -ENOTSUPP) 1927 if (ret != -ENOTSUPP)
1919 return ret; 1928 return ret;
1920 } 1929 }
1921 1930
1922 dev_dbg(pctldev->dev, "%s(group=%s, config=%#lx)\n", 1931 for (j = 0; j < num_configs; j++) {
1923 __func__, g->name, config); 1932 param = pinconf_to_config_param(configs[j]);
1924 1933
1925 /* Get register information */ 1934 dev_dbg(pctldev->dev, "%s(group=%s, config=%#lx)\n",
1926 ret = tz1090_pinconf_group_reg(pctldev, g, param, true, 1935 __func__, g->name, configs[j]);
1927 &reg, &width, &mask, &shift, &map);
1928 if (ret < 0) {
1929 /*
1930 * Maybe we're trying to set a per-pin configuration of a group,
1931 * so do the pins one by one. This is mainly as a convenience.
1932 */
1933 for (i = 0, pit = g->pins; i < g->npins; ++i, ++pit) {
1934 ret = tz1090_pinconf_set(pctldev, *pit, config);
1935 if (ret)
1936 return ret;
1937 }
1938 return 0;
1939 }
1940 1936
1941 /* Unpack argument and map it to register value */ 1937 /* Get register information */
1942 arg = pinconf_to_config_argument(config); 1938 ret = tz1090_pinconf_group_reg(pctldev, g, param, true, &reg,
1943 for (i = 0; i < BIT(width); ++i) { 1939 &width, &mask, &shift, &map);
1944 if (map[i] == arg || (map[i] == -EINVAL && !arg)) { 1940 if (ret < 0) {
1945 /* Write register field */ 1941 /*
1946 __global_lock2(flags); 1942 * Maybe we're trying to set a per-pin configuration
1947 val = pmx_read(pmx, reg); 1943 * of a group, so do the pins one by one. This is
1948 val &= ~mask; 1944 * mainly as a convenience.
1949 val |= i << shift; 1945 */
1950 pmx_write(pmx, val, reg); 1946 for (i = 0, pit = g->pins; i < g->npins; ++i, ++pit) {
1951 __global_unlock2(flags); 1947 ret = tz1090_pinconf_set(pctldev, *pit, configs,
1948 num_configs);
1949 if (ret)
1950 return ret;
1951 }
1952 return 0; 1952 return 0;
1953 } 1953 }
1954 }
1955 1954
1956 dev_dbg(pctldev->dev, "%s: arg %u not supported\n", 1955 /* Unpack argument and map it to register value */
1957 __func__, arg); 1956 arg = pinconf_to_config_argument(configs[j]);
1958 return -EINVAL; 1957 for (i = 0; i < BIT(width); ++i) {
1958 if (map[i] == arg || (map[i] == -EINVAL && !arg)) {
1959 /* Write register field */
1960 __global_lock2(flags);
1961 val = pmx_read(pmx, reg);
1962 val &= ~mask;
1963 val |= i << shift;
1964 pmx_write(pmx, val, reg);
1965 __global_unlock2(flags);
1966 goto next_config;
1967 }
1968 }
1969
1970 dev_dbg(pctldev->dev, "%s: arg %u not supported\n",
1971 __func__, arg);
1972 return -EINVAL;
1973
1974next_config:
1975 ;
1976 } /* for each config */
1977
1978 return 0;
1959} 1979}
1960 1980
1961static struct pinconf_ops tz1090_pinconf_ops = { 1981static struct pinconf_ops tz1090_pinconf_ops = {
diff --git a/drivers/pinctrl/pinctrl-u300.c b/drivers/pinctrl/pinctrl-u300.c
index 6fbdc06d2998..209a01b8bd3b 100644
--- a/drivers/pinctrl/pinctrl-u300.c
+++ b/drivers/pinctrl/pinctrl-u300.c
@@ -1027,21 +1027,23 @@ static int u300_pin_config_get(struct pinctrl_dev *pctldev, unsigned pin,
1027} 1027}
1028 1028
1029static int u300_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin, 1029static int u300_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin,
1030 unsigned long config) 1030 unsigned long *configs, unsigned num_configs)
1031{ 1031{
1032 struct pinctrl_gpio_range *range = 1032 struct pinctrl_gpio_range *range =
1033 pinctrl_find_gpio_range_from_pin(pctldev, pin); 1033 pinctrl_find_gpio_range_from_pin(pctldev, pin);
1034 int ret; 1034 int ret, i;
1035 1035
1036 if (!range) 1036 if (!range)
1037 return -EINVAL; 1037 return -EINVAL;
1038 1038
1039 /* Note: none of these configurations take any argument */ 1039 for (i = 0; i < num_configs; i++) {
1040 ret = u300_gpio_config_set(range->gc, 1040 /* Note: none of these configurations take any argument */
1041 (pin - range->pin_base + range->base), 1041 ret = u300_gpio_config_set(range->gc,
1042 pinconf_to_config_param(config)); 1042 (pin - range->pin_base + range->base),
1043 if (ret) 1043 pinconf_to_config_param(configs[i]));
1044 return ret; 1044 if (ret)
1045 return ret;
1046 } /* for each config */
1045 1047
1046 return 0; 1048 return 0;
1047} 1049}
diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c
index 86c8cf82105b..ed2d1ba69cef 100644
--- a/drivers/pinctrl/pinctrl-xway.c
+++ b/drivers/pinctrl/pinctrl-xway.c
@@ -499,74 +499,101 @@ static int xway_pinconf_get(struct pinctrl_dev *pctldev,
499 499
500static int xway_pinconf_set(struct pinctrl_dev *pctldev, 500static int xway_pinconf_set(struct pinctrl_dev *pctldev,
501 unsigned pin, 501 unsigned pin,
502 unsigned long config) 502 unsigned long *configs,
503 unsigned num_configs)
503{ 504{
504 struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctldev); 505 struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctldev);
505 enum ltq_pinconf_param param = LTQ_PINCONF_UNPACK_PARAM(config); 506 enum ltq_pinconf_param param;
506 int arg = LTQ_PINCONF_UNPACK_ARG(config); 507 int arg;
507 int port = PORT(pin); 508 int port = PORT(pin);
508 u32 reg; 509 u32 reg;
510 int i;
511
512 for (i = 0; i < num_configs; i++) {
513 param = LTQ_PINCONF_UNPACK_PARAM(configs[i]);
514 arg = LTQ_PINCONF_UNPACK_ARG(configs[i]);
515
516 switch (param) {
517 case LTQ_PINCONF_PARAM_OPEN_DRAIN:
518 if (port == PORT3)
519 reg = GPIO3_OD;
520 else
521 reg = GPIO_OD(pin);
522 if (arg == 0)
523 gpio_setbit(info->membase[0],
524 reg,
525 PORT_PIN(pin));
526 else
527 gpio_clearbit(info->membase[0],
528 reg,
529 PORT_PIN(pin));
530 break;
509 531
510 switch (param) { 532 case LTQ_PINCONF_PARAM_PULL:
511 case LTQ_PINCONF_PARAM_OPEN_DRAIN: 533 if (port == PORT3)
512 if (port == PORT3) 534 reg = GPIO3_PUDEN;
513 reg = GPIO3_OD; 535 else
514 else 536 reg = GPIO_PUDEN(pin);
515 reg = GPIO_OD(pin); 537 if (arg == 0) {
516 if (arg == 0) 538 gpio_clearbit(info->membase[0],
539 reg,
540 PORT_PIN(pin));
541 break;
542 }
517 gpio_setbit(info->membase[0], reg, PORT_PIN(pin)); 543 gpio_setbit(info->membase[0], reg, PORT_PIN(pin));
518 else
519 gpio_clearbit(info->membase[0], reg, PORT_PIN(pin));
520 break;
521 544
522 case LTQ_PINCONF_PARAM_PULL: 545 if (port == PORT3)
523 if (port == PORT3) 546 reg = GPIO3_PUDSEL;
524 reg = GPIO3_PUDEN; 547 else
525 else 548 reg = GPIO_PUDSEL(pin);
526 reg = GPIO_PUDEN(pin); 549 if (arg == 1)
527 if (arg == 0) { 550 gpio_clearbit(info->membase[0],
528 gpio_clearbit(info->membase[0], reg, PORT_PIN(pin)); 551 reg,
552 PORT_PIN(pin));
553 else if (arg == 2)
554 gpio_setbit(info->membase[0],
555 reg,
556 PORT_PIN(pin));
557 else
558 dev_err(pctldev->dev,
559 "Invalid pull value %d\n", arg);
529 break; 560 break;
530 }
531 gpio_setbit(info->membase[0], reg, PORT_PIN(pin));
532 561
533 if (port == PORT3) 562 case LTQ_PINCONF_PARAM_OUTPUT:
534 reg = GPIO3_PUDSEL; 563 reg = GPIO_DIR(pin);
535 else 564 if (arg == 0)
536 reg = GPIO_PUDSEL(pin); 565 gpio_clearbit(info->membase[0],
537 if (arg == 1) 566 reg,
538 gpio_clearbit(info->membase[0], reg, PORT_PIN(pin)); 567 PORT_PIN(pin));
539 else if (arg == 2) 568 else
540 gpio_setbit(info->membase[0], reg, PORT_PIN(pin)); 569 gpio_setbit(info->membase[0],
541 else 570 reg,
542 dev_err(pctldev->dev, "Invalid pull value %d\n", arg); 571 PORT_PIN(pin));
543 break; 572 break;
544 573
545 case LTQ_PINCONF_PARAM_OUTPUT: 574 default:
546 reg = GPIO_DIR(pin); 575 dev_err(pctldev->dev,
547 if (arg == 0) 576 "Invalid config param %04x\n", param);
548 gpio_clearbit(info->membase[0], reg, PORT_PIN(pin)); 577 return -ENOTSUPP;
549 else 578 }
550 gpio_setbit(info->membase[0], reg, PORT_PIN(pin)); 579 } /* for each config */
551 break;
552 580
553 default:
554 dev_err(pctldev->dev, "Invalid config param %04x\n", param);
555 return -ENOTSUPP;
556 }
557 return 0; 581 return 0;
558} 582}
559 583
560int xway_pinconf_group_set(struct pinctrl_dev *pctldev, 584int xway_pinconf_group_set(struct pinctrl_dev *pctldev,
561 unsigned selector, 585 unsigned selector,
562 unsigned long config) 586 unsigned long *configs,
587 unsigned num_configs)
563{ 588{
564 struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctldev); 589 struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctldev);
565 int i, ret = 0; 590 int i, ret = 0;
566 591
567 for (i = 0; i < info->grps[selector].npins && !ret; i++) 592 for (i = 0; i < info->grps[selector].npins && !ret; i++)
568 ret = xway_pinconf_set(pctldev, 593 ret = xway_pinconf_set(pctldev,
569 info->grps[selector].pins[i], config); 594 info->grps[selector].pins[i],
595 configs,
596 num_configs);
570 597
571 return ret; 598 return ret;
572} 599}
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}
diff --git a/drivers/pinctrl/vt8500/pinctrl-wmt.c b/drivers/pinctrl/vt8500/pinctrl-wmt.c
index 0cc4335bc0f2..39aec0850810 100644
--- a/drivers/pinctrl/vt8500/pinctrl-wmt.c
+++ b/drivers/pinctrl/vt8500/pinctrl-wmt.c
@@ -424,15 +424,16 @@ static int wmt_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin,
424} 424}
425 425
426static int wmt_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin, 426static int wmt_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin,
427 unsigned long config) 427 unsigned long *configs, unsigned num_configs)
428{ 428{
429 struct wmt_pinctrl_data *data = pinctrl_dev_get_drvdata(pctldev); 429 struct wmt_pinctrl_data *data = pinctrl_dev_get_drvdata(pctldev);
430 enum pin_config_param param = pinconf_to_config_param(config); 430 enum pin_config_param param;
431 u16 arg = pinconf_to_config_argument(config); 431 u16 arg;
432 u32 bank = WMT_BANK_FROM_PIN(pin); 432 u32 bank = WMT_BANK_FROM_PIN(pin);
433 u32 bit = WMT_BIT_FROM_PIN(pin); 433 u32 bit = WMT_BIT_FROM_PIN(pin);
434 u32 reg_pull_en = data->banks[bank].reg_pull_en; 434 u32 reg_pull_en = data->banks[bank].reg_pull_en;
435 u32 reg_pull_cfg = data->banks[bank].reg_pull_cfg; 435 u32 reg_pull_cfg = data->banks[bank].reg_pull_cfg;
436 int i;
436 437
437 if ((reg_pull_en == NO_REG) || (reg_pull_cfg == NO_REG)) { 438 if ((reg_pull_en == NO_REG) || (reg_pull_cfg == NO_REG)) {
438 dev_err(data->dev, "bias functions not supported on pin %d\n", 439 dev_err(data->dev, "bias functions not supported on pin %d\n",
@@ -440,28 +441,33 @@ static int wmt_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin,
440 return -EINVAL; 441 return -EINVAL;
441 } 442 }
442 443
443 if ((param == PIN_CONFIG_BIAS_PULL_DOWN) || 444 for (i = 0; i < num_configs; i++) {
444 (param == PIN_CONFIG_BIAS_PULL_UP)) { 445 param = pinconf_to_config_param(configs[i]);
445 if (arg == 0) 446 arg = pinconf_to_config_argument(configs[i]);
446 param = PIN_CONFIG_BIAS_DISABLE;
447 }
448 447
449 switch (param) { 448 if ((param == PIN_CONFIG_BIAS_PULL_DOWN) ||
450 case PIN_CONFIG_BIAS_DISABLE: 449 (param == PIN_CONFIG_BIAS_PULL_UP)) {
451 wmt_clearbits(data, reg_pull_en, BIT(bit)); 450 if (arg == 0)
452 break; 451 param = PIN_CONFIG_BIAS_DISABLE;
453 case PIN_CONFIG_BIAS_PULL_DOWN: 452 }
454 wmt_clearbits(data, reg_pull_cfg, BIT(bit)); 453
455 wmt_setbits(data, reg_pull_en, BIT(bit)); 454 switch (param) {
456 break; 455 case PIN_CONFIG_BIAS_DISABLE:
457 case PIN_CONFIG_BIAS_PULL_UP: 456 wmt_clearbits(data, reg_pull_en, BIT(bit));
458 wmt_setbits(data, reg_pull_cfg, BIT(bit)); 457 break;
459 wmt_setbits(data, reg_pull_en, BIT(bit)); 458 case PIN_CONFIG_BIAS_PULL_DOWN:
460 break; 459 wmt_clearbits(data, reg_pull_cfg, BIT(bit));
461 default: 460 wmt_setbits(data, reg_pull_en, BIT(bit));
462 dev_err(data->dev, "unknown pinconf param\n"); 461 break;
463 return -EINVAL; 462 case PIN_CONFIG_BIAS_PULL_UP:
464 } 463 wmt_setbits(data, reg_pull_cfg, BIT(bit));
464 wmt_setbits(data, reg_pull_en, BIT(bit));
465 break;
466 default:
467 dev_err(data->dev, "unknown pinconf param\n");
468 return -EINVAL;
469 }
470 } /* for each config */
465 471
466 return 0; 472 return 0;
467} 473}