提交 ff279202 编写于 作者: P Philipp Zabel 提交者: Russell King

[ARM] 5042/1: magician: request GPIOs for pda_power

Signed-off-by: NPhilipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
上级 6a566fbb
...@@ -511,6 +511,37 @@ static struct platform_device pasic3 = { ...@@ -511,6 +511,37 @@ static struct platform_device pasic3 = {
* External power * External power
*/ */
static int power_supply_init(struct device *dev)
{
int ret;
ret = gpio_request(EGPIO_MAGICIAN_CABLE_STATE_AC, "CABLE_STATE_AC");
if (ret)
goto err_cs_ac;
ret = gpio_request(EGPIO_MAGICIAN_CABLE_STATE_USB, "CABLE_STATE_USB");
if (ret)
goto err_cs_usb;
ret = gpio_request(EGPIO_MAGICIAN_CHARGE_EN, "CHARGE_EN");
if (ret)
goto err_chg_en;
ret = gpio_request(GPIO30_MAGICIAN_nCHARGE_EN, "nCHARGE_EN");
if (!ret)
ret = gpio_direction_output(GPIO30_MAGICIAN_nCHARGE_EN, 0);
if (ret)
goto err_nchg_en;
return 0;
err_nchg_en:
gpio_free(EGPIO_MAGICIAN_CHARGE_EN);
err_chg_en:
gpio_free(EGPIO_MAGICIAN_CABLE_STATE_USB);
err_cs_usb:
gpio_free(EGPIO_MAGICIAN_CABLE_STATE_AC);
err_cs_ac:
return ret;
}
static int magician_is_ac_online(void) static int magician_is_ac_online(void)
{ {
return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_AC); return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_AC);
...@@ -527,14 +558,24 @@ static void magician_set_charge(int flags) ...@@ -527,14 +558,24 @@ static void magician_set_charge(int flags)
gpio_set_value(EGPIO_MAGICIAN_CHARGE_EN, flags); gpio_set_value(EGPIO_MAGICIAN_CHARGE_EN, flags);
} }
static void power_supply_exit(struct device *dev)
{
gpio_free(GPIO30_MAGICIAN_nCHARGE_EN);
gpio_free(EGPIO_MAGICIAN_CHARGE_EN);
gpio_free(EGPIO_MAGICIAN_CABLE_STATE_USB);
gpio_free(EGPIO_MAGICIAN_CABLE_STATE_AC);
}
static char *magician_supplicants[] = { static char *magician_supplicants[] = {
"ds2760-battery.0", "backup-battery" "ds2760-battery.0", "backup-battery"
}; };
static struct pda_power_pdata power_supply_info = { static struct pda_power_pdata power_supply_info = {
.init = power_supply_init,
.is_ac_online = magician_is_ac_online, .is_ac_online = magician_is_ac_online,
.is_usb_online = magician_is_usb_online, .is_usb_online = magician_is_usb_online,
.set_charge = magician_set_charge, .set_charge = magician_set_charge,
.exit = power_supply_exit,
.supplied_to = magician_supplicants, .supplied_to = magician_supplicants,
.num_supplicants = ARRAY_SIZE(magician_supplicants), .num_supplicants = ARRAY_SIZE(magician_supplicants),
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册