From: Gary King Date: Sun, 15 Aug 2010 17:32:12 +0000 (-0700) Subject: [ARM] tegra: ventana: add tps6586x rtc and pda_power devices X-Git-Tag: firefly_0821_release~9833^2~218 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1ada8fb6713b6b7d75c530e8d2980a241a660ea2;p=firefly-linux-kernel-4.4.55.git [ARM] tegra: ventana: add tps6586x rtc and pda_power devices Change-Id: I1c851ab4982764b7f72d968d665d0c898fae25aa Signed-off-by: Gary King --- diff --git a/arch/arm/mach-tegra/board-ventana-power.c b/arch/arm/mach-tegra/board-ventana-power.c index 5d998589eb12..868b94faa5d1 100644 --- a/arch/arm/mach-tegra/board-ventana-power.c +++ b/arch/arm/mach-tegra/board-ventana-power.c @@ -16,15 +16,100 @@ * 02111-1307, USA */ #include +#include +#include +#include #include #include #include #include - +#include "gpio-names.h" #include "power.h" #include "wakeups-t2.h" #include "board.h" +static int ac_ok = TEGRA_GPIO_PV3; +static int charge_disable = TEGRA_GPIO_PR6; + +static int charge_init(struct device *dev) +{ + int ret = gpio_request(charge_disable, "chg_disable"); + if (ret < 0) + return ret; + + ret = gpio_request(ac_ok, "ac_ok"); + if (ret < 0) { + gpio_free(charge_disable); + return ret; + } + + ret = gpio_direction_output(charge_disable, 0); + if (ret < 0) + goto cleanup; + + ret = gpio_direction_input(ac_ok); + if (ret < 0) + goto cleanup; + + tegra_gpio_enable(ac_ok); + tegra_gpio_enable(charge_disable); + + return 0; + +cleanup: + gpio_free(ac_ok); + gpio_free(charge_disable); + return ret; +} + +static void charge_exit(struct device *dev) +{ + gpio_free(charge_disable); +} + +static int ac_online(void) +{ + return !gpio_get_value(ac_ok); +} + +static void set_charge(int flags) +{ + if (flags == PDA_POWER_CHARGE_AC) + gpio_set_value(charge_disable, 0); + else if (!flags) + gpio_set_value(charge_disable, 1); + else + BUG(); +} + +static struct resource ventana_pda_resources[] = { + [0] = { + .name = "ac", + .start = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV3), + .end = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV3), + .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | + IORESOURCE_IRQ_LOWEDGE), + }, +}; + +static struct pda_power_pdata ventana_pda_data = { + .is_ac_online = ac_online, + .exit = charge_exit, + .init = charge_init, + .set_charge = set_charge, +}; + +static struct platform_device ventana_pda_power_device = { + .name = "pda-power", + .id = -1, + .resource = ventana_pda_resources, + .num_resources = ARRAY_SIZE(ventana_pda_resources), + .dev = { + .platform_data = &ventana_pda_data, + }, +}; + + static struct regulator_consumer_supply tps658621_sm0_supply[] = { REGULATOR_SUPPLY("vdd_core", NULL), }; @@ -121,6 +206,11 @@ static struct tps6586x_subdev_info tps_devs[] = { TPS_REG(LDO_7, &ldo7_data), TPS_REG(LDO_8, &ldo8_data), TPS_REG(LDO_9, &ldo9_data), + { + .id = 0, + .name = "tps6586x-rtc", + .platform_data = NULL, + }, }; static struct tps6586x_platform_data tps_platform = { @@ -153,6 +243,7 @@ static struct tegra_suspend_platform_data ventana_suspend_data = { int __init ventana_regulator_init(void) { + platform_device_register(&ventana_pda_power_device); i2c_register_board_info(4, ventana_regulators, 1); tegra_init_suspend(&ventana_suspend_data); return 0; diff --git a/arch/arm/mach-tegra/board-ventana.c b/arch/arm/mach-tegra/board-ventana.c index 0b2ec53aedfe..ee9b7c9429dc 100644 --- a/arch/arm/mach-tegra/board-ventana.c +++ b/arch/arm/mach-tegra/board-ventana.c @@ -79,18 +79,6 @@ static __initdata struct tegra_clk_init_table ventana_clk_init_table[] = { { NULL, NULL, 0, 0}, }; -/* PDA power */ -static struct pda_power_pdata pda_power_pdata = { -}; - -static struct platform_device pda_power_device = { - .name = "pda_power", - .id = -1, - .dev = { - .platform_data = &pda_power_pdata, - }, -}; - static struct tegra_i2c_platform_data ventana_i2c1_platform_data = { .adapter_nr = 0, .bus_count = 1, @@ -178,7 +166,6 @@ static struct platform_device *ventana_devices[] __initdata = { &debug_uart, &pmu_device, &tegra_udc_device, - &pda_power_device, &tegra_gart_device, &ventana_keys_device, };