CV:Constant Voltage恆壓 SMMB charger:Switch ModeBattery Charger and Boost peripheral開關模式電池充電器和升壓外圍設備 OCV:Open circuitvoltage EOC:End OfCharge充電結束 UUC:Un ...
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 up. This ensures
SoCis updated in userspace constantly when we are near
shutdown.
當SOC低於此閾值,calculate_soc縮短工作周期,這樣可以在接近關機的時候不斷地更新用戶空間的SOC。如qcom,low-soc-calculate-soc-threshold =<15>;
- qcom,low-voltage-threshold : The batteryvoltage threshold in micro-volts for
whenthe BMS tries to wake up and hold a wakelock to
ensurea clean shutdown.
低壓閾值,用於關機,當達到此值BMS嘗試喚醒和持有喚醒鎖來保證一個乾凈的關機。如qcom,low-voltage-threshold = <3450000>;
qcom,low-voltage-calculate-soc-ms : Thetime period between subsequent
SoCrecalculations when the current voltage is below qcom,low-voltagethreshold. This takes precedence over qcom,low-soc-calculate-soc-ms.
當電池電壓低於qcom,low-voltage threshold,隨後重新計算soc的時間周期,者優先於qcom,low-soc-calculate-soc-ms,如qcom,low-voltage-calculate-soc-ms = <1000>;。
qcom,low-soc-calculate-soc-ms : The timeperiod between subsequent
SoCrecalculations when the current SoC is below qcom,low-soc-calculate-soc-threshold.This takes precedenceover qcom,calculate-soc-ms.
當前SOC低於qcom,low-soc-calculate-soc-threshold時,隨後重新計算SOC的時間周期,這優先於qcom,calculate-soc-ms,如low-soc-calculate-soc-ms = <5000>;
qcom,calculate-soc-ms : The time periodbetween subsequent SoC
recalculationswhen the current SoC is above or equal qcom,low-soc-calculate-soc-threshold.
當前SOC>= qcom,low-soc-calculate-soc-threshold時的計算soc的時間周期。如qcom,calculate-soc-ms =<20000>;
qcom,volatge-soc-timeout-ms : The timeoutperiod after which the module starts
reportingvolage based SOC and does not use the VMBMS algorithmfor SOC calculation.
如果沒有使用VMBMS演算法來計算SOC,模塊在此時間後基於SOC來報告電壓。如qcom,volatge-soc-timeout-ms =<60000>;
- qcom,bms-vadc: Corresponding VADCdevice's phandle.
相應的VADC設備的phandle,qcom,bms-vadc = <&pm8909_vadc>;
qcom,bms-adc_tm: Corresponding ADC_TMdevice's phandle to set recurring
measurements andreceive notifications for vbatt.
相應ADC_TM設備的phandle,用於設置迴圈測量和接受vbatt的通知。如qcom,bms-adc_tm =<&pm8909_adc_tm>;
- qcom,pmic-revid : Phandle pointing to therevision peripheral node.
指向revision外圍節點的phandle,如qcom,pmic-revid = <&pm8909_revid>;
Parent node Optional properties
父節點可選屬性
qcom,s1-sample-interval-ms: The samplingrate in ms of the accumulator in state
S1.(i.e) the rate at which the accumulator is being filledwith vbat samples. Minimum value = 0 and Maximumvalue = 2550ms.
qcom,s2-sample-interval-ms: The samplingrate in ms of the accumulator in state
S2.(i.e) the rate at which the accumulator is being filledwith vbat samples. Minimum value = 0 and Maximumvalue = 2550ms.
qcom,s1-sample-count: The number ofsamples to be accululated for one FIFO in
stateS1. Possible values are - 0, 4, 8, 16, 32, 64, 128, 256.
qcom,s2-sample-count: The number ofsamples to be accululated for one FIFO in
stateS2. Possible values are - 0, 4, 8, 16, 32, 64, 128, 256.
qcom,s1-fifo-legth: Number of FIFO's to be filled in state S1, togenerate
thefifo_update_done interrupt. Possile values - 0 to 8
qcom,s2-fifo-legth: Number of FIFO's to be filled in state S2, togenerate
thefifo_update_done interrupt. Possible values- 0 to 8
上面幾個可選屬性沒有用到就不描述了。
qcom,force-s3-on-suspend : Bool propertyto force the BMS into S3 (sleep) state
whileentering into system suspend.
如有此項,當系統休眠時此屬性強迫BMS進入S3(sleep)狀態。
- qcom,force-bms-active-on-charger: Boolproperty to keep BMS FSM active
ifcharger is present.
只要充電器在,保證BMS FSM激活狀態。
- qcom,report-charger-eoc : Bool propertyto indicate if BMS needs to indicate
EOCto charger.
指示BMS需要通知EOC(充電結束)給充電器
- qcom,ignore-shutdown-soc: A boolean thatcontrols whether BMS will
tryto force the startup SoC to be the same as the
shutdownSoC. Defining it will make BMS ignore the
shutdownSoC.
控制BMS是否嘗試去強迫啟動時SOC和關機SOC一樣,如果定義此項將使BMS忽略關機SOC,這意味著開機時不會用上次關機SOC,一般情況下都需要這樣,所以沒有採用此屬性
- qcom,use-voltage-soc : A boolean thatcontrols whether BMS will use
voltage-basedSoC instead of a coulomb counter based
one.Voltage-based SoC will not guarantee linearity.
BMS根據此項的值來決定是否採用基於電壓的SOC來替代基於庫倫電量計的方式,基於電壓的SOC不保證線性性。
- qcom,disable-bms : Bool property to disable the VMBMS hardware module.
Enablethis property if BMS is not supported or an external
fuelgauge is used.
此屬性用於關閉VM BMS硬體模塊,在不支持BMS或是使用一個外部電量計時使能此屬性。
- qcom,s3-ocv-tolerence-uv : The S3 stateOCV tolerence threshold in uV. The
LSBvalue is 300uV and maximum value is 76500uV.
S3狀態OCV相容閾值,最低值是300uV和最大值是76500uV。
- qcom,low-soc-fifo-length : The fifolength (of S2 STATE) to be used at lower
SOCs.If this value is not specified the system uses
defaultlenght.
低SOC時S2狀態FIFO長度,如果沒有指定則系統採用預設長度,這裡為qcom,low-soc-fifo-length= <2>;
- qcom,resume-soc: Capacity in percent at which charging should resume
whena fully charged battery drops below this level.
當充滿的電池百分比低於此值,則重新開始充電。如qcom,resume-soc =<99>;
- qcom,low-temp-threshold : The temperaturethreshold below which the IBAT
averagingand UUC smoothening is disabled. This value
isin deci-degrees centigrade. If not specified it
defaultsto 0.
當溫度閾值低於此值,禁用IBAT求取平均值和UUC(不可用電量)平滑功能,如沒指定預設為0,我們這裡沒有指定。
- qcom,ibat-avg-samples : The number ofsamples to be averaged for IBAT
estimation.If not specified it defaults to 16.
Thepossible values are 1 to 16.
IBAT平均值估算的採用次數,如沒有指定預設為16,有效值1~16,我們沒有指定。
- qcom,batt-aging-comp : A boolean thatdefines if battery aging compensation
isenabled.
定義此項表示使能電池老化補償,但我沒有用到,建議使用。
- qcom,use-reported-soc : Bool property toenable the reported_soc logic. To
enablethis feature, qcom,resume-soc must be defined as
aproper value. The BMS is also required to control the
charging,discharging and recharging.
此項使能reported_soc邏輯,而且要定義qcom,resume-soc為一個合適的值,BMS也需要控制充電、停止充電和重新充電。高通給出的代碼預設是定義qcom,use-reported-soc,但我們核心板廠家註釋掉此項,並增加qcom,report-charger-eoc
qcom,batt-pres-status節點需要的屬性值
- reg : offset and length of the PMIC LBCbattery interface BATT_PRES_STATUS
register
如
qcom,batt-pres-status@1208 {
reg= <0x1208 0x1>;
};
qcom,qpnp-chg-pres節點需要的屬性
- reg : offset and length of the PMIC LBCcharger interafce CHARGER_OPTION
register.
如
qcom,qpnp-chg-pres@1008 {
reg= <0x1008 0x1>;
};