1===================== 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 36 (*pdata->set_max_mpu_wakeup_lat)(struct device *dev, unsigned long t) 37 382. Set the maximum device wakeup latency:: 39 40 (*pdata->set_max_dev_wakeup_lat)(struct device *dev, unsigned long t) 41 423. Set the maximum system DMA transfer start latency (CORE pwrdm):: 43 44 (*pdata->set_max_sdma_lat)(struct device *dev, long t) 45 464. Set the minimum bus throughput needed by a device:: 47 48 (*pdata->set_min_bus_tput)(struct device *dev, u8 agent_id, unsigned long r) 49 505. Return the number of times the device has lost context:: 51 52 (*pdata->get_dev_context_loss_count)(struct device *dev) 53 54 55Further documentation for all OMAP PM interface functions can be 56found in arch/arm/plat-omap/include/mach/omap-pm.h. 57 58 59The OMAP PM layer is intended to be temporary 60--------------------------------------------- 61 62The intention is that eventually the Linux PM QoS layer should support 63the range of power management features present in OMAP3. As this 64happens, existing drivers using the OMAP PM interface can be modified 65to use the Linux PM QoS code; and the OMAP PM interface can disappear. 66 67 68Driver usage of the OMAP PM functions 69------------------------------------- 70 71As the 'pdata' in the above examples indicates, these functions are 72exposed to drivers through function pointers in driver .platform_data 73structures. The function pointers are initialized by the `board-*.c` 74files to point to the corresponding OMAP PM functions: 75 76- set_max_dev_wakeup_lat will point to 77 omap_pm_set_max_dev_wakeup_lat(), etc. Other architectures which do 78 not support these functions should leave these function pointers set 79 to NULL. Drivers should use the following idiom:: 80 81 if (pdata->set_max_dev_wakeup_lat) 82 (*pdata->set_max_dev_wakeup_lat)(dev, t); 83 84The most common usage of these functions will probably be to specify 85the maximum time from when an interrupt occurs, to when the device 86becomes accessible. To accomplish this, driver writers should use the 87set_max_mpu_wakeup_lat() function to constrain the MPU wakeup 88latency, and the set_max_dev_wakeup_lat() function to constrain the 89device wakeup latency (from clk_enable() to accessibility). For 90example:: 91 92 /* Limit MPU wakeup latency */ 93 if (pdata->set_max_mpu_wakeup_lat) 94 (*pdata->set_max_mpu_wakeup_lat)(dev, tc); 95 96 /* Limit device powerdomain wakeup latency */ 97 if (pdata->set_max_dev_wakeup_lat) 98 (*pdata->set_max_dev_wakeup_lat)(dev, td); 99 100 /* total wakeup latency in this example: (tc + td) */ 101 102The PM parameters can be overwritten by calling the function again 103with the new value. The settings can be removed by calling the 104function with a t argument of -1 (except in the case of 105set_max_bus_tput(), which should be called with an r argument of 0). 106 107The fifth function above, omap_pm_get_dev_context_loss_count(), 108is intended as an optimization to allow drivers to determine whether the 109device has lost its internal context. If context has been lost, the 110driver must restore its internal context before proceeding. 111 112 113Other specialized interface functions 114------------------------------------- 115 116The five functions listed above are intended to be usable by any 117device driver. DSPBridge and CPUFreq have a few special requirements. 118DSPBridge expresses target DSP performance levels in terms of OPP IDs. 119CPUFreq expresses target MPU performance levels in terms of MPU 120frequency. The OMAP PM interface contains functions for these 121specialized cases to convert that input information (OPPs/MPU 122frequency) into the form that the underlying power management 123implementation needs: 124 1256. `(*pdata->dsp_get_opp_table)(void)` 126 1277. `(*pdata->dsp_set_min_opp)(u8 opp_id)` 128 1298. `(*pdata->dsp_get_opp)(void)` 130 1319. `(*pdata->cpu_get_freq_table)(void)` 132 13310. `(*pdata->cpu_set_freq)(unsigned long f)` 134 13511. `(*pdata->cpu_get_freq)(void)` 136 137Customizing OPP for platform 138============================ 139Defining CONFIG_PM should enable OPP layer for the silicon 140and the registration of OPP table should take place automatically. 141However, in special cases, the default OPP table may need to be 142tweaked, for e.g.: 143 144 * enable default OPPs which are disabled by default, but which 145 could be enabled on a platform 146 * Disable an unsupported OPP on the platform 147 * Define and add a custom opp table entry 148 in these cases, the board file needs to do additional steps as follows: 149 150arch/arm/mach-omapx/board-xyz.c:: 151 152 #include "pm.h" 153 .... 154 static void __init omap_xyz_init_irq(void) 155 { 156 .... 157 /* Initialize the default table */ 158 omapx_opp_init(); 159 /* Do customization to the defaults */ 160 .... 161 } 162 163NOTE: 164 omapx_opp_init will be omap3_opp_init or as required 165 based on the omap family. 166