]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/i2c/chips/twl4030-core.c
twl4030 uses gpiolib
[linux-2.6-omap-h63xx.git] / drivers / i2c / chips / twl4030-core.c
index 02be771a9225f2dca3bdf3649069afdef0b5e4a1..c9460f754f9dad43fc58b4e814d59c41a9723e03 100644 (file)
 #define twl_has_usb()  false
 #endif
 
+#ifdef CONFIG_TWL4030_GPIO
+#define twl_has_gpio() true
+#else
+#define twl_has_gpio() false
+#endif
+
 /* Primary Interrupt Handler on TWL4030 Registers */
 
 /* Register Definitions */
@@ -656,6 +662,44 @@ static int add_children(struct twl4030_platform_data *pdata)
        struct twl4030_client   *twl = NULL;
        int                     status = 0;
 
+       if (twl_has_gpio() && pdata->gpio) {
+               twl = &twl4030_modules[TWL4030_SLAVENUM_NUM1];
+
+               pdev = platform_device_alloc("twl4030_gpio", -1);
+               if (!pdev)
+                       status = -ENOMEM;
+
+               /* more driver model init */
+               if (status == 0) {
+                       pdev->dev.parent = &twl->client->dev;
+                       /* device_init_wakeup(&pdev->dev, 1); */
+
+                       status = platform_device_add_data(pdev, pdata->gpio,
+                                       sizeof(*pdata->gpio));
+               }
+
+               /* GPIO module IRQ */
+               if (status == 0) {
+                       struct resource r = {
+                               .start = pdata->irq_base + 0,
+                               .flags = IORESOURCE_IRQ,
+                       };
+
+                       status = platform_device_add_resources(pdev, &r, 1);
+               }
+
+               if (status == 0)
+                       status = platform_device_add(pdev);
+
+               if (status < 0) {
+                       platform_device_put(pdev);
+                       dev_dbg(&twl->client->dev,
+                                       "can't create gpio dev, %d\n",
+                                       status);
+                       goto err;
+               }
+       }
+
        if (twl_has_rtc()) {
                pdev = platform_device_alloc("twl4030_rtc", -1);
                if (pdev) {