Skip to content

Commit

Permalink
[ARM] 5099/1: Tosa: support AC-in detection.
Browse files Browse the repository at this point in the history
Add support for ac-in via pda_power device.

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Dmitry Baryshkov authored and Russell King committed Jul 7, 2008
1 parent 4440cbd commit 53b14ea
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions arch/arm/mach-pxa/tosa.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/gpio_keys.h>
#include <linux/input.h>
#include <linux/gpio.h>
#include <linux/pda_power.h>

#include <asm/setup.h>
#include <asm/mach-types.h>
Expand Down Expand Up @@ -409,6 +410,70 @@ static struct pxaficp_platform_data tosa_ficp_platform_data = {
.shutdown = tosa_irda_shutdown,
};

/*
* Tosa AC IN
*/
static int tosa_power_init(struct device *dev)
{
int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
if (ret)
goto err_gpio_req;

ret = gpio_direction_input(TOSA_GPIO_AC_IN);
if (ret)
goto err_gpio_in;

return 0;

err_gpio_in:
gpio_free(TOSA_GPIO_AC_IN);
err_gpio_req:
return ret;
}

static void tosa_power_exit(struct device *dev)
{
gpio_free(TOSA_GPIO_AC_IN);
}

static int tosa_power_ac_online(void)
{
return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
}

static char *tosa_ac_supplied_to[] = {
"main-battery",
"backup-battery",
"jacket-battery",
};

static struct pda_power_pdata tosa_power_data = {
.init = tosa_power_init,
.is_ac_online = tosa_power_ac_online,
.exit = tosa_power_exit,
.supplied_to = tosa_ac_supplied_to,
.num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
};

static struct resource tosa_power_resource[] = {
{
.name = "ac",
.start = gpio_to_irq(TOSA_GPIO_AC_IN),
.end = gpio_to_irq(TOSA_GPIO_AC_IN),
.flags = IORESOURCE_IRQ |
IORESOURCE_IRQ_HIGHEDGE |
IORESOURCE_IRQ_LOWEDGE,
},
};

static struct platform_device tosa_power_device = {
.name = "pda-power",
.id = -1,
.dev.platform_data = &tosa_power_data,
.resource = tosa_power_resource,
.num_resources = ARRAY_SIZE(tosa_power_resource),
};

/*
* Tosa Keyboard
*/
Expand Down Expand Up @@ -633,6 +698,7 @@ static struct platform_device *devices[] __initdata = {
&tosascoop_device,
&tosascoop_jc_device,
&tc6393xb_device,
&tosa_power_device,
&tosakbd_device,
&tosa_gpio_keys_device,
&tosaled_device,
Expand Down

0 comments on commit 53b14ea

Please sign in to comment.