aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/gpio/gpio-twl4030.txt6
-rw-r--r--drivers/gpio/gpio-twl4030.c82
2 files changed, 61 insertions, 27 deletions
diff --git a/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt b/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
index 16695d9cf1e8..66788fda1db3 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
@@ -11,6 +11,11 @@ Required properties:
11- interrupt-controller: Mark the device node as an interrupt controller 11- interrupt-controller: Mark the device node as an interrupt controller
12 The first cell is the GPIO number. 12 The first cell is the GPIO number.
13 The second cell is not used. 13 The second cell is not used.
14- ti,use-leds : Enables LEDA and LEDB outputs if set
15- ti,debounce : if n-th bit is set, debounces GPIO-n
16- ti,mmc-cd : if n-th bit is set, GPIO-n controls VMMC(n+1)
17- ti,pullups : if n-th bit is set, set a pullup on GPIO-n
18- ti,pulldowns : if n-th bit is set, set a pulldown on GPIO-n
14 19
15Example: 20Example:
16 21
@@ -20,4 +25,5 @@ twl_gpio: gpio {
20 gpio-controller; 25 gpio-controller;
21 #interrupt-cells = <2>; 26 #interrupt-cells = <2>;
22 interrupt-controller; 27 interrupt-controller;
28 ti,use-leds;
23}; 29};
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index 94256fe7bf36..f923252da839 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -395,6 +395,31 @@ static int __devinit gpio_twl4030_debounce(u32 debounce, u8 mmc_cd)
395 395
396static int gpio_twl4030_remove(struct platform_device *pdev); 396static int gpio_twl4030_remove(struct platform_device *pdev);
397 397
398static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev)
399{
400 struct twl4030_gpio_platform_data *omap_twl_info;
401
402 omap_twl_info = devm_kzalloc(dev, sizeof(*omap_twl_info), GFP_KERNEL);
403 if (!omap_twl_info)
404 return NULL;
405
406 omap_twl_info->gpio_base = -1;
407
408 omap_twl_info->use_leds = of_property_read_bool(dev->of_node,
409 "ti,use-leds");
410
411 of_property_read_u32(dev->of_node, "ti,debounce",
412 &omap_twl_info->debounce);
413 of_property_read_u32(dev->of_node, "ti,mmc-cd",
414 (u32 *)&omap_twl_info->mmc_cd);
415 of_property_read_u32(dev->of_node, "ti,pullups",
416 &omap_twl_info->pullups);
417 of_property_read_u32(dev->of_node, "ti,pulldowns",
418 &omap_twl_info->pulldowns);
419
420 return omap_twl_info;
421}
422
398static int __devinit gpio_twl4030_probe(struct platform_device *pdev) 423static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
399{ 424{
400 struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data; 425 struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data;
@@ -423,39 +448,42 @@ static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
423 twl4030_gpio_irq_base = irq_base; 448 twl4030_gpio_irq_base = irq_base;
424 449
425no_irqs: 450no_irqs:
426 twl_gpiochip.base = -1;
427 twl_gpiochip.ngpio = TWL4030_GPIO_MAX; 451 twl_gpiochip.ngpio = TWL4030_GPIO_MAX;
428 twl_gpiochip.dev = &pdev->dev; 452 twl_gpiochip.dev = &pdev->dev;
429 453
430 if (pdata) { 454 if (node)
431 twl_gpiochip.base = pdata->gpio_base; 455 pdata = of_gpio_twl4030(&pdev->dev);
432 456
433 /* 457 if (pdata == NULL) {
434 * NOTE: boards may waste power if they don't set pullups 458 dev_err(&pdev->dev, "Platform data is missing\n");
435 * and pulldowns correctly ... default for non-ULPI pins is 459 return -ENXIO;
436 * pulldown, and some other pins may have external pullups
437 * or pulldowns. Careful!
438 */
439 ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns);
440 if (ret)
441 dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n",
442 pdata->pullups, pdata->pulldowns,
443 ret);
444
445 ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
446 if (ret)
447 dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
448 pdata->debounce, pdata->mmc_cd,
449 ret);
450
451 /*
452 * NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE,
453 * is (still) clear if use_leds is set.
454 */
455 if (pdata->use_leds)
456 twl_gpiochip.ngpio += 2;
457 } 460 }
458 461
462 twl_gpiochip.base = pdata->gpio_base;
463
464 /*
465 * NOTE: boards may waste power if they don't set pullups
466 * and pulldowns correctly ... default for non-ULPI pins is
467 * pulldown, and some other pins may have external pullups
468 * or pulldowns. Careful!
469 */
470 ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns);
471 if (ret)
472 dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n",
473 pdata->pullups, pdata->pulldowns, ret);
474
475 ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
476 if (ret)
477 dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
478 pdata->debounce, pdata->mmc_cd, ret);
479
480 /*
481 * NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE,
482 * is (still) clear if use_leds is set.
483 */
484 if (pdata->use_leds)
485 twl_gpiochip.ngpio += 2;
486
459 ret = gpiochip_add(&twl_gpiochip); 487 ret = gpiochip_add(&twl_gpiochip);
460 if (ret < 0) { 488 if (ret < 0) {
461 dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret); 489 dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret);