aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorRoland Stigge <stigge@antcom.de>2012-05-18 04:19:52 -0400
committerGrant Likely <grant.likely@secretlab.ca>2012-05-18 18:48:36 -0400
commite92935e13a052df7e6bc274e00fc91b80531f1e4 (patch)
treeb04f80aa90bab2d71f2299b00f5cccc3e7ee9a7a /drivers/gpio
parent3d0f7cf0f3633f92ddeb767eb59cab73963d4dee (diff)
gpio/lpc32xx: Add device tree support
This patch adds device tree support for gpio-lpc32xx.c. To register the various GPIO banks as (struct) gpio_chips via the same DT gpio-controller, we utilize the adjusted of_xlate API to manipulate the actually used struct gpio_chip. Signed-off-by: Roland Stigge <stigge@antcom.de> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-lpc32xx.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c
index 61c2d08d37b6..c2199beca98a 100644
--- a/drivers/gpio/gpio-lpc32xx.c
+++ b/drivers/gpio/gpio-lpc32xx.c
@@ -21,6 +21,9 @@
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/of_gpio.h>
25#include <linux/platform_device.h>
26#include <linux/module.h>
24 27
25#include <mach/hardware.h> 28#include <mach/hardware.h>
26#include <mach/platform.h> 29#include <mach/platform.h>
@@ -454,10 +457,57 @@ static struct lpc32xx_gpio_chip lpc32xx_gpiochip[] = {
454 }, 457 },
455}; 458};
456 459
460/* Empty now, can be removed later when mach-lpc32xx is finally switched over
461 * to DT support
462 */
457void __init lpc32xx_gpio_init(void) 463void __init lpc32xx_gpio_init(void)
458{ 464{
465}
466
467static int lpc32xx_of_xlate(struct gpio_chip *gc,
468 const struct of_phandle_args *gpiospec, u32 *flags)
469{
470 /* Is this the correct bank? */
471 u32 bank = gpiospec->args[0];
472 if ((bank > ARRAY_SIZE(lpc32xx_gpiochip) ||
473 (gc != &lpc32xx_gpiochip[bank].chip)))
474 return -EINVAL;
475
476 if (flags)
477 *flags = gpiospec->args[2];
478 return gpiospec->args[1];
479}
480
481static int __devinit lpc32xx_gpio_probe(struct platform_device *pdev)
482{
459 int i; 483 int i;
460 484
461 for (i = 0; i < ARRAY_SIZE(lpc32xx_gpiochip); i++) 485 for (i = 0; i < ARRAY_SIZE(lpc32xx_gpiochip); i++) {
486 if (pdev->dev.of_node) {
487 lpc32xx_gpiochip[i].chip.of_xlate = lpc32xx_of_xlate;
488 lpc32xx_gpiochip[i].chip.of_gpio_n_cells = 3;
489 lpc32xx_gpiochip[i].chip.of_node = pdev->dev.of_node;
490 }
462 gpiochip_add(&lpc32xx_gpiochip[i].chip); 491 gpiochip_add(&lpc32xx_gpiochip[i].chip);
492 }
493
494 return 0;
463} 495}
496
497#ifdef CONFIG_OF
498static struct of_device_id lpc32xx_gpio_of_match[] __devinitdata = {
499 { .compatible = "nxp,lpc3220-gpio", },
500 { },
501};
502#endif
503
504static struct platform_driver lpc32xx_gpio_driver = {
505 .driver = {
506 .name = "lpc32xx-gpio",
507 .owner = THIS_MODULE,
508 .of_match_table = of_match_ptr(lpc32xx_gpio_of_match),
509 },
510 .probe = lpc32xx_gpio_probe,
511};
512
513module_platform_driver(lpc32xx_gpio_driver);