blob: 0d5101dcf09afb673b1eec0bacf537a34c0afbb6 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* arch/arm/mach-msm/pm.h
2 *
3 * Copyright (C) 2007 Google, Inc.
Matt Wagantall8c327c52012-02-01 16:51:03 -08004 * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005 * Author: San Mehat <san@android.com>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17
18#ifndef __ARCH_ARM_MACH_MSM_PM_H
19#define __ARCH_ARM_MACH_MSM_PM_H
20
21#include <linux/types.h>
22#include <linux/cpuidle.h>
23
24#ifdef CONFIG_SMP
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025extern void msm_secondary_startup(void);
26#else
27#define msm_secondary_startup NULL
28#endif
29
Taniya Dase30a6b22012-03-20 11:37:45 +053030extern int power_collapsed;
31
Murali Nalajala2a0bbda2012-03-28 12:12:54 +053032struct msm_pm_irq_calls {
33 unsigned int (*irq_pending)(void);
34 int (*idle_sleep_allowed)(void);
35 void (*enter_sleep1)(bool modem_wake, int from_idle, uint32_t
36 *irq_mask);
37 int (*enter_sleep2)(bool modem_wake, int from_idle);
38 void (*exit_sleep1)(uint32_t irq_mask, uint32_t wakeup_reason,
39 uint32_t pending_irqs);
40 void (*exit_sleep2)(uint32_t irq_mask, uint32_t wakeup_reason,
41 uint32_t pending_irqs);
42 void (*exit_sleep3)(uint32_t irq_mask, uint32_t wakeup_reason,
43 uint32_t pending_irqs);
44};
45
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046enum msm_pm_sleep_mode {
Praveen Chidambaramd3d844d2012-04-24 09:47:38 -060047 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT = 0,
48 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT = 1,
49 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE = 2,
50 MSM_PM_SLEEP_MODE_POWER_COLLAPSE = 3,
51 MSM_PM_SLEEP_MODE_APPS_SLEEP = 4,
52 MSM_PM_SLEEP_MODE_RETENTION = MSM_PM_SLEEP_MODE_APPS_SLEEP,
53 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_SUSPEND = 5,
54 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN = 6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055 MSM_PM_SLEEP_MODE_NR
56};
57
58#define MSM_PM_MODE(cpu, mode_nr) ((cpu) * MSM_PM_SLEEP_MODE_NR + (mode_nr))
59
60struct msm_pm_platform_data {
61 u8 idle_supported; /* Allow device to enter mode during idle */
62 u8 suspend_supported; /* Allow device to enter mode during suspend */
63 u8 suspend_enabled; /* enabled for suspend */
64 u8 idle_enabled; /* enabled for idle low power */
65 u32 latency; /* interrupt latency in microseconds when entering
66 and exiting the low power mode */
67 u32 residency; /* time threshold in microseconds beyond which
68 staying in the low power mode saves power */
69};
70
Praveen Chidambaram42da9d22012-03-30 12:16:34 -060071extern struct msm_pm_platform_data msm_pm_sleep_modes[];
72
Maheshkumar Sivasubramanian6866b1c2011-06-07 14:20:33 -060073struct msm_pm_sleep_status_data {
74 void *base_addr;
75 uint32_t cpu_offset;
76 uint32_t mask;
77};
78
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -060079struct msm_pm_sleep_ops {
80 void *(*lowest_limits)(bool from_idle,
81 enum msm_pm_sleep_mode sleep_mode, uint32_t latency_us,
82 uint32_t sleep_us, uint32_t *power);
83 int (*enter_sleep)(uint32_t sclk_count, void *limits,
84 bool from_idle, bool notify_rpm);
85 void (*exit_sleep)(void *limits, bool from_idle,
86 bool notify_rpm, bool collapsed);
87};
88
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070089void msm_pm_set_platform_data(struct msm_pm_platform_data *data, int count);
Murali Nalajala2a0bbda2012-03-28 12:12:54 +053090void msm_pm_set_irq_extns(struct msm_pm_irq_calls *irq_calls);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091int msm_pm_idle_prepare(struct cpuidle_device *dev);
92int msm_pm_idle_enter(enum msm_pm_sleep_mode sleep_mode);
Mahesh Sivasubramaniand23add12011-11-18 14:30:11 -070093void msm_pm_cpu_enter_lowpower(unsigned int cpu);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094
Maheshkumar Sivasubramanian6866b1c2011-06-07 14:20:33 -060095void __init msm_pm_init_sleep_status_data(
96 struct msm_pm_sleep_status_data *sleep_data);
Praveen Chidambaram3895bde2012-05-14 19:42:40 +053097
98
Matt Wagantall8c327c52012-02-01 16:51:03 -080099#ifdef CONFIG_MSM_PM8X60
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700100void msm_pm_set_rpm_wakeup_irq(unsigned int irq);
Matt Wagantall8c327c52012-02-01 16:51:03 -0800101int msm_pm_wait_cpu_shutdown(unsigned int cpu);
102bool msm_pm_verify_cpu_pc(unsigned int cpu);
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600103void msm_pm_set_sleep_ops(struct msm_pm_sleep_ops *ops);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700104#else
105static inline void msm_pm_set_rpm_wakeup_irq(unsigned int irq) {}
Matt Wagantall8c327c52012-02-01 16:51:03 -0800106static inline int msm_pm_wait_cpu_shutdown(unsigned int cpu) { return 0; }
107static inline bool msm_pm_verify_cpu_pc(unsigned int cpu) { return true; }
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600108static inline void msm_pm_set_sleep_ops(struct msm_pm_sleep_ops *ops) {}
Mahesh Sivasubramaniand23add12011-11-18 14:30:11 -0700109#endif
Mahesh Sivasubramaniand23add12011-11-18 14:30:11 -0700110#ifdef CONFIG_HOTPLUG_CPU
111int msm_platform_secondary_init(unsigned int cpu);
112#else
113static inline int msm_platform_secondary_init(unsigned int cpu) { return 0; }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700114#endif
Praveen Chidambaram3895bde2012-05-14 19:42:40 +0530115
116enum msm_pm_time_stats_id {
117 MSM_PM_STAT_REQUESTED_IDLE = 0,
118 MSM_PM_STAT_IDLE_SPIN,
119 MSM_PM_STAT_IDLE_WFI,
120 MSM_PM_STAT_RETENTION,
121 MSM_PM_STAT_IDLE_STANDALONE_POWER_COLLAPSE,
122 MSM_PM_STAT_IDLE_FAILED_STANDALONE_POWER_COLLAPSE,
123 MSM_PM_STAT_IDLE_POWER_COLLAPSE,
124 MSM_PM_STAT_IDLE_FAILED_POWER_COLLAPSE,
125 MSM_PM_STAT_SUSPEND,
126 MSM_PM_STAT_FAILED_SUSPEND,
127 MSM_PM_STAT_NOT_IDLE,
128 MSM_PM_STAT_COUNT
129};
130
131#ifdef CONFIG_MSM_IDLE_STATS
132void msm_pm_add_stats(enum msm_pm_time_stats_id *enable_stats, int size);
133void msm_pm_add_stat(enum msm_pm_time_stats_id id, int64_t t);
134#else
135static inline void msm_pm_add_stats(enum msm_pm_time_stats_id *enable_stats,
136 int size) {}
137static inline void msm_pm_add_stat(enum msm_pm_time_stats_id id, int64_t t) {}
138#endif
139
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700140#endif /* __ARCH_ARM_MACH_MSM_PM_H */