/include/linux/mfd/pm8xxx/misc.h

https://github.com/airy09/android_kernel_sony_apq8064 · C Header · 350 lines · 169 code · 36 blank · 145 comment · 1 complexity · a1c7f94066199230cad28b8bf2e09cf2 MD5 · raw file

  1. /*
  2. * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
  3. * Copyright (C) 2012 Sony Mobile Communications AB.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 and
  7. * only version 2 as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef __MFD_PM8XXX_MISC_H__
  15. #define __MFD_PM8XXX_MISC_H__
  16. #include <linux/err.h>
  17. #define PM8XXX_MISC_DEV_NAME "pm8xxx-misc"
  18. /**
  19. * struct pm8xxx_misc_platform_data - PM8xxx misc driver platform data
  20. * @priority: PMIC prority level in a multi-PMIC system. Lower value means
  21. * greater priority. Actions are performed from highest to lowest
  22. * priority PMIC.
  23. */
  24. struct pm8xxx_misc_platform_data {
  25. int priority;
  26. };
  27. enum pm8xxx_uart_path_sel {
  28. UART_NONE,
  29. UART_TX1_RX1,
  30. UART_TX2_RX2,
  31. UART_TX3_RX3,
  32. };
  33. enum pm8xxx_coincell_chg_voltage {
  34. PM8XXX_COINCELL_VOLTAGE_3p2V = 1,
  35. PM8XXX_COINCELL_VOLTAGE_3p1V,
  36. PM8XXX_COINCELL_VOLTAGE_3p0V,
  37. PM8XXX_COINCELL_VOLTAGE_2p5V = 16
  38. };
  39. enum pm8xxx_coincell_chg_resistor {
  40. PM8XXX_COINCELL_RESISTOR_2100_OHMS,
  41. PM8XXX_COINCELL_RESISTOR_1700_OHMS,
  42. PM8XXX_COINCELL_RESISTOR_1200_OHMS,
  43. PM8XXX_COINCELL_RESISTOR_800_OHMS
  44. };
  45. enum pm8xxx_coincell_chg_state {
  46. PM8XXX_COINCELL_CHG_DISABLE,
  47. PM8XXX_COINCELL_CHG_ENABLE
  48. };
  49. struct pm8xxx_coincell_chg {
  50. enum pm8xxx_coincell_chg_state state;
  51. enum pm8xxx_coincell_chg_voltage voltage;
  52. enum pm8xxx_coincell_chg_resistor resistor;
  53. };
  54. enum pm8xxx_smpl_delay {
  55. PM8XXX_SMPL_DELAY_0p5,
  56. PM8XXX_SMPL_DELAY_1p0,
  57. PM8XXX_SMPL_DELAY_1p5,
  58. PM8XXX_SMPL_DELAY_2p0,
  59. };
  60. enum pm8xxx_pon_config {
  61. PM8XXX_DISABLE_HARD_RESET = 0,
  62. PM8XXX_SHUTDOWN_ON_HARD_RESET,
  63. PM8XXX_RESTART_ON_HARD_RESET,
  64. };
  65. enum pm8xxx_pon_delay_config {
  66. PM8XXX_HARD_RESET_DELAY_MS_MIN = 0,
  67. PM8XXX_HARD_RESET_DELAY_MS_0 = PM8XXX_HARD_RESET_DELAY_MS_MIN,
  68. PM8XXX_HARD_RESET_DELAY_MS_10,
  69. PM8XXX_HARD_RESET_DELAY_MS_50,
  70. PM8XXX_HARD_RESET_DELAY_MS_100,
  71. PM8XXX_HARD_RESET_DELAY_MS_250,
  72. PM8XXX_HARD_RESET_DELAY_MS_500,
  73. PM8XXX_HARD_RESET_DELAY_MS_1000,
  74. PM8XXX_HARD_RESET_DELAY_MS_2000,
  75. PM8XXX_HARD_RESET_DELAY_MS_MAX,
  76. };
  77. enum pm8xxx_pon_debounce_config {
  78. PM8XXX_HARD_RESET_DEBOUNCE_MS_MIN = 0,
  79. PM8XXX_HARD_RESET_DEBOUNCE_MS_0 = PM8XXX_HARD_RESET_DEBOUNCE_MS_MIN,
  80. PM8XXX_HARD_RESET_DEBOUNCE_MS_32,
  81. PM8XXX_HARD_RESET_DEBOUNCE_MS_56,
  82. PM8XXX_HARD_RESET_DEBOUNCE_MS_80,
  83. PM8XXX_HARD_RESET_DEBOUNCE_MS_128,
  84. PM8XXX_HARD_RESET_DEBOUNCE_MS_184,
  85. PM8XXX_HARD_RESET_DEBOUNCE_MS_272,
  86. PM8XXX_HARD_RESET_DEBOUNCE_MS_408,
  87. PM8XXX_HARD_RESET_DEBOUNCE_MS_608,
  88. PM8XXX_HARD_RESET_DEBOUNCE_MS_904,
  89. PM8XXX_HARD_RESET_DEBOUNCE_MS_1352,
  90. PM8XXX_HARD_RESET_DEBOUNCE_MS_2048,
  91. PM8XXX_HARD_RESET_DEBOUNCE_MS_3072,
  92. PM8XXX_HARD_RESET_DEBOUNCE_MS_4480,
  93. PM8XXX_HARD_RESET_DEBOUNCE_MS_6720,
  94. PM8XXX_HARD_RESET_DEBOUNCE_MS_10256,
  95. PM8XXX_HARD_RESET_DEBOUNCE_MS_MAX,
  96. };
  97. enum pm8xxx_aux_clk_id {
  98. CLK_MP3_1,
  99. CLK_MP3_2,
  100. };
  101. enum pm8xxx_aux_clk_div {
  102. XO_DIV_NONE,
  103. XO_DIV_1,
  104. XO_DIV_2,
  105. XO_DIV_4,
  106. XO_DIV_8,
  107. XO_DIV_16,
  108. XO_DIV_32,
  109. XO_DIV_64,
  110. };
  111. enum pm8xxx_hsed_bias {
  112. PM8XXX_HSED_BIAS0,
  113. PM8XXX_HSED_BIAS1,
  114. PM8XXX_HSED_BIAS2,
  115. };
  116. #if defined(CONFIG_MFD_PM8XXX_MISC) || defined(CONFIG_MFD_PM8XXX_MISC_MODULE)
  117. /**
  118. * pm8xxx_reset_pwr_off - switch all PM8XXX PMIC chips attached to the system to
  119. * either reset or shutdown when they are turned off
  120. * @reset: 0 = shudown the PMICs, 1 = shutdown and then restart the PMICs
  121. *
  122. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  123. */
  124. int pm8xxx_reset_pwr_off(int reset);
  125. int pm8xxx_uart_gpio_mux_ctrl(enum pm8xxx_uart_path_sel uart_path_sel);
  126. /**
  127. * pm8xxx_coincell_chg_config - Disables or enables the coincell charger, and
  128. * configures its voltage and resistor settings.
  129. * @chg_config: Holds both voltage and resistor values, and a
  130. * switch to change the state of charger.
  131. * If state is to disable the charger then
  132. * both voltage and resistor are disregarded.
  133. *
  134. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  135. */
  136. int pm8xxx_coincell_chg_config(struct pm8xxx_coincell_chg *chg_config);
  137. /**
  138. * pm8xxx_smpl_control - enables/disables SMPL detection
  139. * @enable: 0 = shutdown PMIC on power loss, 1 = reset PMIC on power loss
  140. *
  141. * This function enables or disables the Sudden Momentary Power Loss detection
  142. * module. If SMPL detection is enabled, then when a sufficiently long power
  143. * loss event occurs, the PMIC will automatically reset itself. If SMPL
  144. * detection is disabled, then the PMIC will shutdown when power loss occurs.
  145. *
  146. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  147. */
  148. int pm8xxx_smpl_control(int enable);
  149. /**
  150. * pm8xxx_smpl_set_delay - sets the SMPL detection time delay
  151. * @delay: enum value corresponding to delay time
  152. *
  153. * This function sets the time delay of the SMPL detection module. If power
  154. * is reapplied within this interval, then the PMIC reset automatically. The
  155. * SMPL detection module must be enabled for this delay time to take effect.
  156. *
  157. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  158. */
  159. int pm8xxx_smpl_set_delay(enum pm8xxx_smpl_delay delay);
  160. /**
  161. * pm8xxx_watchdog_reset_control - enables/disables watchdog reset detection
  162. * @enable: 0 = shutdown when PS_HOLD goes low, 1 = reset when PS_HOLD goes low
  163. *
  164. * This function enables or disables the PMIC watchdog reset detection feature.
  165. * If watchdog reset detection is enabled, then the PMIC will reset itself
  166. * when PS_HOLD goes low. If it is not enabled, then the PMIC will shutdown
  167. * when PS_HOLD goes low.
  168. *
  169. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  170. */
  171. int pm8xxx_watchdog_reset_control(int enable);
  172. /**
  173. * pm8xxx_hard_reset_config - Allows different reset configurations
  174. *
  175. * config = DISABLE_HARD_RESET to disable hard reset
  176. * = SHUTDOWN_ON_HARD_RESET to turn off the system on hard reset
  177. * = RESTART_ON_HARD_RESET to restart the system on hard reset
  178. *
  179. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  180. */
  181. int pm8xxx_hard_reset_config(enum pm8xxx_pon_config config);
  182. /**
  183. * pm8xxx_hard_reset_delay_config - Set hard reset delay time
  184. *
  185. * Available delay time values are as follows:
  186. * 0, 10, 50, 100, 250, 500, 1000, 2000
  187. *
  188. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  189. */
  190. int pm8xxx_hard_reset_delay_config(enum pm8xxx_pon_delay_config config);
  191. /**
  192. * pm8xxx_hard_reset_debounce_config - Set hard reset debounce time
  193. *
  194. * Available debounce time values are as follows:
  195. * 0, 32, 56, 80, 128, 184, 272, 408, 608, 904, 1352, 2048, 3072,
  196. * 4480, 6720, 10256
  197. *
  198. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  199. */
  200. int pm8xxx_hard_reset_debounce_config(enum pm8xxx_pon_debounce_config config);
  201. /**
  202. * pm8xxx_stay_on - enables stay_on feature
  203. *
  204. * PMIC stay-on feature allows PMIC to ignore MSM PS_HOLD=low
  205. * signal so that some special functions like debugging could be
  206. * performed.
  207. *
  208. * This feature should not be used in any product release.
  209. *
  210. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  211. */
  212. int pm8xxx_stay_on(void);
  213. /**
  214. * pm8xxx_preload_dVdd - preload the dVdd regulator during off state.
  215. *
  216. * This can help to reduce fluctuations in the dVdd voltage during startup
  217. * at the cost of additional off state current draw.
  218. *
  219. * This API should only be called if dVdd startup issues are suspected.
  220. *
  221. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  222. */
  223. int pm8xxx_preload_dVdd(void);
  224. /**
  225. * pm8xxx_usb_id_pullup - Control a pullup for USB ID
  226. *
  227. * @enable: enable (1) or disable (0) the pullup
  228. *
  229. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  230. */
  231. int pm8xxx_usb_id_pullup(int enable);
  232. /**
  233. * pm8xxx_aux_clk_control - Control an auxiliary clock
  234. * @clk_id: ID of clock to be programmed, registers of XO_CNTRL2
  235. * @divider: divisor to use when configuring desired clock
  236. * @enable: enable (1) the designated clock with the supplied division,
  237. * or disable (0) the designated clock
  238. *
  239. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  240. */
  241. int pm8xxx_aux_clk_control(enum pm8xxx_aux_clk_id clk_id,
  242. enum pm8xxx_aux_clk_div divider,
  243. bool enable);
  244. /**
  245. * pm8xxx_hsed_bias_control - Control the HSED_BIAS signal
  246. * @bias: the bias line to be controlled (of the 3)
  247. * @enable: enable/disable the bias line
  248. *
  249. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  250. */
  251. int pm8xxx_hsed_bias_control(enum pm8xxx_hsed_bias bias, bool enable);
  252. /**
  253. * pm8xxx_read_register - Read a PMIC register
  254. * @addr: PMIC register address
  255. * @value: Output parameter which gets the value of the register read.
  256. *
  257. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  258. */
  259. int pm8xxx_read_register(u16 addr, u8 *value);
  260. #else
  261. static inline int pm8xxx_reset_pwr_off(int reset)
  262. {
  263. return -ENODEV;
  264. }
  265. static inline int
  266. pm8xxx_uart_gpio_mux_ctrl(enum pm8xxx_uart_path_sel uart_path_sel)
  267. {
  268. return -ENODEV;
  269. }
  270. static inline int
  271. pm8xxx_coincell_chg_config(struct pm8xxx_coincell_chg *chg_config)
  272. {
  273. return -ENODEV;
  274. }
  275. static inline int pm8xxx_smpl_set_delay(enum pm8xxx_smpl_delay delay)
  276. {
  277. return -ENODEV;
  278. }
  279. static inline int pm8xxx_smpl_control(int enable)
  280. {
  281. return -ENODEV;
  282. }
  283. static inline int pm8xxx_watchdog_reset_control(int enable)
  284. {
  285. return -ENODEV;
  286. }
  287. static inline int pm8xxx_hard_reset_config(enum pm8xxx_pon_config config)
  288. {
  289. return -ENODEV;
  290. }
  291. static inline int pm8xxx_stay_on(void)
  292. {
  293. return -ENODEV;
  294. }
  295. static inline int pm8xxx_preload_dVdd(void)
  296. {
  297. return -ENODEV;
  298. }
  299. static inline int pm8xxx_usb_id_pullup(int enable)
  300. {
  301. return -ENODEV;
  302. }
  303. static inline int pm8xxx_aux_clk_control(enum pm8xxx_aux_clk_id clk_id,
  304. enum pm8xxx_aux_clk_div divider, bool enable)
  305. {
  306. return -ENODEV;
  307. }
  308. static inline int pm8xxx_hsed_bias_control(enum pm8xxx_hsed_bias bias,
  309. bool enable)
  310. {
  311. return -ENODEV;
  312. }
  313. #endif
  314. #endif