Commit 2e056215 authored by David Brownell's avatar David Brownell Committed by Tony Lindgren

twl4030 uses gpiolib

Make the twl4030 core create a platform device to which its
GPIO code will bind, with platform_data used to configure
board-specific behaviors and configuration.

Update the twl4030 GPIO code:

  - Morph its gpio function code into a platform driver.

  - Move away from IRQ (and GPIO) numbers hard-wired in headers.

  - Hook up the twl4030 GPIO code to gpiolib.

  - Start phasing out the older TWL-specific calls ... currently
    those are used only by arch/arm/mach-omap2/hsmmc.c setup code.

  - Use a mutex for locking, not a binary semaphore.

NOTE:  more patches pending:  (a) this doesn't use pdata->pullups
to initialize (currently hsmmc code always sets GPIO-0 pullup even
if the board has an external pullup);  (b) there's a new gpio
request/free hook forthcoming in 2.6.28, which this should use;
(c) likewise there's a new gpio_to_irq() hook; (d) the irq_chip
set_type() mechanism needs to be supported; (e) needs to move over
to drivers/gpio; (f) upcoming threaded IRQ infrastructure should
be used, when that merges.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent fca78930
......@@ -159,7 +159,7 @@ config TWL4030_CORE
config TWL4030_GPIO
bool "TWL4030 GPIO Driver"
depends on TWL4030_CORE
depends on TWL4030_CORE && GPIOLIB
config TWL4030_MADC
tristate "TWL4030 MADC Driver"
......
......@@ -63,6 +63,12 @@
#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) {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment