aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-twl4030.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio/gpio-twl4030.c')
-rw-r--r--drivers/gpio/gpio-twl4030.c77
1 files changed, 52 insertions, 25 deletions
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index f030880bc9bb..c5f8ca233e1f 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -396,6 +396,29 @@ static int __devinit gpio_twl4030_debounce(u32 debounce, u8 mmc_cd)
396 396
397static int gpio_twl4030_remove(struct platform_device *pdev); 397static int gpio_twl4030_remove(struct platform_device *pdev);
398 398
399static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev)
400{
401 struct twl4030_gpio_platform_data *omap_twl_info;
402
403 omap_twl_info = devm_kzalloc(dev, sizeof(*omap_twl_info), GFP_KERNEL);
404 if (!omap_twl_info)
405 return NULL;
406
407 omap_twl_info->use_leds = of_property_read_bool(dev->of_node,
408 "ti,use-leds");
409
410 of_property_read_u32(dev->of_node, "ti,debounce",
411 &omap_twl_info->debounce);
412 of_property_read_u32(dev->of_node, "ti,mmc-cd",
413 (u32 *)&omap_twl_info->mmc_cd);
414 of_property_read_u32(dev->of_node, "ti,pullups",
415 &omap_twl_info->pullups);
416 of_property_read_u32(dev->of_node, "ti,pulldowns",
417 &omap_twl_info->pulldowns);
418
419 return omap_twl_info;
420}
421
399static int __devinit gpio_twl4030_probe(struct platform_device *pdev) 422static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
400{ 423{
401 struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data; 424 struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data;
@@ -428,33 +451,37 @@ no_irqs:
428 twl_gpiochip.ngpio = TWL4030_GPIO_MAX; 451 twl_gpiochip.ngpio = TWL4030_GPIO_MAX;
429 twl_gpiochip.dev = &pdev->dev; 452 twl_gpiochip.dev = &pdev->dev;
430 453
431 if (pdata) { 454 if (node)
432 /* 455 pdata = of_gpio_twl4030(&pdev->dev);
433 * NOTE: boards may waste power if they don't set pullups 456
434 * and pulldowns correctly ... default for non-ULPI pins is 457 if (pdata == NULL) {
435 * pulldown, and some other pins may have external pullups 458 dev_err(&pdev->dev, "Platform data is missing\n");
436 * or pulldowns. Careful! 459 return -ENXIO;
437 */
438 ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns);
439 if (ret)
440 dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n",
441 pdata->pullups, pdata->pulldowns,
442 ret);
443
444 ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
445 if (ret)
446 dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
447 pdata->debounce, pdata->mmc_cd,
448 ret);
449
450 /*
451 * NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE,
452 * is (still) clear if use_leds is set.
453 */
454 if (pdata->use_leds)
455 twl_gpiochip.ngpio += 2;
456 } 460 }
457 461
462 /*
463 * NOTE: boards may waste power if they don't set pullups
464 * and pulldowns correctly ... default for non-ULPI pins is
465 * pulldown, and some other pins may have external pullups
466 * or pulldowns. Careful!
467 */
468 ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns);
469 if (ret)
470 dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n",
471 pdata->pullups, pdata->pulldowns, ret);
472
473 ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
474 if (ret)
475 dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
476 pdata->debounce, pdata->mmc_cd, ret);
477
478 /*
479 * NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE,
480 * is (still) clear if use_leds is set.
481 */
482 if (pdata->use_leds)
483 twl_gpiochip.ngpio += 2;
484
458 ret = gpiochip_add(&twl_gpiochip); 485 ret = gpiochip_add(&twl_gpiochip);
459 if (ret < 0) { 486 if (ret < 0) {
460 dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret); 487 dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret);