aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-falcon.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-falcon.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-falcon.c')
-rw-r--r--drivers/pinctrl/pinctrl-falcon.c63
1 files changed, 36 insertions, 27 deletions
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