blob: 9012bb03909443e4978d9d3a9fd6bbf0f095d907 [file] [log] [blame]
Paul Walmsleyc0407a92009-09-03 20:14:01 +03001
2The OMAP PM interface
3=====================
4
5This document describes the temporary OMAP PM interface. Driver
6authors use these functions to communicate minimum latency or
7throughput constraints to the kernel power management code.
8Over time, the intention is to merge features from the OMAP PM
9interface into the Linux PM QoS code.
10
11Drivers need to express PM parameters which:
12
13- support the range of power management parameters present in the TI SRF;
14
15- separate the drivers from the underlying PM parameter
16 implementation, whether it is the TI SRF or Linux PM QoS or Linux
17 latency framework or something else;
18
19- specify PM parameters in terms of fundamental units, such as
20 latency and throughput, rather than units which are specific to OMAP
21 or to particular OMAP variants;
22
23- allow drivers which are shared with other architectures (e.g.,
24 DaVinci) to add these constraints in a way which won't affect non-OMAP
25 systems,
26
27- can be implemented immediately with minimal disruption of other
28 architectures.
29
30
31This document proposes the OMAP PM interface, including the following
32five power management functions for driver code:
33
341. Set the maximum MPU wakeup latency:
35 (*pdata->set_max_mpu_wakeup_lat)(struct device *dev, unsigned long t)
36
372. Set the maximum device wakeup latency:
38 (*pdata->set_max_dev_wakeup_lat)(struct device *dev, unsigned long t)
39
403. Set the maximum system DMA transfer start latency (CORE pwrdm):
41 (*pdata->set_max_sdma_lat)(struct device *dev, long t)
42
434. Set the minimum bus throughput needed by a device:
44 (*pdata->set_min_bus_tput)(struct device *dev, u8 agent_id, unsigned long r)
45
465. Return the number of times the device has lost context
47 (*pdata->get_dev_context_loss_count)(struct device *dev)
48
49
50Further documentation for all OMAP PM interface functions can be
51found in arch/arm/plat-omap/include/mach/omap-pm.h.
52
53
54The OMAP PM layer is intended to be temporary
55---------------------------------------------
56
57The intention is that eventually the Linux PM QoS layer should support
58the range of power management features present in OMAP3. As this
59happens, existing drivers using the OMAP PM interface can be modified
60to use the Linux PM QoS code; and the OMAP PM interface can disappear.
61
62
63Driver usage of the OMAP PM functions
64-------------------------------------
65
66As the 'pdata' in the above examples indicates, these functions are
67exposed to drivers through function pointers in driver .platform_data
68structures. The function pointers are initialized by the board-*.c
69files to point to the corresponding OMAP PM functions:
70.set_max_dev_wakeup_lat will point to
71omap_pm_set_max_dev_wakeup_lat(), etc. Other architectures which do
72not support these functions should leave these function pointers set
73to NULL. Drivers should use the following idiom:
74
75 if (pdata->set_max_dev_wakeup_lat)
76 (*pdata->set_max_dev_wakeup_lat)(dev, t);
77
78The most common usage of these functions will probably be to specify
79the maximum time from when an interrupt occurs, to when the device
80becomes accessible. To accomplish this, driver writers should use the
81set_max_mpu_wakeup_lat() function to to constrain the MPU wakeup
82latency, and the set_max_dev_wakeup_lat() function to constrain the
83device wakeup latency (from clk_enable() to accessibility). For
84example,
85
86 /* Limit MPU wakeup latency */
87 if (pdata->set_max_mpu_wakeup_lat)
88 (*pdata->set_max_mpu_wakeup_lat)(dev, tc);
89
90 /* Limit device powerdomain wakeup latency */
91 if (pdata->set_max_dev_wakeup_lat)
92 (*pdata->set_max_dev_wakeup_lat)(dev, td);
93
94 /* total wakeup latency in this example: (tc + td) */
95
96The PM parameters can be overwritten by calling the function again
97with the new value. The settings can be removed by calling the
98function with a t argument of -1 (except in the case of
99set_max_bus_tput(), which should be called with an r argument of 0).
100
101The fifth function above, omap_pm_get_dev_context_loss_count(),
102is intended as an optimization to allow drivers to determine whether the
103device has lost its internal context. If context has been lost, the
104driver must restore its internal context before proceeding.
105
106
107Other specialized interface functions
108-------------------------------------
109
110The five functions listed above are intended to be usable by any
111device driver. DSPBridge and CPUFreq have a few special requirements.
112DSPBridge expresses target DSP performance levels in terms of OPP IDs.
113CPUFreq expresses target MPU performance levels in terms of MPU
114frequency. The OMAP PM interface contains functions for these
115specialized cases to convert that input information (OPPs/MPU
116frequency) into the form that the underlying power management
117implementation needs:
118
1196. (*pdata->dsp_get_opp_table)(void)
120
1217. (*pdata->dsp_set_min_opp)(u8 opp_id)
122
1238. (*pdata->dsp_get_opp)(void)
124
1259. (*pdata->cpu_get_freq_table)(void)
126
12710. (*pdata->cpu_set_freq)(unsigned long f)
128
12911. (*pdata->cpu_get_freq)(void)
Nishanth Menonfd1478c2010-12-09 09:13:46 -0600130
131Customizing OPP for platform
132============================
133Defining CONFIG_PM should enable OPP layer for the silicon
134and the registration of OPP table should take place automatically.
135However, in special cases, the default OPP table may need to be
136tweaked, for e.g.:
137 * enable default OPPs which are disabled by default, but which
138 could be enabled on a platform
139 * Disable an unsupported OPP on the platform
140 * Define and add a custom opp table entry
141in these cases, the board file needs to do additional steps as follows:
142arch/arm/mach-omapx/board-xyz.c
143 #include "pm.h"
144 ....
145 static void __init omap_xyz_init_irq(void)
146 {
147 ....
148 /* Initialize the default table */
149 omapx_opp_init();
150 /* Do customization to the defaults */
151 ....
152 }
153NOTE: omapx_opp_init will be omap3_opp_init or as required
154based on the omap family.