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