omap-pm-noop.c 7.8 KB

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