]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/arm/plat-omap/omap-pm-noop.c
OMAP2+: powerdomain: move header file from plat-omap to mach-omap2
[karo-tx-linux.git] / arch / arm / plat-omap / omap-pm-noop.c
1 /*
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 */
25 #include <plat/omap-pm.h>
26
27 /*
28  * Device-driver-originated constraints (via board-*.c files)
29  */
30
31 int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t)
32 {
33         if (!dev || t < -1) {
34                 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
35                 return -EINVAL;
36         };
37
38         if (t == -1)
39                 pr_debug("OMAP PM: remove max MPU wakeup latency constraint: "
40                          "dev %s\n", dev_name(dev));
41         else
42                 pr_debug("OMAP PM: add max MPU wakeup latency constraint: "
43                          "dev %s, t = %ld usec\n", dev_name(dev), t);
44
45         /*
46          * For current Linux, this needs to map the MPU to a
47          * powerdomain, then go through the list of current max lat
48          * constraints on the MPU and find the smallest.  If
49          * the latency constraint has changed, the code should
50          * recompute the state to enter for the next powerdomain
51          * state.
52          *
53          * TI CDP code can call constraint_set here.
54          */
55
56         return 0;
57 }
58
59 int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r)
60 {
61         if (!dev || (agent_id != OCP_INITIATOR_AGENT &&
62             agent_id != OCP_TARGET_AGENT)) {
63                 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
64                 return -EINVAL;
65         };
66
67         if (r == 0)
68                 pr_debug("OMAP PM: remove min bus tput constraint: "
69                          "dev %s for agent_id %d\n", dev_name(dev), agent_id);
70         else
71                 pr_debug("OMAP PM: add min bus tput constraint: "
72                          "dev %s for agent_id %d: rate %ld KiB\n",
73                          dev_name(dev), agent_id, r);
74
75         /*
76          * This code should model the interconnect and compute the
77          * required clock frequency, convert that to a VDD2 OPP ID, then
78          * set the VDD2 OPP appropriately.
79          *
80          * TI CDP code can call constraint_set here on the VDD2 OPP.
81          */
82
83         return 0;
84 }
85
86 int omap_pm_set_max_dev_wakeup_lat(struct device *req_dev, struct device *dev,
87                                    long t)
88 {
89         if (!req_dev || !dev || t < -1) {
90                 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
91                 return -EINVAL;
92         };
93
94         if (t == -1)
95                 pr_debug("OMAP PM: remove max device latency constraint: "
96                          "dev %s\n", dev_name(dev));
97         else
98                 pr_debug("OMAP PM: add max device latency constraint: "
99                          "dev %s, t = %ld usec\n", dev_name(dev), t);
100
101         /*
102          * For current Linux, this needs to map the device to a
103          * powerdomain, then go through the list of current max lat
104          * constraints on that powerdomain and find the smallest.  If
105          * the latency constraint has changed, the code should
106          * recompute the state to enter for the next powerdomain
107          * state.  Conceivably, this code should also determine
108          * whether to actually disable the device clocks or not,
109          * depending on how long it takes to re-enable the clocks.
110          *
111          * TI CDP code can call constraint_set here.
112          */
113
114         return 0;
115 }
116
117 int omap_pm_set_max_sdma_lat(struct device *dev, long t)
118 {
119         if (!dev || t < -1) {
120                 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
121                 return -EINVAL;
122         };
123
124         if (t == -1)
125                 pr_debug("OMAP PM: remove max DMA latency constraint: "
126                          "dev %s\n", dev_name(dev));
127         else
128                 pr_debug("OMAP PM: add max DMA latency constraint: "
129                          "dev %s, t = %ld usec\n", dev_name(dev), t);
130
131         /*
132          * For current Linux PM QOS params, this code should scan the
133          * list of maximum CPU and DMA latencies and select the
134          * smallest, then set cpu_dma_latency pm_qos_param
135          * accordingly.
136          *
137          * For future Linux PM QOS params, with separate CPU and DMA
138          * latency params, this code should just set the dma_latency param.
139          *
140          * TI CDP code can call constraint_set here.
141          */
142
143         return 0;
144 }
145
146 int omap_pm_set_min_clk_rate(struct device *dev, struct clk *c, long r)
147 {
148         if (!dev || !c || r < 0) {
149                 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
150                 return -EINVAL;
151         }
152
153         if (r == 0)
154                 pr_debug("OMAP PM: remove min clk rate constraint: "
155                          "dev %s\n", dev_name(dev));
156         else
157                 pr_debug("OMAP PM: add min clk rate constraint: "
158                          "dev %s, rate = %ld Hz\n", dev_name(dev), r);
159
160         /*
161          * Code in a real implementation should keep track of these
162          * constraints on the clock, and determine the highest minimum
163          * clock rate.  It should iterate over each OPP and determine
164          * whether the OPP will result in a clock rate that would
165          * satisfy this constraint (and any other PM constraint in effect
166          * at that time).  Once it finds the lowest-voltage OPP that
167          * meets those conditions, it should switch to it, or return
168          * an error if the code is not capable of doing so.
169          */
170
171         return 0;
172 }
173
174 /*
175  * DSP Bridge-specific constraints
176  */
177
178 const struct omap_opp *omap_pm_dsp_get_opp_table(void)
179 {
180         pr_debug("OMAP PM: DSP request for OPP table\n");
181
182         /*
183          * Return DSP frequency table here:  The final item in the
184          * array should have .rate = .opp_id = 0.
185          */
186
187         return NULL;
188 }
189
190 void omap_pm_dsp_set_min_opp(u8 opp_id)
191 {
192         if (opp_id == 0) {
193                 WARN_ON(1);
194                 return;
195         }
196
197         pr_debug("OMAP PM: DSP requests minimum VDD1 OPP to be %d\n", opp_id);
198
199         /*
200          *
201          * For l-o dev tree, our VDD1 clk is keyed on OPP ID, so we
202          * can just test to see which is higher, the CPU's desired OPP
203          * ID or the DSP's desired OPP ID, and use whichever is
204          * highest.
205          *
206          * In CDP12.14+, the VDD1 OPP custom clock that controls the DSP
207          * rate is keyed on MPU speed, not the OPP ID.  So we need to
208          * map the OPP ID to the MPU speed for use with clk_set_rate()
209          * if it is higher than the current OPP clock rate.
210          *
211          */
212 }
213
214
215 u8 omap_pm_dsp_get_opp(void)
216 {
217         pr_debug("OMAP PM: DSP requests current DSP OPP ID\n");
218
219         /*
220          * For l-o dev tree, call clk_get_rate() on VDD1 OPP clock
221          *
222          * CDP12.14+:
223          * Call clk_get_rate() on the OPP custom clock, map that to an
224          * OPP ID using the tables defined in board-*.c/chip-*.c files.
225          */
226
227         return 0;
228 }
229
230 /*
231  * CPUFreq-originated constraint
232  *
233  * In the future, this should be handled by custom OPP clocktype
234  * functions.
235  */
236
237 struct cpufreq_frequency_table **omap_pm_cpu_get_freq_table(void)
238 {
239         pr_debug("OMAP PM: CPUFreq request for frequency table\n");
240
241         /*
242          * Return CPUFreq frequency table here: loop over
243          * all VDD1 clkrates, pull out the mpu_ck frequencies, build
244          * table
245          */
246
247         return NULL;
248 }
249
250 void omap_pm_cpu_set_freq(unsigned long f)
251 {
252         if (f == 0) {
253                 WARN_ON(1);
254                 return;
255         }
256
257         pr_debug("OMAP PM: CPUFreq requests CPU frequency to be set to %lu\n",
258                  f);
259
260         /*
261          * For l-o dev tree, determine whether MPU freq or DSP OPP id
262          * freq is higher.  Find the OPP ID corresponding to the
263          * higher frequency.  Call clk_round_rate() and clk_set_rate()
264          * on the OPP custom clock.
265          *
266          * CDP should just be able to set the VDD1 OPP clock rate here.
267          */
268 }
269
270 unsigned long omap_pm_cpu_get_freq(void)
271 {
272         pr_debug("OMAP PM: CPUFreq requests current CPU frequency\n");
273
274         /*
275          * Call clk_get_rate() on the mpu_ck.
276          */
277
278         return 0;
279 }
280
281 /*
282  * Device context loss tracking
283  */
284
285 int omap_pm_get_dev_context_loss_count(struct device *dev)
286 {
287         if (!dev) {
288                 WARN_ON(1);
289                 return -EINVAL;
290         };
291
292         pr_debug("OMAP PM: returning context loss count for dev %s\n",
293                  dev_name(dev));
294
295         /*
296          * Map the device to the powerdomain.  Return the powerdomain
297          * off counter.
298          */
299
300         return 0;
301 }
302
303
304 /* Should be called before clk framework init */
305 int __init omap_pm_if_early_init(void)
306 {
307         return 0;
308 }
309
310 /* Must be called after clock framework is initialized */
311 int __init omap_pm_if_init(void)
312 {
313         return 0;
314 }
315
316 void omap_pm_if_exit(void)
317 {
318         /* Deallocate CPUFreq frequency table here */
319 }
320