Skip to content

Commit

Permalink
Add PowerSuspend
Browse files Browse the repository at this point in the history
Signed-off-by: Javier Sayago <admin@lonasdigital.com>
  • Loading branch information
javilonas committed May 30, 2015
1 parent f7e8ea7 commit 6c78050
Show file tree
Hide file tree
Showing 8 changed files with 446 additions and 1 deletion.
2 changes: 2 additions & 0 deletions arch/arm/configs/apq8084_sec_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ CONFIG_CPU_IDLE=y
CONFIG_VFP=y
CONFIG_NEON=y
# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
CONFIG_POWERSUSPEND=y
# CONFIG_POWERSUSPEND_DEBUG is not set
CONFIG_PM_AUTOSLEEP=y
CONFIG_PM_WAKELOCKS=y
CONFIG_PM_WAKELOCKS_LIMIT=0
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/configs/lonas_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,8 @@ CONFIG_SUSPEND_FREEZER=y
CONFIG_CPU_FREQ_LIMIT_USERSPACE=y
CONFIG_HAS_WAKELOCK=y
CONFIG_WAKELOCK=y
CONFIG_POWERSUSPEND=y
# CONFIG_POWERSUSPEND_DEBUG is not set
CONFIG_PM_SLEEP=y
CONFIG_PM_SLEEP_SMP=y
CONFIG_PM_AUTOSLEEP=y
Expand Down
2 changes: 1 addition & 1 deletion drivers/pinctrl/pinctrl-msm-tlmm-v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ static void msm_tlmm_v3_gp_irq_resume(void)
int num_irqs = ic->num_irqs;

spin_lock_irqsave(&ic->irq_lock, irq_flags);
for_each_set_bit(i, ic->wake_irqs, num_irqs)
for_each_set_bit(i, ic->enabled_irqs, num_irqs)
msm_tlmm_v3_set_intr_cfg_enable(ic, i, 0);

for_each_set_bit(i, ic->enabled_irqs, num_irqs)
Expand Down
56 changes: 56 additions & 0 deletions include/linux/earlysuspend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* include/linux/earlysuspend.h
*
* Copyright (C) 2007-2008 Google, Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/

#ifndef _LINUX_EARLYSUSPEND_H
#define _LINUX_EARLYSUSPEND_H

#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/list.h>
#endif

/* The early_suspend structure defines suspend and resume hooks to be called
* when the user visible sleep state of the system changes, and a level to
* control the order. They can be used to turn off the screen and input
* devices that are not used for wakeup.
* Suspend handlers are called in low to high level order, resume handlers are
* called in the opposite order. If, when calling register_early_suspend,
* the suspend handlers have already been called without a matching call to the
* resume handlers, the suspend handler will be called directly from
* register_early_suspend. This direct call can violate the normal level order.
*/
enum {
EARLY_SUSPEND_LEVEL_BLANK_SCREEN = 50,
EARLY_SUSPEND_LEVEL_STOP_DRAWING = 100,
EARLY_SUSPEND_LEVEL_DISABLE_FB = 150,
};
struct early_suspend {
#ifdef CONFIG_HAS_EARLYSUSPEND
struct list_head link;
int level;
void (*suspend)(struct early_suspend *h);
void (*resume)(struct early_suspend *h);
#endif
};

#ifdef CONFIG_HAS_EARLYSUSPEND
void register_early_suspend(struct early_suspend *handler);
void unregister_early_suspend(struct early_suspend *handler);
#else
#define register_early_suspend(handler) do { } while (0)
#define unregister_early_suspend(handler) do { } while (0)
#endif

#endif

51 changes: 51 additions & 0 deletions include/linux/powersuspend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* include/linux/powersuspend.h
*
* Copyright (C) 2007-2008 Google, Inc.
* Copyright (C) 2013 Paul Reioux
*
* Modified by Jean-Pierre Rasquin <yank555.lu@gmail.com>
*
* v1.1 - make powersuspend not depend on a userspace initiator anymore,
* but use a hook in autosleep instead.
*
* v1.2 - make kernel / userspace mode switchable
*
* v1.3 - add a hook in display panel driver as alternative kernel trigger
*
* v1.4 - add a hybrid-kernel mode, accepting both kernel hooks (first wins)
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/

#ifndef _LINUX_POWERSUSPEND_H
#define _LINUX_POWERSUSPEND_H

#include <linux/list.h>

#define POWER_SUSPEND_INACTIVE 0
#define POWER_SUSPEND_ACTIVE 1

#define POWER_SUSPEND_USERSPACE 1 // Use fauxclock as trigger
#define POWER_SUSPEND_PANEL 2 // Use display panel state as hook

struct power_suspend {
struct list_head link;
void (*suspend)(struct power_suspend *h);
void (*resume)(struct power_suspend *h);
};

void register_power_suspend(struct power_suspend *handler);
void unregister_power_suspend(struct power_suspend *handler);

void set_power_suspend_state_panel_hook(int new_state);

#endif

13 changes: 13 additions & 0 deletions kernel/power/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ config WAKELOCK
bool
default y

config POWERSUSPEND
bool "Power suspend"
default y
---help---
Call early suspend handlers when the user requested sleep state
changes.

config POWERSUSPEND_DEBUG
bool "Powersuspend driver debugging code"
depends on POWERSUSPEND
help
Output debugging info in dmesg [POWERSUSPEND] (Yank555.lu)

config HIBERNATE_CALLBACKS
bool

Expand Down
1 change: 1 addition & 0 deletions kernel/power/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ obj-$(CONFIG_SUSPEND) += suspend.o
obj-$(CONFIG_PM_TEST_SUSPEND) += suspend_test.o
obj-$(CONFIG_HIBERNATION) += hibernate.o snapshot.o swap.o user.o \
block_io.o
obj-$(CONFIG_POWERSUSPEND) += powersuspend.o
obj-$(CONFIG_PM_AUTOSLEEP) += autosleep.o
obj-$(CONFIG_PM_WAKELOCKS) += wakelock.o
obj-$(CONFIG_SUSPEND_TIME) += suspend_time.o
Expand Down
Loading

0 comments on commit 6c78050

Please sign in to comment.