blob: 46d6d94c3cd7b83d54802f18aab3d7f35e103c86 [file] [log] [blame]
Praveen Chidambaram78499012011-11-01 17:15:17 -06001/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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_RPM_RESOURCES_H
15#define __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H
16
17#include <mach/rpm.h>
Matt Wagantall7cca4642012-02-01 16:43:24 -080018#include "pm.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019
Praveen Chidambaram78499012011-11-01 17:15:17 -060020enum {
21 MSM_RPMRS_ID_PXO_CLK = 0,
22 MSM_RPMRS_ID_L2_CACHE_CTL = 1,
23 MSM_RPMRS_ID_VDD_DIG_0 = 2,
24 MSM_RPMRS_ID_VDD_DIG_1 = 3,
25 MSM_RPMRS_ID_VDD_MEM_0 = 4,
26 MSM_RPMRS_ID_VDD_MEM_1 = 5,
27 MSM_RPMRS_ID_RPM_CTL = 6,
28 MSM_RPMRS_ID_LAST,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070029};
30
31enum {
32 MSM_RPMRS_PXO_OFF = 0,
33 MSM_RPMRS_PXO_ON = 1,
34};
35
36enum {
37 MSM_RPMRS_L2_CACHE_HSFS_OPEN = 0,
38 MSM_RPMRS_L2_CACHE_GDHS = 1,
39 MSM_RPMRS_L2_CACHE_RETENTION = 2,
40 MSM_RPMRS_L2_CACHE_ACTIVE = 3,
41};
42
Praveen Chidambaram9dfa8712011-09-14 16:25:01 -060043enum {
44 MSM_RPMRS_MASK_RPM_CTL_CPU_HALT = 1,
45 MSM_RPMRS_MASK_RPM_CTL_MULTI_TIER = 2,
46};
47
Praveen Chidambaram78499012011-11-01 17:15:17 -060048enum {
49 MSM_RPMRS_VDD_MEM_RET_LOW = 0,
50 MSM_RPMRS_VDD_MEM_RET_HIGH = 1,
51 MSM_RPMRS_VDD_MEM_ACTIVE = 2,
52 MSM_RPMRS_VDD_MEM_MAX = 3,
53 MSM_RPMRS_VDD_MEM_LAST,
54};
55
56enum {
57 MSM_RPMRS_VDD_DIG_RET_LOW = 0,
58 MSM_RPMRS_VDD_DIG_RET_HIGH = 1,
59 MSM_RPMRS_VDD_DIG_ACTIVE = 2,
60 MSM_RPMRS_VDD_DIG_MAX = 3,
61 MSM_RPMRS_VDD_DIG_LAST,
62};
63
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064#define MSM_RPMRS_LIMITS(_pxo, _l2, _vdd_upper_b, _vdd) { \
65 MSM_RPMRS_PXO_##_pxo, \
66 MSM_RPMRS_L2_CACHE_##_l2, \
67 MSM_RPMRS_VDD_MEM_##_vdd_upper_b, \
68 MSM_RPMRS_VDD_MEM_##_vdd, \
69 MSM_RPMRS_VDD_DIG_##_vdd_upper_b, \
70 MSM_RPMRS_VDD_DIG_##_vdd, \
71 {0}, {0}, \
72}
73
Praveen Chidambaram78499012011-11-01 17:15:17 -060074struct msm_rpmrs_limits {
75 uint32_t pxo;
76 uint32_t l2_cache;
77 uint32_t vdd_mem_upper_bound;
78 uint32_t vdd_mem;
79 uint32_t vdd_dig_upper_bound;
80 uint32_t vdd_dig;
81
82 uint32_t latency_us[NR_CPUS];
83 uint32_t power[NR_CPUS];
84};
85
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070086struct msm_rpmrs_level {
87 enum msm_pm_sleep_mode sleep_mode;
88 struct msm_rpmrs_limits rs_limits;
89 bool available;
90 uint32_t latency_us;
91 uint32_t steady_state_power;
92 uint32_t energy_overhead;
93 uint32_t time_overhead_us;
94};
95
Praveen Chidambaram78499012011-11-01 17:15:17 -060096struct msm_rpmrs_platform_data {
97 struct msm_rpmrs_level *levels;
98 unsigned int num_levels;
99 unsigned int vdd_mem_levels[MSM_RPMRS_VDD_MEM_LAST];
100 unsigned int vdd_dig_levels[MSM_RPMRS_VDD_DIG_LAST];
101 unsigned int vdd_mask;
102 unsigned int rpmrs_target_id[MSM_RPMRS_ID_LAST];
103};
104
Vikram Mulukutlabe97fbe2012-05-16 21:36:33 -0700105#if defined(CONFIG_MSM_RPM)
106
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700107int msm_rpmrs_set(int ctx, struct msm_rpm_iv_pair *req, int count);
108int msm_rpmrs_set_noirq(int ctx, struct msm_rpm_iv_pair *req, int count);
Praveen Chidambaram9dfa8712011-09-14 16:25:01 -0600109int msm_rpmrs_set_bits_noirq(int ctx, struct msm_rpm_iv_pair *req, int count,
110 int *mask);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700111
112static inline int msm_rpmrs_set_nosleep(
113 int ctx, struct msm_rpm_iv_pair *req, int count)
114{
115 unsigned long flags;
116 int rc;
117
118 local_irq_save(flags);
119 rc = msm_rpmrs_set_noirq(ctx, req, count);
120 local_irq_restore(flags);
121
122 return rc;
123}
124
125int msm_rpmrs_clear(int ctx, struct msm_rpm_iv_pair *req, int count);
126int msm_rpmrs_clear_noirq(int ctx, struct msm_rpm_iv_pair *req, int count);
127
128static inline int msm_rpmrs_clear_nosleep(
129 int ctx, struct msm_rpm_iv_pair *req, int count)
130{
131 unsigned long flags;
132 int rc;
133
134 local_irq_save(flags);
135 rc = msm_rpmrs_clear_noirq(ctx, req, count);
136 local_irq_restore(flags);
137
138 return rc;
139}
140
141void msm_rpmrs_show_resources(void);
Praveen Chidambaram78499012011-11-01 17:15:17 -0600142int msm_rpmrs_levels_init(struct msm_rpmrs_platform_data *data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700143
Vikram Mulukutlabe97fbe2012-05-16 21:36:33 -0700144#else
145
146static inline int msm_rpmrs_set(int ctx, struct msm_rpm_iv_pair *req,
147 int count)
148{
149 return -ENODEV;
150}
151
152static inline int msm_rpmrs_set_noirq(int ctx, struct msm_rpm_iv_pair *req,
153 int count)
154{
155 return -ENODEV;
156}
157
158static inline int msm_rpmrs_set_bits_noirq(int ctx, struct msm_rpm_iv_pair *req,
159 int count, int *mask)
160{
161 return -ENODEV;
162}
163
164static inline int msm_rpmrs_set_nosleep(
165 int ctx, struct msm_rpm_iv_pair *req, int count)
166{
167 return -ENODEV;
168}
169
170static inline int msm_rpmrs_clear(int ctx, struct msm_rpm_iv_pair *req,
171 int count)
172{
173 return -ENODEV;
174}
175
176static inline int msm_rpmrs_clear_noirq(int ctx, struct msm_rpm_iv_pair *req,
177 int count)
178{
179 return -ENODEV;
180}
181
182static inline int msm_rpmrs_clear_nosleep(
183 int ctx, struct msm_rpm_iv_pair *req, int count)
184{
185 return -ENODEV;
186}
187
188static inline struct msm_rpmrs_limits *msm_rpmrs_lowest_limits(
189 bool from_idle, enum msm_pm_sleep_mode sleep_mode, uint32_t latency_us,
190 uint32_t sleep_us)
191{
192 return NULL;
193}
194
195static inline int msm_rpmrs_enter_sleep(uint32_t sclk_count,
196 struct msm_rpmrs_limits *limits, bool from_idle, bool notify_rpm)
197{
198 return -ENODEV;
199}
200
201static inline void msm_rpmrs_exit_sleep(struct msm_rpmrs_limits *limits,
202 bool from_idle, bool notify_rpm, bool collapsed)
203{
204 return;
205}
206
207static inline int msm_rpmrs_levels_init(struct msm_rpmrs_platform_data *data)
208{
209 return -ENODEV;
210}
211
212#endif /* CONFIG_MSM_RPM */
213
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700214#endif /* __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H */