CV:Constant Voltage恒压
SMMB charger:Switch-ModeBattery Charger and Boost peripheral开关模式电池充电器和升压外围设备
OCV:Open circuitvoltage
EOC:End OfCharge充电结束
UUC:UnusableCapacity不可用电量
对应的源代码文件为\kernel\drivers\power\qpnp-vm-bms.c,高通QPNP电压模式的PMIC电池管理系统(Qualcomm'sQPNP Voltage-Mode(VM) PMIC Battery Management System),提供接口给客户端来读取电池相关属性,它的主要功能是基于周期性采样VBAT(vattery voltage)来计算SOC(state ofcharge)
下面学习kernel\Documentation\devicetree\bindings\power\qpnp-vm-bms.txt
父节点需要的属性如下
见kernel\arch\arm\boot\dts\qcom\msm-pm8909.dtsi文件的pm8909_bms: qcom,vmbms节点
- compatible : Must be "qcom,qpnp-vm-bms" for the BM driver.
- reg :Offset and length of the PMIC peripheral register map.
比如reg = <0x4000 0x100>;
- interrupts : The interrupt mappings.
The format should be
<slave-id peripheral-idinterrupt-number>.
比如
interrupts = <0x0 0x40 0x0>,
<0x00x40 0x3>,
<0x00x40 0x4>,
<0x00x40 0x5>;
- interrupt-names : names for the mappedbms interrupt
Thefollowing interrupts are required:
0: leave CV state离开恒压状态
1: enter CV state
2: good ocv generated
3: ocv_thr
4: fifo update
5: fsm state changed
比如
interrupt-names = "leave_cv",
"ocv_thr",
"fifo_update_done",
"fsm_state_change";
此外,可选的子节点可包含:
- qcom,batt-pres-status : A subnode with aregister address for the SMBB
batteryinterface's BATT_PRES_STATUS register. If this node is
added,then the BMS will try to detect offmode battery removal
viathe battery interface's offmode battery removal circuit.
这是带有一个关于SMMB电池接口寄存器BATT_PRES_STATUS地址的子节点,如果增加了此节点,BMS将会尝试通过电池接口的offmode电池接插电路检测offmode电池接插
例如
qcom,batt-pres-status@1208 {
reg= <0x1208 0x1>;
};
电池曲线:
- qcom,battery-data : A phandle to a nodecontaining the available batterydata
profiles.See the batterydata bindings documentation for more
details.
此节点的值是一个phandle,它指向一个包含有效电池曲线数据的节点,详见kernel\Documentation\devicetree\bindings\batterydata\batterydata.txt
在kernel\arch\arm\boot\dts\qcom\msm8909-qrd-skue.dtsi中定义
/ {
qrd_batterydata:qcom,battery-data {
qcom,rpull-up-kohm= <0>;
qcom,vref-batt-therm= <1800000>;
#include"batterydata-qrd-skue-4v35-2000mah.dtsi"
};
};
&pm8909_bms {
status= "okay";
qcom,resume-soc= <95>;
qcom,use-reported-soc;
qcom,force-bms-active-on-charger;
qcom,battery-data = <&qrd_batterydata>;
};
父节点需要的属性
- qcom,v-cutoff-uv : cutoff voltage wherethe battery is considered dead in
micro-volts(微伏).
关机电压,用于计算SOC,如修改关机电压,除了修改这里,还需要修改电池曲线数据的qcom,v-cutoff-uv,其实最好是用电池曲线数据里的。
比如qcom,v-cutoff-uv = <3400000>;
- qcom,max-voltage-uv : maximum voltage forthe battery in micro-volts.
电池最大的电压,单位为毫伏,比如qcom,max-voltage-uv =<4200000>;
- qcom,r-conn-mohm : connector resistancein milli-ohms.
连接器电阻,如qcom,r-conn-mohm = <0>;
- qcom,shutdown-soc-valid-limit : If theocv upon restart is within this
distanceof the shutdown ocv, the BMS will try to force
thenew SoC to the old one to provide charge continuity.
Thatis to say,
if(abs(shutdown-soc - current-soc) < limit)
thenuse old SoC.
如qcom,shutdown-soc-valid-limit =<100>;
- qcom,low-soc-calculate-soc-threshold :The SoC threshold for when
theperiodic calculate_soc work speeds u