blob: ca75abb18068da5a3554f34eebe0dd6f2c7654ba [file] [log] [blame]
Paul Walmsleyc0407a92009-09-03 20:14:01 +03001/*
2 * omap-pm-noop.c - OMAP power management interface - dummy version
3 *
4 * This code implements the OMAP power management interface to
5 * drivers, CPUIdle, CPUFreq, and DSP Bridge. It is strictly for
6 * debug/demonstration use, as it does nothing but printk() whenever a
7 * function is called (when DEBUG is defined, below)
8 *
9 * Copyright (C) 2008-2009 Texas Instruments, Inc.
10 * Copyright (C) 2008-2009 Nokia Corporation
11 * Paul Walmsley
12 *
13 * Interface developed by (in alphabetical order):
14 * Karthik Dasu, Tony Lindgren, Rajendra Nayak, Sakari Poussa, Veeramanikandan
15 * Raju, Anand Sawant, Igor Stoppa, Paul Walmsley, Richard Woodruff
16 */
17
18#undef DEBUG
19
20#include <linux/init.h>
21#include <linux/cpufreq.h>
22#include <linux/device.h>
23
24/* Interface documentation is in mach/omap-pm.h */
Tony Lindgrence491cf2009-10-20 09:40:47 -070025#include <plat/omap-pm.h>
Paul Walmsleyc0407a92009-09-03 20:14:01 +030026
Tony Lindgrence491cf2009-10-20 09:40:47 -070027#include <plat/powerdomain.h>
Paul Walmsleyc0407a92009-09-03 20:14:01 +030028
Paul Walmsleyc0407a92009-09-03 20:14:01 +030029/*
30 * Device-driver-originated constraints (via board-*.c files)
31 */
32
Paul Walmsley564889c2010-07-26 16:34:34 -060033int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t)
Paul Walmsleyc0407a92009-09-03 20:14:01 +030034{
35 if (!dev || t < -1) {
Paul Walmsley564889c2010-07-26 16:34:34 -060036 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
37 return -EINVAL;
Paul Walmsleyc0407a92009-09-03 20:14:01 +030038 };
39
40 if (t == -1)
41 pr_debug("OMAP PM: remove max MPU wakeup latency constraint: "
42 "dev %s\n", dev_name(dev));
43 else
44 pr_debug("OMAP PM: add max MPU wakeup latency constraint: "
45 "dev %s, t = %ld usec\n", dev_name(dev), t);
46
47 /*
48 * For current Linux, this needs to map the MPU to a
49 * powerdomain, then go through the list of current max lat
50 * constraints on the MPU and find the smallest. If
51 * the latency constraint has changed, the code should
52 * recompute the state to enter for the next powerdomain
53 * state.
54 *
55 * TI CDP code can call constraint_set here.
56 */
Paul Walmsley564889c2010-07-26 16:34:34 -060057
58 return 0;
Paul Walmsleyc0407a92009-09-03 20:14:01 +030059}
60
Paul Walmsley564889c2010-07-26 16:34:34 -060061int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r)
Paul Walmsleyc0407a92009-09-03 20:14:01 +030062{
63 if (!dev || (agent_id != OCP_INITIATOR_AGENT &&
64 agent_id != OCP_TARGET_AGENT)) {
Paul Walmsley564889c2010-07-26 16:34:34 -060065 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
66 return -EINVAL;
Paul Walmsleyc0407a92009-09-03 20:14:01 +030067 };
68
69 if (r == 0)
70 pr_debug("OMAP PM: remove min bus tput constraint: "
71 "dev %s for agent_id %d\n", dev_name(dev), agent_id);
72 else
73 pr_debug("OMAP PM: add min bus tput constraint: "
74 "dev %s for agent_id %d: rate %ld KiB\n",
75 dev_name(dev), agent_id, r);
76
77 /*
78 * This code should model the interconnect and compute the
79 * required clock frequency, convert that to a VDD2 OPP ID, then
80 * set the VDD2 OPP appropriately.
81 *
82 * TI CDP code can call constraint_set here on the VDD2 OPP.
83 */
Paul Walmsley564889c2010-07-26 16:34:34 -060084
85 return 0;
Paul Walmsleyc0407a92009-09-03 20:14:01 +030086}
87
Paul Walmsley564889c2010-07-26 16:34:34 -060088int omap_pm_set_max_dev_wakeup_lat(struct device *req_dev, struct device *dev,
89 long t)
Paul Walmsleyc0407a92009-09-03 20:14:01 +030090{
Paul Walmsley564889c2010-07-26 16:34:34 -060091 if (!req_dev || !dev || t < -1) {
92 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
93 return -EINVAL;
Paul Walmsleyc0407a92009-09-03 20:14:01 +030094 };
95
96 if (t == -1)
97 pr_debug("OMAP PM: remove max device latency constraint: "
98 "dev %s\n", dev_name(dev));
99 else
100 pr_debug("OMAP PM: add max device latency constraint: "
101 "dev %s, t = %ld usec\n", dev_name(dev), t);
102
103 /*
104 * For current Linux, this needs to map the device to a
105 * powerdomain, then go through the list of current max lat
106 * constraints on that powerdomain and find the smallest. If
107 * the latency constraint has changed, the code should
108 * recompute the state to enter for the next powerdomain
109 * state. Conceivably, this code should also determine
110 * whether to actually disable the device clocks or not,
111 * depending on how long it takes to re-enable the clocks.
112 *
113 * TI CDP code can call constraint_set here.
114 */
Paul Walmsley564889c2010-07-26 16:34:34 -0600115
116 return 0;
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300117}
118
Paul Walmsley564889c2010-07-26 16:34:34 -0600119int omap_pm_set_max_sdma_lat(struct device *dev, long t)
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300120{
121 if (!dev || t < -1) {
Paul Walmsley564889c2010-07-26 16:34:34 -0600122 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
123 return -EINVAL;
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300124 };
125
126 if (t == -1)
127 pr_debug("OMAP PM: remove max DMA latency constraint: "
128 "dev %s\n", dev_name(dev));
129 else
130 pr_debug("OMAP PM: add max DMA latency constraint: "
131 "dev %s, t = %ld usec\n", dev_name(dev), t);
132
133 /*
134 * For current Linux PM QOS params, this code should scan the
135 * list of maximum CPU and DMA latencies and select the
136 * smallest, then set cpu_dma_latency pm_qos_param
137 * accordingly.
138 *
139 * For future Linux PM QOS params, with separate CPU and DMA
140 * latency params, this code should just set the dma_latency param.
141 *
142 * TI CDP code can call constraint_set here.
143 */
144
Paul Walmsley564889c2010-07-26 16:34:34 -0600145 return 0;
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300146}
147
Paul Walmsleyfb8ce142010-07-26 16:34:34 -0600148int omap_pm_set_min_clk_rate(struct device *dev, struct clk *c, long r)
149{
150 if (!dev || !c || r < 0) {
151 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
152 return -EINVAL;
153 }
154
155 if (r == 0)
156 pr_debug("OMAP PM: remove min clk rate constraint: "
157 "dev %s\n", dev_name(dev));
158 else
159 pr_debug("OMAP PM: add min clk rate constraint: "
160 "dev %s, rate = %ld Hz\n", dev_name(dev), r);
161
162 /*
163 * Code in a real implementation should keep track of these
164 * constraints on the clock, and determine the highest minimum
165 * clock rate. It should iterate over each OPP and determine
166 * whether the OPP will result in a clock rate that would
167 * satisfy this constraint (and any other PM constraint in effect
168 * at that time). Once it finds the lowest-voltage OPP that
169 * meets those conditions, it should switch to it, or return
170 * an error if the code is not capable of doing so.
171 */
172
173 return 0;
174}
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300175
176/*
177 * DSP Bridge-specific constraints
178 */
179
180const struct omap_opp *omap_pm_dsp_get_opp_table(void)
181{
182 pr_debug("OMAP PM: DSP request for OPP table\n");
183
184 /*
185 * Return DSP frequency table here: The final item in the
186 * array should have .rate = .opp_id = 0.
187 */
188
189 return NULL;
190}
191
192void omap_pm_dsp_set_min_opp(u8 opp_id)
193{
194 if (opp_id == 0) {
195 WARN_ON(1);
196 return;
197 }
198
199 pr_debug("OMAP PM: DSP requests minimum VDD1 OPP to be %d\n", opp_id);
200
201 /*
202 *
203 * For l-o dev tree, our VDD1 clk is keyed on OPP ID, so we
204 * can just test to see which is higher, the CPU's desired OPP
205 * ID or the DSP's desired OPP ID, and use whichever is
206 * highest.
207 *
208 * In CDP12.14+, the VDD1 OPP custom clock that controls the DSP
209 * rate is keyed on MPU speed, not the OPP ID. So we need to
210 * map the OPP ID to the MPU speed for use with clk_set_rate()
211 * if it is higher than the current OPP clock rate.
212 *
213 */
214}
215
216
217u8 omap_pm_dsp_get_opp(void)
218{
219 pr_debug("OMAP PM: DSP requests current DSP OPP ID\n");
220
221 /*
222 * For l-o dev tree, call clk_get_rate() on VDD1 OPP clock
223 *
224 * CDP12.14+:
225 * Call clk_get_rate() on the OPP custom clock, map that to an
226 * OPP ID using the tables defined in board-*.c/chip-*.c files.
227 */
228
229 return 0;
230}
231
232/*
233 * CPUFreq-originated constraint
234 *
235 * In the future, this should be handled by custom OPP clocktype
236 * functions.
237 */
238
239struct cpufreq_frequency_table **omap_pm_cpu_get_freq_table(void)
240{
241 pr_debug("OMAP PM: CPUFreq request for frequency table\n");
242
243 /*
244 * Return CPUFreq frequency table here: loop over
245 * all VDD1 clkrates, pull out the mpu_ck frequencies, build
246 * table
247 */
248
249 return NULL;
250}
251
252void omap_pm_cpu_set_freq(unsigned long f)
253{
254 if (f == 0) {
255 WARN_ON(1);
256 return;
257 }
258
259 pr_debug("OMAP PM: CPUFreq requests CPU frequency to be set to %lu\n",
260 f);
261
262 /*
263 * For l-o dev tree, determine whether MPU freq or DSP OPP id
264 * freq is higher. Find the OPP ID corresponding to the
265 * higher frequency. Call clk_round_rate() and clk_set_rate()
266 * on the OPP custom clock.
267 *
268 * CDP should just be able to set the VDD1 OPP clock rate here.
269 */
270}
271
272unsigned long omap_pm_cpu_get_freq(void)
273{
274 pr_debug("OMAP PM: CPUFreq requests current CPU frequency\n");
275
276 /*
277 * Call clk_get_rate() on the mpu_ck.
278 */
279
280 return 0;
281}
282
283/*
284 * Device context loss tracking
285 */
286
287int omap_pm_get_dev_context_loss_count(struct device *dev)
288{
289 if (!dev) {
290 WARN_ON(1);
291 return -EINVAL;
292 };
293
294 pr_debug("OMAP PM: returning context loss count for dev %s\n",
295 dev_name(dev));
296
297 /*
298 * Map the device to the powerdomain. Return the powerdomain
299 * off counter.
300 */
301
302 return 0;
303}
304
305
306/* Should be called before clk framework init */
Kevin Hilman53da4ce2010-12-09 09:13:48 -0600307int __init omap_pm_if_early_init(void)
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300308{
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300309 return 0;
310}
311
312/* Must be called after clock framework is initialized */
313int __init omap_pm_if_init(void)
314{
315 return 0;
316}
317
318void omap_pm_if_exit(void)
319{
320 /* Deallocate CPUFreq frequency table here */
321}
322