summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/board-ventana-power.c
diff options
context:
space:
mode:
authorGary King <gking@nvidia.com>2010-08-15 10:32:12 -0700
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:35:37 -0800
commit836612beb7722f62d92583130318cc1108448d55 (patch)
tree0aad0d099c50d8f5c2481c81dfe302f89ce86d48 /arch/arm/mach-tegra/board-ventana-power.c
parent428377879090cd29429b2f9d77b37a2264d72360 (diff)
[ARM] tegra: ventana: add tps6586x rtc and pda_power devices
Change-Id: I1c851ab4982764b7f72d968d665d0c898fae25aa Signed-off-by: Gary King <gking@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra/board-ventana-power.c')
-rw-r--r--arch/arm/mach-tegra/board-ventana-power.c93
1 files changed, 92 insertions, 1 deletions
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 <linux/i2c.h>
+#include <linux/pda_power.h>
+#include <linux/platform_device.h>
+#include <linux/resource.h>
#include <linux/regulator/machine.h>
#include <linux/mfd/tps6586x.h>
#include <linux/gpio.h>
#include <mach/suspend.h>
-
+#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;