omap-pm-noop.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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 <mach/omap-pm.h>
  23. #include <mach/powerdomain.h>
  24. struct omap_opp *dsp_opps;
  25. struct omap_opp *mpu_opps;
  26. struct omap_opp *l3_opps;
  27. /*
  28. * Device-driver-originated constraints (via board-*.c files)
  29. */
  30. void omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t)
  31. {
  32. if (!dev || t < -1) {
  33. WARN_ON(1);
  34. return;
  35. };
  36. if (t == -1)
  37. pr_debug("OMAP PM: remove max MPU wakeup latency constraint: "
  38. "dev %s\n", dev_name(dev));
  39. else
  40. pr_debug("OMAP PM: add max MPU wakeup latency constraint: "
  41. "dev %s, t = %ld usec\n", dev_name(dev), t);
  42. /*
  43. * For current Linux, this needs to map the MPU to a
  44. * powerdomain, then go through the list of current max lat
  45. * constraints on the MPU and find the smallest. If
  46. * the latency constraint has changed, the code should
  47. * recompute the state to enter for the next powerdomain
  48. * state.
  49. *
  50. * TI CDP code can call constraint_set here.
  51. */
  52. }
  53. void omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r)
  54. {
  55. if (!dev || (agent_id != OCP_INITIATOR_AGENT &&
  56. agent_id != OCP_TARGET_AGENT)) {
  57. WARN_ON(1);
  58. return;
  59. };
  60. if (r == 0)
  61. pr_debug("OMAP PM: remove min bus tput constraint: "
  62. "dev %s for agent_id %d\n", dev_name(dev), agent_id);
  63. else
  64. pr_debug("OMAP PM: add min bus tput constraint: "
  65. "dev %s for agent_id %d: rate %ld KiB\n",
  66. dev_name(dev), agent_id, r);
  67. /*
  68. * This code should model the interconnect and compute the
  69. * required clock frequency, convert that to a VDD2 OPP ID, then
  70. * set the VDD2 OPP appropriately.
  71. *
  72. * TI CDP code can call constraint_set here on the VDD2 OPP.
  73. */
  74. }
  75. void omap_pm_set_max_dev_wakeup_lat(struct device *dev, long t)
  76. {
  77. if (!dev || t < -1) {
  78. WARN_ON(1);
  79. return;
  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. }
  100. void omap_pm_set_max_sdma_lat(struct device *dev, long t)
  101. {
  102. if (!dev || t < -1) {
  103. WARN_ON(1);
  104. return;
  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. }
  124. /*
  125. * DSP Bridge-specific constraints
  126. */
  127. const struct omap_opp *omap_pm_dsp_get_opp_table(void)
  128. {
  129. pr_debug("OMAP PM: DSP request for OPP table\n");
  130. /*
  131. * Return DSP frequency table here: The final item in the
  132. * array should have .rate = .opp_id = 0.
  133. */
  134. return NULL;
  135. }
  136. void omap_pm_dsp_set_min_opp(u8 opp_id)
  137. {
  138. if (opp_id == 0) {
  139. WARN_ON(1);
  140. return;
  141. }
  142. pr_debug("OMAP PM: DSP requests minimum VDD1 OPP to be %d\n", opp_id);
  143. /*
  144. *
  145. * For l-o dev tree, our VDD1 clk is keyed on OPP ID, so we
  146. * can just test to see which is higher, the CPU's desired OPP
  147. * ID or the DSP's desired OPP ID, and use whichever is
  148. * highest.
  149. *
  150. * In CDP12.14+, the VDD1 OPP custom clock that controls the DSP
  151. * rate is keyed on MPU speed, not the OPP ID. So we need to
  152. * map the OPP ID to the MPU speed for use with clk_set_rate()
  153. * if it is higher than the current OPP clock rate.
  154. *
  155. */
  156. }
  157. u8 omap_pm_dsp_get_opp(void)
  158. {
  159. pr_debug("OMAP PM: DSP requests current DSP OPP ID\n");
  160. /*
  161. * For l-o dev tree, call clk_get_rate() on VDD1 OPP clock
  162. *
  163. * CDP12.14+:
  164. * Call clk_get_rate() on the OPP custom clock, map that to an
  165. * OPP ID using the tables defined in board-*.c/chip-*.c files.
  166. */
  167. return 0;
  168. }
  169. /*
  170. * CPUFreq-originated constraint
  171. *
  172. * In the future, this should be handled by custom OPP clocktype
  173. * functions.
  174. */
  175. struct cpufreq_frequency_table **omap_pm_cpu_get_freq_table(void)
  176. {
  177. pr_debug("OMAP PM: CPUFreq request for frequency table\n");
  178. /*
  179. * Return CPUFreq frequency table here: loop over
  180. * all VDD1 clkrates, pull out the mpu_ck frequencies, build
  181. * table
  182. */
  183. return NULL;
  184. }
  185. void omap_pm_cpu_set_freq(unsigned long f)
  186. {
  187. if (f == 0) {
  188. WARN_ON(1);
  189. return;
  190. }
  191. pr_debug("OMAP PM: CPUFreq requests CPU frequency to be set to %lu\n",
  192. f);
  193. /*
  194. * For l-o dev tree, determine whether MPU freq or DSP OPP id
  195. * freq is higher. Find the OPP ID corresponding to the
  196. * higher frequency. Call clk_round_rate() and clk_set_rate()
  197. * on the OPP custom clock.
  198. *
  199. * CDP should just be able to set the VDD1 OPP clock rate here.
  200. */
  201. }
  202. unsigned long omap_pm_cpu_get_freq(void)
  203. {
  204. pr_debug("OMAP PM: CPUFreq requests current CPU frequency\n");
  205. /*
  206. * Call clk_get_rate() on the mpu_ck.
  207. */
  208. return 0;
  209. }
  210. /*
  211. * Device context loss tracking
  212. */
  213. int omap_pm_get_dev_context_loss_count(struct device *dev)
  214. {
  215. if (!dev) {
  216. WARN_ON(1);
  217. return -EINVAL;
  218. };
  219. pr_debug("OMAP PM: returning context loss count for dev %s\n",
  220. dev_name(dev));
  221. /*
  222. * Map the device to the powerdomain. Return the powerdomain
  223. * off counter.
  224. */
  225. return 0;
  226. }
  227. /* Should be called before clk framework init */
  228. int __init omap_pm_if_early_init(struct omap_opp *mpu_opp_table,
  229. struct omap_opp *dsp_opp_table,
  230. struct omap_opp *l3_opp_table)
  231. {
  232. mpu_opps = mpu_opp_table;
  233. dsp_opps = dsp_opp_table;
  234. l3_opps = l3_opp_table;
  235. return 0;
  236. }
  237. /* Must be called after clock framework is initialized */
  238. int __init omap_pm_if_init(void)
  239. {
  240. return 0;
  241. }
  242. void omap_pm_if_exit(void)
  243. {
  244. /* Deallocate CPUFreq frequency table here */
  245. }