blob: 120832fffe2041f5bfca3fab670ddce40964b565 [file] [log] [blame]
Girish Mahadevan40abbe12012-04-25 14:58:13 -06001/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#ifndef __ARCH_ARM_MACH_MSM_LPM_RESOURCES_H
15#define __ARCH_ARM_MACH_MSM_LPM_RESOURCES_H
16
17#include "pm.h"
18
19enum {
20 MSM_LPM_PXO_OFF = 0,
21 MSM_LPM_PXO_ON = 1,
22};
23
24enum {
25 MSM_LPM_L2_CACHE_HSFS_OPEN = 0,
26 MSM_LPM_L2_CACHE_GDHS = 1,
27 MSM_LPM_L2_CACHE_RETENTION = 2,
28 MSM_LPM_L2_CACHE_ACTIVE = 3,
29};
30
31struct msm_rpmrs_limits {
32 uint32_t pxo;
33 uint32_t l2_cache;
34 uint32_t vdd_mem_upper_bound;
35 uint32_t vdd_mem_lower_bound;
36 uint32_t vdd_dig_upper_bound;
37 uint32_t vdd_dig_lower_bound;
38
39 uint32_t latency_us[NR_CPUS];
40 uint32_t power[NR_CPUS];
41};
42
43struct msm_rpmrs_level {
44 enum msm_pm_sleep_mode sleep_mode;
45 struct msm_rpmrs_limits rs_limits;
46 bool available;
47 uint32_t latency_us;
48 uint32_t steady_state_power;
49 uint32_t energy_overhead;
50 uint32_t time_overhead_us;
51};
52
53#ifdef CONFIG_MSM_RPM_SMD
54
55/**
56 * msm_lpm_level_beyond_limit() - Check if the resources in a low power level
57 * is beyond the limits of the driver votes received for those resources.This
58 * function is used by lpm_levels to eliminate any low power level that cannot
59 * be entered.
60 *
61 * @limits: pointer to the resource limits of a low power level.
62 *
63 * returns true if the resource limits are beyond driver resource votes.
64 * false otherwise.
65 */
66bool msm_lpm_level_beyond_limit(struct msm_rpmrs_limits *limits);
67
68/**
69 * msm_lpmrs_enter_sleep() - Enter sleep flushes the sleep votes of low power
70 * resources to the RPM driver, also configure the MPM if needed depending
71 * on the low power mode being entered. L2 low power mode is also set in
72 * this function.
73
Mahesh Sivasubramanian2efbc352012-07-18 14:15:44 -060074 * @sclk_count: wakeup counter for RPM.
Girish Mahadevan40abbe12012-04-25 14:58:13 -060075 * @limits: pointer to the resource limits of the low power mode being entered.
76 * @from_idle: bool to determine if this call being made as a part of
77 * idle power collapse.
78 * @notify_rpm: bool that informs if this is an RPM notified power collapse.
79 *
80 * returns 0 on success.
81 */
Mahesh Sivasubramanian2efbc352012-07-18 14:15:44 -060082int msm_lpmrs_enter_sleep(uint32_t sclk_count, struct msm_rpmrs_limits *limits,
Girish Mahadevan40abbe12012-04-25 14:58:13 -060083 bool from_idle, bool notify_rpm);
84
85/**
86 * msm_lpmrs_exit_sleep() - Exit sleep, reset the MPM and L2 mode.
Girish Mahadevan40abbe12012-04-25 14:58:13 -060087 * @ limits: pointer to resource limits of the most recent low power mode.
88 * @from_idle: bool to determine if this call being made as a part of
89 * idle power collapse.
90 * @notify_rpm: bool that informs if this is an RPM notified power collapse.
Girish Mahadevana9964a52012-06-29 10:14:09 -060091 * @collapsed: bool that informs if the Krait was power collapsed.
Girish Mahadevan40abbe12012-04-25 14:58:13 -060092 */
Girish Mahadevana9964a52012-06-29 10:14:09 -060093void msm_lpmrs_exit_sleep(struct msm_rpmrs_limits *limits,
94 bool from_idle, bool notify_rpm, bool collapsed);
Girish Mahadevan40abbe12012-04-25 14:58:13 -060095/**
96 * msm_lpmrs_module_init() - Init function that parses the device tree to
97 * get the low power resource attributes and registers with RPM driver for
98 * callback notification.
99 *
100 * returns 0 on success.
101 */
102int __init msm_lpmrs_module_init(void);
103
104#else
105static inline bool msm_lpm_level_beyond_limit(struct msm_rpmrs_limits *limits)
106{
107 return true;
108}
109
Mahesh Sivasubramanian2efbc352012-07-18 14:15:44 -0600110static inline int msm_lpmrs_enter_sleep(uint32_t sclk_count,
111 struct msm_rpmrs_limits *limits, bool from_idle, bool notify_rpm)
Girish Mahadevan40abbe12012-04-25 14:58:13 -0600112{
113 return 0;
114}
115
Girish Mahadevana9964a52012-06-29 10:14:09 -0600116static inline void msm_lpmrs_exit_sleep(struct msm_rpmrs_limits *limits,
117 bool from_idle, bool notify_rpm, bool collapsed)
Girish Mahadevan40abbe12012-04-25 14:58:13 -0600118{
119 return;
120}
121
122static inline int __init msm_lpmrs_module_init(void)
123{
124 return 0;
125}
126#endif /* CONFIG_MSM_RPM_SMD */
127
128#endif