[ARM] tegra: ventana: add tps6586x rtc and pda_power devices

Change-Id: I1c851ab4982764b7f72d968d665d0c898fae25aa
Signed-off-by: Gary King <gking@nvidia.com>
This commit is contained in:
Gary King 2010-08-15 10:32:12 -07:00 committed by Colin Cross
parent fd143bbab4
commit 1ada8fb671
2 changed files with 92 additions and 14 deletions

View File

@ -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;

View File

@ -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,
};