aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2012-12-15 17:51:20 -0500
committerSimon Horman <horms+renesas@verge.net.au>2013-01-24 19:24:26 -0500
commit19bb7fe36950ff74ce322cc29f6f4e025999f1f0 (patch)
tree60bfaecf7af2940af44928131cba9054004105e6 /drivers/pinctrl
parent6e54d8d252ed09ae148af6565971974af9a96e10 (diff)
sh-pfc: Support pinmux info in driver data instead of platform data
Pinmux information should be provided by the pinmux driver, not arch code. Make it possible to do so by supporting pinmux information passed through the driver_data field in the platform ID table. Platform data will remain supported until all arch code has been converted. Rename the sh_pfc_platform_data structure to sh_pfc_soc_info to reflect this. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Paul Mundt <lethal@linux-sh.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/sh-pfc/core.c52
-rw-r--r--drivers/pinctrl/sh-pfc/core.h2
-rw-r--r--drivers/pinctrl/sh-pfc/gpio.c18
-rw-r--r--drivers/pinctrl/sh-pfc/pinctrl.c28
4 files changed, 51 insertions, 49 deletions
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c
index 8e7818bccb29..95cd10f83e18 100644
--- a/drivers/pinctrl/sh-pfc/core.c
+++ b/drivers/pinctrl/sh-pfc/core.c
@@ -213,9 +213,9 @@ static void sh_pfc_write_config_reg(struct sh_pfc *pfc,
213 data &= mask; 213 data &= mask;
214 data |= value; 214 data |= value;
215 215
216 if (pfc->pdata->unlock_reg) 216 if (pfc->info->unlock_reg)
217 sh_pfc_write_raw_reg( 217 sh_pfc_write_raw_reg(
218 sh_pfc_phys_to_virt(pfc, pfc->pdata->unlock_reg), 32, 218 sh_pfc_phys_to_virt(pfc, pfc->info->unlock_reg), 32,
219 ~data); 219 ~data);
220 220
221 sh_pfc_write_raw_reg(mapped_reg, crp->reg_width, data); 221 sh_pfc_write_raw_reg(mapped_reg, crp->reg_width, data);
@@ -223,16 +223,16 @@ static void sh_pfc_write_config_reg(struct sh_pfc *pfc,
223 223
224static int sh_pfc_setup_data_reg(struct sh_pfc *pfc, unsigned gpio) 224static int sh_pfc_setup_data_reg(struct sh_pfc *pfc, unsigned gpio)
225{ 225{
226 struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio]; 226 struct pinmux_gpio *gpiop = &pfc->info->gpios[gpio];
227 struct pinmux_data_reg *data_reg; 227 struct pinmux_data_reg *data_reg;
228 int k, n; 228 int k, n;
229 229
230 if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->pdata->data)) 230 if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->info->data))
231 return -1; 231 return -1;
232 232
233 k = 0; 233 k = 0;
234 while (1) { 234 while (1) {
235 data_reg = pfc->pdata->data_regs + k; 235 data_reg = pfc->info->data_regs + k;
236 236
237 if (!data_reg->reg_width) 237 if (!data_reg->reg_width)
238 break; 238 break;
@@ -261,12 +261,12 @@ static void sh_pfc_setup_data_regs(struct sh_pfc *pfc)
261 struct pinmux_data_reg *drp; 261 struct pinmux_data_reg *drp;
262 int k; 262 int k;
263 263
264 for (k = pfc->pdata->first_gpio; k <= pfc->pdata->last_gpio; k++) 264 for (k = pfc->info->first_gpio; k <= pfc->info->last_gpio; k++)
265 sh_pfc_setup_data_reg(pfc, k); 265 sh_pfc_setup_data_reg(pfc, k);
266 266
267 k = 0; 267 k = 0;
268 while (1) { 268 while (1) {
269 drp = pfc->pdata->data_regs + k; 269 drp = pfc->info->data_regs + k;
270 270
271 if (!drp->reg_width) 271 if (!drp->reg_width)
272 break; 272 break;
@@ -280,15 +280,15 @@ static void sh_pfc_setup_data_regs(struct sh_pfc *pfc)
280int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio, 280int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio,
281 struct pinmux_data_reg **drp, int *bitp) 281 struct pinmux_data_reg **drp, int *bitp)
282{ 282{
283 struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio]; 283 struct pinmux_gpio *gpiop = &pfc->info->gpios[gpio];
284 int k, n; 284 int k, n;
285 285
286 if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->pdata->data)) 286 if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->info->data))
287 return -1; 287 return -1;
288 288
289 k = (gpiop->flags & PINMUX_FLAG_DREG) >> PINMUX_FLAG_DREG_SHIFT; 289 k = (gpiop->flags & PINMUX_FLAG_DREG) >> PINMUX_FLAG_DREG_SHIFT;
290 n = (gpiop->flags & PINMUX_FLAG_DBIT) >> PINMUX_FLAG_DBIT_SHIFT; 290 n = (gpiop->flags & PINMUX_FLAG_DBIT) >> PINMUX_FLAG_DBIT_SHIFT;
291 *drp = pfc->pdata->data_regs + k; 291 *drp = pfc->info->data_regs + k;
292 *bitp = n; 292 *bitp = n;
293 return 0; 293 return 0;
294} 294}
@@ -303,7 +303,7 @@ static int sh_pfc_get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id,
303 303
304 k = 0; 304 k = 0;
305 while (1) { 305 while (1) {
306 config_reg = pfc->pdata->cfg_regs + k; 306 config_reg = pfc->info->cfg_regs + k;
307 307
308 r_width = config_reg->reg_width; 308 r_width = config_reg->reg_width;
309 f_width = config_reg->field_width; 309 f_width = config_reg->field_width;
@@ -341,12 +341,12 @@ static int sh_pfc_get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id,
341int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos, 341int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos,
342 pinmux_enum_t *enum_idp) 342 pinmux_enum_t *enum_idp)
343{ 343{
344 pinmux_enum_t enum_id = pfc->pdata->gpios[gpio].enum_id; 344 pinmux_enum_t enum_id = pfc->info->gpios[gpio].enum_id;
345 pinmux_enum_t *data = pfc->pdata->gpio_data; 345 pinmux_enum_t *data = pfc->info->gpio_data;
346 int k; 346 int k;
347 347
348 if (!sh_pfc_enum_in_range(enum_id, &pfc->pdata->data)) { 348 if (!sh_pfc_enum_in_range(enum_id, &pfc->info->data)) {
349 if (!sh_pfc_enum_in_range(enum_id, &pfc->pdata->mark)) { 349 if (!sh_pfc_enum_in_range(enum_id, &pfc->info->mark)) {
350 pr_err("non data/mark enum_id for gpio %d\n", gpio); 350 pr_err("non data/mark enum_id for gpio %d\n", gpio);
351 return -1; 351 return -1;
352 } 352 }
@@ -357,7 +357,7 @@ int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos,
357 return pos + 1; 357 return pos + 1;
358 } 358 }
359 359
360 for (k = 0; k < pfc->pdata->gpio_data_size; k++) { 360 for (k = 0; k < pfc->info->gpio_data_size; k++) {
361 if (data[k] == enum_id) { 361 if (data[k] == enum_id) {
362 *enum_idp = data[k + 1]; 362 *enum_idp = data[k + 1];
363 return k + 1; 363 return k + 1;
@@ -384,19 +384,19 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
384 break; 384 break;
385 385
386 case PINMUX_TYPE_OUTPUT: 386 case PINMUX_TYPE_OUTPUT:
387 range = &pfc->pdata->output; 387 range = &pfc->info->output;
388 break; 388 break;
389 389
390 case PINMUX_TYPE_INPUT: 390 case PINMUX_TYPE_INPUT:
391 range = &pfc->pdata->input; 391 range = &pfc->info->input;
392 break; 392 break;
393 393
394 case PINMUX_TYPE_INPUT_PULLUP: 394 case PINMUX_TYPE_INPUT_PULLUP:
395 range = &pfc->pdata->input_pu; 395 range = &pfc->info->input_pu;
396 break; 396 break;
397 397
398 case PINMUX_TYPE_INPUT_PULLDOWN: 398 case PINMUX_TYPE_INPUT_PULLDOWN:
399 range = &pfc->pdata->input_pd; 399 range = &pfc->info->input_pd;
400 break; 400 break;
401 401
402 default: 402 default:
@@ -416,7 +416,7 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
416 break; 416 break;
417 417
418 /* first check if this is a function enum */ 418 /* first check if this is a function enum */
419 in_range = sh_pfc_enum_in_range(enum_id, &pfc->pdata->function); 419 in_range = sh_pfc_enum_in_range(enum_id, &pfc->info->function);
420 if (!in_range) { 420 if (!in_range) {
421 /* not a function enum */ 421 /* not a function enum */
422 if (range) { 422 if (range) {
@@ -482,7 +482,7 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
482 482
483static int sh_pfc_probe(struct platform_device *pdev) 483static int sh_pfc_probe(struct platform_device *pdev)
484{ 484{
485 struct sh_pfc_platform_data *pdata = pdev->dev.platform_data; 485 struct sh_pfc_soc_info *info;
486 struct sh_pfc *pfc; 486 struct sh_pfc *pfc;
487 int ret; 487 int ret;
488 488
@@ -491,14 +491,16 @@ static int sh_pfc_probe(struct platform_device *pdev)
491 */ 491 */
492 BUILD_BUG_ON(PINMUX_FLAG_TYPE > ((1 << PINMUX_FLAG_DBIT_SHIFT) - 1)); 492 BUILD_BUG_ON(PINMUX_FLAG_TYPE > ((1 << PINMUX_FLAG_DBIT_SHIFT) - 1));
493 493
494 if (pdata == NULL) 494 info = pdev->id_entry->driver_data
495 ? (void *)pdev->id_entry->driver_data : pdev->dev.platform_data;
496 if (info == NULL)
495 return -ENODEV; 497 return -ENODEV;
496 498
497 pfc = devm_kzalloc(&pdev->dev, sizeof(pfc), GFP_KERNEL); 499 pfc = devm_kzalloc(&pdev->dev, sizeof(pfc), GFP_KERNEL);
498 if (pfc == NULL) 500 if (pfc == NULL)
499 return -ENOMEM; 501 return -ENOMEM;
500 502
501 pfc->pdata = pdata; 503 pfc->info = info;
502 pfc->dev = &pdev->dev; 504 pfc->dev = &pdev->dev;
503 505
504 ret = sh_pfc_ioremap(pfc, pdev); 506 ret = sh_pfc_ioremap(pfc, pdev);
@@ -534,7 +536,7 @@ static int sh_pfc_probe(struct platform_device *pdev)
534 536
535 platform_set_drvdata(pdev, pfc); 537 platform_set_drvdata(pdev, pfc);
536 538
537 pr_info("%s support registered\n", pdata->name); 539 pr_info("%s support registered\n", info->name);
538 540
539 return 0; 541 return 0;
540} 542}
diff --git a/drivers/pinctrl/sh-pfc/core.h b/drivers/pinctrl/sh-pfc/core.h
index 87ae5fd2a201..2c82e9df6f8a 100644
--- a/drivers/pinctrl/sh-pfc/core.h
+++ b/drivers/pinctrl/sh-pfc/core.h
@@ -25,7 +25,7 @@ struct sh_pfc_pinctrl;
25 25
26struct sh_pfc { 26struct sh_pfc {
27 struct device *dev; 27 struct device *dev;
28 struct sh_pfc_platform_data *pdata; 28 struct sh_pfc_soc_info *info;
29 spinlock_t lock; 29 spinlock_t lock;
30 30
31 unsigned int num_windows; 31 unsigned int num_windows;
diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c
index a0454f321710..3cbdfea1dec0 100644
--- a/drivers/pinctrl/sh-pfc/gpio.c
+++ b/drivers/pinctrl/sh-pfc/gpio.c
@@ -106,11 +106,11 @@ static int sh_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
106 if (pos <= 0 || !enum_id) 106 if (pos <= 0 || !enum_id)
107 break; 107 break;
108 108
109 for (i = 0; i < pfc->pdata->gpio_irq_size; i++) { 109 for (i = 0; i < pfc->info->gpio_irq_size; i++) {
110 enum_ids = pfc->pdata->gpio_irq[i].enum_ids; 110 enum_ids = pfc->info->gpio_irq[i].enum_ids;
111 for (k = 0; enum_ids[k]; k++) { 111 for (k = 0; enum_ids[k]; k++) {
112 if (enum_ids[k] == enum_id) 112 if (enum_ids[k] == enum_id)
113 return pfc->pdata->gpio_irq[i].irq; 113 return pfc->info->gpio_irq[i].irq;
114 } 114 }
115 } 115 }
116 } 116 }
@@ -131,12 +131,12 @@ static void sh_pfc_gpio_setup(struct sh_pfc_chip *chip)
131 gc->set = sh_gpio_set; 131 gc->set = sh_gpio_set;
132 gc->to_irq = sh_gpio_to_irq; 132 gc->to_irq = sh_gpio_to_irq;
133 133
134 WARN_ON(pfc->pdata->first_gpio != 0); /* needs testing */ 134 WARN_ON(pfc->info->first_gpio != 0); /* needs testing */
135 135
136 gc->label = pfc->pdata->name; 136 gc->label = pfc->info->name;
137 gc->owner = THIS_MODULE; 137 gc->owner = THIS_MODULE;
138 gc->base = pfc->pdata->first_gpio; 138 gc->base = pfc->info->first_gpio;
139 gc->ngpio = (pfc->pdata->last_gpio - pfc->pdata->first_gpio) + 1; 139 gc->ngpio = (pfc->info->last_gpio - pfc->info->first_gpio) + 1;
140} 140}
141 141
142int sh_pfc_register_gpiochip(struct sh_pfc *pfc) 142int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
@@ -159,8 +159,8 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
159 pfc->gpio = chip; 159 pfc->gpio = chip;
160 160
161 pr_info("%s handling gpio %d -> %d\n", 161 pr_info("%s handling gpio %d -> %d\n",
162 pfc->pdata->name, pfc->pdata->first_gpio, 162 pfc->info->name, pfc->info->first_gpio,
163 pfc->pdata->last_gpio); 163 pfc->info->last_gpio);
164 164
165 return 0; 165 return 0;
166} 166}
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index 221bde03913a..fdfe7bea1502 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -140,7 +140,7 @@ static int sh_pfc_reconfig_pin(struct sh_pfc *pfc, unsigned offset,
140 140
141 spin_lock_irqsave(&pfc->lock, flags); 141 spin_lock_irqsave(&pfc->lock, flags);
142 142
143 pinmux_type = pfc->pdata->gpios[offset].flags & PINMUX_FLAG_TYPE; 143 pinmux_type = pfc->info->gpios[offset].flags & PINMUX_FLAG_TYPE;
144 144
145 /* 145 /*
146 * See if the present config needs to first be de-configured. 146 * See if the present config needs to first be de-configured.
@@ -172,8 +172,8 @@ static int sh_pfc_reconfig_pin(struct sh_pfc *pfc, unsigned offset,
172 GPIO_CFG_REQ) != 0) 172 GPIO_CFG_REQ) != 0)
173 goto err; 173 goto err;
174 174
175 pfc->pdata->gpios[offset].flags &= ~PINMUX_FLAG_TYPE; 175 pfc->info->gpios[offset].flags &= ~PINMUX_FLAG_TYPE;
176 pfc->pdata->gpios[offset].flags |= new_type; 176 pfc->info->gpios[offset].flags |= new_type;
177 177
178 ret = 0; 178 ret = 0;
179 179
@@ -195,7 +195,7 @@ static int sh_pfc_gpio_request_enable(struct pinctrl_dev *pctldev,
195 195
196 spin_lock_irqsave(&pfc->lock, flags); 196 spin_lock_irqsave(&pfc->lock, flags);
197 197
198 pinmux_type = pfc->pdata->gpios[offset].flags & PINMUX_FLAG_TYPE; 198 pinmux_type = pfc->info->gpios[offset].flags & PINMUX_FLAG_TYPE;
199 199
200 switch (pinmux_type) { 200 switch (pinmux_type) {
201 case PINMUX_TYPE_FUNCTION: 201 case PINMUX_TYPE_FUNCTION:
@@ -236,7 +236,7 @@ static void sh_pfc_gpio_disable_free(struct pinctrl_dev *pctldev,
236 236
237 spin_lock_irqsave(&pfc->lock, flags); 237 spin_lock_irqsave(&pfc->lock, flags);
238 238
239 pinmux_type = pfc->pdata->gpios[offset].flags & PINMUX_FLAG_TYPE; 239 pinmux_type = pfc->info->gpios[offset].flags & PINMUX_FLAG_TYPE;
240 240
241 sh_pfc_config_gpio(pfc, offset, pinmux_type, GPIO_CFG_FREE); 241 sh_pfc_config_gpio(pfc, offset, pinmux_type, GPIO_CFG_FREE);
242 242
@@ -270,7 +270,7 @@ static int sh_pfc_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin,
270 struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); 270 struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
271 struct sh_pfc *pfc = pmx->pfc; 271 struct sh_pfc *pfc = pmx->pfc;
272 272
273 *config = pfc->pdata->gpios[pin].flags & PINMUX_FLAG_TYPE; 273 *config = pfc->info->gpios[pin].flags & PINMUX_FLAG_TYPE;
274 274
275 return 0; 275 return 0;
276} 276}
@@ -354,7 +354,7 @@ static int sh_pfc_map_gpios(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
354 unsigned long flags; 354 unsigned long flags;
355 int i; 355 int i;
356 356
357 pmx->nr_pads = pfc->pdata->last_gpio - pfc->pdata->first_gpio + 1; 357 pmx->nr_pads = pfc->info->last_gpio - pfc->info->first_gpio + 1;
358 358
359 pmx->pads = devm_kzalloc(pfc->dev, sizeof(*pmx->pads) * pmx->nr_pads, 359 pmx->pads = devm_kzalloc(pfc->dev, sizeof(*pmx->pads) * pmx->nr_pads,
360 GFP_KERNEL); 360 GFP_KERNEL);
@@ -373,9 +373,9 @@ static int sh_pfc_map_gpios(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
373 */ 373 */
374 for (i = 0; i < pmx->nr_pads; i++) { 374 for (i = 0; i < pmx->nr_pads; i++) {
375 struct pinctrl_pin_desc *pin = pmx->pads + i; 375 struct pinctrl_pin_desc *pin = pmx->pads + i;
376 struct pinmux_gpio *gpio = pfc->pdata->gpios + i; 376 struct pinmux_gpio *gpio = pfc->info->gpios + i;
377 377
378 pin->number = pfc->pdata->first_gpio + i; 378 pin->number = pfc->info->first_gpio + i;
379 pin->name = gpio->name; 379 pin->name = gpio->name;
380 380
381 /* XXX */ 381 /* XXX */
@@ -406,7 +406,7 @@ static int sh_pfc_map_functions(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
406 spin_lock_irqsave(&pmx->lock, flags); 406 spin_lock_irqsave(&pmx->lock, flags);
407 407
408 for (i = fn = 0; i < pmx->nr_pads; i++) { 408 for (i = fn = 0; i < pmx->nr_pads; i++) {
409 struct pinmux_gpio *gpio = pfc->pdata->gpios + i; 409 struct pinmux_gpio *gpio = pfc->info->gpios + i;
410 410
411 if ((gpio->flags & PINMUX_FLAG_TYPE) == PINMUX_TYPE_FUNCTION) 411 if ((gpio->flags & PINMUX_FLAG_TYPE) == PINMUX_TYPE_FUNCTION)
412 pmx->functions[fn++] = gpio; 412 pmx->functions[fn++] = gpio;
@@ -443,10 +443,10 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
443 if (IS_ERR(pmx->pctl)) 443 if (IS_ERR(pmx->pctl))
444 return PTR_ERR(pmx->pctl); 444 return PTR_ERR(pmx->pctl);
445 445
446 sh_pfc_gpio_range.npins = pfc->pdata->last_gpio 446 sh_pfc_gpio_range.npins = pfc->info->last_gpio
447 - pfc->pdata->first_gpio + 1; 447 - pfc->info->first_gpio + 1;
448 sh_pfc_gpio_range.base = pfc->pdata->first_gpio; 448 sh_pfc_gpio_range.base = pfc->info->first_gpio;
449 sh_pfc_gpio_range.pin_base = pfc->pdata->first_gpio; 449 sh_pfc_gpio_range.pin_base = pfc->info->first_gpio;
450 450
451 pinctrl_add_gpio_range(pmx->pctl, &sh_pfc_gpio_range); 451 pinctrl_add_gpio_range(pmx->pctl, &sh_pfc_gpio_range);
452 452