Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sherman Yin and committed by
Linus Walleij
03b054e9 f5ba9c52

+936 -710
+20 -6
drivers/pinctrl/mvebu/pinctrl-mvebu.c
··· 191 191 } 192 192 193 193 static 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 197 struct mvebu_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 197 198 struct mvebu_pinctrl_group *grp = &pctl->groups[gid]; 199 + int i, ret; 198 200 199 201 if (!grp->ctrl) 200 202 return -EINVAL; 201 203 202 - if (grp->ctrl->mpp_set) 203 - return grp->ctrl->mpp_set(grp->ctrl, config); 204 + for (i = 0; i < num_configs; i++) { 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 208 217 static void mvebu_pinconf_group_dbg_show(struct pinctrl_dev *pctldev, ··· 312 303 struct mvebu_pinctrl_group *grp = &pctl->groups[gid]; 313 304 struct mvebu_mpp_ctrl_setting *setting; 314 305 int ret; 306 + unsigned long config; 315 307 316 308 setting = mvebu_pinctrl_find_setting_by_name(pctl, grp, 317 309 func->name); ··· 323 313 return -EINVAL; 324 314 } 325 315 326 - ret = mvebu_pinconf_group_set(pctldev, grp->gid, setting->val); 316 + config = setting->val; 317 + ret = mvebu_pinconf_group_set(pctldev, grp->gid, &config, 1); 327 318 if (ret) { 328 319 dev_err(pctl->dev, "cannot set group %s to %s\n", 329 320 func->groups[gid], func->name); ··· 340 329 struct mvebu_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 341 330 struct mvebu_pinctrl_group *grp; 342 331 struct mvebu_mpp_ctrl_setting *setting; 332 + unsigned long config; 343 333 344 334 grp = mvebu_pinctrl_find_group_by_pid(pctl, offset); 345 335 if (!grp) ··· 353 341 if (!setting) 354 342 return -ENOTSUPP; 355 343 356 - return mvebu_pinconf_group_set(pctldev, grp->gid, setting->val); 344 + config = setting->val; 345 + 346 + return mvebu_pinconf_group_set(pctldev, grp->gid, &config, 1); 357 347 } 358 348 359 349 static int mvebu_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
+19 -23
drivers/pinctrl/pinconf.c
··· 158 158 { 159 159 struct pinctrl_dev *pctldev = setting->pctldev; 160 160 const struct pinconf_ops *ops = pctldev->desc->confops; 161 - int i, ret; 161 + int ret; 162 162 163 163 if (!ops) { 164 164 dev_err(pctldev->dev, "missing confops\n"); ··· 171 171 dev_err(pctldev->dev, "missing pin_config_set op\n"); 172 172 return -EINVAL; 173 173 } 174 - for (i = 0; i < setting->data.configs.num_configs; i++) { 175 - ret = ops->pin_config_set(pctldev, 176 - setting->data.configs.group_or_pin, 177 - setting->data.configs.configs[i]); 178 - if (ret < 0) { 179 - dev_err(pctldev->dev, 180 - "pin_config_set op failed for pin %d config %08lx\n", 181 - setting->data.configs.group_or_pin, 182 - setting->data.configs.configs[i]); 183 - return ret; 184 - } 174 + ret = ops->pin_config_set(pctldev, 175 + setting->data.configs.group_or_pin, 176 + setting->data.configs.configs, 177 + setting->data.configs.num_configs); 178 + if (ret < 0) { 179 + dev_err(pctldev->dev, 180 + "pin_config_set op failed for pin %d\n", 181 + setting->data.configs.group_or_pin); 182 + return ret; 185 183 } 186 184 break; 187 185 case PIN_MAP_TYPE_CONFIGS_GROUP: ··· 188 190 "missing pin_config_group_set op\n"); 189 191 return -EINVAL; 190 192 } 191 - for (i = 0; i < setting->data.configs.num_configs; i++) { 192 - ret = ops->pin_config_group_set(pctldev, 193 - setting->data.configs.group_or_pin, 194 - setting->data.configs.configs[i]); 195 - if (ret < 0) { 196 - dev_err(pctldev->dev, 197 - "pin_config_group_set op failed for group %d config %08lx\n", 198 - setting->data.configs.group_or_pin, 199 - setting->data.configs.configs[i]); 200 - return ret; 201 - } 193 + ret = ops->pin_config_group_set(pctldev, 194 + setting->data.configs.group_or_pin, 195 + setting->data.configs.configs, 196 + setting->data.configs.num_configs); 197 + if (ret < 0) { 198 + dev_err(pctldev->dev, 199 + "pin_config_group_set op failed for group %d\n", 200 + setting->data.configs.group_or_pin); 201 + return ret; 202 202 } 203 203 break; 204 204 default:
+97 -80
drivers/pinctrl/pinctrl-abx500.c
··· 1041 1041 1042 1042 static int abx500_pin_config_set(struct pinctrl_dev *pctldev, 1043 1043 unsigned pin, 1044 - unsigned long config) 1044 + unsigned long *configs, 1045 + unsigned num_configs) 1045 1046 { 1046 1047 struct abx500_pinctrl *pct = pinctrl_dev_get_drvdata(pctldev); 1047 1048 struct gpio_chip *chip = &pct->chip; 1048 1049 unsigned offset; 1049 1050 int ret = -EINVAL; 1050 - enum pin_config_param param = pinconf_to_config_param(config); 1051 - enum pin_config_param argument = pinconf_to_config_argument(config); 1051 + int i; 1052 + enum pin_config_param param; 1053 + enum pin_config_param argument; 1052 1054 1053 - dev_dbg(chip->dev, "pin %d [%#lx]: %s %s\n", 1054 - pin, config, (param == PIN_CONFIG_OUTPUT) ? "output " : "input", 1055 - (param == PIN_CONFIG_OUTPUT) ? (argument ? "high" : "low") : 1056 - (argument ? "pull up" : "pull down")); 1055 + for (i = 0; i < num_configs; i++) { 1056 + param = pinconf_to_config_param(configs[i]); 1057 + argument = pinconf_to_config_argument(configs[i]); 1057 1058 1058 - /* on ABx500, there is no GPIO0, so adjust the offset */ 1059 - offset = pin - 1; 1059 + dev_dbg(chip->dev, "pin %d [%#lx]: %s %s\n", 1060 + pin, configs[i], 1061 + (param == PIN_CONFIG_OUTPUT) ? "output " : "input", 1062 + (param == PIN_CONFIG_OUTPUT) ? 1063 + (argument ? "high" : "low") : 1064 + (argument ? "pull up" : "pull down")); 1060 1065 1061 - switch (param) { 1062 - case PIN_CONFIG_BIAS_DISABLE: 1063 - ret = abx500_gpio_direction_input(chip, offset); 1064 - if (ret < 0) 1065 - goto out; 1066 - /* 1067 - * Some chips only support pull down, while some actually 1068 - * support both pull up and pull down. Such chips have 1069 - * a "pullud" range specified for the pins that support 1070 - * both features. If the pin is not within that range, we 1071 - * fall back to the old bit set that only support pull down. 1072 - */ 1073 - if (abx500_pullud_supported(chip, pin)) 1074 - ret = abx500_set_pull_updown(pct, 1075 - pin, 1076 - ABX500_GPIO_PULL_NONE); 1077 - else 1078 - /* Chip only supports pull down */ 1079 - ret = abx500_gpio_set_bits(chip, AB8500_GPIO_PUD1_REG, 1080 - offset, ABX500_GPIO_PULL_NONE); 1081 - break; 1066 + /* on ABx500, there is no GPIO0, so adjust the offset */ 1067 + offset = pin - 1; 1082 1068 1083 - case PIN_CONFIG_BIAS_PULL_DOWN: 1084 - ret = abx500_gpio_direction_input(chip, offset); 1085 - if (ret < 0) 1086 - goto out; 1087 - /* 1088 - * if argument = 1 set the pull down 1089 - * else clear the pull down 1090 - * Some chips only support pull down, while some actually 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; 1069 + switch (param) { 1070 + case PIN_CONFIG_BIAS_DISABLE: 1071 + ret = abx500_gpio_direction_input(chip, offset); 1072 + if (ret < 0) 1073 + goto out; 1074 + /* 1075 + * Some chips only support pull down, while some 1076 + * actually support both pull up and pull down. Such 1077 + * chips have a "pullud" range specified for the pins 1078 + * that support both features. If the pin is not 1079 + * within that range, we fall back to the old bit set 1080 + * that only support pull down. 1081 + */ 1082 + if (abx500_pullud_supported(chip, pin)) 1083 + ret = abx500_set_pull_updown(pct, 1084 + pin, 1085 + ABX500_GPIO_PULL_NONE); 1086 + else 1087 + /* Chip only supports pull down */ 1088 + ret = abx500_gpio_set_bits(chip, 1089 + AB8500_GPIO_PUD1_REG, offset, 1090 + ABX500_GPIO_PULL_NONE); 1091 + break; 1106 1092 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; 1093 + case PIN_CONFIG_BIAS_PULL_DOWN: 1094 + ret = abx500_gpio_direction_input(chip, offset); 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; 1128 1120 1129 - case PIN_CONFIG_OUTPUT: 1130 - ret = abx500_gpio_direction_output(chip, offset, argument); 1131 - break; 1121 + case PIN_CONFIG_BIAS_PULL_UP: 1122 + ret = abx500_gpio_direction_input(chip, offset); 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; 1132 1143 1133 - default: 1134 - dev_err(chip->dev, "illegal configuration requested\n"); 1135 - } 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 */ 1136 1153 out: 1137 1154 if (ret < 0) 1138 1155 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret);
+26 -16
drivers/pinctrl/pinctrl-at91.c
··· 736 736 } 737 737 738 738 static 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 742 struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 742 743 unsigned mask; 743 744 void __iomem *pio; 745 + int i; 746 + unsigned long config; 744 747 745 - dev_dbg(info->dev, "%s:%d, pin_id=%d, config=0x%lx", __func__, __LINE__, pin_id, config); 746 - pio = pin_to_controller(info, pin_to_bank(pin_id)); 747 - mask = pin_to_mask(pin_id % MAX_NB_GPIO_PER_BANK); 748 + for (i = 0; i < num_configs; i++) { 749 + config = configs[i]; 748 750 749 - if (config & PULL_UP && config & PULL_DOWN) 750 - return -EINVAL; 751 + dev_dbg(info->dev, 752 + "%s:%d, pin_id=%d, config=0x%lx", 753 + __func__, __LINE__, pin_id, config); 754 + pio = pin_to_controller(info, pin_to_bank(pin_id)); 755 + mask = pin_to_mask(pin_id % MAX_NB_GPIO_PER_BANK); 751 756 752 - at91_mux_set_pullup(pio, mask, config & PULL_UP); 753 - at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE); 754 - if (info->ops->set_deglitch) 755 - info->ops->set_deglitch(pio, mask, config & DEGLITCH); 756 - if (info->ops->set_debounce) 757 - info->ops->set_debounce(pio, mask, config & DEBOUNCE, 757 + if (config & PULL_UP && config & PULL_DOWN) 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 766 (config & DEBOUNCE_VAL) >> DEBOUNCE_VAL_SHIFT); 759 - if (info->ops->set_pulldown) 760 - info->ops->set_pulldown(pio, mask, config & PULL_DOWN); 761 - if (info->ops->disable_schmitt_trig && config & DIS_SCHMIT) 762 - info->ops->disable_schmitt_trig(pio, mask); 767 + if (info->ops->set_pulldown) 768 + info->ops->set_pulldown(pio, mask, config & PULL_DOWN); 769 + if (info->ops->disable_schmitt_trig && config & DIS_SCHMIT) 770 + info->ops->disable_schmitt_trig(pio, mask); 771 + 772 + } /* for each config */ 763 773 764 774 return 0; 765 775 }
+23 -16
drivers/pinctrl/pinctrl-bcm2835.c
··· 893 893 } 894 894 895 895 static 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 899 struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev); 899 - enum bcm2835_pinconf_param param = BCM2835_PINCONF_UNPACK_PARAM(config); 900 - u16 arg = BCM2835_PINCONF_UNPACK_ARG(config); 900 + enum bcm2835_pinconf_param param; 901 + u16 arg; 901 902 u32 off, bit; 903 + int i; 902 904 903 - if (param != BCM2835_PINCONF_PARAM_PULL) 904 - return -EINVAL; 905 + for (i = 0; i < num_configs; i++) { 906 + param = BCM2835_PINCONF_UNPACK_PARAM(configs[i]); 907 + arg = BCM2835_PINCONF_UNPACK_ARG(configs[i]); 905 908 906 - off = GPIO_REG_OFFSET(pin); 907 - bit = GPIO_REG_SHIFT(pin); 909 + if (param != BCM2835_PINCONF_PARAM_PULL) 910 + return -EINVAL; 908 911 909 - bcm2835_gpio_wr(pc, GPPUD, arg & 3); 910 - /* 911 - * Docs say to wait 150 cycles, but not of what. We assume a 912 - * 1 MHz clock here, which is pretty slow... 913 - */ 914 - udelay(150); 915 - bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), BIT(bit)); 916 - udelay(150); 917 - bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), 0); 912 + off = GPIO_REG_OFFSET(pin); 913 + bit = GPIO_REG_SHIFT(pin); 914 + 915 + bcm2835_gpio_wr(pc, GPPUD, arg & 3); 916 + /* 917 + * Docs say to wait 150 cycles, but not of what. We assume a 918 + * 1 MHz clock here, which is pretty slow... 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 926 return 0; 920 927 }
+58 -49
drivers/pinctrl/pinctrl-exynos5440.c
··· 401 401 402 402 /* set the pin config settings for a specified pin */ 403 403 static 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 407 struct exynos5440_pinctrl_priv_data *priv; 407 408 void __iomem *base; 408 - enum pincfg_type cfg_type = PINCFG_UNPACK_TYPE(config); 409 - u32 cfg_value = PINCFG_UNPACK_VALUE(config); 409 + enum pincfg_type cfg_type; 410 + u32 cfg_value; 410 411 u32 data; 412 + int i; 411 413 412 414 priv = pinctrl_dev_get_drvdata(pctldev); 413 415 base = priv->reg_base; 414 416 415 - switch (cfg_type) { 416 - case PINCFG_TYPE_PUD: 417 - /* first set pull enable/disable bit */ 418 - data = readl(base + GPIO_PE); 419 - data &= ~(1 << pin); 420 - if (cfg_value) 421 - data |= (1 << pin); 422 - writel(data, base + GPIO_PE); 417 + for (i = 0; i < num_configs; i++) { 418 + cfg_type = PINCFG_UNPACK_TYPE(configs[i]); 419 + cfg_value = PINCFG_UNPACK_VALUE(configs[i]); 423 420 424 - /* then set pull up/down bit */ 425 - data = readl(base + GPIO_PS); 426 - data &= ~(1 << pin); 427 - if (cfg_value == 2) 428 - data |= (1 << pin); 429 - writel(data, base + GPIO_PS); 430 - break; 421 + switch (cfg_type) { 422 + case PINCFG_TYPE_PUD: 423 + /* first set pull enable/disable bit */ 424 + data = readl(base + GPIO_PE); 425 + data &= ~(1 << pin); 426 + if (cfg_value) 427 + data |= (1 << pin); 428 + writel(data, base + GPIO_PE); 431 429 432 - case PINCFG_TYPE_DRV: 433 - /* set the first bit of the drive strength */ 434 - data = readl(base + GPIO_DS0); 435 - data &= ~(1 << pin); 436 - data |= ((cfg_value & 1) << pin); 437 - writel(data, base + GPIO_DS0); 438 - cfg_value >>= 1; 430 + /* then set pull up/down bit */ 431 + data = readl(base + GPIO_PS); 432 + data &= ~(1 << pin); 433 + if (cfg_value == 2) 434 + data |= (1 << pin); 435 + writel(data, base + GPIO_PS); 436 + break; 439 437 440 - /* set the second bit of the driver strength */ 441 - data = readl(base + GPIO_DS1); 442 - data &= ~(1 << pin); 443 - data |= ((cfg_value & 1) << pin); 444 - writel(data, base + GPIO_DS1); 445 - break; 446 - case PINCFG_TYPE_SKEW_RATE: 447 - data = readl(base + GPIO_SR); 448 - data &= ~(1 << pin); 449 - data |= ((cfg_value & 1) << pin); 450 - writel(data, base + GPIO_SR); 451 - break; 452 - case PINCFG_TYPE_INPUT_TYPE: 453 - data = readl(base + GPIO_TYPE); 454 - data &= ~(1 << pin); 455 - data |= ((cfg_value & 1) << pin); 456 - writel(data, base + GPIO_TYPE); 457 - break; 458 - default: 459 - WARN_ON(1); 460 - return -EINVAL; 461 - } 438 + case PINCFG_TYPE_DRV: 439 + /* set the first bit of the drive strength */ 440 + data = readl(base + GPIO_DS0); 441 + data &= ~(1 << pin); 442 + data |= ((cfg_value & 1) << pin); 443 + writel(data, base + GPIO_DS0); 444 + cfg_value >>= 1; 445 + 446 + /* set the second bit of the driver strength */ 447 + data = readl(base + GPIO_DS1); 448 + data &= ~(1 << pin); 449 + data |= ((cfg_value & 1) << pin); 450 + writel(data, base + GPIO_DS1); 451 + break; 452 + case PINCFG_TYPE_SKEW_RATE: 453 + data = readl(base + GPIO_SR); 454 + data &= ~(1 << pin); 455 + data |= ((cfg_value & 1) << pin); 456 + writel(data, base + GPIO_SR); 457 + break; 458 + case PINCFG_TYPE_INPUT_TYPE: 459 + data = readl(base + GPIO_TYPE); 460 + data &= ~(1 << pin); 461 + data |= ((cfg_value & 1) << pin); 462 + writel(data, base + GPIO_TYPE); 463 + break; 464 + default: 465 + WARN_ON(1); 466 + return -EINVAL; 467 + } 468 + } /* for each config */ 462 469 463 470 return 0; 464 471 } ··· 517 510 518 511 /* set the pin config settings for a specified pin group */ 519 512 static int exynos5440_pinconf_group_set(struct pinctrl_dev *pctldev, 520 - unsigned group, unsigned long config) 513 + unsigned group, unsigned long *configs, 514 + unsigned num_configs) 521 515 { 522 516 struct exynos5440_pinctrl_priv_data *priv; 523 517 const unsigned int *pins; ··· 528 520 pins = priv->pin_groups[group].pins; 529 521 530 522 for (cnt = 0; cnt < priv->pin_groups[group].num_pins; cnt++) 531 - exynos5440_pinconf_set(pctldev, pins[cnt], config); 523 + exynos5440_pinconf_set(pctldev, pins[cnt], configs, 524 + num_configs); 532 525 533 526 return 0; 534 527 }
+34 -25
drivers/pinctrl/pinctrl-falcon.c
··· 238 238 } 239 239 240 240 static 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 244 return -ENOTSUPP; 244 245 } ··· 280 279 } 281 280 282 281 static int falcon_pinconf_set(struct pinctrl_dev *pctrldev, 283 - unsigned pin, unsigned long config) 282 + unsigned pin, unsigned long *configs, 283 + unsigned num_configs) 284 284 { 285 - enum ltq_pinconf_param param = LTQ_PINCONF_UNPACK_PARAM(config); 286 - int arg = LTQ_PINCONF_UNPACK_ARG(config); 285 + enum ltq_pinconf_param param; 286 + int arg; 287 287 struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); 288 288 void __iomem *mem = info->membase[PORT(pin)]; 289 289 u32 reg; 290 + int i; 290 291 291 - switch (param) { 292 - case LTQ_PINCONF_PARAM_DRIVE_CURRENT: 293 - reg = LTQ_PADC_DCC; 294 - break; 292 + for (i = 0; i < num_configs; i++) { 293 + param = LTQ_PINCONF_UNPACK_PARAM(configs[i]); 294 + arg = LTQ_PINCONF_UNPACK_ARG(configs[i]); 295 295 296 - case LTQ_PINCONF_PARAM_SLEW_RATE: 297 - reg = LTQ_PADC_SRC; 298 - break; 296 + switch (param) { 297 + case LTQ_PINCONF_PARAM_DRIVE_CURRENT: 298 + reg = LTQ_PADC_DCC; 299 + break; 299 300 300 - case LTQ_PINCONF_PARAM_PULL: 301 - if (arg == 1) 302 - reg = LTQ_PADC_PDEN; 303 - else 304 - reg = LTQ_PADC_PUEN; 305 - break; 301 + case LTQ_PINCONF_PARAM_SLEW_RATE: 302 + reg = LTQ_PADC_SRC; 303 + break; 306 304 307 - default: 308 - pr_err("%s: Invalid config param %04x\n", 309 - pinctrl_dev_get_name(pctrldev), param); 310 - return -ENOTSUPP; 311 - } 305 + case LTQ_PINCONF_PARAM_PULL: 306 + if (arg == 1) 307 + reg = LTQ_PADC_PDEN; 308 + else 309 + reg = LTQ_PADC_PUEN; 310 + break; 312 311 313 - pad_w32(mem, BIT(PORT_PIN(pin)), reg); 314 - if (!(pad_r32(mem, reg) & BIT(PORT_PIN(pin)))) 315 - return -ENOTSUPP; 312 + default: 313 + pr_err("%s: Invalid config param %04x\n", 314 + pinctrl_dev_get_name(pctrldev), param); 315 + return -ENOTSUPP; 316 + } 317 + 318 + pad_w32(mem, BIT(PORT_PIN(pin)), reg); 319 + if (!(pad_r32(mem, reg) & BIT(PORT_PIN(pin)))) 320 + return -ENOTSUPP; 321 + } /* for each config */ 322 + 316 323 return 0; 317 324 } 318 325
+16 -12
drivers/pinctrl/pinctrl-imx.c
··· 323 323 } 324 324 325 325 static 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 329 struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 329 330 const struct imx_pinctrl_soc_info *info = ipctl->info; 330 331 const struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id]; 332 + int i; 331 333 332 334 if (!(info->flags & ZERO_OFFSET_VALID) && !pin_reg->conf_reg) { 333 335 dev_err(info->dev, "Pin(%s) does not support config function\n", ··· 340 338 dev_dbg(ipctl->dev, "pinconf set pin %s\n", 341 339 info->pins[pin_id].name); 342 340 343 - if (info->flags & SHARE_MUX_CONF_REG) { 344 - u32 reg; 345 - reg = readl(ipctl->base + pin_reg->conf_reg); 346 - reg &= ~0xffff; 347 - reg |= config; 348 - writel(reg, ipctl->base + pin_reg->conf_reg); 349 - } else { 350 - writel(config, ipctl->base + pin_reg->conf_reg); 351 - } 352 - dev_dbg(ipctl->dev, "write: offset 0x%x val 0x%lx\n", 353 - pin_reg->conf_reg, config); 341 + for (i = 0; i < num_configs; i++) { 342 + if (info->flags & SHARE_MUX_CONF_REG) { 343 + u32 reg; 344 + reg = readl(ipctl->base + pin_reg->conf_reg); 345 + reg &= ~0xffff; 346 + reg |= configs[i]; 347 + writel(reg, ipctl->base + pin_reg->conf_reg); 348 + } else { 349 + writel(configs[i], ipctl->base + pin_reg->conf_reg); 350 + } 351 + dev_dbg(ipctl->dev, "write: offset 0x%x val 0x%lx\n", 352 + pin_reg->conf_reg, configs[i]); 353 + } /* for each config */ 354 354 355 355 return 0; 356 356 }
+47 -38
drivers/pinctrl/pinctrl-mxs.c
··· 233 233 } 234 234 235 235 static 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 239 return -ENOTSUPP; 239 240 } ··· 250 249 } 251 250 252 251 static int mxs_pinconf_group_set(struct pinctrl_dev *pctldev, 253 - unsigned group, unsigned long config) 252 + unsigned group, unsigned long *configs, 253 + unsigned num_configs) 254 254 { 255 255 struct mxs_pinctrl_data *d = pinctrl_dev_get_drvdata(pctldev); 256 256 struct mxs_group *g = &d->soc->groups[group]; ··· 259 257 u8 ma, vol, pull, bank, shift; 260 258 u16 pin; 261 259 u32 i; 260 + int n; 261 + unsigned long config; 262 262 263 - ma = CONFIG_TO_MA(config); 264 - vol = CONFIG_TO_VOL(config); 265 - pull = CONFIG_TO_PULL(config); 263 + for (n = 0; n < num_configs; n++) { 264 + config = configs[n]; 266 265 267 - for (i = 0; i < g->npins; i++) { 268 - bank = PINID_TO_BANK(g->pins[i]); 269 - pin = PINID_TO_PIN(g->pins[i]); 266 + ma = CONFIG_TO_MA(config); 267 + vol = CONFIG_TO_VOL(config); 268 + pull = CONFIG_TO_PULL(config); 270 269 271 - /* drive */ 272 - reg = d->base + d->soc->regs->drive; 273 - reg += bank * 0x40 + pin / 8 * 0x10; 270 + for (i = 0; i < g->npins; i++) { 271 + bank = PINID_TO_BANK(g->pins[i]); 272 + pin = PINID_TO_PIN(g->pins[i]); 274 273 275 - /* mA */ 276 - if (config & MA_PRESENT) { 277 - shift = pin % 8 * 4; 278 - writel(0x3 << shift, reg + CLR); 279 - writel(ma << shift, reg + SET); 274 + /* drive */ 275 + reg = d->base + d->soc->regs->drive; 276 + reg += bank * 0x40 + pin / 8 * 0x10; 277 + 278 + /* mA */ 279 + if (config & MA_PRESENT) { 280 + shift = pin % 8 * 4; 281 + writel(0x3 << shift, reg + CLR); 282 + writel(ma << shift, reg + SET); 283 + } 284 + 285 + /* vol */ 286 + if (config & VOL_PRESENT) { 287 + shift = pin % 8 * 4 + 2; 288 + if (vol) 289 + writel(1 << shift, reg + SET); 290 + else 291 + writel(1 << shift, reg + CLR); 292 + } 293 + 294 + /* pull */ 295 + if (config & PULL_PRESENT) { 296 + reg = d->base + d->soc->regs->pull; 297 + reg += bank * 0x10; 298 + shift = pin; 299 + if (pull) 300 + writel(1 << shift, reg + SET); 301 + else 302 + writel(1 << shift, reg + CLR); 303 + } 280 304 } 281 305 282 - /* vol */ 283 - if (config & VOL_PRESENT) { 284 - shift = pin % 8 * 4 + 2; 285 - if (vol) 286 - writel(1 << shift, reg + SET); 287 - else 288 - writel(1 << shift, reg + CLR); 289 - } 306 + /* cache the config value for mxs_pinconf_group_get() */ 307 + g->config = config; 290 308 291 - /* pull */ 292 - if (config & PULL_PRESENT) { 293 - reg = d->base + d->soc->regs->pull; 294 - reg += bank * 0x10; 295 - shift = pin; 296 - if (pull) 297 - writel(1 << shift, reg + SET); 298 - else 299 - writel(1 << shift, reg + CLR); 300 - } 301 - } 302 - 303 - /* cache the config value for mxs_pinconf_group_get() */ 304 - g->config = config; 309 + } /* for each config */ 305 310 306 311 return 0; 307 312 }
+66 -57
drivers/pinctrl/pinctrl-nomadik.c
··· 1695 1695 } 1696 1696 1697 1697 static 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 1700 static const char *pullnames[] = { 1701 1701 [NMK_GPIO_PULL_NONE] = "none", ··· 1712 1712 struct pinctrl_gpio_range *range; 1713 1713 struct gpio_chip *chip; 1714 1714 unsigned bit; 1715 - 1716 - /* 1717 - * The pin config contains pin number and altfunction fields, here 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); 1715 + pin_cfg_t cfg; 1716 + int pull, slpm, output, val, i; 1717 + bool lowemi, gpiomode, sleep; 1729 1718 1730 1719 range = nmk_match_gpio_range(pctldev, pin); 1731 1720 if (!range) { ··· 1729 1740 chip = range->gc; 1730 1741 nmk_chip = container_of(chip, struct nmk_gpio_chip, chip); 1731 1742 1732 - if (sleep) { 1733 - int slpm_pull = PIN_SLPM_PULL(cfg); 1734 - int slpm_output = PIN_SLPM_DIR(cfg); 1735 - int slpm_val = PIN_SLPM_VAL(cfg); 1736 - 1737 - /* All pins go into GPIO mode at sleep */ 1738 - gpiomode = true; 1739 - 1743 + for (i = 0; i < num_configs; i++) { 1740 1744 /* 1741 - * The SLPM_* values are normal values + 1 to allow zero to 1742 - * mean "same as normal". 1745 + * The pin config contains pin number and altfunction fields, 1746 + * here we just ignore that part. It's being handled by the 1747 + * framework and pinmux callback respectively. 1743 1748 */ 1744 - if (slpm_pull) 1745 - pull = slpm_pull - 1; 1746 - if (slpm_output) 1747 - output = slpm_output - 1; 1748 - if (slpm_val) 1749 - val = slpm_val - 1; 1749 + cfg = (pin_cfg_t) configs[i]; 1750 + pull = PIN_PULL(cfg); 1751 + slpm = PIN_SLPM(cfg); 1752 + output = PIN_DIR(cfg); 1753 + val = PIN_VAL(cfg); 1754 + lowemi = PIN_LOWEMI(cfg); 1755 + gpiomode = PIN_GPIOMODE(cfg); 1756 + sleep = PIN_SLEEPMODE(cfg); 1750 1757 1751 - dev_dbg(nmk_chip->chip.dev, "pin %d: sleep pull %s, dir %s, val %s\n", 1752 - pin, 1753 - slpm_pull ? pullnames[pull] : "same", 1754 - slpm_output ? (output ? "output" : "input") : "same", 1755 - slpm_val ? (val ? "high" : "low") : "same"); 1756 - } 1758 + if (sleep) { 1759 + int slpm_pull = PIN_SLPM_PULL(cfg); 1760 + int slpm_output = PIN_SLPM_DIR(cfg); 1761 + int slpm_val = PIN_SLPM_VAL(cfg); 1757 1762 1758 - dev_dbg(nmk_chip->chip.dev, "pin %d [%#lx]: pull %s, slpm %s (%s%s), lowemi %s\n", 1759 - pin, cfg, pullnames[pull], slpmnames[slpm], 1760 - output ? "output " : "input", 1761 - output ? (val ? "high" : "low") : "", 1762 - lowemi ? "on" : "off"); 1763 + /* All pins go into GPIO mode at sleep */ 1764 + gpiomode = true; 1763 1765 1764 - clk_enable(nmk_chip->clk); 1765 - bit = pin % NMK_GPIO_PER_CHIP; 1766 - if (gpiomode) 1767 - /* No glitch when going to GPIO mode */ 1768 - __nmk_gpio_set_mode(nmk_chip, bit, NMK_GPIO_ALT_GPIO); 1769 - if (output) 1770 - __nmk_gpio_make_output(nmk_chip, bit, val); 1771 - else { 1772 - __nmk_gpio_make_input(nmk_chip, bit); 1773 - __nmk_gpio_set_pull(nmk_chip, bit, pull); 1774 - } 1775 - /* TODO: isn't this only applicable on output pins? */ 1776 - __nmk_gpio_set_lowemi(nmk_chip, bit, lowemi); 1766 + /* 1767 + * The SLPM_* values are normal values + 1 to allow zero 1768 + * to mean "same as normal". 1769 + */ 1770 + if (slpm_pull) 1771 + pull = slpm_pull - 1; 1772 + if (slpm_output) 1773 + output = slpm_output - 1; 1774 + if (slpm_val) 1775 + val = slpm_val - 1; 1777 1776 1778 - __nmk_gpio_set_slpm(nmk_chip, bit, slpm); 1779 - clk_disable(nmk_chip->clk); 1777 + dev_dbg(nmk_chip->chip.dev, 1778 + "pin %d: sleep pull %s, dir %s, val %s\n", 1779 + pin, 1780 + slpm_pull ? pullnames[pull] : "same", 1781 + slpm_output ? (output ? "output" : "input") 1782 + : "same", 1783 + slpm_val ? (val ? "high" : "low") : "same"); 1784 + } 1785 + 1786 + dev_dbg(nmk_chip->chip.dev, 1787 + "pin %d [%#lx]: pull %s, slpm %s (%s%s), lowemi %s\n", 1788 + pin, cfg, pullnames[pull], slpmnames[slpm], 1789 + output ? "output " : "input", 1790 + output ? (val ? "high" : "low") : "", 1791 + lowemi ? "on" : "off"); 1792 + 1793 + clk_enable(nmk_chip->clk); 1794 + bit = pin % NMK_GPIO_PER_CHIP; 1795 + if (gpiomode) 1796 + /* No glitch when going to GPIO mode */ 1797 + __nmk_gpio_set_mode(nmk_chip, bit, NMK_GPIO_ALT_GPIO); 1798 + if (output) 1799 + __nmk_gpio_make_output(nmk_chip, bit, val); 1800 + else { 1801 + __nmk_gpio_make_input(nmk_chip, bit); 1802 + __nmk_gpio_set_pull(nmk_chip, bit, pull); 1803 + } 1804 + /* TODO: isn't this only applicable on output pins? */ 1805 + __nmk_gpio_set_lowemi(nmk_chip, bit, lowemi); 1806 + 1807 + __nmk_gpio_set_slpm(nmk_chip, bit, slpm); 1808 + clk_disable(nmk_chip->clk); 1809 + } /* for each config */ 1810 + 1780 1811 return 0; 1781 1812 } 1782 1813
+73 -63
drivers/pinctrl/pinctrl-palmas.c
··· 854 854 } 855 855 856 856 static 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 860 struct palmas_pctrl_chip_info *pci = pinctrl_dev_get_drvdata(pctldev); 860 - enum pin_config_param param = pinconf_to_config_param(config); 861 - u16 param_val = pinconf_to_config_argument(config); 861 + enum pin_config_param param; 862 + u16 param_val; 862 863 const struct palmas_pingroup *g; 863 864 const struct palmas_pin_info *opt; 864 865 int ret; 865 866 int base, add, mask; 866 867 int rval; 867 868 int group_nr; 869 + int i; 868 870 869 871 for (group_nr = 0; group_nr < pci->num_pin_groups; ++group_nr) { 870 872 if (pci->pin_groups[group_nr].pins[0] == pin) ··· 887 885 return -ENOTSUPP; 888 886 } 889 887 890 - switch (param) { 891 - case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: 892 - return 0; 893 - case PIN_CONFIG_BIAS_DISABLE: 894 - case PIN_CONFIG_BIAS_PULL_UP: 895 - case PIN_CONFIG_BIAS_PULL_DOWN: 896 - if (!opt->pud_info) { 897 - dev_err(pci->dev, 898 - "PULL control not supported for pin %s\n", 899 - g->name); 888 + for (i = 0; i < num_configs; i++) { 889 + param = pinconf_to_config_param(configs[i]); 890 + param_val = pinconf_to_config_argument(configs[i]); 891 + 892 + switch (param) { 893 + case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: 894 + return 0; 895 + case PIN_CONFIG_BIAS_DISABLE: 896 + case PIN_CONFIG_BIAS_PULL_UP: 897 + case PIN_CONFIG_BIAS_PULL_DOWN: 898 + if (!opt->pud_info) { 899 + dev_err(pci->dev, 900 + "PULL control not supported for pin %s\n", 901 + g->name); 902 + return -ENOTSUPP; 903 + } 904 + base = opt->pud_info->pullup_dn_reg_base; 905 + add = opt->pud_info->pullup_dn_reg_add; 906 + mask = opt->pud_info->pullup_dn_mask; 907 + 908 + if (param == PIN_CONFIG_BIAS_DISABLE) 909 + rval = opt->pud_info->normal_val; 910 + else if (param == PIN_CONFIG_BIAS_PULL_UP) 911 + rval = opt->pud_info->pull_up_val; 912 + else 913 + rval = opt->pud_info->pull_dn_val; 914 + 915 + if (rval < 0) { 916 + dev_err(pci->dev, 917 + "PULL control not supported for pin %s\n", 918 + g->name); 919 + return -ENOTSUPP; 920 + } 921 + break; 922 + 923 + case PIN_CONFIG_DRIVE_OPEN_DRAIN: 924 + if (!opt->od_info) { 925 + dev_err(pci->dev, 926 + "OD control not supported for pin %s\n", 927 + g->name); 928 + return -ENOTSUPP; 929 + } 930 + base = opt->od_info->od_reg_base; 931 + add = opt->od_info->od_reg_add; 932 + mask = opt->od_info->od_mask; 933 + if (param_val == 0) 934 + rval = opt->od_info->od_disable; 935 + else 936 + rval = opt->od_info->od_enable; 937 + if (rval < 0) { 938 + dev_err(pci->dev, 939 + "OD control not supported for pin %s\n", 940 + g->name); 941 + return -ENOTSUPP; 942 + } 943 + break; 944 + default: 945 + dev_err(pci->dev, "Properties not supported\n"); 900 946 return -ENOTSUPP; 901 947 } 902 - base = opt->pud_info->pullup_dn_reg_base; 903 - add = opt->pud_info->pullup_dn_reg_add; 904 - mask = opt->pud_info->pullup_dn_mask; 905 948 906 - if (param == PIN_CONFIG_BIAS_DISABLE) 907 - rval = opt->pud_info->normal_val; 908 - else if (param == PIN_CONFIG_BIAS_PULL_UP) 909 - rval = opt->pud_info->pull_up_val; 910 - else 911 - rval = opt->pud_info->pull_dn_val; 912 - 913 - if (rval < 0) { 914 - dev_err(pci->dev, 915 - "PULL control not supported for pin %s\n", 916 - g->name); 917 - return -ENOTSUPP; 949 + dev_dbg(pci->dev, "%s(): Add0x%02x:0x%02x:0x%02x:0x%02x\n", 950 + __func__, base, add, mask, rval); 951 + ret = palmas_update_bits(pci->palmas, base, add, mask, rval); 952 + if (ret < 0) { 953 + dev_err(pci->dev, "Reg 0x%02x update failed: %d\n", 954 + add, ret); 955 + return ret; 918 956 } 919 - break; 957 + } /* for each config */ 920 958 921 - case PIN_CONFIG_DRIVE_OPEN_DRAIN: 922 - if (!opt->od_info) { 923 - dev_err(pci->dev, 924 - "OD control not supported for pin %s\n", 925 - g->name); 926 - return -ENOTSUPP; 927 - } 928 - base = opt->od_info->od_reg_base; 929 - add = opt->od_info->od_reg_add; 930 - mask = opt->od_info->od_mask; 931 - if (param_val == 0) 932 - rval = opt->od_info->od_disable; 933 - else 934 - rval = opt->od_info->od_enable; 935 - if (rval < 0) { 936 - dev_err(pci->dev, 937 - "OD control not supported for pin %s\n", 938 - g->name); 939 - return -ENOTSUPP; 940 - } 941 - break; 942 - default: 943 - dev_err(pci->dev, "Properties not supported\n"); 944 - return -ENOTSUPP; 945 - } 946 - 947 - dev_dbg(pci->dev, "%s(): Add0x%02x:0x%02x:0x%02x:0x%02x\n", 948 - __func__, base, add, mask, rval); 949 - ret = palmas_update_bits(pci->palmas, base, add, mask, rval); 950 - if (ret < 0) { 951 - dev_err(pci->dev, "Reg 0x%02x update failed: %d\n", add, ret); 952 - return ret; 953 - } 954 959 return 0; 955 960 } 956 961 ··· 969 960 } 970 961 971 962 static int palmas_pinconf_group_set(struct pinctrl_dev *pctldev, 972 - unsigned group, unsigned long config) 963 + unsigned group, unsigned long *configs, 964 + unsigned num_configs) 973 965 { 974 966 dev_err(pctldev->dev, "palmas_pinconf_group_set op not supported\n"); 975 967 return -ENOTSUPP;
+34 -21
drivers/pinctrl/pinctrl-rockchip.c
··· 574 574 575 575 /* set the pin config settings for a specified pin */ 576 576 static 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 579 struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 580 580 struct rockchip_pin_bank *bank = pin_to_bank(info, pin); 581 - enum pin_config_param param = pinconf_to_config_param(config); 582 - u16 arg = pinconf_to_config_argument(config); 581 + enum pin_config_param param; 582 + u16 arg; 583 + int i; 584 + int rc; 583 585 584 - switch (param) { 585 - case PIN_CONFIG_BIAS_DISABLE: 586 - return rockchip_set_pull(bank, pin - bank->pin_base, param); 587 - break; 588 - case PIN_CONFIG_BIAS_PULL_UP: 589 - case PIN_CONFIG_BIAS_PULL_DOWN: 590 - case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: 591 - if (!rockchip_pinconf_pull_valid(info->ctrl, param)) 586 + for (i = 0; i < num_configs; i++) { 587 + param = pinconf_to_config_param(configs[i]); 588 + arg = pinconf_to_config_argument(configs[i]); 589 + 590 + switch (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 612 return -ENOTSUPP; 593 - 594 - if (!arg) 595 - return -EINVAL; 596 - 597 - return rockchip_set_pull(bank, pin - bank->pin_base, param); 598 - break; 599 - default: 600 - return -ENOTSUPP; 601 - break; 602 - } 613 + break; 614 + } 615 + } /* for each config */ 603 616 604 617 return 0; 605 618 }
+13 -4
drivers/pinctrl/pinctrl-samsung.c
··· 442 442 443 443 /* set the pin config settings for a specified pin */ 444 444 static 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 458 /* get the pin config settings for a specified pin */ ··· 464 456 465 457 /* set the pin config settings for a specified pin group */ 466 458 static int samsung_pinconf_group_set(struct pinctrl_dev *pctldev, 467 - unsigned group, unsigned long config) 459 + unsigned group, unsigned long *configs, 460 + unsigned num_configs) 468 461 { 469 462 struct samsung_pinctrl_drv_data *drvdata; 470 463 const unsigned int *pins; ··· 475 466 pins = drvdata->pin_groups[group].pins; 476 467 477 468 for (cnt = 0; cnt < drvdata->pin_groups[group].num_pins; cnt++) 478 - samsung_pinconf_set(pctldev, pins[cnt], config); 469 + samsung_pinconf_set(pctldev, pins[cnt], configs, num_configs); 479 470 480 471 return 0; 481 472 }
+22 -11
drivers/pinctrl/pinctrl-single.c
··· 209 209 static int pcs_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin, 210 210 unsigned long *config); 211 211 static int pcs_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin, 212 - unsigned long config); 212 + unsigned long *configs, unsigned num_configs); 213 213 214 214 static enum pin_config_param pcs_bias[] = { 215 215 PIN_CONFIG_BIAS_PULL_DOWN, ··· 536 536 int i; 537 537 for (i = 0; i < ARRAY_SIZE(pcs_bias); i++) { 538 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 622 } 623 623 624 624 static 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 628 struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev); 628 629 struct pcs_function *func; 629 630 unsigned offset = 0, shift = 0, i, data, ret; 630 631 u16 arg; 632 + int j; 631 633 632 634 ret = pcs_get_function(pctldev, pin, &func); 633 635 if (ret) 634 636 return ret; 635 637 636 - for (i = 0; i < func->nconfs; i++) { 637 - if (pinconf_to_config_param(config) == func->conf[i].param) { 638 + for (j = 0; j < num_configs; j++) { 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 644 offset = pin * (pcs->width / BITS_PER_BYTE); 639 645 data = pcs->read(pcs->base + offset); 640 - arg = pinconf_to_config_argument(config); 646 + arg = pinconf_to_config_argument(configs[j]); 641 647 switch (func->conf[i].param) { 642 648 /* 2 parameters */ 643 649 case PIN_CONFIG_INPUT_SCHMITT: ··· 673 667 return -ENOTSUPP; 674 668 } 675 669 pcs->write(data, pcs->base + offset); 676 - return 0; 670 + 671 + break; 677 672 } 678 - } 679 - return -ENOTSUPP; 673 + if (i >= func->nconfs) 674 + return -ENOTSUPP; 675 + } /* for each config */ 676 + 677 + return 0; 680 678 } 681 679 682 680 static int pcs_pinconf_group_get(struct pinctrl_dev *pctldev, ··· 705 695 } 706 696 707 697 static int pcs_pinconf_group_set(struct pinctrl_dev *pctldev, 708 - unsigned group, unsigned long config) 698 + unsigned group, unsigned long *configs, 699 + unsigned num_configs) 709 700 { 710 701 const unsigned *pins; 711 702 unsigned npins; ··· 716 705 if (ret) 717 706 return ret; 718 707 for (i = 0; i < npins; i++) { 719 - if (pcs_pinconf_set(pctldev, pins[i], config)) 708 + if (pcs_pinconf_set(pctldev, pins[i], configs, num_configs)) 720 709 return -ENOTSUPP; 721 710 } 722 711 return 0;
+7 -4
drivers/pinctrl/pinctrl-st.c
··· 909 909 config, pin); 910 910 } 911 911 912 - static int st_pinconf_set(struct pinctrl_dev *pctldev, 913 - unsigned pin_id, unsigned long config) 912 + static int st_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin_id, 913 + unsigned long *configs, unsigned num_configs) 914 914 { 915 915 int pin = st_gpio_pin(pin_id); 916 916 struct st_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 917 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 - st_pinconf_set_retime(info, pc, pin, config); 920 + for (i = 0; i < num_configs; i++) { 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 925 return 0; 923 926 }
+41 -36
drivers/pinctrl/pinctrl-sunxi.c
··· 274 274 275 275 static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev, 276 276 unsigned group, 277 - unsigned long config) 277 + unsigned long *configs, 278 + unsigned num_configs) 278 279 { 279 280 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 280 281 struct sunxi_pinctrl_group *g = &pctl->groups[group]; 281 282 u32 val, mask; 282 283 u16 strength; 283 284 u8 dlevel; 285 + int i; 284 286 285 - switch (pinconf_to_config_param(config)) { 286 - case PIN_CONFIG_DRIVE_STRENGTH: 287 - strength = pinconf_to_config_argument(config); 288 - if (strength > 40) 289 - return -EINVAL; 290 - /* 291 - * We convert from mA to what the register expects: 292 - * 0: 10mA 293 - * 1: 20mA 294 - * 2: 30mA 295 - * 3: 40mA 296 - */ 297 - dlevel = strength / 10 - 1; 298 - val = readl(pctl->membase + sunxi_dlevel_reg(g->pin)); 299 - mask = DLEVEL_PINS_MASK << sunxi_dlevel_offset(g->pin); 300 - writel((val & ~mask) | dlevel << sunxi_dlevel_offset(g->pin), 301 - pctl->membase + sunxi_dlevel_reg(g->pin)); 302 - break; 303 - case PIN_CONFIG_BIAS_PULL_UP: 304 - val = readl(pctl->membase + sunxi_pull_reg(g->pin)); 305 - mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin); 306 - writel((val & ~mask) | 1 << sunxi_pull_offset(g->pin), 307 - pctl->membase + sunxi_pull_reg(g->pin)); 308 - break; 309 - case PIN_CONFIG_BIAS_PULL_DOWN: 310 - val = readl(pctl->membase + sunxi_pull_reg(g->pin)); 311 - mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin); 312 - writel((val & ~mask) | 2 << sunxi_pull_offset(g->pin), 313 - pctl->membase + sunxi_pull_reg(g->pin)); 314 - break; 315 - default: 316 - break; 317 - } 287 + for (i = 0; i < num_configs; i++) { 288 + switch (pinconf_to_config_param(configs[i])) { 289 + case PIN_CONFIG_DRIVE_STRENGTH: 290 + strength = pinconf_to_config_argument(configs[i]); 291 + if (strength > 40) 292 + return -EINVAL; 293 + /* 294 + * We convert from mA to what the register expects: 295 + * 0: 10mA 296 + * 1: 20mA 297 + * 2: 30mA 298 + * 3: 40mA 299 + */ 300 + dlevel = strength / 10 - 1; 301 + val = readl(pctl->membase + sunxi_dlevel_reg(g->pin)); 302 + mask = DLEVEL_PINS_MASK << sunxi_dlevel_offset(g->pin); 303 + writel((val & ~mask) 304 + | dlevel << sunxi_dlevel_offset(g->pin), 305 + pctl->membase + sunxi_dlevel_reg(g->pin)); 306 + break; 307 + case PIN_CONFIG_BIAS_PULL_UP: 308 + val = readl(pctl->membase + sunxi_pull_reg(g->pin)); 309 + mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin); 310 + writel((val & ~mask) | 1 << sunxi_pull_offset(g->pin), 311 + pctl->membase + sunxi_pull_reg(g->pin)); 312 + break; 313 + case PIN_CONFIG_BIAS_PULL_DOWN: 314 + val = readl(pctl->membase + sunxi_pull_reg(g->pin)); 315 + mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin); 316 + writel((val & ~mask) | 2 << sunxi_pull_offset(g->pin), 317 + pctl->membase + sunxi_pull_reg(g->pin)); 318 + break; 319 + default: 320 + break; 321 + } 318 322 319 - /* cache the config value */ 320 - g->config = config; 323 + /* cache the config value */ 324 + g->config = configs[i]; 325 + } /* for each config */ 321 326 322 327 return 0; 323 328 }
+39 -32
drivers/pinctrl/pinctrl-tegra.c
··· 436 436 } 437 437 438 438 static 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 442 dev_err(pctldev->dev, "pin_config_set op not supported\n"); 442 443 return -ENOTSUPP; ··· 472 471 } 473 472 474 473 static int tegra_pinconf_group_set(struct pinctrl_dev *pctldev, 475 - unsigned group, unsigned long config) 474 + unsigned group, unsigned long *configs, 475 + unsigned num_configs) 476 476 { 477 477 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 478 - enum tegra_pinconf_param param = TEGRA_PINCONF_UNPACK_PARAM(config); 479 - u16 arg = TEGRA_PINCONF_UNPACK_ARG(config); 478 + enum tegra_pinconf_param param; 479 + u16 arg; 480 480 const struct tegra_pingroup *g; 481 - int ret; 481 + int ret, i; 482 482 s8 bank, bit, width; 483 483 s16 reg; 484 484 u32 val, mask; 485 485 486 486 g = &pmx->soc->groups[group]; 487 487 488 - ret = tegra_pinconf_reg(pmx, g, param, true, &bank, &reg, &bit, 489 - &width); 490 - if (ret < 0) 491 - return ret; 488 + for (i = 0; i < num_configs; i++) { 489 + param = TEGRA_PINCONF_UNPACK_PARAM(configs[i]); 490 + arg = TEGRA_PINCONF_UNPACK_ARG(configs[i]); 492 491 493 - val = pmx_readl(pmx, bank, reg); 492 + ret = tegra_pinconf_reg(pmx, g, param, true, &bank, &reg, &bit, 493 + &width); 494 + if (ret < 0) 495 + return ret; 494 496 495 - /* LOCK can't be cleared */ 496 - if (param == TEGRA_PINCONF_PARAM_LOCK) { 497 - if ((val & BIT(bit)) && !arg) { 498 - dev_err(pctldev->dev, "LOCK bit cannot be cleared\n"); 497 + val = pmx_readl(pmx, bank, reg); 498 + 499 + /* LOCK can't be cleared */ 500 + if (param == TEGRA_PINCONF_PARAM_LOCK) { 501 + if ((val & BIT(bit)) && !arg) { 502 + dev_err(pctldev->dev, "LOCK bit cannot be cleared\n"); 503 + return -EINVAL; 504 + } 505 + } 506 + 507 + /* Special-case Boolean values; allow any non-zero as true */ 508 + if (width == 1) 509 + arg = !!arg; 510 + 511 + /* Range-check user-supplied value */ 512 + mask = (1 << width) - 1; 513 + if (arg & ~mask) { 514 + dev_err(pctldev->dev, 515 + "config %lx: %x too big for %d bit register\n", 516 + configs[i], arg, width); 499 517 return -EINVAL; 500 518 } 501 - } 502 519 503 - /* Special-case Boolean values; allow any non-zero as true */ 504 - if (width == 1) 505 - arg = !!arg; 506 - 507 - /* Range-check user-supplied value */ 508 - mask = (1 << width) - 1; 509 - if (arg & ~mask) { 510 - dev_err(pctldev->dev, 511 - "config %lx: %x too big for %d bit register\n", 512 - config, arg, width); 513 - return -EINVAL; 514 - } 515 - 516 - /* Update register */ 517 - val &= ~(mask << bit); 518 - val |= arg << bit; 519 - pmx_writel(pmx, val, bank, reg); 520 + /* Update register */ 521 + val &= ~(mask << bit); 522 + val |= arg << bit; 523 + pmx_writel(pmx, val, bank, reg); 524 + } /* for each config */ 520 525 521 526 return 0; 522 527 }
+78 -57
drivers/pinctrl/pinctrl-tz1090-pdc.c
··· 737 737 } 738 738 739 739 static 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 743 struct tz1090_pdc_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 743 - enum pin_config_param param = pinconf_to_config_param(config); 744 - unsigned int arg = pinconf_to_config_argument(config); 744 + enum pin_config_param param; 745 + unsigned int arg; 745 746 int ret; 746 747 u32 reg, width, mask, shift, val, tmp; 747 748 unsigned long flags; 749 + int i; 748 750 749 - dev_dbg(pctldev->dev, "%s(pin=%s, config=%#lx)\n", 750 - __func__, tz1090_pdc_pins[pin].name, config); 751 + for (i = 0; i < num_configs; i++) { 752 + param = pinconf_to_config_param(configs[i]); 753 + arg = pinconf_to_config_argument(configs[i]); 751 754 752 - /* Get register information */ 753 - ret = tz1090_pdc_pinconf_reg(pctldev, pin, param, true, 754 - &reg, &width, &mask, &shift, &val); 755 - if (ret < 0) 756 - return ret; 755 + dev_dbg(pctldev->dev, "%s(pin=%s, config=%#lx)\n", 756 + __func__, tz1090_pdc_pins[pin].name, configs[i]); 757 757 758 - /* Unpack argument and range check it */ 759 - if (arg > 1) { 760 - dev_dbg(pctldev->dev, "%s: arg %u out of range\n", 761 - __func__, arg); 762 - return -EINVAL; 763 - } 758 + /* Get register information */ 759 + ret = tz1090_pdc_pinconf_reg(pctldev, pin, param, true, 760 + &reg, &width, &mask, &shift, &val); 761 + if (ret < 0) 762 + return ret; 764 763 765 - /* Write register field */ 766 - __global_lock2(flags); 767 - tmp = pmx_read(pmx, reg); 768 - tmp &= ~mask; 769 - if (arg) 770 - tmp |= val << shift; 771 - pmx_write(pmx, tmp, reg); 772 - __global_unlock2(flags); 764 + /* Unpack argument and range check it */ 765 + if (arg > 1) { 766 + dev_dbg(pctldev->dev, "%s: arg %u out of range\n", 767 + __func__, arg); 768 + return -EINVAL; 769 + } 770 + 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 781 return 0; 775 782 } ··· 867 860 868 861 static int tz1090_pdc_pinconf_group_set(struct pinctrl_dev *pctldev, 869 862 unsigned int group, 870 - unsigned long config) 863 + unsigned long *configs, 864 + unsigned num_configs) 871 865 { 872 866 struct tz1090_pdc_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 873 867 const struct tz1090_pdc_pingroup *g = &tz1090_pdc_groups[group]; 874 - enum pin_config_param param = pinconf_to_config_param(config); 868 + enum pin_config_param param; 875 869 const unsigned int *pit; 876 870 unsigned int i; 877 871 int ret, arg; 878 872 u32 reg, width, mask, shift, val; 879 873 unsigned long flags; 880 874 const int *map; 875 + int j; 881 876 882 - dev_dbg(pctldev->dev, "%s(group=%s, config=%#lx)\n", 883 - __func__, g->name, config); 877 + for (j = 0; j < num_configs; j++) { 878 + param = pinconf_to_config_param(configs[j]); 884 879 885 - /* Get register information */ 886 - ret = tz1090_pdc_pinconf_group_reg(pctldev, g, param, true, 887 - &reg, &width, &mask, &shift, &map); 888 - if (ret < 0) { 889 - /* 890 - * Maybe we're trying to set a per-pin configuration of a group, 891 - * so do the pins one by one. This is mainly as a convenience. 892 - */ 893 - for (i = 0, pit = g->pins; i < g->npins; ++i, ++pit) { 894 - ret = tz1090_pdc_pinconf_set(pctldev, *pit, config); 895 - if (ret) 896 - return ret; 897 - } 898 - return 0; 899 - } 880 + dev_dbg(pctldev->dev, "%s(group=%s, config=%#lx)\n", 881 + __func__, g->name, configs[j]); 900 882 901 - /* Unpack argument and map it to register value */ 902 - arg = pinconf_to_config_argument(config); 903 - for (i = 0; i < BIT(width); ++i) { 904 - if (map[i] == arg || (map[i] == -EINVAL && !arg)) { 905 - /* Write register field */ 906 - __global_lock2(flags); 907 - val = pmx_read(pmx, reg); 908 - val &= ~mask; 909 - val |= i << shift; 910 - pmx_write(pmx, val, reg); 911 - __global_unlock2(flags); 883 + /* Get register information */ 884 + ret = tz1090_pdc_pinconf_group_reg(pctldev, g, param, true, 885 + &reg, &width, &mask, &shift, 886 + &map); 887 + if (ret < 0) { 888 + /* 889 + * Maybe we're trying to set a per-pin configuration 890 + * of a group, so do the pins one by one. This is 891 + * mainly as a convenience. 892 + */ 893 + for (i = 0, pit = g->pins; i < g->npins; ++i, ++pit) { 894 + ret = tz1090_pdc_pinconf_set(pctldev, *pit, 895 + configs, num_configs); 896 + if (ret) 897 + return ret; 898 + } 912 899 return 0; 913 900 } 914 - } 915 901 916 - dev_dbg(pctldev->dev, "%s: arg %u not supported\n", 917 - __func__, arg); 902 + /* Unpack argument and map it to register value */ 903 + arg = pinconf_to_config_argument(configs[j]); 904 + for (i = 0; i < BIT(width); ++i) { 905 + if (map[i] == arg || (map[i] == -EINVAL && !arg)) { 906 + /* Write register field */ 907 + __global_lock2(flags); 908 + val = pmx_read(pmx, reg); 909 + val &= ~mask; 910 + val |= i << shift; 911 + pmx_write(pmx, val, reg); 912 + __global_unlock2(flags); 913 + goto next_config; 914 + } 915 + } 916 + 917 + dev_dbg(pctldev->dev, "%s: arg %u not supported\n", 918 + __func__, arg); 919 + return 0; 920 + 921 + next_config: 922 + ; 923 + } /* for each config */ 924 + 918 925 return 0; 919 926 } 920 927
+80 -60
drivers/pinctrl/pinctrl-tz1090.c
··· 1762 1762 } 1763 1763 1764 1764 static 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 1768 struct tz1090_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 1768 - enum pin_config_param param = pinconf_to_config_param(config); 1769 - unsigned int arg = pinconf_to_config_argument(config); 1769 + enum pin_config_param param; 1770 + unsigned int arg; 1770 1771 int ret; 1771 1772 u32 reg, width, mask, shift, val, tmp; 1772 1773 unsigned long flags; 1774 + int i; 1773 1775 1774 - dev_dbg(pctldev->dev, "%s(pin=%s, config=%#lx)\n", 1775 - __func__, tz1090_pins[pin].name, config); 1776 + for (i = 0; i < num_configs; i++) { 1777 + param = pinconf_to_config_param(configs[i]); 1778 + arg = pinconf_to_config_argument(configs[i]); 1776 1779 1777 - /* Get register information */ 1778 - ret = tz1090_pinconf_reg(pctldev, pin, param, true, 1779 - &reg, &width, &mask, &shift, &val); 1780 - if (ret < 0) 1781 - return ret; 1780 + dev_dbg(pctldev->dev, "%s(pin=%s, config=%#lx)\n", 1781 + __func__, tz1090_pins[pin].name, configs[i]); 1782 1782 1783 - /* Unpack argument and range check it */ 1784 - if (arg > 1) { 1785 - dev_dbg(pctldev->dev, "%s: arg %u out of range\n", 1786 - __func__, arg); 1787 - return -EINVAL; 1788 - } 1783 + /* Get register information */ 1784 + ret = tz1090_pinconf_reg(pctldev, pin, param, true, 1785 + &reg, &width, &mask, &shift, &val); 1786 + if (ret < 0) 1787 + return ret; 1789 1788 1790 - /* Write register field */ 1791 - __global_lock2(flags); 1792 - tmp = pmx_read(pmx, reg); 1793 - tmp &= ~mask; 1794 - if (arg) 1795 - tmp |= val << shift; 1796 - pmx_write(pmx, tmp, reg); 1797 - __global_unlock2(flags); 1789 + /* Unpack argument and range check it */ 1790 + if (arg > 1) { 1791 + dev_dbg(pctldev->dev, "%s: arg %u out of range\n", 1792 + __func__, arg); 1793 + return -EINVAL; 1794 + } 1795 + 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 1806 return 0; 1800 1807 } ··· 1901 1894 } 1902 1895 1903 1896 static int tz1090_pinconf_group_set(struct pinctrl_dev *pctldev, 1904 - unsigned int group, unsigned long config) 1897 + unsigned int group, unsigned long *configs, 1898 + unsigned num_configs) 1905 1899 { 1906 1900 struct tz1090_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 1907 1901 const struct tz1090_pingroup *g; 1908 - enum pin_config_param param = pinconf_to_config_param(config); 1902 + enum pin_config_param param; 1909 1903 unsigned int arg, pin, i; 1910 1904 const unsigned int *pit; 1911 1905 int ret; 1912 1906 u32 reg, width, mask, shift, val; 1913 1907 unsigned long flags; 1914 1908 const int *map; 1909 + int j; 1915 1910 1916 1911 if (group >= ARRAY_SIZE(tz1090_groups)) { 1917 1912 pin = group - ARRAY_SIZE(tz1090_groups); 1918 - return tz1090_pinconf_set(pctldev, pin, config); 1913 + return tz1090_pinconf_set(pctldev, pin, configs, num_configs); 1919 1914 } 1920 1915 1921 1916 g = &tz1090_groups[group]; 1922 1917 if (g->npins == 1) { 1923 1918 pin = g->pins[0]; 1924 - ret = tz1090_pinconf_set(pctldev, pin, config); 1919 + ret = tz1090_pinconf_set(pctldev, pin, configs, num_configs); 1925 1920 if (ret != -ENOTSUPP) 1926 1921 return ret; 1927 1922 } 1928 1923 1929 - dev_dbg(pctldev->dev, "%s(group=%s, config=%#lx)\n", 1930 - __func__, g->name, config); 1924 + for (j = 0; j < num_configs; j++) { 1925 + param = pinconf_to_config_param(configs[j]); 1931 1926 1932 - /* Get register information */ 1933 - ret = tz1090_pinconf_group_reg(pctldev, g, param, true, 1934 - &reg, &width, &mask, &shift, &map); 1935 - if (ret < 0) { 1936 - /* 1937 - * Maybe we're trying to set a per-pin configuration of a group, 1938 - * so do the pins one by one. This is mainly as a convenience. 1939 - */ 1940 - for (i = 0, pit = g->pins; i < g->npins; ++i, ++pit) { 1941 - ret = tz1090_pinconf_set(pctldev, *pit, config); 1942 - if (ret) 1943 - return ret; 1944 - } 1945 - return 0; 1946 - } 1927 + dev_dbg(pctldev->dev, "%s(group=%s, config=%#lx)\n", 1928 + __func__, g->name, configs[j]); 1947 1929 1948 - /* Unpack argument and map it to register value */ 1949 - arg = pinconf_to_config_argument(config); 1950 - for (i = 0; i < BIT(width); ++i) { 1951 - if (map[i] == arg || (map[i] == -EINVAL && !arg)) { 1952 - /* Write register field */ 1953 - __global_lock2(flags); 1954 - val = pmx_read(pmx, reg); 1955 - val &= ~mask; 1956 - val |= i << shift; 1957 - pmx_write(pmx, val, reg); 1958 - __global_unlock2(flags); 1930 + /* Get register information */ 1931 + ret = tz1090_pinconf_group_reg(pctldev, g, param, true, &reg, 1932 + &width, &mask, &shift, &map); 1933 + if (ret < 0) { 1934 + /* 1935 + * Maybe we're trying to set a per-pin configuration 1936 + * of a group, so do the pins one by one. This is 1937 + * mainly as a convenience. 1938 + */ 1939 + for (i = 0, pit = g->pins; i < g->npins; ++i, ++pit) { 1940 + ret = tz1090_pinconf_set(pctldev, *pit, configs, 1941 + num_configs); 1942 + if (ret) 1943 + return ret; 1944 + } 1959 1945 return 0; 1960 1946 } 1961 - } 1962 1947 1963 - dev_dbg(pctldev->dev, "%s: arg %u not supported\n", 1964 - __func__, arg); 1965 - return -EINVAL; 1948 + /* Unpack argument and map it to register value */ 1949 + arg = pinconf_to_config_argument(configs[j]); 1950 + for (i = 0; i < BIT(width); ++i) { 1951 + if (map[i] == arg || (map[i] == -EINVAL && !arg)) { 1952 + /* Write register field */ 1953 + __global_lock2(flags); 1954 + val = pmx_read(pmx, reg); 1955 + val &= ~mask; 1956 + val |= i << shift; 1957 + pmx_write(pmx, val, reg); 1958 + __global_unlock2(flags); 1959 + goto next_config; 1960 + } 1961 + } 1962 + 1963 + dev_dbg(pctldev->dev, "%s: arg %u not supported\n", 1964 + __func__, arg); 1965 + return -EINVAL; 1966 + 1967 + next_config: 1968 + ; 1969 + } /* for each config */ 1970 + 1971 + return 0; 1966 1972 } 1967 1973 1968 1974 static struct pinconf_ops tz1090_pinconf_ops = {
+10 -8
drivers/pinctrl/pinctrl-u300.c
··· 1027 1027 } 1028 1028 1029 1029 static 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 1032 struct pinctrl_gpio_range *range = 1033 1033 pinctrl_find_gpio_range_from_pin(pctldev, pin); 1034 - int ret; 1034 + int ret, i; 1035 1035 1036 1036 if (!range) 1037 1037 return -EINVAL; 1038 1038 1039 - /* Note: none of these configurations take any argument */ 1040 - ret = u300_gpio_config_set(range->gc, 1041 - (pin - range->pin_base + range->base), 1042 - pinconf_to_config_param(config)); 1043 - if (ret) 1044 - return ret; 1039 + for (i = 0; i < num_configs; i++) { 1040 + /* Note: none of these configurations take any argument */ 1041 + ret = u300_gpio_config_set(range->gc, 1042 + (pin - range->pin_base + range->base), 1043 + pinconf_to_config_param(configs[i])); 1044 + if (ret) 1045 + return ret; 1046 + } /* for each config */ 1045 1047 1046 1048 return 0; 1047 1049 }
+75 -48
drivers/pinctrl/pinctrl-xway.c
··· 499 499 500 500 static int xway_pinconf_set(struct pinctrl_dev *pctldev, 501 501 unsigned pin, 502 - unsigned long config) 502 + unsigned long *configs, 503 + unsigned num_configs) 503 504 { 504 505 struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctldev); 505 - enum ltq_pinconf_param param = LTQ_PINCONF_UNPACK_PARAM(config); 506 - int arg = LTQ_PINCONF_UNPACK_ARG(config); 506 + enum ltq_pinconf_param param; 507 + int arg; 507 508 int port = PORT(pin); 508 509 u32 reg; 510 + int i; 509 511 510 - switch (param) { 511 - case LTQ_PINCONF_PARAM_OPEN_DRAIN: 512 - if (port == PORT3) 513 - reg = GPIO3_OD; 514 - else 515 - reg = GPIO_OD(pin); 516 - if (arg == 0) 517 - gpio_setbit(info->membase[0], reg, PORT_PIN(pin)); 518 - else 519 - gpio_clearbit(info->membase[0], reg, PORT_PIN(pin)); 520 - break; 512 + for (i = 0; i < num_configs; i++) { 513 + param = LTQ_PINCONF_UNPACK_PARAM(configs[i]); 514 + arg = LTQ_PINCONF_UNPACK_ARG(configs[i]); 521 515 522 - case LTQ_PINCONF_PARAM_PULL: 523 - if (port == PORT3) 524 - reg = GPIO3_PUDEN; 525 - else 526 - reg = GPIO_PUDEN(pin); 527 - if (arg == 0) { 528 - gpio_clearbit(info->membase[0], reg, PORT_PIN(pin)); 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)); 529 530 break; 531 + 532 + case LTQ_PINCONF_PARAM_PULL: 533 + if (port == PORT3) 534 + reg = GPIO3_PUDEN; 535 + else 536 + reg = GPIO_PUDEN(pin); 537 + if (arg == 0) { 538 + gpio_clearbit(info->membase[0], 539 + reg, 540 + PORT_PIN(pin)); 541 + break; 542 + } 543 + gpio_setbit(info->membase[0], reg, PORT_PIN(pin)); 544 + 545 + if (port == PORT3) 546 + reg = GPIO3_PUDSEL; 547 + else 548 + reg = GPIO_PUDSEL(pin); 549 + if (arg == 1) 550 + gpio_clearbit(info->membase[0], 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); 560 + break; 561 + 562 + case LTQ_PINCONF_PARAM_OUTPUT: 563 + reg = GPIO_DIR(pin); 564 + if (arg == 0) 565 + gpio_clearbit(info->membase[0], 566 + reg, 567 + PORT_PIN(pin)); 568 + else 569 + gpio_setbit(info->membase[0], 570 + reg, 571 + PORT_PIN(pin)); 572 + break; 573 + 574 + default: 575 + dev_err(pctldev->dev, 576 + "Invalid config param %04x\n", param); 577 + return -ENOTSUPP; 530 578 } 531 - gpio_setbit(info->membase[0], reg, PORT_PIN(pin)); 579 + } /* for each config */ 532 580 533 - if (port == PORT3) 534 - reg = GPIO3_PUDSEL; 535 - else 536 - reg = GPIO_PUDSEL(pin); 537 - if (arg == 1) 538 - gpio_clearbit(info->membase[0], reg, PORT_PIN(pin)); 539 - else if (arg == 2) 540 - gpio_setbit(info->membase[0], reg, PORT_PIN(pin)); 541 - else 542 - dev_err(pctldev->dev, "Invalid pull value %d\n", arg); 543 - break; 544 - 545 - case LTQ_PINCONF_PARAM_OUTPUT: 546 - reg = GPIO_DIR(pin); 547 - if (arg == 0) 548 - gpio_clearbit(info->membase[0], reg, PORT_PIN(pin)); 549 - else 550 - gpio_setbit(info->membase[0], reg, PORT_PIN(pin)); 551 - break; 552 - 553 - default: 554 - dev_err(pctldev->dev, "Invalid config param %04x\n", param); 555 - return -ENOTSUPP; 556 - } 557 581 return 0; 558 582 } 559 583 560 584 int xway_pinconf_group_set(struct pinctrl_dev *pctldev, 561 585 unsigned selector, 562 - unsigned long config) 586 + unsigned long *configs, 587 + unsigned num_configs) 563 588 { 564 589 struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctldev); 565 590 int i, ret = 0; 566 591 567 592 for (i = 0; i < info->grps[selector].npins && !ret; i++) 568 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 598 return ret; 572 599 }
+24 -18
drivers/pinctrl/sh-pfc/pinctrl.c
··· 529 529 } 530 530 531 531 static 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 534 struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); 535 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 537 unsigned long flags; 538 + unsigned int i; 538 539 539 - if (!sh_pfc_pinconf_validate(pfc, _pin, param)) 540 - return -ENOTSUPP; 540 + for (i = 0; i < num_configs; i++) { 541 + param = pinconf_to_config_param(configs[i]); 541 542 542 - switch (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) 543 + if (!sh_pfc_pinconf_validate(pfc, _pin, param)) 547 544 return -ENOTSUPP; 548 545 549 - spin_lock_irqsave(&pfc->lock, flags); 550 - pfc->info->ops->set_bias(pfc, _pin, param); 551 - spin_unlock_irqrestore(&pfc->lock, flags); 546 + switch (param) { 547 + case PIN_CONFIG_BIAS_PULL_UP: 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: 556 - return -ENOTSUPP; 557 - } 557 + break; 558 + 559 + default: 560 + return -ENOTSUPP; 561 + } 562 + } /* for each config */ 558 563 559 564 return 0; 560 565 } 561 566 562 567 static 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 571 struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); 566 572 const unsigned int *pins; ··· 577 571 num_pins = pmx->pfc->info->groups[group].nr_pins; 578 572 579 573 for (i = 0; i < num_pins; ++i) 580 - sh_pfc_pinconf_set(pctldev, pins[i], config); 574 + sh_pfc_pinconf_set(pctldev, pins[i], configs, num_configs); 581 575 582 576 return 0; 583 577 }
+30 -24
drivers/pinctrl/vt8500/pinctrl-wmt.c
··· 424 424 } 425 425 426 426 static int wmt_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin, 427 - unsigned long config) 427 + unsigned long *configs, unsigned num_configs) 428 428 { 429 429 struct wmt_pinctrl_data *data = pinctrl_dev_get_drvdata(pctldev); 430 - enum pin_config_param param = pinconf_to_config_param(config); 431 - u16 arg = pinconf_to_config_argument(config); 430 + enum pin_config_param param; 431 + u16 arg; 432 432 u32 bank = WMT_BANK_FROM_PIN(pin); 433 433 u32 bit = WMT_BIT_FROM_PIN(pin); 434 434 u32 reg_pull_en = data->banks[bank].reg_pull_en; 435 435 u32 reg_pull_cfg = data->banks[bank].reg_pull_cfg; 436 + int i; 436 437 437 438 if ((reg_pull_en == NO_REG) || (reg_pull_cfg == NO_REG)) { 438 439 dev_err(data->dev, "bias functions not supported on pin %d\n", ··· 441 440 return -EINVAL; 442 441 } 443 442 444 - if ((param == PIN_CONFIG_BIAS_PULL_DOWN) || 445 - (param == PIN_CONFIG_BIAS_PULL_UP)) { 446 - if (arg == 0) 447 - param = PIN_CONFIG_BIAS_DISABLE; 448 - } 443 + for (i = 0; i < num_configs; i++) { 444 + param = pinconf_to_config_param(configs[i]); 445 + arg = pinconf_to_config_argument(configs[i]); 449 446 450 - switch (param) { 451 - case PIN_CONFIG_BIAS_DISABLE: 452 - wmt_clearbits(data, reg_pull_en, BIT(bit)); 453 - break; 454 - case PIN_CONFIG_BIAS_PULL_DOWN: 455 - wmt_clearbits(data, reg_pull_cfg, BIT(bit)); 456 - wmt_setbits(data, reg_pull_en, BIT(bit)); 457 - break; 458 - case PIN_CONFIG_BIAS_PULL_UP: 459 - wmt_setbits(data, reg_pull_cfg, BIT(bit)); 460 - wmt_setbits(data, reg_pull_en, BIT(bit)); 461 - break; 462 - default: 463 - dev_err(data->dev, "unknown pinconf param\n"); 464 - return -EINVAL; 465 - } 447 + if ((param == PIN_CONFIG_BIAS_PULL_DOWN) || 448 + (param == PIN_CONFIG_BIAS_PULL_UP)) { 449 + if (arg == 0) 450 + param = PIN_CONFIG_BIAS_DISABLE; 451 + } 452 + 453 + switch (param) { 454 + case PIN_CONFIG_BIAS_DISABLE: 455 + wmt_clearbits(data, reg_pull_en, BIT(bit)); 456 + break; 457 + case PIN_CONFIG_BIAS_PULL_DOWN: 458 + wmt_clearbits(data, reg_pull_cfg, BIT(bit)); 459 + wmt_setbits(data, reg_pull_en, BIT(bit)); 460 + break; 461 + case PIN_CONFIG_BIAS_PULL_UP: 462 + wmt_setbits(data, reg_pull_cfg, BIT(bit)); 463 + wmt_setbits(data, reg_pull_en, BIT(bit)); 464 + break; 465 + default: 466 + dev_err(data->dev, "unknown pinconf param\n"); 467 + return -EINVAL; 468 + } 469 + } /* for each config */ 466 470 467 471 return 0; 468 472 }
+4 -2
include/linux/pinctrl/pinconf.h
··· 47 47 unsigned long *config); 48 48 int (*pin_config_set) (struct pinctrl_dev *pctldev, 49 49 unsigned pin, 50 - unsigned long config); 50 + unsigned long *configs, 51 + unsigned num_configs); 51 52 int (*pin_config_group_get) (struct pinctrl_dev *pctldev, 52 53 unsigned selector, 53 54 unsigned long *config); 54 55 int (*pin_config_group_set) (struct pinctrl_dev *pctldev, 55 56 unsigned selector, 56 - unsigned long config); 57 + unsigned long *configs, 58 + unsigned num_configs); 57 59 int (*pin_config_dbg_parse_modify) (struct pinctrl_dev *pctldev, 58 60 const char *arg, 59 61 unsigned long *config);