Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

More power button fixes #2

Merged
merged 2 commits into from
Nov 20, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions arch/arm/mach-tegra/board-smba1002-power.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -554,6 +554,9 @@ static void smba1002_power_off(void)
/* Power down through NvEC */ /* Power down through NvEC */
//nvec_poweroff(); //nvec_poweroff();


/* Turn off main supply */
tps6586x_power_off();

/* Then try by powering off supplies */ /* Then try by powering off supplies */
reg_off("vdd_sm2"); reg_off("vdd_sm2");
reg_off("vdd_core"); reg_off("vdd_core");
Expand Down
22 changes: 19 additions & 3 deletions arch/arm/mach-tegra/board-smba1002-wake.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,16 +40,32 @@ MODULE_DESCRIPTION("Wake smb_a1002 when power button is pressed");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");


static void smba1002_wake_do_wake(struct work_struct *work) { static void smba1002_wake_do_wake(struct work_struct *work) {
tps6586x_cancel_sleep();
// Need to queue this function since i2c is slow and this handler // Need to queue this function since i2c is slow and this handler
// should be atomic. // should be atomic.
tps6586x_cancel_sleep();
} }
DECLARE_WORK(do_wake, smba1002_wake_do_wake); DECLARE_WORK(do_wake, smba1002_wake_do_wake);


static void smba1002_wake_force_shutdown(struct work_struct *work) {
// Need to queue this function since i2c is slow and this handler
// should be atomic.
tps6586x_power_off();
}
DECLARE_DELAYED_WORK(do_shutdown, smba1002_wake_force_shutdown);

static void smba1002_wake_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) static void smba1002_wake_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
{ {
if(type == EV_KEY && code == KEY_POWER && !!value) { code = code;
schedule_work(&do_wake); if(type == EV_KEY && code == KEY_POWER) {
if(!!value) {
// button pressed; cancel TPS sleep mode
schedule_work(&do_wake);
// ... and schedule shutdown if button remains pressed
schedule_delayed_work(&do_shutdown, 5*HZ);
} else {
// button is not longer pressed; cancel shutdown
cancel_delayed_work(&do_shutdown);
}
} }
} }


Expand Down