Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio/twl4030: get platform data from device tree

Adds a number of missing device tree properties for
twl4030/gpio, and update bindings:
- "ti,use-leds" -> .use_leds
- "ti,debounce" -> .debounce
- "ti,mmc-cd" -> .mmc_cd
- "ti,pullups" -> .pullups
- "ti,pulldowns" -> .pulldowns

Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Vaibhav Hiremath <hvaibhav@ti.com>
[b-cousson@ti.com: Fix some checkpatch CHECK issues]
Signed-off-by: Benoit Cousson <b-cousson@ti.com>

authored by

Florian Vaussard and committed by
Benoit Cousson
f74ce8fb 5635121e

+61 -27
+6
Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
··· 11 11 - interrupt-controller: Mark the device node as an interrupt controller 12 12 The first cell is the GPIO number. 13 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 15 20 Example: 16 21 ··· 25 20 gpio-controller; 26 21 #interrupt-cells = <2>; 27 22 interrupt-controller; 23 + ti,use-leds; 28 24 };
+55 -27
drivers/gpio/gpio-twl4030.c
··· 395 395 396 396 static int gpio_twl4030_remove(struct platform_device *pdev); 397 397 398 + static 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 + 398 423 static int __devinit gpio_twl4030_probe(struct platform_device *pdev) 399 424 { 400 425 struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data; ··· 448 423 twl4030_gpio_irq_base = irq_base; 449 424 450 425 no_irqs: 451 - twl_gpiochip.base = -1; 452 426 twl_gpiochip.ngpio = TWL4030_GPIO_MAX; 453 427 twl_gpiochip.dev = &pdev->dev; 454 428 455 - if (pdata) { 456 - twl_gpiochip.base = pdata->gpio_base; 429 + if (node) 430 + pdata = of_gpio_twl4030(&pdev->dev); 457 431 458 - /* 459 - * NOTE: boards may waste power if they don't set pullups 460 - * and pulldowns correctly ... default for non-ULPI pins is 461 - * pulldown, and some other pins may have external pullups 462 - * or pulldowns. Careful! 463 - */ 464 - ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns); 465 - if (ret) 466 - dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n", 467 - pdata->pullups, pdata->pulldowns, 468 - ret); 469 - 470 - ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd); 471 - if (ret) 472 - dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n", 473 - pdata->debounce, pdata->mmc_cd, 474 - ret); 475 - 476 - /* 477 - * NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE, 478 - * is (still) clear if use_leds is set. 479 - */ 480 - if (pdata->use_leds) 481 - twl_gpiochip.ngpio += 2; 432 + if (pdata == NULL) { 433 + dev_err(&pdev->dev, "Platform data is missing\n"); 434 + return -ENXIO; 482 435 } 436 + 437 + twl_gpiochip.base = pdata->gpio_base; 438 + 439 + /* 440 + * NOTE: boards may waste power if they don't set pullups 441 + * and pulldowns correctly ... default for non-ULPI pins is 442 + * pulldown, and some other pins may have external pullups 443 + * or pulldowns. Careful! 444 + */ 445 + ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns); 446 + if (ret) 447 + dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n", 448 + pdata->pullups, pdata->pulldowns, ret); 449 + 450 + ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd); 451 + if (ret) 452 + dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n", 453 + pdata->debounce, pdata->mmc_cd, ret); 454 + 455 + /* 456 + * NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE, 457 + * is (still) clear if use_leds is set. 458 + */ 459 + if (pdata->use_leds) 460 + twl_gpiochip.ngpio += 2; 483 461 484 462 ret = gpiochip_add(&twl_gpiochip); 485 463 if (ret < 0) {