omap-pm-noop.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. #include <linux/platform_device.h>
  22. #include "omap_device.h"
  23. #include "omap-pm.h"
  24. static bool off_mode_enabled;
  25. static int dummy_context_loss_counter;
  26. /*
  27. * Device-driver-originated constraints (via board-*.c files)
  28. */
  29. int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t)
  30. {
  31. if (!dev || t < -1) {
  32. WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
  33. return -EINVAL;
  34. }
  35. if (t == -1)
  36. pr_debug("OMAP PM: remove max MPU wakeup latency constraint: dev %s\n",
  37. dev_name(dev));
  38. else
  39. pr_debug("OMAP PM: add max MPU wakeup latency constraint: dev %s, t = %ld usec\n",
  40. dev_name(dev), t);
  41. /*
  42. * For current Linux, this needs to map the MPU to a
  43. * powerdomain, then go through the list of current max lat
  44. * constraints on the MPU and find the smallest. If
  45. * the latency constraint has changed, the code should
  46. * recompute the state to enter for the next powerdomain
  47. * state.
  48. *
  49. * TI CDP code can call constraint_set here.
  50. */
  51. return 0;
  52. }
  53. int 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(1, "OMAP PM: %s: invalid parameter(s)", __func__);
  58. return -EINVAL;
  59. }
  60. if (r == 0)
  61. pr_debug("OMAP PM: remove min bus tput constraint: dev %s for agent_id %d\n",
  62. dev_name(dev), agent_id);
  63. else
  64. pr_debug("OMAP PM: add min bus tput constraint: dev %s for agent_id %d: rate %ld KiB\n",
  65. dev_name(dev), agent_id, r);
  66. /*
  67. * This code should model the interconnect and compute the
  68. * required clock frequency, convert that to a VDD2 OPP ID, then
  69. * set the VDD2 OPP appropriately.
  70. *
  71. * TI CDP code can call constraint_set here on the VDD2 OPP.
  72. */
  73. return 0;
  74. }
  75. /*
  76. * DSP Bridge-specific constraints
  77. */
  78. /**
  79. * omap_pm_enable_off_mode - notify OMAP PM that off-mode is enabled
  80. *
  81. * Intended for use only by OMAP PM core code to notify this layer
  82. * that off mode has been enabled.
  83. */
  84. void omap_pm_enable_off_mode(void)
  85. {
  86. off_mode_enabled = true;
  87. }
  88. /**
  89. * omap_pm_disable_off_mode - notify OMAP PM that off-mode is disabled
  90. *
  91. * Intended for use only by OMAP PM core code to notify this layer
  92. * that off mode has been disabled.
  93. */
  94. void omap_pm_disable_off_mode(void)
  95. {
  96. off_mode_enabled = false;
  97. }
  98. /*
  99. * Device context loss tracking
  100. */
  101. #ifdef CONFIG_ARCH_OMAP2PLUS
  102. int omap_pm_get_dev_context_loss_count(struct device *dev)
  103. {
  104. struct platform_device *pdev = to_platform_device(dev);
  105. int count;
  106. if (WARN_ON(!dev))
  107. return -ENODEV;
  108. if (dev->pm_domain == &omap_device_pm_domain) {
  109. count = omap_device_get_context_loss_count(pdev);
  110. } else {
  111. WARN_ONCE(off_mode_enabled, "omap_pm: using dummy context loss counter; device %s should be converted to omap_device",
  112. dev_name(dev));
  113. count = dummy_context_loss_counter;
  114. if (off_mode_enabled) {
  115. count++;
  116. /*
  117. * Context loss count has to be a non-negative value.
  118. * Clear the sign bit to get a value range from 0 to
  119. * INT_MAX.
  120. */
  121. count &= INT_MAX;
  122. dummy_context_loss_counter = count;
  123. }
  124. }
  125. pr_debug("OMAP PM: context loss count for dev %s = %d\n",
  126. dev_name(dev), count);
  127. return count;
  128. }
  129. #else
  130. int omap_pm_get_dev_context_loss_count(struct device *dev)
  131. {
  132. return dummy_context_loss_counter;
  133. }
  134. #endif
  135. /* Should be called before clk framework init */
  136. int __init omap_pm_if_early_init(void)
  137. {
  138. return 0;
  139. }
  140. /* Must be called after clock framework is initialized */
  141. int __init omap_pm_if_init(void)
  142. {
  143. return 0;
  144. }