qpnp-fg-gen3.txt 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. Qualcomm Techonologies, Inc. QPNP PMIC Fuel Gauge Gen3 Device
  2. QPNP PMIC FG Gen3 device provides interface to the clients to read properties
  3. related to the battery. Its main function is to retrieve the State of Charge
  4. (SOC), in percentage scale representing the amount of charge left in the
  5. battery.
  6. =======================
  7. Required Node Structure
  8. =======================
  9. FG Gen3 device must be described in two levels of device nodes. The first
  10. level describes the FG Gen3 device. The second level describes one or more
  11. peripherals managed by FG Gen3 driver. All the peripheral specific parameters
  12. such as base address, interrupts etc., should be under second level node.
  13. ====================================
  14. First Level Node - FG Gen3 device
  15. ====================================
  16. - compatible
  17. Usage: required
  18. Value type: <string>
  19. Definition: Should be "qcom,fg-gen3".
  20. - qcom,pmic-revid
  21. Usage: required
  22. Value type: <phandle>
  23. Definition: Should specify the phandle of PMIC revid module. This is
  24. used to identify the PMIC subtype.
  25. - io-channels
  26. - io-channel-names
  27. Usage: required
  28. Value type: <phandle>
  29. Definition: For details about IIO bindings see:
  30. Documentation/devicetree/bindings/iio/iio-bindings.txt
  31. - #thermal-sensor-cells: Should be 0. See thermal.txt for a description.
  32. - qcom,rradc-base
  33. Usage: required
  34. Value type: <u32>
  35. Definition: Should specify the base address of RR_ADC peripheral. This
  36. is used for reading certain peripheral registers under it.
  37. - qcom,fg-cutoff-voltage
  38. Usage: optional
  39. Value type: <u32>
  40. Definition: The voltage (in mV) where the fuel gauge will steer the SOC
  41. to be zero. For example, if the cutoff voltage is set to
  42. 3400mv, the fuel gauge will try to count SoC so that the
  43. battery SOC will be 0 when it is 3400mV. If this property
  44. is not specified, then the default value used will be
  45. 3200mV.
  46. - qcom,fg-empty-voltage
  47. Usage: optional
  48. Value type: <u32>
  49. Definition: The voltage threshold (in mV) based on which the empty soc
  50. interrupt will be triggered. When the empty soc interrupt
  51. fires, battery soc will be set to 0 and the userspace will
  52. be notified via the power supply framework. The userspace
  53. will read 0% soc and immediately shutdown. If this property
  54. is not specified, then the default value used will be
  55. 2800mV.
  56. - qcom,fg-vbatt-low-thr
  57. Usage: optional
  58. Value type: <u32>
  59. Definition: The voltage threshold (in mV) which upon set will be used
  60. for configuring the low battery voltage threshold.
  61. - qcom,fg-recharge-voltage
  62. Usage: optional
  63. Value type: <u32>
  64. Definition: The voltage threshold (in mV) based on which the charging
  65. will be resumed once the charging is complete. If this
  66. property is not specified, then the default value will be
  67. 4250mV.
  68. - qcom,fg-chg-term-current
  69. Usage: optional
  70. Value type: <u32>
  71. Definition: Battery current (in mA) at which the fuel gauge will issue
  72. an end of charge if the charger is configured to use the
  73. fuel gauge ADC for end of charge detection. If this
  74. property is not specified, then the default value used
  75. will be 100mA.
  76. - qcom,fg-sys-term-current
  77. Usage: optional
  78. Value type: <u32>
  79. Definition: Battery current (in mA) at which the fuel gauge will try to
  80. scale towards 100%. When the charge current goes above this
  81. the SOC should be at 100%. If this property is not
  82. specified, then the default value used will be -125mA.
  83. This value has to be specified in negative values for
  84. the charging current.
  85. - qcom,fg-chg-term-base-current
  86. Usage: optional
  87. Value type: <u32>
  88. Definition: Battery current (in mA) upper boundary at which the fuel
  89. gauge will issue an end of charge during discharging. If
  90. this property is not specified, then the default value used
  91. will be 75mA.
  92. - qcom,fg-cutoff-current
  93. Usage: optional
  94. Value type: <u32>
  95. Definition: Minimum Battery current (in mA) used for cutoff SOC
  96. estimate. If this property is not specified, then a default
  97. value of 500 mA will be applied.
  98. - qcom,fg-delta-soc-thr
  99. Usage: optional
  100. Value type: <u32>
  101. Definition: Percentage of SOC increase upon which the delta monotonic &
  102. battery SOC interrupts will be triggered. If this property
  103. is not specified, then the default value will be 1.
  104. Possible values are in the range of 0 to 12.
  105. - qcom,fg-recharge-soc-thr
  106. Usage: optional
  107. Value type: <u32>
  108. Definition: Percentage of monotonic SOC upon which the charging will
  109. will be resumed once the charging is complete. If this
  110. property is not specified, then the default value will be
  111. 95.
  112. - qcom,fg-rsense-sel
  113. Usage: optional
  114. Value type: <u32>
  115. Definition: Specifies the source of sense resistor.
  116. Allowed values are:
  117. 0 - Rsense is from Battery FET
  118. 2 - Rsense is Battery FET and SMB
  119. Option 2 can be used only when a parallel charger is
  120. present. If this property is not specified, then the
  121. default value will be 2.
  122. - qcom,fg-jeita-thresholds
  123. Usage: optional
  124. Value type: <prop-encoded-array>
  125. Definition: A list of integers which holds the jeita thresholds (degC)
  126. in the following order. Allowed size is 4.
  127. Element 0 - JEITA cold threshold
  128. Element 1 - JEITA cool threshold
  129. Element 2 - JEITA warm threshold
  130. Element 3 - JEITA hot threshold
  131. If these parameters are not specified, then the default
  132. values used will be 0, 5, 45, 50.
  133. - qcom,fg-esr-timer-charging
  134. Usage: optional
  135. Value type: <prop-encoded-array>
  136. Definition: Number of cycles between ESR pulses while the battery is
  137. charging. Array of 2 elements if specified.
  138. Element 0 - Retry value for timer
  139. Element 1 - Maximum value for timer
  140. - qcom,fg-esr-timer-awake
  141. Usage: optional
  142. Value type: <prop-encoded-array>
  143. Definition: Number of cycles between ESR pulses while the system is
  144. awake and the battery is discharging. Array of 2 elements
  145. if specified.
  146. Element 0 - Retry value for timer
  147. Element 1 - Maximum value for timer
  148. - qcom,fg-esr-timer-asleep
  149. Usage: optional
  150. Value type: <prop-encoded-array>
  151. Definition: Number of cycles between ESR pulses while the system is
  152. asleep and the battery is discharging. This option requires
  153. qcom,fg-esr-timer-awake to be defined. Array of 2 elements
  154. if specified.
  155. Element 0 - Retry value for timer
  156. Element 1 - Maximum value for timer
  157. - qcom,fg-esr-pulse-thresh-ma
  158. Usage: optional
  159. Value type: <u32>
  160. Definition: ESR pulse qualification threshold in mA. If this is not
  161. specified, a default value of 110 mA will be configured.
  162. Allowed values are from 1 to 997.
  163. - qcom,fg-esr-meas-curr-ma
  164. Usage: optional
  165. Value type: <u32>
  166. Definition: ESR measurement current in mA. If this is not specified,
  167. a default value of 120 mA will be configured. Allowed
  168. values are 60, 120, 180 and 240.
  169. - qcom,cycle-counter-en
  170. Usage: optional
  171. Value type: <empty>
  172. Definition: Enables the cycle counter feature.
  173. - qcom,fg-force-load-profile
  174. Usage: optional
  175. Value type: <empty>
  176. Definition: If set, battery profile will be force loaded if the profile
  177. loaded earlier by bootloader doesn't match with the profile
  178. available in the device tree.
  179. - qcom,cl-start-capacity
  180. Usage: optional
  181. Value type: <u32>
  182. Definition: Battery SOC threshold to start the capacity learning.
  183. If this is not specified, then the default value used
  184. will be 15.
  185. - qcom,cl-min-temp
  186. Usage: optional
  187. Value type: <u32>
  188. Definition: Lower limit of battery temperature to start the capacity
  189. learning. If this is not specified, then the default value
  190. used will be 150 (15 C). Unit is in decidegC.
  191. - qcom,cl-max-temp
  192. Usage: optional
  193. Value type: <u32>
  194. Definition: Upper limit of battery temperature to start the capacity
  195. learning. If this is not specified, then the default value
  196. used will be 500 (50 C). Unit is in decidegC.
  197. - qcom,cl-max-increment
  198. Usage: optional
  199. Value type: <u32>
  200. Definition: Maximum capacity increment allowed per capacity learning
  201. cycle. If this is not specified, then the default value
  202. used will be 5 (0.5%). Unit is in decipercentage.
  203. - qcom,cl-max-decrement
  204. Usage: optional
  205. Value type: <u32>
  206. Definition: Maximum capacity decrement allowed per capacity learning
  207. cycle. If this is not specified, then the default value
  208. used will be 100 (10%). Unit is in decipercentage.
  209. - qcom,cl-min-limit
  210. Usage: optional
  211. Value type: <u32>
  212. Definition: Minimum limit that the capacity cannot go below in a
  213. capacity learning cycle. If this is not specified, then
  214. the default value is 0. Unit is in decipercentage.
  215. - qcom,cl-max-limit
  216. Usage: optional
  217. Value type: <u32>
  218. Definition: Maximum limit that the capacity cannot go above in a
  219. capacity learning cycle. If this is not specified, then
  220. the default value is 0. Unit is in decipercentage.
  221. - qcom,battery-thermal-coefficients
  222. Usage: optional
  223. Value type: <u8>
  224. Definition: Byte array of battery thermal coefficients.
  225. This should be exactly 3 bytes in length.
  226. - qcom,fg-jeita-hyst-temp
  227. Usage: optional
  228. Value type: <u32>
  229. Definition: Hysteresis applied to Jeita temperature comparison.
  230. Possible values are:
  231. 0 - No hysteresis
  232. 1,2,3 - Value in Celsius.
  233. - qcom,fg-batt-temp-delta
  234. Usage: optional
  235. Value type: <u32>
  236. Definition: Battery temperature delta interrupt threshold. Possible
  237. values are: 2, 4, 6 and 10. Unit is in Kelvin.
  238. - qcom,hold-soc-while-full
  239. Usage: optional
  240. Value type: <empty>
  241. Definition: A boolean property that when defined holds SOC at 100% when
  242. the battery is full.
  243. - qcom,linearize-soc
  244. Usage: optional
  245. Value type: <empty>
  246. Definition: A boolean property that when defined linearizes SOC when
  247. the SOC drops after charge termination monotonically to
  248. improve the user experience. This is applicable only if
  249. "qcom,hold-soc-while-full" is specified.
  250. - qcom,ki-coeff-soc-dischg
  251. Usage: optional
  252. Value type: <prop-encoded-array>
  253. Definition: Array of monotonic SOC threshold values to change the ki
  254. coefficient for medium discharge current during discharge.
  255. This should be defined in the ascending order and in the
  256. range of 0-100. Array limit is set to 3.
  257. - qcom,ki-coeff-med-dischg
  258. Usage: optional
  259. Value type: <prop-encoded-array>
  260. Definition: Array of ki coefficient values for medium discharge current
  261. during discharge. These values will be applied when the
  262. monotonic SOC goes below the SOC threshold specified under
  263. qcom,ki-coeff-soc-dischg. Array limit is set to 3. This
  264. property should be specified if qcom,ki-coeff-soc-dischg
  265. is specified to make it fully functional. Value has no
  266. unit. Allowed range is 0 to 62200 in micro units.
  267. - qcom,ki-coeff-hi-dischg
  268. Usage: optional
  269. Value type: <prop-encoded-array>
  270. Definition: Array of ki coefficient values for high discharge current
  271. during discharge. These values will be applied when the
  272. monotonic SOC goes below the SOC threshold specified under
  273. qcom,ki-coeff-soc-dischg. Array limit is set to 3. This
  274. property should be specified if qcom,ki-coeff-soc-dischg
  275. is specified to make it fully functional. Value has no
  276. unit. Allowed range is 0 to 62200 in micro units.
  277. - qcom,ki-coeff-full-dischg
  278. Usage: optional
  279. Value type: <u32>
  280. Definition: Ki coefficient full SOC value that will be applied during
  281. discharging. If not specified, a value of 0 will be set.
  282. Allowed range is from 245 to 62256.
  283. - qcom,ki-coeff-low-dischg
  284. Usage: optional
  285. Value type: <u32>
  286. Definition: Ki coefficient value for low discharge current during
  287. discharging. Value has no unit. Allowed range is 0-62200
  288. in micro units.
  289. - qcom,ki-coeff-hi-chg
  290. Usage: optional
  291. Value type: <u32>
  292. Definition: Ki coefficient value for high charge current during
  293. charging. Value has no unit. Allowed range is 0-62200
  294. in micro units.
  295. - qcom,fg-rconn-mohms
  296. Usage: optional
  297. Value type: <u32>
  298. Definition: Battery connector resistance (Rconn) in milliohms. If Rconn
  299. is specified, then ESR to Rslow scaling factors will be
  300. updated to account it for an accurate ESR.
  301. - qcom,fg-esr-clamp-mohms
  302. Usage: optional
  303. Value type: <u32>
  304. Definition: Equivalent series resistance (ESR) in milliohms. If this
  305. is specified, then ESR will be clamped to this value when
  306. ESR is found to be dropping below this. Default value is
  307. 20.
  308. - qcom,fg-esr-filter-switch-temp
  309. Usage: optional
  310. Value type: <u32>
  311. Definition: Battery temperature threshold below which low temperature
  312. ESR filter coefficients will be switched to normal
  313. temperature ESR filter coefficients. If this is not
  314. specified, then the default value used will be 100. Unit is
  315. in decidegC.
  316. - qcom,fg-esr-tight-filter-micro-pct
  317. Usage: optional
  318. Value type: <u32>
  319. Definition: Value in micro percentage for ESR tight filter. If this is
  320. not specified, then a default value of 3907 (0.39 %) will
  321. be used. Lowest possible value is 1954 (0.19 %).
  322. - qcom,fg-esr-broad-filter-micro-pct
  323. Usage: optional
  324. Value type: <u32>
  325. Definition: Value in micro percentage for ESR broad filter. If this is
  326. not specified, then a default value of 99610 (9.96 %) will
  327. be used. Lowest possible value is 1954 (0.19 %).
  328. - qcom,fg-esr-tight-lt-filter-micro-pct
  329. Usage: optional
  330. Value type: <u32>
  331. Definition: Value in micro percentage for low temperature ESR tight
  332. filter. If this is not specified, then a default value of
  333. 30000 (3 %) will be used. Lowest possible value is 1954
  334. (0.19 %).
  335. - qcom,fg-esr-broad-lt-filter-micro-pct
  336. Usage: optional
  337. Value type: <u32>
  338. Definition: Value in micro percentage for low temperature ESR broad
  339. filter. If this is not specified, then a default value of
  340. 30000 (3 %) will be used. Lowest possible value is
  341. 1954 (0.19 %).
  342. - qcom,fg-esr-rt-filter-switch-temp
  343. Usage: optional
  344. Value type: <u32>
  345. Definition: Battery temperature threshold below which ESR relax
  346. filter coefficients will be applied after a certain
  347. number of delta battery temperature interrupts firing in
  348. an interval of time. This will be applied only when Qnovo
  349. is enabled. If this is not specified, then the default
  350. value used will be -100. Unit is in decidegC.
  351. - qcom,fg-esr-tight-rt-filter-micro-pct
  352. Usage: optional
  353. Value type: <u32>
  354. Definition: Value in micro percentage for relax temperature ESR tight
  355. filter. If this is not specified, then a default value of
  356. 5860 will be used. Lowest possible value is 1954 (0.19 %).
  357. This will be applied only if Qnovo is enabled.
  358. - qcom,fg-esr-broad-rt-filter-micro-pct
  359. Usage: optional
  360. Value type: <u32>
  361. Definition: Value in micro percentage for relax temperature ESR broad
  362. filter. If this is not specified, then a default value of
  363. 156250 will be used. Lowest possible value is 1954 (0.19 %).
  364. This will be applied only if Qnovo is enabled.
  365. - qcom,fg-auto-recharge-soc
  366. Usage: optional
  367. Value type: <empty>
  368. Definition: A boolean property when defined will configure automatic
  369. recharge SOC threshold. If not specified, automatic
  370. recharge voltage threshold will be configured. This has
  371. to be configured in conjunction with the charger side
  372. configuration for proper functionality.
  373. - qcom,slope-limit-temp-threshold
  374. Usage: optional
  375. Value type: <u32>
  376. Definition: Battery temperature threshold to decide when slope limit
  377. coefficients should be applied along with charging status.
  378. Unit is in decidegC.
  379. - qcom,slope-limit-coeffs
  380. Usage: optional
  381. Value type: <prop-encoded-array>
  382. Definition: A list of integers which holds the slope limit coefficients
  383. in the following order. Allowed size is 4. Possible values
  384. are from 0 to 31. Unit is in decipercentage.
  385. Element 0 - Low temperature discharging
  386. Element 1 - Low temperature charging
  387. Element 2 - High temperature discharging
  388. Element 3 - High temperature charging
  389. These coefficients have to be specified along with the
  390. property "qcom,slope-limit-temp-threshold" to make dynamic
  391. slope limit adjustment functional.
  392. - qcom,fg-bmd-en-delay-ms
  393. Usage: optional
  394. Value type: <u32>
  395. Definition: The delay in ms for FG to enable BMD after reading RID.
  396. ==========================================================
  397. Second Level Nodes - Peripherals managed by FG Gen3 driver
  398. ==========================================================
  399. - reg
  400. Usage: required
  401. Value type: <prop-encoded-array>
  402. Definition: Addresses and sizes for the specified peripheral
  403. - interrupts
  404. Usage: optional
  405. Value type: <prop-encoded-array>
  406. Definition: Interrupt mapping as per the interrupt encoding
  407. - interrupt-names
  408. Usage: optional
  409. Value type: <stringlist>
  410. Definition: Interrupt names. This list must match up 1-to-1 with the
  411. interrupts specified in the 'interrupts' property.
  412. ========
  413. Example
  414. ========
  415. pmi8998_fg: qpnp,fg {
  416. compatible = "qcom,fg-gen3";
  417. #address-cells = <1>;
  418. #size-cells = <1>;
  419. qcom,pmic-revid = <&pmi8998_revid>;
  420. io-channels = <&pmi8998_rradc 3>;
  421. io-channel-names = "rradc_batt_id";
  422. qcom,rradc-base = <0x4500>;
  423. qcom,ki-coeff-soc-dischg = <30 60 90>;
  424. qcom,ki-coeff-med-dischg = <800 1000 1400>;
  425. qcom,ki-coeff-hi-dischg = <1200 1500 2100>;
  426. qcom,slope-limit-temp-threshold = <100>;
  427. qcom,slope-limit-coeffs = <10 11 12 13>;
  428. qcom,battery-thermal-coefficients = [9d 50 ff];
  429. #thermal-sensor-cells = <0>;
  430. status = "okay";
  431. qcom,fg-batt-soc@4000 {
  432. status = "okay";
  433. reg = <0x4000 0x100>;
  434. interrupts = <0x2 0x40 0x0 IRQ_TYPE_EDGE_BOTH>,
  435. <0x2 0x40 0x1 IRQ_TYPE_EDGE_BOTH>,
  436. <0x2 0x40 0x2 IRQ_TYPE_EDGE_BOTH>,
  437. <0x2 0x40 0x3 IRQ_TYPE_EDGE_BOTH>;
  438. interrupt-names = "soc-update",
  439. "soc-ready",
  440. "bsoc-delta",
  441. "msoc-delta";
  442. };
  443. qcom,fg-batt-info@4100 {
  444. status = "okay";
  445. reg = <0x4100 0x100>;
  446. interrupts = <0x2 0x41 0x3 IRQ_TYPE_EDGE_BOTH>;
  447. interrupt-names = "batt-missing";
  448. };
  449. qcom,fg-memif@4400 {
  450. status = "okay";
  451. reg = <0x4400 0x100>;
  452. };
  453. };
  454. ======================================
  455. Example for thermal zone configuration
  456. ======================================
  457. thermal_zones {
  458. pmi8998_fg {
  459. polling-delay-passive = <200>;
  460. polling-delay = <200>;
  461. thermal-governor = <userspace>;
  462. thermal-sensors = <&pmi8998_fg>;
  463. pmi8998_fg_trip1: pmi8998-fg-trip0 {
  464. temperature = <45000>;
  465. hysteresis = <0>;
  466. type = "passive";
  467. };
  468. pmi8998_fg_trip2: pmi8998-fg-trip2 {
  469. temperature = <50000>;
  470. hysteresis = <0>;
  471. type = "hot";
  472. };
  473. pmi8998_fg_trip3: pmi8998-fg-trip3 {
  474. temperature = <60000>;
  475. hysteresis = <0>;
  476. type = "alert";
  477. };
  478. };
  479. };