mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 21:07:02 +09:00
A22:change power off to restart if charging
This commit is contained in:
25
arch/arm/mach-rk29/board-rk29-a22.c
Executable file → Normal file
25
arch/arm/mach-rk29/board-rk29-a22.c
Executable file → Normal file
@@ -2994,18 +2994,10 @@ static void __init machine_rk29_init_irq(void)
|
||||
}
|
||||
|
||||
#define POWER_ON_PIN RK29_PIN4_PA4
|
||||
static void rk29_pm_power_off(void)
|
||||
{
|
||||
printk(KERN_ERR "rk29_pm_power_off start...\n");
|
||||
gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
|
||||
#if defined(CONFIG_MFD_WM831X)
|
||||
wm831x_device_shutdown(gWm831x);
|
||||
#endif
|
||||
while (1);
|
||||
}
|
||||
|
||||
static void rk29_pm_power_restart(void)
|
||||
{
|
||||
printk("%s\n",__FUNCTION__);
|
||||
printk("%s,line=%d\n",__FUNCTION__,__LINE__);
|
||||
mdelay(2);
|
||||
#if defined(CONFIG_MFD_WM831X)
|
||||
wm831x_device_restart(gWm831x);
|
||||
@@ -3013,6 +3005,19 @@ static void rk29_pm_power_restart(void)
|
||||
|
||||
}
|
||||
|
||||
static void rk29_pm_power_off(void)
|
||||
{
|
||||
printk(KERN_ERR "rk29_pm_power_off start...\n");
|
||||
gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
|
||||
#if defined(CONFIG_MFD_WM831X)
|
||||
if(wm831x_read_usb(gWm831x))
|
||||
rk29_pm_power_restart(); //if charging then restart
|
||||
else
|
||||
wm831x_device_shutdown(gWm831x);//else shutdown
|
||||
#endif
|
||||
while (1);
|
||||
}
|
||||
|
||||
static void __init machine_rk29_board_init(void)
|
||||
{
|
||||
rk29_board_iomux_init();
|
||||
|
||||
18
drivers/mfd/wm831x-core.c
Executable file → Normal file
18
drivers/mfd/wm831x-core.c
Executable file → Normal file
@@ -1817,6 +1817,24 @@ int wm831x_device_shutdown(struct wm831x *wm831x)
|
||||
EXPORT_SYMBOL_GPL(wm831x_device_shutdown);
|
||||
|
||||
|
||||
int wm831x_read_usb(struct wm831x *wm831x)
|
||||
{
|
||||
int ret, usb_chg = 0, wall_chg = 0;
|
||||
|
||||
ret = wm831x_reg_read(wm831x, WM831X_SYSTEM_STATUS);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (ret & WM831X_PWR_USB)
|
||||
usb_chg = 1;
|
||||
if (ret & WM831X_PWR_WALL)
|
||||
wall_chg = 1;
|
||||
|
||||
return ((usb_chg | wall_chg) ? 1 : 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int wm831x_device_restart(struct wm831x *wm831x)
|
||||
{
|
||||
wm831x_reg_write(wm831x,WM831X_RESET_ID, 0xffff);
|
||||
|
||||
1
include/linux/mfd/wm831x/core.h
Executable file → Normal file
1
include/linux/mfd/wm831x/core.h
Executable file → Normal file
@@ -346,6 +346,7 @@ void wm831x_device_exit(struct wm831x *wm831x);
|
||||
int wm831x_device_suspend(struct wm831x *wm831x);
|
||||
int wm831x_device_resume(struct wm831x *wm831x);
|
||||
int wm831x_device_shutdown(struct wm831x *wm831x);
|
||||
int wm831x_read_usb(struct wm831x *wm831x);
|
||||
int wm831x_device_restart(struct wm831x *wm831x);
|
||||
int wm831x_irq_init(struct wm831x *wm831x, int irq);
|
||||
void wm831x_irq_exit(struct wm831x *wm831x);
|
||||
|
||||
Reference in New Issue
Block a user