高通电池管理基于qpnp-vm-bms电压模式
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>;
};
高通电池管理基于qpnp-vm-bms电压模式的更多相关文章
- 高通电源管理qpnp-vm-bms驱动
1. compatible节点: qpnp-vm-bms.c使用来控制电池曲线的和BMS功能的,其compatible节点是"qcom,qpnp-vm-bms" 2. probe函 ...
- 高通电源管理函数的power_supply的调用关系
以msm8909为例,高通的主要文件有几个: qpnp-linear-charger.c(线性充电器) qpnp-vm-bms.c(BMS管理) power_supply_core.c(power_s ...
- 高通方案的Android设备几种开机模式的进入与退出
高通方案的Android设备主要有以下几种开机模式,Android.EDL.Fastboot.Recovery和FFBM,其进入及退出的方式如下表. 开机模式 屏幕显示 冷启动 热启动 按键退出 命令 ...
- Nubia Z5S(高通公司MSM8974) QHSUSB_BULK砖的方法节省模式(随着win7在恢复recovery分区案例)
Nubia Z5S在某些异常情况或按组合键进入QHSUSB_BULK状态, 这种模式的现象, 猜想windows(实例win7)即使在数据线, 它会出现在计算机n载,甚至会提示要格式化某些分区(这里要 ...
- 高通ASOC中的codec驱动
ASOC的出现是为了让codec独立于CPU,减少和CPU之间的耦合,这样同一个codec驱动就无需修改就可以匹配任何一款平台. 在Machine中已经知道,snd_soc_dai_link结构就指明 ...
- 高通8X16电池BMS算法(一)【转】
本文转载自:http://www.voidcn.com/blog/yanleizhouqing/article/p-6037399.html 最近一直在搞电源管理相关内容,之前是8610的bms,现在 ...
- 针对高通BMS的研究 高通电量计
点击打开链接 高通8064 8974 8926等pm芯片都集成了电量计,估计后续芯片都会一直存在,现在许多项目UI状态栏电池都有百分比显示,所以需要深入分析BMS有助于解决电量方面的BUG. 一: S ...
- Android图形合成和显示系统---基于高通MSM8k MDP4平台
介绍了Android SurfaceFlinger层次以下的图形合成和显示系统,主要基于高通MSM8k MDP4x平台. 做为Android Display专题.SurfaceFlinger的详细介绍 ...
- Android上HDMI介绍(基于高通平台)
本文重点针对HDMI在android上的应用,而比较相关的就是overlay机制.overlay在这里只是简单的介绍,后续会有文章再专门详述. 我没记错的话,高通从7X30开始,平台就可以支持HDMI ...
随机推荐
- Leetcode题解 - 链表简单部分题目代码+思路(21、83、203、206、24、19、876)
- jQuery-验证码倒计时的实现
点击发送验证码,通常需要加入倒计时功能,HTML如下: <center class='block captchaArea'> <input class="input pwd ...
- IDEA的Maven设置阿里镜像
作为一名.net开发学习java,虽然学习起来没啥难度,但是各种配置实在让人头大. 下面就简单记录下IDEA的Maven设置阿里镜像 进入开发软件的这个设置 点击进入 如图所示 第一个是你安装mave ...
- PlayJava Day027
进程状态 1.创建状态:在程序中用构造方法创建了一个线程对象后,新的线程对象便处于新建状态 此时,它已经有了相应的内存空间和其他资源,但还处于不可运行状态 新建一个线程对象可采用Thread类的构造方 ...
- mysql中skip-grant-tables无效
今天我登录MySQL时,MySQL竟然报出这样的错误:ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using pass ...
- bootstrap-table 常用总结-1
两种表格工具,今天都用到了,一种是我前几篇写到过的jqgrid,(传送门)另一个就是bootstrap-table了.用过之后会发现,两种表格的方式大同小异,但是为什么这次要换成bootstrap-t ...
- 第03讲 fragment
Fragment 官网文档:https://developer.android.google.cn/guide/components/fragments 什么是Fragment 在手机上,Activi ...
- SpringCloud之Feign:REST客户端
在Spring Cloud集群中,各个角色的通信基于REST服务,在调用服务时,需要使用REST客户端,常用,除了使用Spring自带的RestTemplate,也可使用另一个REST客户端:Feig ...
- C#&.Net干货分享- 构造SMSWebChineseApi对接第三方短信平台
你们想要的短信对接,要舍得点钱哦.... /// <summary> /// http://sms.webchinese.cn/api.shtml /// </summa ...
- centos8 yum 安装 rabbitmq
进入/etc/yum.repos.d/ 文件夹创建rabbitmq-erlang.repo 文件内容如下[rabbitmq-erlang] name=rabbitmq-erlangbaseurl=ht ...