aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-abx500.c
diff options
context:
space:
mode:
authorSherman Yin <syin@broadcom.com>2013-08-27 14:32:12 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-08-28 07:34:41 -0400
commit03b054e9696c3cbd3d5905ec96da15acd0a2fe8d (patch)
tree7123b780c194d350b3e5134c267e17262effb385 /drivers/pinctrl/pinctrl-abx500.c
parentf5ba9c52bf1e236c4698c240955e5f119db62a28 (diff)
pinctrl: Pass all configs to driver on pin_config_set()
When setting pin configuration in the pinctrl framework, pin_config_set() or pin_config_group_set() is called in a loop to set one configuration at a time for the specified pin or group. This patch 1) removes the loop and 2) changes the API to pass the whole pin config array to the driver. It is now up to the driver to loop through the configs. This allows the driver to potentially combine configs and reduce the number of writes to pin config registers. All c files changed have been build-tested to verify the change compiles and that the corresponding .o is successfully generated. Signed-off-by: Sherman Yin <syin@broadcom.com> Reviewed-by: Christian Daudt <csd@broadcom.com> Reviewed-by: Matt Porter <matt.porter@linaro.org> Tested-by: Stephen Warren <swarren@nvidia.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-abx500.c')
-rw-r--r--drivers/pinctrl/pinctrl-abx500.c187
1 files changed, 102 insertions, 85 deletions
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);