OMAP3: remove OPP interfaces from OMAP PM layer
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / plat-omap / include / plat / omap-pm.h
blob62c3fe918ab21674fed25f99d7dbce020066f0b4
1 /*
2 * omap-pm.h - OMAP power management interface
4 * Copyright (C) 2008-2010 Texas Instruments, Inc.
5 * Copyright (C) 2008-2010 Nokia Corporation
6 * Paul Walmsley
8 * Interface developed by (in alphabetical order): Karthik Dasu, Jouni
9 * Högander, Tony Lindgren, Rajendra Nayak, Sakari Poussa,
10 * Veeramanikandan Raju, Anand Sawant, Igor Stoppa, Paul Walmsley,
11 * Richard Woodruff
14 #ifndef ASM_ARM_ARCH_OMAP_OMAP_PM_H
15 #define ASM_ARM_ARCH_OMAP_OMAP_PM_H
17 #include <linux/device.h>
18 #include <linux/cpufreq.h>
19 #include <linux/clk.h>
20 #include <linux/opp.h>
22 #include "powerdomain.h"
25 * agent_id values for use with omap_pm_set_min_bus_tput():
27 * OCP_INITIATOR_AGENT is only valid for devices that can act as
28 * initiators -- it represents the device's L3 interconnect
29 * connection. OCP_TARGET_AGENT represents the device's L4
30 * interconnect connection.
32 #define OCP_TARGET_AGENT 1
33 #define OCP_INITIATOR_AGENT 2
35 /**
36 * omap_pm_if_early_init - OMAP PM init code called before clock fw init
37 * @mpu_opp_table: array ptr to struct omap_opp for MPU
38 * @dsp_opp_table: array ptr to struct omap_opp for DSP
39 * @l3_opp_table : array ptr to struct omap_opp for CORE
41 * Initialize anything that must be configured before the clock
42 * framework starts. The "_if_" is to avoid name collisions with the
43 * PM idle-loop code.
45 #ifdef CONFIG_OMAP_PM_NONE
46 #define omap_pm_if_early_init() 0
47 #else
48 int __init omap_pm_if_early_init(void);
49 #endif
51 /**
52 * omap_pm_if_init - OMAP PM init code called after clock fw init
54 * The main initialization code. OPP tables are passed in here. The
55 * "_if_" is to avoid name collisions with the PM idle-loop code.
57 #ifdef CONFIG_OMAP_PM_NONE
58 #define omap_pm_if_init() 0
59 #else
60 int __init omap_pm_if_init(void);
61 #endif
63 /**
64 * omap_pm_if_exit - OMAP PM exit code
66 * Exit code; currently unused. The "_if_" is to avoid name
67 * collisions with the PM idle-loop code.
69 void omap_pm_if_exit(void);
72 * Device-driver-originated constraints (via board-*.c files, platform_data)
76 /**
77 * omap_pm_set_max_mpu_wakeup_lat - set the maximum MPU wakeup latency
78 * @dev: struct device * requesting the constraint
79 * @t: maximum MPU wakeup latency in microseconds
81 * Request that the maximum interrupt latency for the MPU to be no
82 * greater than @t microseconds. "Interrupt latency" in this case is
83 * defined as the elapsed time from the occurrence of a hardware or
84 * timer interrupt to the time when the device driver's interrupt
85 * service routine has been entered by the MPU.
87 * It is intended that underlying PM code will use this information to
88 * determine what power state to put the MPU powerdomain into, and
89 * possibly the CORE powerdomain as well, since interrupt handling
90 * code currently runs from SDRAM. Advanced PM or board*.c code may
91 * also configure interrupt controller priorities, OCP bus priorities,
92 * CPU speed(s), etc.
94 * This function will not affect device wakeup latency, e.g., time
95 * elapsed from when a device driver enables a hardware device with
96 * clk_enable(), to when the device is ready for register access or
97 * other use. To control this device wakeup latency, use
98 * omap_pm_set_max_dev_wakeup_lat()
100 * Multiple calls to omap_pm_set_max_mpu_wakeup_lat() will replace the
101 * previous t value. To remove the latency target for the MPU, call
102 * with t = -1.
104 * XXX This constraint will be deprecated soon in favor of the more
105 * general omap_pm_set_max_dev_wakeup_lat()
107 * Returns -EINVAL for an invalid argument, -ERANGE if the constraint
108 * is not satisfiable, or 0 upon success.
110 int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t);
114 * omap_pm_set_min_bus_tput - set minimum bus throughput needed by device
115 * @dev: struct device * requesting the constraint
116 * @tbus_id: interconnect to operate on (OCP_{INITIATOR,TARGET}_AGENT)
117 * @r: minimum throughput (in KiB/s)
119 * Request that the minimum data throughput on the OCP interconnect
120 * attached to device @dev interconnect agent @tbus_id be no less
121 * than @r KiB/s.
123 * It is expected that the OMAP PM or bus code will use this
124 * information to set the interconnect clock to run at the lowest
125 * possible speed that satisfies all current system users. The PM or
126 * bus code will adjust the estimate based on its model of the bus, so
127 * device driver authors should attempt to specify an accurate
128 * quantity for their device use case, and let the PM or bus code
129 * overestimate the numbers as necessary to handle request/response
130 * latency, other competing users on the system, etc. On OMAP2/3, if
131 * a driver requests a minimum L4 interconnect speed constraint, the
132 * code will also need to add an minimum L3 interconnect speed
133 * constraint,
135 * Multiple calls to omap_pm_set_min_bus_tput() will replace the
136 * previous rate value for this device. To remove the interconnect
137 * throughput restriction for this device, call with r = 0.
139 * Returns -EINVAL for an invalid argument, -ERANGE if the constraint
140 * is not satisfiable, or 0 upon success.
142 int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r);
146 * omap_pm_set_max_dev_wakeup_lat - set the maximum device enable latency
147 * @req_dev: struct device * requesting the constraint, or NULL if none
148 * @dev: struct device * to set the constraint one
149 * @t: maximum device wakeup latency in microseconds
151 * Request that the maximum amount of time necessary for a device @dev
152 * to become accessible after its clocks are enabled should be no
153 * greater than @t microseconds. Specifically, this represents the
154 * time from when a device driver enables device clocks with
155 * clk_enable(), to when the register reads and writes on the device
156 * will succeed. This function should be called before clk_disable()
157 * is called, since the power state transition decision may be made
158 * during clk_disable().
160 * It is intended that underlying PM code will use this information to
161 * determine what power state to put the powerdomain enclosing this
162 * device into.
164 * Multiple calls to omap_pm_set_max_dev_wakeup_lat() will replace the
165 * previous wakeup latency values for this device. To remove the
166 * wakeup latency restriction for this device, call with t = -1.
168 * Returns -EINVAL for an invalid argument, -ERANGE if the constraint
169 * is not satisfiable, or 0 upon success.
171 int omap_pm_set_max_dev_wakeup_lat(struct device *req_dev, struct device *dev,
172 long t);
176 * omap_pm_set_max_sdma_lat - set the maximum system DMA transfer start latency
177 * @dev: struct device *
178 * @t: maximum DMA transfer start latency in microseconds
180 * Request that the maximum system DMA transfer start latency for this
181 * device 'dev' should be no greater than 't' microseconds. "DMA
182 * transfer start latency" here is defined as the elapsed time from
183 * when a device (e.g., McBSP) requests that a system DMA transfer
184 * start or continue, to the time at which data starts to flow into
185 * that device from the system DMA controller.
187 * It is intended that underlying PM code will use this information to
188 * determine what power state to put the CORE powerdomain into.
190 * Since system DMA transfers may not involve the MPU, this function
191 * will not affect MPU wakeup latency. Use set_max_cpu_lat() to do
192 * so. Similarly, this function will not affect device wakeup latency
193 * -- use set_max_dev_wakeup_lat() to affect that.
195 * Multiple calls to set_max_sdma_lat() will replace the previous t
196 * value for this device. To remove the maximum DMA latency for this
197 * device, call with t = -1.
199 * Returns -EINVAL for an invalid argument, -ERANGE if the constraint
200 * is not satisfiable, or 0 upon success.
202 int omap_pm_set_max_sdma_lat(struct device *dev, long t);
206 * omap_pm_set_min_clk_rate - set minimum clock rate requested by @dev
207 * @dev: struct device * requesting the constraint
208 * @clk: struct clk * to set the minimum rate constraint on
209 * @r: minimum rate in Hz
211 * Request that the minimum clock rate on the device @dev's clk @clk
212 * be no less than @r Hz.
214 * It is expected that the OMAP PM code will use this information to
215 * find an OPP or clock setting that will satisfy this clock rate
216 * constraint, along with any other applicable system constraints on
217 * the clock rate or corresponding voltage, etc.
219 * omap_pm_set_min_clk_rate() differs from the clock code's
220 * clk_set_rate() in that it considers other constraints before taking
221 * any hardware action, and may change a system OPP rather than just a
222 * clock rate. clk_set_rate() is intended to be a low-level
223 * interface.
225 * omap_pm_set_min_clk_rate() is easily open to abuse. A better API
226 * would be something like "omap_pm_set_min_dev_performance()";
227 * however, there is no easily-generalizable concept of performance
228 * that applies to all devices. Only a device (and possibly the
229 * device subsystem) has both the subsystem-specific knowledge, and
230 * the hardware IP block-specific knowledge, to translate a constraint
231 * on "touchscreen sampling accuracy" or "number of pixels or polygons
232 * rendered per second" to a clock rate. This translation can be
233 * dependent on the hardware IP block's revision, or firmware version,
234 * and the driver is the only code on the system that has this
235 * information and can know how to translate that into a clock rate.
237 * The intended use-case for this function is for userspace or other
238 * kernel code to communicate a particular performance requirement to
239 * a subsystem; then for the subsystem to communicate that requirement
240 * to something that is meaningful to the device driver; then for the
241 * device driver to convert that requirement to a clock rate, and to
242 * then call omap_pm_set_min_clk_rate().
244 * Users of this function (such as device drivers) should not simply
245 * call this function with some high clock rate to ensure "high
246 * performance." Rather, the device driver should take a performance
247 * constraint from its subsystem, such as "render at least X polygons
248 * per second," and use some formula or table to convert that into a
249 * clock rate constraint given the hardware type and hardware
250 * revision. Device drivers or subsystems should not assume that they
251 * know how to make a power/performance tradeoff - some device use
252 * cases may tolerate a lower-fidelity device function for lower power
253 * consumption; others may demand a higher-fidelity device function,
254 * no matter what the power consumption.
256 * Multiple calls to omap_pm_set_min_clk_rate() will replace the
257 * previous rate value for the device @dev. To remove the minimum clock
258 * rate constraint for the device, call with r = 0.
260 * Returns -EINVAL for an invalid argument, -ERANGE if the constraint
261 * is not satisfiable, or 0 upon success.
263 int omap_pm_set_min_clk_rate(struct device *dev, struct clk *c, long r);
266 * DSP Bridge-specific constraints
270 * omap_pm_dsp_get_opp_table - get OPP->DSP clock frequency table
272 * Intended for use by DSPBridge. Returns an array of OPP->DSP clock
273 * frequency entries. The final item in the array should have .rate =
274 * .opp_id = 0.
276 const struct omap_opp *omap_pm_dsp_get_opp_table(void);
279 * omap_pm_dsp_set_min_opp - receive desired OPP target ID from DSP Bridge
280 * @opp_id: target DSP OPP ID
282 * Set a minimum OPP ID for the DSP. This is intended to be called
283 * only from the DSP Bridge MPU-side driver. Unfortunately, the only
284 * information that code receives from the DSP/BIOS load estimator is the
285 * target OPP ID; hence, this interface. No return value.
287 void omap_pm_dsp_set_min_opp(u8 opp_id);
290 * omap_pm_dsp_get_opp - report the current DSP OPP ID
292 * Report the current OPP for the DSP. Since on OMAP3, the DSP and
293 * MPU share a single voltage domain, the OPP ID returned back may
294 * represent a higher DSP speed than the OPP requested via
295 * omap_pm_dsp_set_min_opp().
297 * Returns the current VDD1 OPP ID, or 0 upon error.
299 u8 omap_pm_dsp_get_opp(void);
303 * CPUFreq-originated constraint
305 * In the future, this should be handled by custom OPP clocktype
306 * functions.
310 * omap_pm_cpu_get_freq_table - return a cpufreq_frequency_table array ptr
312 * Provide a frequency table usable by CPUFreq for the current chip/board.
313 * Returns a pointer to a struct cpufreq_frequency_table array or NULL
314 * upon error.
316 struct cpufreq_frequency_table **omap_pm_cpu_get_freq_table(void);
319 * omap_pm_cpu_set_freq - set the current minimum MPU frequency
320 * @f: MPU frequency in Hz
322 * Set the current minimum CPU frequency. The actual CPU frequency
323 * used could end up higher if the DSP requested a higher OPP.
324 * Intended to be called by plat-omap/cpu_omap.c:omap_target(). No
325 * return value.
327 void omap_pm_cpu_set_freq(unsigned long f);
330 * omap_pm_cpu_get_freq - report the current CPU frequency
332 * Returns the current MPU frequency, or 0 upon error.
334 unsigned long omap_pm_cpu_get_freq(void);
338 * Device context loss tracking
342 * omap_pm_get_dev_context_loss_count - return count of times dev has lost ctx
343 * @dev: struct device *
345 * This function returns the number of times that the device @dev has
346 * lost its internal context. This generally occurs on a powerdomain
347 * transition to OFF. Drivers use this as an optimization to avoid restoring
348 * context if the device hasn't lost it. To use, drivers should initially
349 * call this in their context save functions and store the result. Early in
350 * the driver's context restore function, the driver should call this function
351 * again, and compare the result to the stored counter. If they differ, the
352 * driver must restore device context. If the number of context losses
353 * exceeds the maximum positive integer, the function will wrap to 0 and
354 * continue counting. Returns the number of context losses for this device,
355 * or -EINVAL upon error.
357 int omap_pm_get_dev_context_loss_count(struct device *dev);
360 #endif