omap-pm-noop.c 7.8 KB

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