SC60 模块可编程开关模式锂电池充电功能,可以给单节锂电池和聚合物电池充电。其充电过程包括涓流充电、预充电、恒流充电、恒压充电等状态。
◆ 涓流充电:电池电压低于2.1V 时,系统处于涓流充电模式,充电电流为45mA;
◆ 预充电:当电池电压在2.1V–3.0V(截止电压可编程:2.4V–3.0V,默认3.0V)之间时,模块进入预充电模式,充电电流默认为250mA(可编程:100mA~250mA,默认250mA);
◆ 恒流充电:当电池电压在预充电截止电压和4.2V(恒流充电截止电压可编程:3.6V-4.5V,默认4.2V)之间时,模块进入恒流充电模式,充电电流软件可设置为300mA~3000mA(软件默认设置:USB 充电电流为500mA,适配器充电电流为2A);
◆ 恒压充电:当电池电压达到4.2V 时开始恒压充电,此时充电电流逐渐下降,当充电电流降低到100mA 左右时,截止充电。
SC60 模块带有电池温度检测功能。该功能的实现需要电池内部集成有热敏电阻(默认选择47K 1%,B 常数为4050K 的NTC,推荐SUNLORD 的SDNT1608X473F4050FTF),并且该热敏电阻需连接到VBAT_THERM 引脚。VBAT_THERM 引脚若不连接,则会导致不开机、电池不能充电、电池电量显示错误等故障。电池充电连接示意图如下所示:
如果客户使用的电池没有热敏电阻,或者客户使用电源适配器对模块进行供电,则只需连接VBAT 和GND。此时为防止系统误判电池不存在而导致无法开机,客户应该将VBAT_THERM 引脚通过一个47KΩ的电阻连接到GND。
充电相关的config:
CONFIG_QPNP_SMB5=y
CONFIG_QPNP_SMBCHARGER=y
CONFIG_QPNP_TYPEC=y
CONFIG_QPNP_QG=y //Qualcomm Gauge电量计 不用CONFIG_QPNP_VM_BMS
充电过程:
电池温度:
◆电池NTC的上拉电压是1.875V,上拉电阻可选为30K,100K,400K。配置项在SC60_pmi632.dtsi:
qcom,connector-internal-pull-kohm = <100>;
这个值如果修改了,对应函数qg_get_battery_temp(kernel\msm-4.9\drivers\power\supply\qcom\qg-util.c)中读取电池温度的参数也需要修改,默认的是VADC_BAT_THERM_PU2,对应到100K。
◆温度对应表为adcmap_batt_therm(kernel\msm-4.9\drivers\hwmon\qpnp-adc-common.c),根据电池的ntc和上拉电阻的分压来修改。
◆电池dtsi文件中的qcom,battery-therm-kohm = <10>;没有使用
◆可以使用cat /sys/class/power_supply/battery/temp读取温度值(读到的温度值除以10是实际温度)
◆读取温度流程:
设备树SC60_pmi632.dtsi中:
pmi632_qg: qpnp,qg {
compatible = “qcom,qpnp-qg”; //这里不是qcom,qpnp-fg
……
对应bms管理的驱动文件为qpnp-qg.c文件,调用devm_power_supply_register注册bms
对应的函数指针.get_property = qg_psy_get_property
→ case POWER_SUPPLY_PROP_TEMP:
rc = qg_get_battery_temp(chip, &pval->intval);
break;
qg_get_battery_temp调用qpnp_vadc_read,channel通道是VADC_BAT_THERM_PU2, →0x4a
而设备树中:
chan@4a {
label = “bat_therm”;
reg = <0x4a>;
qcom,decimation = <2>;
qcom,pre-div-channel-scaling = <0>;
qcom,calibration-type = “ratiometric”;
qcom,scale-function = <17>;
qcom,hw-settle-time = <0>;
qcom,fast-avg-setup = <0>;
qcom,cal-val = <0>;
};
[SCALE_BATT_THERM_TEMP] = {qpnp_adc_batt_therm},
所以就是调用qpnp_adc_batt_therm这个函数进行scale处理,调用的数组就是adcmap_batt_therm了。
adcmap_batt_therm这个表就是电压和温度的对应表。
电池ID:
kernel/msm-4.9/arch/arm64/boot/dts/sc/SC60-pmi632.dtsi:
/{
mtp_batterydata: qcom,battery-data {
qcom,batt-id-range-pct = <15>;
#include “qg-batterydata-ascent-3450mah.dtsi”
#include “qg-batterydata-mlp-2800mah.dtsi”
};
};
参考设备树说明文档:
android\kernel\msm-4.9\Documentation\devicetree\bindings\power\supply\qcom
qpnp_qg_probe → qg_setup_battery →get_batt_id_ohm
这个函数会去将ID脚内部上拉100K到1.875V,采样得到电池的ID。
qg_load_battery_profile → of_batterydata_get_best_profile
根据id得到最合适的电池profile文件,误差定义15% qcom,batt-id-range-pct = <15>;
SC60的核心板ID脚上接了47K的下拉,这样函数get_batt_id_ohm得到的电池ID为47K,会匹配到qg-batterydata-ascent-3450mah.dtsi:
qcom,batt-id-kohm = <47>; //如果需要,根据实际的电池ID修改
电池曲线:
参考设备树中的qg-batterydata-ascent-3450mah.dtsi,代码注释参考如下:
/* Copyright (c) 2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ qcom,ascent_3450mah {
/* Ascent_wConn_3450mAh_Fresh_averaged_MasterSlave_Feb7th2018 */ //电池最大充电电压,高压电池才设为4350mV //注意:这个是给电量计算用的,充电限制电压在pmi632_charger: qcom,qpnp-smb5 {} 中需要设置的 qcom,max-voltage-uv = <>; //恒流恒压充电电压门限 qcom,fg-cc-cv-threshold-mv = <4340>; // /sys/class/power_supply/battery/POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX //快充电流设置1C qcom,fastchg-current-ma = <3450>; //电池ID,会根据温度调整,demo板设计为47K,使用电池时,这里就定义为47K qcom,batt-id-kohm = <47>; // sys/class/power_supply/bms/POWER_SUPPLY_CHARGE_FULL //电池容量mAh,会根据温度调整的 qcom,battery-beta = <3435>; //stone add comment not use qcom,battery-therm-kohm = <47>; //sys/class/power_supply/bms/POWER_SUPPLY_BATTERY_TYPE中的名字 qcom,battery-type = "Ascent_wConn_3450mAh_Fresh_averaged_MasterSlave_Feb7th2018"; qcom,qg-batt-profile-ver = <100>; //需要根据容量修改 step-chg-jeita.c //0-10°充电电流 qcom,jeita-fcc-ranges = <0 100 101 400 401 450 >; //0-10°充电电压 qcom,jeita-fv-ranges = <0 100 101 400 401 450 >; //分阶段充电电流 qcom,step-chg-ranges = < >; /* COOL = 5 DegC, WARM = 40 DegC */ qcom,jeita-soft-thresholds = <0x44bd 0x1fc4>; /* COLD = 0 DegC, HOT = 45 DegC */ qcom,jeita-hard-thresholds = <0x4aa5 0x1bfb>; qcom,fcc1-temp-lut {
qcom,lut-col-legend = <0 10 25 40 50>; //需要根据容量修改 qcom,lut-data = <3377 3428 3481 3496 3500>; }; qcom,fcc2-temp-lut {
qcom,lut-col-legend = <(-10) 0 10 25 40 50>; //需要根据容量修改 qcom,lut-data = <3480 3482 3476 3492 3478 3466>; }; //充电时的电压vs温度百分比 qcom,pc-temp-v1-lut {
qcom,lut-col-legend = <0 10 25 40 50>; qcom,lut-row-legend = <10000 9800 9600 9400 9200>, <9000 8800 8600 8400 8200>, <8000 7800 7600 7400 7200>, <7000 6800 6600 6400 6200>, <6000 5800 5600 5400 5200>, <5000 4800 4600 4400 4200>, <4000 3800 3600 3400 3200>, <3000 2800 2600 2400 2200>, <2000 1800 1600 1400 1200>, <1000 900 800 700 600>, <500 400 300 200 100>, <0>; //一共56个百分比 qcom,lut-data = <43212 43315 43370 43380 43383>, //100% <42963 43071 43141 43149 43152>, //98% <42723 42832 42902 42916 42922>, //96% <42488 42597 42662 42683 42693>, //94% <42262 42367 42430 42454 42465>, //92% <42043 42143 42202 42225 42238>, //90% <41832 41924 41976 41999 42013>, //88% <41624 41709 41754 41775 41791>, //86% <41419 41497 41536 41556 41571>, //84% <41220 41288 41322 41341 41355>, //82% <41039 41091 41113 41132 41143>, //80% <40866 40911 40916 40928 40936>, //78% <40676 40732 40729 40729 40734>, //76% <40449 40526 40541 40538 40541>, //74% <40230 40302 40340 40351 40355>, //72% <40061 40115 40146 40170 40176>, //70% <39918 39974 39984 40002 40007>, //68% <39787 39846 39843 39845 39846>, //66% <39672 39712 39697 39690 39689>, //64% <39560 39579 39548 39536 39538>, //62% <39426 39419 39388 39376 39384>, //60% <39271 39170 39192 39187 39198>, //58% <39112 38928 38961 38960 38967>, //56% <38934 38809 38788 38776 38775>, //54% <38764 38736 38674 38650 38646>, //52% <38660 38665 38581 38546 38539>, //50% <38589 38587 38491 38448 38439>, //48% <38533 38513 38408 38359 38347>, //46% <38487 38444 38334 38278 38263>, //44% <38448 38381 38265 38204 38187>, //42% <38407 38323 38204 38138 38118>, //40% <38364 38269 38149 38078 38055>, //38% <38322 38219 38099 38026 37999>, //36% <38284 38175 38053 37975 37942>, //34% <38249 38137 38014 37930 37889>, //32% <38211 38098 37974 37884 37834>, //30% <38174 38061 37930 37831 37767>, //28% <38129 38020 37882 37771 37691>, //26% <38055 37954 37816 37698 37610>, //24% <37946 37848 37718 37605 37524>, //22% <37825 37726 37602 37497 37426>, //20% <37689 37595 37474 37372 37301>, //18% <37541 37451 37332 37231 37156>, //16% <37372 37290 37178 37080 36999>, //14% <37271 37162 37061 36964 36886>, //12% <37191 37093 36992 36897 36819>, //10% <37157 37064 36970 36870 36798>, //9% <37128 37039 36949 36844 36770>, //8% <37084 37007 36903 36788 36714>, //7% <36927 36851 36683 36562 36488>, //6% <36555 36481 36290 36180 36108>, //5% <36071 35999 35771 35687 35620>, //4% <35450 35376 35098 35050 34994>, //3% <34604 34523 34174 34184 34150>, //2% <33275 33138 32725 32851 32862>, //1% <31900 32000 32000 32000 32000>; //0% }; //不充电时的电压vs温度百分比 qcom,pc-temp-v2-lut {
qcom,lut-col-legend = <(-10) 0 10 25 40 50>; qcom,lut-row-legend = <10000 9800 9600 9400 9200 9000>, <8800 8600 8400 8200 8000 7800>, <7600 7400 7200 7000 6800 6600>, <6400 6200 6000 5800 5600 5400>, <5200 5000 4800 4600 4400 4200>, <4000 3800 3600 3400 3200 3000>, <2800 2600 2400 2200 2000 1800>, <1600 1400 1200 1000 900 800>, <700 600 500 400 300 200>, <100 0>; qcom,lut-data = <43425 43415 43385 43360 43315 43295>, <43070 43109 43097 43094 43052 43033>, <42748 42821 42826 42838 42799 42781>, <42462 42555 42571 42594 42557 42541>, <42208 42308 42333 42361 42326 42312>, <41968 42072 42101 42133 42099 42086>, <41736 41844 41872 41904 41872 41860>, <41516 41625 41649 41680 41649 41637>, <41303 41405 41431 41460 41430 41419>, <41100 41186 41217 41243 41215 41204>, <40896 40979 41012 41034 41005 40994>, <40694 40796 40826 40840 40802 40789>, <40482 40616 40642 40648 40604 40590>, <40220 40407 40432 40445 40411 40399>, <39903 40175 40199 40233 40222 40214>, <39636 39954 39996 40043 40042 40036>, <39443 39759 39844 39886 39877 39868>, <39272 39570 39700 39736 39717 39706>, <39091 39370 39511 39573 39556 39547>, <38908 39162 39283 39399 39396 39391>, <38742 38973 39072 39208 39217 39217>, <38591 38806 38886 38975 38988 38994>, <38460 38655 38721 38760 38766 38771>, <38358 38519 38585 38613 38613 38614>, <38274 38396 38468 38496 38494 38494>, <38201 38287 38362 38390 38388 38387>, <38138 38189 38265 38294 38291 38288>, <38080 38106 38177 38206 38202 38198>, <38027 38039 38096 38126 38120 38114>, <37980 37983 38021 38051 38044 38037>, <37934 37935 37954 37984 37976 37967>, <37889 37895 37891 37921 37915 37905>, <37843 37856 37838 37862 37856 37846>, <37795 37815 37799 37803 37790 37781>, <37746 37774 37768 37746 37720 37707>, <37692 37727 37728 37685 37643 37621>, <37633 37677 37677 37620 37554 37517>, <37568 37618 37617 37550 37465 37411>, <37491 37546 37548 37475 37387 37327>, <37404 37459 37466 37395 37313 37256>, <37310 37360 37369 37301 37226 37174>, <37206 37243 37246 37187 37117 37069>, <37103 37111 37106 37050 36988 36945>, <37005 36964 36946 36900 36839 36796>, <36909 36860 36837 36818 36761 36712>, <36808 36782 36769 36775 36718 36673>, <36746 36740 36732 36741 36690 36651>, <36670 36688 36684 36692 36649 36612>, <36553 36594 36591 36575 36542 36528>, <36329 36380 36368 36272 36271 36278>, <35961 35991 35957 35796 35833 35867>, <35436 35452 35401 35193 35271 35340>, <34709 34745 34680 34409 34550 34676>, <33672 33759 33677 33330 33585 33791>, <31857 32191 32244 31867 32001 32517>, <28160 28896 29014 27510 28586 29617>; }; //好像没有用 kernel\msm-4.9\drivers\power\supply\qcom\qg-battery-profile.c里面 qcom,pc-temp-z1-lut {
qcom,lut-col-legend = <0 10 25 40 50>; qcom,lut-row-legend = <10000 9800 9600 9400 9200>, <9000 8800 8600 8400 8200>, <8000 7800 7600 7400 7200>, <7000 6800 6600 6400 6200>, <6000 5800 5600 5400 5200>, <5000 4800 4600 4400 4200>, <4000 3800 3600 3400 3200>, <3000 2800 2600 2400 2200>, <2000 1800 1600 1400 1200>, <1000 900 800 700 600>, <500 400 300 200 100>, <0>; qcom,lut-data = <13703 12983 12375 12138 12079>, <13647 12967 12370 12145
今天的文章
移远sc66_android 开发板分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/81252.html