blob: b0414f90c6e3dd59b018890f38da923f91cdd3a5 [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
29struct omap_opp *dsp_opps;
30struct omap_opp *mpu_opps;
31struct omap_opp *l3_opps;
32
33/*
34 * Device-driver-originated constraints (via board-*.c files)
35 */
36
Paul Walmsley564889c2010-07-26 16:34:34 -060037int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t)
Paul Walmsleyc0407a92009-09-03 20:14:01 +030038{
39 if (!dev || t < -1) {
Paul Walmsley564889c2010-07-26 16:34:34 -060040 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
41 return -EINVAL;
Paul Walmsleyc0407a92009-09-03 20:14:01 +030042 };
43
44 if (t == -1)
45 pr_debug("OMAP PM: remove max MPU wakeup latency constraint: "
46 "dev %s\n", dev_name(dev));
47 else
48 pr_debug("OMAP PM: add max MPU wakeup latency constraint: "
49 "dev %s, t = %ld usec\n", dev_name(dev), t);
50
51 /*
52 * For current Linux, this needs to map the MPU to a
53 * powerdomain, then go through the list of current max lat
54 * constraints on the MPU and find the smallest. If
55 * the latency constraint has changed, the code should
56 * recompute the state to enter for the next powerdomain
57 * state.
58 *
59 * TI CDP code can call constraint_set here.
60 */
Paul Walmsley564889c2010-07-26 16:34:34 -060061
62 return 0;
Paul Walmsleyc0407a92009-09-03 20:14:01 +030063}
64
Paul Walmsley564889c2010-07-26 16:34:34 -060065int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r)
Paul Walmsleyc0407a92009-09-03 20:14:01 +030066{
67 if (!dev || (agent_id != OCP_INITIATOR_AGENT &&
68 agent_id != OCP_TARGET_AGENT)) {
Paul Walmsley564889c2010-07-26 16:34:34 -060069 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
70 return -EINVAL;
Paul Walmsleyc0407a92009-09-03 20:14:01 +030071 };
72
73 if (r == 0)
74 pr_debug("OMAP PM: remove min bus tput constraint: "
75 "dev %s for agent_id %d\n", dev_name(dev), agent_id);
76 else
77 pr_debug("OMAP PM: add min bus tput constraint: "
78 "dev %s for agent_id %d: rate %ld KiB\n",
79 dev_name(dev), agent_id, r);
80
81 /*
82 * This code should model the interconnect and compute the
83 * required clock frequency, convert that to a VDD2 OPP ID, then
84 * set the VDD2 OPP appropriately.
85 *
86 * TI CDP code can call constraint_set here on the VDD2 OPP.
87 */
Paul Walmsley564889c2010-07-26 16:34:34 -060088
89 return 0;
Paul Walmsleyc0407a92009-09-03 20:14:01 +030090}
91
Paul Walmsley564889c2010-07-26 16:34:34 -060092int omap_pm_set_max_dev_wakeup_lat(struct device *req_dev, struct device *dev,
93 long t)
Paul Walmsleyc0407a92009-09-03 20:14:01 +030094{
Paul Walmsley564889c2010-07-26 16:34:34 -060095 if (!req_dev || !dev || t < -1) {
96 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
97 return -EINVAL;
Paul Walmsleyc0407a92009-09-03 20:14:01 +030098 };
99
100 if (t == -1)
101 pr_debug("OMAP PM: remove max device latency constraint: "
102 "dev %s\n", dev_name(dev));
103 else
104 pr_debug("OMAP PM: add max device latency constraint: "
105 "dev %s, t = %ld usec\n", dev_name(dev), t);
106
107 /*
108 * For current Linux, this needs to map the device to a
109 * powerdomain, then go through the list of current max lat
110 * constraints on that powerdomain and find the smallest. If
111 * the latency constraint has changed, the code should
112 * recompute the state to enter for the next powerdomain
113 * state. Conceivably, this code should also determine
114 * whether to actually disable the device clocks or not,
115 * depending on how long it takes to re-enable the clocks.
116 *
117 * TI CDP code can call constraint_set here.
118 */
Paul Walmsley564889c2010-07-26 16:34:34 -0600119
120 return 0;
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300121}
122
Paul Walmsley564889c2010-07-26 16:34:34 -0600123int omap_pm_set_max_sdma_lat(struct device *dev, long t)
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300124{
125 if (!dev || t < -1) {
Paul Walmsley564889c2010-07-26 16:34:34 -0600126 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
127 return -EINVAL;
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300128 };
129
130 if (t == -1)
131 pr_debug("OMAP PM: remove max DMA latency constraint: "
132 "dev %s\n", dev_name(dev));
133 else
134 pr_debug("OMAP PM: add max DMA latency constraint: "
135 "dev %s, t = %ld usec\n", dev_name(dev), t);
136
137 /*
138 * For current Linux PM QOS params, this code should scan the
139 * list of maximum CPU and DMA latencies and select the
140 * smallest, then set cpu_dma_latency pm_qos_param
141 * accordingly.
142 *
143 * For future Linux PM QOS params, with separate CPU and DMA
144 * latency params, this code should just set the dma_latency param.
145 *
146 * TI CDP code can call constraint_set here.
147 */
148
Paul Walmsley564889c2010-07-26 16:34:34 -0600149 return 0;
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300150}
151
152
153/*
154 * DSP Bridge-specific constraints
155 */
156
157const struct omap_opp *omap_pm_dsp_get_opp_table(void)
158{
159 pr_debug("OMAP PM: DSP request for OPP table\n");
160
161 /*
162 * Return DSP frequency table here: The final item in the
163 * array should have .rate = .opp_id = 0.
164 */
165
166 return NULL;
167}
168
169void omap_pm_dsp_set_min_opp(u8 opp_id)
170{
171 if (opp_id == 0) {
172 WARN_ON(1);
173 return;
174 }
175
176 pr_debug("OMAP PM: DSP requests minimum VDD1 OPP to be %d\n", opp_id);
177
178 /*
179 *
180 * For l-o dev tree, our VDD1 clk is keyed on OPP ID, so we
181 * can just test to see which is higher, the CPU's desired OPP
182 * ID or the DSP's desired OPP ID, and use whichever is
183 * highest.
184 *
185 * In CDP12.14+, the VDD1 OPP custom clock that controls the DSP
186 * rate is keyed on MPU speed, not the OPP ID. So we need to
187 * map the OPP ID to the MPU speed for use with clk_set_rate()
188 * if it is higher than the current OPP clock rate.
189 *
190 */
191}
192
193
194u8 omap_pm_dsp_get_opp(void)
195{
196 pr_debug("OMAP PM: DSP requests current DSP OPP ID\n");
197
198 /*
199 * For l-o dev tree, call clk_get_rate() on VDD1 OPP clock
200 *
201 * CDP12.14+:
202 * Call clk_get_rate() on the OPP custom clock, map that to an
203 * OPP ID using the tables defined in board-*.c/chip-*.c files.
204 */
205
206 return 0;
207}
208
209/*
210 * CPUFreq-originated constraint
211 *
212 * In the future, this should be handled by custom OPP clocktype
213 * functions.
214 */
215
216struct cpufreq_frequency_table **omap_pm_cpu_get_freq_table(void)
217{
218 pr_debug("OMAP PM: CPUFreq request for frequency table\n");
219
220 /*
221 * Return CPUFreq frequency table here: loop over
222 * all VDD1 clkrates, pull out the mpu_ck frequencies, build
223 * table
224 */
225
226 return NULL;
227}
228
229void omap_pm_cpu_set_freq(unsigned long f)
230{
231 if (f == 0) {
232 WARN_ON(1);
233 return;
234 }
235
236 pr_debug("OMAP PM: CPUFreq requests CPU frequency to be set to %lu\n",
237 f);
238
239 /*
240 * For l-o dev tree, determine whether MPU freq or DSP OPP id
241 * freq is higher. Find the OPP ID corresponding to the
242 * higher frequency. Call clk_round_rate() and clk_set_rate()
243 * on the OPP custom clock.
244 *
245 * CDP should just be able to set the VDD1 OPP clock rate here.
246 */
247}
248
249unsigned long omap_pm_cpu_get_freq(void)
250{
251 pr_debug("OMAP PM: CPUFreq requests current CPU frequency\n");
252
253 /*
254 * Call clk_get_rate() on the mpu_ck.
255 */
256
257 return 0;
258}
259
260/*
261 * Device context loss tracking
262 */
263
264int omap_pm_get_dev_context_loss_count(struct device *dev)
265{
266 if (!dev) {
267 WARN_ON(1);
268 return -EINVAL;
269 };
270
271 pr_debug("OMAP PM: returning context loss count for dev %s\n",
272 dev_name(dev));
273
274 /*
275 * Map the device to the powerdomain. Return the powerdomain
276 * off counter.
277 */
278
279 return 0;
280}
281
282
283/* Should be called before clk framework init */
284int __init omap_pm_if_early_init(struct omap_opp *mpu_opp_table,
285 struct omap_opp *dsp_opp_table,
286 struct omap_opp *l3_opp_table)
287{
288 mpu_opps = mpu_opp_table;
289 dsp_opps = dsp_opp_table;
290 l3_opps = l3_opp_table;
291 return 0;
292}
293
294/* Must be called after clock framework is initialized */
295int __init omap_pm_if_init(void)
296{
297 return 0;
298}
299
300void omap_pm_if_exit(void)
301{
302 /* Deallocate CPUFreq frequency table here */
303}
304