blob: caafbdd410e4602c3f58b64e1b1626d92c8272db [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 {
47 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_SUSPEND,
48 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
49 MSM_PM_SLEEP_MODE_APPS_SLEEP,
50 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT,
51 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
52 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN,
53 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
54 MSM_PM_SLEEP_MODE_NR
55};
56
57#define MSM_PM_MODE(cpu, mode_nr) ((cpu) * MSM_PM_SLEEP_MODE_NR + (mode_nr))
58
59struct msm_pm_platform_data {
60 u8 idle_supported; /* Allow device to enter mode during idle */
61 u8 suspend_supported; /* Allow device to enter mode during suspend */
62 u8 suspend_enabled; /* enabled for suspend */
63 u8 idle_enabled; /* enabled for idle low power */
64 u32 latency; /* interrupt latency in microseconds when entering
65 and exiting the low power mode */
66 u32 residency; /* time threshold in microseconds beyond which
67 staying in the low power mode saves power */
68};
69
Maheshkumar Sivasubramanian6866b1c2011-06-07 14:20:33 -060070struct msm_pm_sleep_status_data {
71 void *base_addr;
72 uint32_t cpu_offset;
73 uint32_t mask;
74};
75
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076void msm_pm_set_platform_data(struct msm_pm_platform_data *data, int count);
Murali Nalajala2a0bbda2012-03-28 12:12:54 +053077void msm_pm_set_irq_extns(struct msm_pm_irq_calls *irq_calls);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070078int msm_pm_idle_prepare(struct cpuidle_device *dev);
79int msm_pm_idle_enter(enum msm_pm_sleep_mode sleep_mode);
Mahesh Sivasubramaniand23add12011-11-18 14:30:11 -070080void msm_pm_cpu_enter_lowpower(unsigned int cpu);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070081
Maheshkumar Sivasubramanian6866b1c2011-06-07 14:20:33 -060082void __init msm_pm_init_sleep_status_data(
83 struct msm_pm_sleep_status_data *sleep_data);
Matt Wagantall8c327c52012-02-01 16:51:03 -080084#ifdef CONFIG_MSM_PM8X60
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070085void msm_pm_set_rpm_wakeup_irq(unsigned int irq);
Matt Wagantall8c327c52012-02-01 16:51:03 -080086int msm_pm_wait_cpu_shutdown(unsigned int cpu);
87bool msm_pm_verify_cpu_pc(unsigned int cpu);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070088#else
89static inline void msm_pm_set_rpm_wakeup_irq(unsigned int irq) {}
Matt Wagantall8c327c52012-02-01 16:51:03 -080090static inline int msm_pm_wait_cpu_shutdown(unsigned int cpu) { return 0; }
91static inline bool msm_pm_verify_cpu_pc(unsigned int cpu) { return true; }
Mahesh Sivasubramaniand23add12011-11-18 14:30:11 -070092#endif
93
94#ifdef CONFIG_HOTPLUG_CPU
95int msm_platform_secondary_init(unsigned int cpu);
96#else
97static inline int msm_platform_secondary_init(unsigned int cpu) { return 0; }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070098#endif
99#endif /* __ARCH_ARM_MACH_MSM_PM_H */