rpm-regulator-private.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __ARCH_ARM_MACH_MSM_RPM_REGULATOR_INT_H
  14. #define __ARCH_ARM_MACH_MSM_RPM_REGULATOR_INT_H
  15. #include <linux/regulator/driver.h>
  16. #include <mach/rpm.h>
  17. #include <mach/rpm-regulator.h>
  18. /* Possible RPM regulator request types */
  19. enum rpm_regulator_type {
  20. RPM_REGULATOR_TYPE_LDO,
  21. RPM_REGULATOR_TYPE_SMPS,
  22. RPM_REGULATOR_TYPE_VS,
  23. RPM_REGULATOR_TYPE_NCP,
  24. RPM_REGULATOR_TYPE_CORNER,
  25. RPM_REGULATOR_TYPE_MAX = RPM_REGULATOR_TYPE_CORNER,
  26. };
  27. struct request_member {
  28. int word;
  29. unsigned int mask;
  30. int shift;
  31. };
  32. /* Possible RPM regulator request members */
  33. struct rpm_vreg_parts {
  34. struct request_member mV; /* voltage: used if voltage is in mV */
  35. struct request_member uV; /* voltage: used if voltage is in uV */
  36. struct request_member ip; /* peak current in mA */
  37. struct request_member pd; /* pull down enable */
  38. struct request_member ia; /* average current in mA */
  39. struct request_member fm; /* force mode */
  40. struct request_member pm; /* power mode */
  41. struct request_member pc; /* pin control */
  42. struct request_member pf; /* pin function */
  43. struct request_member enable_state; /* NCP and switch */
  44. struct request_member comp_mode; /* NCP */
  45. struct request_member freq; /* frequency: NCP and SMPS */
  46. struct request_member freq_clk_src; /* clock source: SMPS */
  47. struct request_member hpm; /* switch: control OCP and SS */
  48. int request_len;
  49. };
  50. struct vreg_range {
  51. int min_uV;
  52. int max_uV;
  53. int step_uV;
  54. unsigned n_voltages;
  55. };
  56. struct vreg_set_points {
  57. struct vreg_range *range;
  58. int count;
  59. unsigned n_voltages;
  60. };
  61. struct vreg {
  62. struct msm_rpm_iv_pair req[2];
  63. struct msm_rpm_iv_pair prev_active_req[2];
  64. struct msm_rpm_iv_pair prev_sleep_req[2];
  65. struct rpm_regulator_init_data pdata;
  66. struct regulator_desc rdesc;
  67. struct regulator_desc rdesc_pc;
  68. struct regulator_dev *rdev;
  69. struct regulator_dev *rdev_pc;
  70. struct vreg_set_points *set_points;
  71. struct rpm_vreg_parts *part;
  72. int type;
  73. int id;
  74. bool requires_cxo;
  75. struct mutex pc_lock;
  76. int save_uV;
  77. int mode;
  78. bool is_enabled;
  79. bool is_enabled_pc;
  80. const int hpm_min_load;
  81. int active_min_uV_vote[RPM_VREG_VOTER_COUNT];
  82. int sleep_min_uV_vote[RPM_VREG_VOTER_COUNT];
  83. };
  84. struct vreg_config {
  85. struct vreg *vregs;
  86. int vregs_len;
  87. int vreg_id_min;
  88. int vreg_id_max;
  89. int pin_func_none;
  90. int pin_func_sleep_b;
  91. unsigned int mode_lpm;
  92. unsigned int mode_hpm;
  93. struct vreg_set_points **set_points;
  94. int set_points_len;
  95. const char **label_pin_ctrl;
  96. int label_pin_ctrl_len;
  97. const char **label_pin_func;
  98. int label_pin_func_len;
  99. const char **label_force_mode;
  100. int label_force_mode_len;
  101. const char **label_power_mode;
  102. int label_power_mode_len;
  103. int (*is_real_id) (int vreg_id);
  104. int (*pc_id_to_real_id) (int vreg_id);
  105. /* Legacy options to be used with MSM8660 */
  106. int use_legacy_optimum_mode;
  107. int ia_follows_ip;
  108. };
  109. #define REQUEST_MEMBER(_word, _mask, _shift) \
  110. { \
  111. .word = _word, \
  112. .mask = _mask, \
  113. .shift = _shift, \
  114. }
  115. #define VOLTAGE_RANGE(_min_uV, _max_uV, _step_uV) \
  116. { \
  117. .min_uV = _min_uV, \
  118. .max_uV = _max_uV, \
  119. .step_uV = _step_uV, \
  120. }
  121. #define SET_POINTS(_ranges) \
  122. { \
  123. .range = _ranges, \
  124. .count = ARRAY_SIZE(_ranges), \
  125. };
  126. #define MICRO_TO_MILLI(uV) ((uV) / 1000)
  127. #define MILLI_TO_MICRO(mV) ((mV) * 1000)
  128. #if defined(CONFIG_MSM_RPM_REGULATOR) && defined(CONFIG_ARCH_MSM8X60)
  129. struct vreg_config *get_config_8660(void);
  130. #else
  131. static inline struct vreg_config *get_config_8660(void)
  132. {
  133. return NULL;
  134. }
  135. #endif
  136. #if defined(CONFIG_MSM_RPM_REGULATOR) && \
  137. (defined(CONFIG_ARCH_MSM8960) || defined(CONFIG_ARCH_APQ8064))
  138. struct vreg_config *get_config_8960(void);
  139. struct vreg_config *get_config_8960_pm8917(void);
  140. #else
  141. static inline struct vreg_config *get_config_8960(void)
  142. {
  143. return NULL;
  144. }
  145. static inline struct vreg_config *get_config_8960_pm8917(void)
  146. {
  147. return NULL;
  148. }
  149. #endif
  150. #if defined(CONFIG_MSM_RPM_REGULATOR) && defined(CONFIG_ARCH_MSM9615)
  151. struct vreg_config *get_config_9615(void);
  152. #else
  153. static inline struct vreg_config *get_config_9615(void)
  154. {
  155. return NULL;
  156. }
  157. #endif
  158. #if defined(CONFIG_MSM_RPM_REGULATOR) && defined(CONFIG_ARCH_MSM8930)
  159. struct vreg_config *get_config_8930(void);
  160. struct vreg_config *get_config_8930_pm8917(void);
  161. #else
  162. static inline struct vreg_config *get_config_8930(void)
  163. {
  164. return NULL;
  165. }
  166. static inline struct vreg_config *get_config_8930_pm8917(void)
  167. {
  168. return NULL;
  169. }
  170. #endif
  171. #endif