qpnp-fg.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. QTI's QPNP PMIC Fuel Gauge Device
  2. QPNP PMIC FG provides interface to clients to read properties related
  3. to the battery. Its main function is to retrieve the State of Charge (SOC),
  4. a 0-100 percentage representing the amount of charge left in the battery.
  5. There are two required peripherals in the FG driver, both implemented as
  6. subnodes in the example. These peripherals must not be disabled if the FG
  7. device is to enabled:
  8. - qcom,fg-soc : The main FG device. Supports battery fuel gauge controls and
  9. sensors.
  10. - qcom,fg-batt : The FG battery device supports interrupts and controls with
  11. respect to the state of the connected battery.For example: the
  12. peripheral informs the driver if the battery has been identified
  13. by the fuel gauge based on a given battery resistance range.
  14. Optionally ADC nodes can be added
  15. - qcom,revid-tp-rev: A subnode with a register address for the TP_REV register
  16. in the REVID peripheral. This is used to apply workarounds that
  17. may depend on the trim program.
  18. - qcom,fg-adc-vbat : A subnode with a register address for the FG_ADC_USR
  19. peripheral which is used mainly for battery current limiting (BCL).
  20. This node maps out the VBAT reading register which allows to have
  21. a +/- 32 mV accurate reading of VBAT.
  22. - qcom,fg-adc-ibat : A subnode with a register address for the FG_ADC_USR
  23. peripheral which is used mainly for battery current limiting (BCL).
  24. This node maps out the IBAT current reading register which allows
  25. to have a +/- 32 mA accurate reading of IBAT.
  26. Parent node required properties:
  27. - compatible : should be "qcom,qpnp-fg" for the FG driver.
  28. - qcom,pmic-revid : Should specify the phandle of PMIC
  29. revid module. This is used to identify
  30. the PMIC subtype.
  31. Parent node optional properties:
  32. - qcom,warm-bat-decidegc: Warm battery temperature in decidegC.
  33. - qcom,cool-bat-decidegc: Cool battery temperature in decidegC.
  34. - qcom,hot-bat-decidegc: Hot battery temperature in decidegC.
  35. - qcom,cold-bat-decidegc: Cold battery temperature in decidegC.
  36. - qcom,cold-hot-jeita-hysteresis: A tuple of 2. Index[0] is cold
  37. hysteresis and index[1] is hot
  38. hysterisis(in decidegC).
  39. - qcom,ext-sense-type: Current sense channel used by the FG.
  40. Set this to use external rsense.
  41. - qcom,thermal-coefficients: Byte array of thermal coefficients for
  42. reading battery thermistor. This should
  43. be exactly 6 bytes in length.
  44. Example: [01 02 03 04 05 06]
  45. - qcom,resume-soc: soc to resume charging in percentage.
  46. - qcom,resume-soc-raw: soc to resume charging in the scale of
  47. [0-255]. This overrides qcom,resume-soc
  48. if defined.
  49. - qcom,hold-soc-while-full: A boolean property that when defined
  50. holds SOC at 100% when the battery is
  51. full.
  52. - qcom,bcl-lm-threshold-ma: BCL LPM to MPM mode transition threshold
  53. in milliAmpere.
  54. - qcom,bcl-mh-threshold-ma: BCL MPM to HPM mode transition threshold
  55. in milliAmpere.
  56. - qcom,use-otp-profile: Specify this flag to avoid RAM loading
  57. any battery profile.
  58. - qcom,sw-rbias-control: Boolean property which defines whether
  59. the Rbias needs to be controlled by
  60. software. If this is not set, it will
  61. be controlled by hardware (default).
  62. - qcom,fg-iterm-ma: Battery current at which the fuel gauge
  63. will try to scale 100% towards. When
  64. the charge current goes above this, the
  65. SoC should be at 100%.
  66. - qcom,fg-chg-iterm-ma: Battery current at which the fuel gauge
  67. will issue end of charge if the charger
  68. is configured to use the fuel gauge
  69. ADCs for end of charge detection. This
  70. property is in milliamps and should be
  71. positive (e.g. 100mA to terminate at
  72. -100mA).
  73. - qcom,irq-volt-empty-mv: The voltage threshold that the empty
  74. soc interrupt will be triggered. When
  75. the empty soc interrupt fires, battery
  76. soc will be pulled to 0 and the
  77. userspace will be notified via the
  78. power supply framework. The userspace
  79. will read 0% soc and immediately
  80. shutdown.
  81. - qcom,fg-cutoff-voltage-mv: The voltage where the fuel gauge will
  82. steer the SOC to be zero. For example,
  83. if the cutoff voltage is set to 3400mv,
  84. the fuel gauge will try to count SoC so
  85. that the battery SoC will be 0 when it
  86. is 3400mV.
  87. - qcom,fg-vbat-estimate-diff-mv: If the estimated voltage based on SoC
  88. and battery current/resistance differs
  89. from the actual voltage by more than
  90. this amount, the fuel gauge will
  91. redo the first SoC estimate when the
  92. driver probes.
  93. - qcom,fg-delta-soc: How many percent the monotonic SoC must
  94. change before a new delta_soc interrupt
  95. is asserted. If this value is raised
  96. above 3-4, some period workarounds may
  97. not function well, so it's best to
  98. leave this at 1 or 2%.
  99. - qcom,fg-vbatt-low-threshold: Voltage (in mV) which upon set will be
  100. used for configuring the low battery
  101. voltage threshold. Interrupt will be
  102. asserted and handled based upon
  103. this. If this property is not specified,
  104. low battery voltage threshold will be
  105. configured to 4200 mV.
  106. - qcom,fg-rconn-mohm: Battery connector resistance (Rconn) in
  107. milliohms. If Rconn is specified, then
  108. Rslow values will be updated to account
  109. it for an accurate ESR.
  110. - qcom,cycle-counter-en: Boolean property which enables the cycle
  111. counter feature. If this property is
  112. present, then the following properties
  113. to specify low and high soc thresholds
  114. should be defined.
  115. - qcom,capacity-learning-on: A boolean property to have the fuel
  116. gauge driver attempt to learn the
  117. battery capacity when charging. Takes
  118. precedence over capacity-estimation-on.
  119. - qcom,capacity-learning-feedback: A boolean property to have the fuel
  120. gauge driver to feedback the learned
  121. capacity into the capacity learning
  122. algorithm. This has to be used only if
  123. the property "qcom,capacity-learning-on"
  124. is specified.
  125. - qcom,cl-max-increment-deciperc: The maximum percent that the capacity
  126. can rise as the result of a single
  127. charge cycle. This property corresponds
  128. to .1% increments.
  129. - qcom,cl-max-decrement-deciperc: The maximum percent that the capacity
  130. can fall as the result of a single
  131. charge cycle. This property corresponds
  132. to .1% decrements.
  133. - qcom,cl-max-temp-decidegc: Above this temperature, capacity
  134. learning will be canceled.
  135. - qcom,cl-mix-temp-decidegc: Below this temperature, capacity
  136. learning will be canceled.
  137. - qcom,cl-max-start-soc: The battery soc has to be below this
  138. value at the start of a charge cycle
  139. for capacity learning to be run.
  140. - qcom,cl-vbat-est-thr-uv: The maximum difference between the
  141. battery voltage shadow and the current
  142. predicted voltage in uV to initiate
  143. capacity learning.
  144. - qcom,cl-max-limit-deciperc: The maximum percent that the capacity
  145. cannot go above during any capacity
  146. learning cycle. This property is in the
  147. unit of .1% increments.
  148. - qcom,cl-min-limit-deciperc: The minimum percent that the capacity
  149. cannot go below during any capacity
  150. learning cycle. This property is in the
  151. unit of .1% increments.
  152. - qcom,capacity-estimation-on: A boolean property to have the fuel
  153. gauge driver attempt to estimate the
  154. battery capacity using battery
  155. resistance.
  156. - qcom,aging-eval-current-ma: Current used to evaluate battery aging.
  157. This value should be around the steady
  158. state current drawn from the battery
  159. when the phone is low on battery.
  160. - qcom,fg-cc-cv-threshold-mv: Voltage threshold in mV for configuring
  161. constant charge (CC) to constant
  162. voltage (CV) setpoint in FG upon
  163. which the battery EOC status will
  164. be determined. This value should be
  165. 10 mV less than the float voltage
  166. configured in the charger.
  167. This property should only be specified
  168. if "qcom,autoadjust-vfloat" property is
  169. specified in the charger driver to
  170. ensure a proper operation.
  171. - qcom,bad-battery-detection-enable: A boolean property to enable the fuel
  172. gauge driver to detect the damaged battery
  173. when the safety-timer expires by using the
  174. coulomb count.
  175. - qcom,fg-therm-delay-us: The time in microseconds to delay battery
  176. thermistor biasing.
  177. - qcom,esr-pulse-tuning-en: A boolean property to enable ESR pulse
  178. tuning feature. If this is enabled,
  179. ESR pulse extraction will be disabled
  180. when state of charge (SOC) is less than
  181. 2%. It will be enabled back when SOC
  182. gets above 2%. In addition, for SOC
  183. between 2% and 5%, ESR pulse timing
  184. settings will be different from default.
  185. Once SOC crosses 5%, ESR pulse timings
  186. will be restored back to default.
  187. - qcom,fg-control-slope-limiter: A boolean property to specify if SOC
  188. slope limiter coefficients needs to
  189. be modified based on charging status
  190. and battery temperature threshold.
  191. - qcom,fg-slope-limit-temp-threshold: Temperature threshold in decidegC used
  192. for applying the slope coefficient based
  193. on charging status and battery
  194. temperature. If this property is not
  195. specified, a default value of 100 (10C)
  196. will be applied by default.
  197. - qcom,fg-slope-limit-low-temp-chg: When the temperature goes below the
  198. specified temperature threshold and
  199. battery is charging, slope coefficient
  200. specified with this property will be
  201. applied. If this property is not
  202. specified, a default value of 45 will be
  203. applied.
  204. - qcom,fg-slope-limit-low-temp-dischg: Same as "qcom,fg-slope-limit-low-temp-chg"
  205. except this is when the battery is
  206. discharging.
  207. - qcom,fg-slope-limit-high-temp-chg: When the temperature goes above the
  208. specified temperature threshold and
  209. battery is charging, slope coefficient
  210. specified with this property will be
  211. applied. If this property is not
  212. specified, a default value of 2 will be
  213. applied.
  214. - qcom,fg-slope-limit-high-temp-dischg: Same as "qcom,fg-slope-limit-high-temp-chg"
  215. except this is when the battery is
  216. discharging.
  217. - qcom,fg-dischg-voltage-gain-ctrl: A boolean property to specify if the
  218. voltage gain needs to be modified
  219. during discharging based on monotonic
  220. soc.
  221. - qcom,fg-dischg-voltage-gain-soc: Array of monotonic SOC threshold values
  222. to change the voltage gain settings
  223. during discharge. This should be defined
  224. in the ascending order and in the range
  225. of 0-100. Array limit is set to 3.
  226. If qcom,fg-dischg-voltage-gain-ctrl is
  227. set, then this property should be
  228. specified to apply the gain settings.
  229. - qcom,fg-dischg-med-voltage-gain: Array of voltage gain values that needs
  230. to be applied to medC voltage gain when
  231. the monotonic SOC goes below the SOC
  232. threshold specified under
  233. qcom,fg-dischg-voltage-gain-soc. Array
  234. limit is set to 3.
  235. If qcom,fg-dischg-voltage-gain-ctrl is
  236. set, then this property should be
  237. specified to apply the gain setting.
  238. - qcom,fg-dischg-high-voltage-gain: Array of voltage gain values that needs
  239. to be applied to highC voltage gain when
  240. the monotonic SOC goes below the SOC
  241. threshold specified under
  242. qcom,fg-dischg-voltage-gain-soc. Array
  243. limit is set to 3.
  244. If qcom,fg-dischg-voltage-gain-ctrl is
  245. set, then this property should be
  246. specified to apply the gain setting.
  247. - qcom,fg-use-vbat-low-empty-soc: A boolean property to specify whether
  248. vbatt-low interrupt is used to handle
  249. empty battery condition. If this is
  250. not specified, empty battery condition
  251. is detected by empty-soc interrupt.
  252. - qcom,fg-batt-temp-low-limit: Battery temperature (in decidegC) low
  253. limit which will be used to validate
  254. the battery temperature reading from FG.
  255. If the battery temperature goes below
  256. this limit, last read good temperature
  257. will be notified to userspace. If this
  258. limit is not specified, then the
  259. default limit would be -60C.
  260. - qcom,fg-batt-temp-high-limit: Battery temperature (in decidegC) high
  261. limit which will be used to validate
  262. the battery temperature reading from FG.
  263. If the battery temperature goes above
  264. this limit, last read good temperature
  265. will be notified to userspace. If this
  266. limit is not specified, then the
  267. default limit would be 150C.
  268. - qcom,fg-cc-soc-limit-pct: Percentage of CC_SOC before resetting
  269. FG and restore the full CC_SOC value.
  270. - qcom,fg-restore-batt-info: A boolean property to specify whether
  271. battery parameters needs to be
  272. restored. If this feature is enabled,
  273. then validating the battery parameters
  274. by OCV/battery SOC, validation range
  275. in percentage should be specified via
  276. appropriate module parameters to make
  277. it work properly.
  278. qcom,fg-soc node required properties:
  279. - reg : offset and length of the PMIC peripheral register map.
  280. - interrupts : the interrupt mappings.
  281. The format should be
  282. <slave-id peripheral-id interrupt-number>.
  283. - interrupt-names : names for the mapped fg soc interrupts
  284. The following interrupts are required:
  285. 0: high-soc
  286. 1: low-soc
  287. 2: full-soc
  288. 3: empty-soc
  289. 4: delta-soc
  290. 5: first-est-done
  291. 6: sw-fallbk-ocv
  292. 7: sw-fallbk-new-batt
  293. qcom,fg-memif node required properties:
  294. - reg : offset and length of the PMIC peripheral register map.
  295. - interrupts : the interrupt mappings.
  296. The format should be
  297. <slave-id peripheral-id interrupt-number>.
  298. - interrupt-names : names for the mapped fg adc interrupts
  299. The following interrupts are required:
  300. 0: mem-avail
  301. Example:
  302. pmi8994_fg: qcom,fg {
  303. compatible = "qcom,qpnp-fg";
  304. #address-cells = <1>;
  305. #size-cells = <1>;
  306. status = "disabled";
  307. qcom,pmic-revid = <&pmi8994_revid>;
  308. qcom,fg-soc@4000 {
  309. reg = <0x4000 0x100>;
  310. interrupts = <0x2 0x40 0x0>,
  311. <0x2 0x40 0x1>,
  312. <0x2 0x40 0x2>,
  313. <0x2 0x40 0x3>,
  314. <0x2 0x40 0x4>,
  315. <0x2 0x40 0x5>,
  316. <0x2 0x40 0x6>,
  317. <0x2 0x40 0x7>;
  318. interrupt-names = "high-soc",
  319. "low-soc",
  320. "full-soc",
  321. "empty-soc",
  322. "delta-soc",
  323. "first-est-done",
  324. "sw-fallbk-ocv",
  325. "sw-fallbk-new-batt";
  326. };
  327. qcom,fg-batt@4100 {
  328. reg = <0x4100 0x100>;
  329. interrupts = <0x2 0x41 0x0>,
  330. <0x2 0x41 0x1>,
  331. <0x2 0x41 0x2>,
  332. <0x2 0x41 0x3>,
  333. <0x2 0x41 0x4>,
  334. <0x2 0x41 0x5>,
  335. <0x2 0x41 0x6>,
  336. <0x2 0x41 0x7>;
  337. interrupt-names = "soft-cold",
  338. "soft-hot",
  339. "vbatt-low",
  340. "batt-ided",
  341. "batt-id-req",
  342. "batt-unknown",
  343. "batt-missing",
  344. "batt-match";
  345. };
  346. qcom,fg-adc-vbat@4254 {
  347. reg = <0x4254 0x1>;
  348. };
  349. qcom,fg-adc-ibat@4255 {
  350. reg = <0x4255 0x1>;
  351. };
  352. qcom,fg-memif@4400 {
  353. reg = <0x4400 0x100>;
  354. interrupts = <0x2 0x44 0x0>,
  355. <0x2 0x44 0x1>;
  356. interrupt-names = "mem-avail",
  357. "data-rcvry-sug";
  358. qcom,cold-hot-jeita-hysteresis = <30 50>;
  359. };
  360. };