高通sdm660-快充调试

高通sdm660-快充调试 艾编程的鲁小班 2023-02-01 08:45:48 3303

目录


1,充电框架

2,电池相关

3,usb相关

4,参数

5,设备树配置

6,编译和下载

7,QC3.0/2.0   快充识别升压典型电路

8,高通PD快充

9,设置安卓系统电池百分之3自动关机

10,高通电池检测服务

11,电池服务log解析

12,查看电池状态


1,充电框架

参考文档<SC66 Charging User Guide>

易百纳社区

易百纳社区

文件名描述
Android\kernel\msm-4.4\drivers\power\supply\qcom\qpnp-smb2.c充电驱动 
Android\kernel\msm-4.4\drivers\power\supply\qcom\smb-lib.c充电驱动
android/kernel\msm-4.4\arch\arm64\boot\dts\qcom\fg-gen3-batterydata-xxx.dtsi电池参数
Android\kernel\msm-4.4\arch\arm64\boot\dts\qcom\msm-pm660.dtsi充电参数
Android\kernel\msm-4.4\drivers\power\supply\qcom\qpnp-fg-gen3.c电量计驱动

2,电池相关

电池进程可以通过如下文件访问:

/sys/class/power_supply/battery

易百纳社区

3,usb相关

USB进程可以通过如下文件访问

/sys/class/power_supply/usb

易百纳社区

易百纳社区

易百纳社区

易百纳社区

4,参数

/sys/module/qcom,qpnp-smb2/parameters.

易百纳社区

5,设备树配置

The charging device tree settings are explain in follow files:

kernel\msm-4.4\Documentation\devicetree\bindings\power\supply\qcom\ qpnp-smb2.txt

qpnp-smb2.txt

pmi8998_charger: qcom,qpnp-smb2 {
        compatible = "qcom,qpnp-smb2";
        #address-cells = <1>;
        #size-cells = <1>;

        io-channels = <&pmic_rradc 0>;
        io-channel-names = "rradc_batt_id";

        dpdm-supply = <&qusb_phy0>;

        qcom,chgr@1000 {
                reg = <0x1000 0x100>;
                interrupts =    <0x2 0x10 0x0 IRQ_TYPE_NONE>,
                                <0x2 0x10 0x1 IRQ_TYPE_NONE>,
                                <0x2 0x10 0x2 IRQ_TYPE_NONE>,
                                <0x2 0x10 0x3 IRQ_TYPE_NONE>,
                                <0x2 0x10 0x4 IRQ_TYPE_NONE>;

                interrupt-names =       "chg-error",
                                        "chg-state-change",
                                        "step-chg-state-change",
                                        "step-chg-soc-update-fail",
                                        "step-chg-soc-update-request";
        };

        qcom,otg@1100 {
                reg = <0x1100 0x100>;
                interrupts =    <0x2 0x11 0x0 IRQ_TYPE_NONE>,
                                <0x2 0x11 0x1 IRQ_TYPE_NONE>,
                                <0x2 0x11 0x2 IRQ_TYPE_NONE>,
                                <0x2 0x11 0x3 IRQ_TYPE_NONE>;

                interrupt-names =       "otg-fail",
                                        "otg-overcurrent",
                                        "otg-oc-dis-sw-sts",
                                        "testmode-change-detect";
        };

        qcom,bat-if@1200 {
                reg = <0x1200 0x100>;
                interrupts =    <0x2 0x12 0x0 IRQ_TYPE_NONE>,
                                <0x2 0x12 0x1 IRQ_TYPE_NONE>,
                                <0x2 0x12 0x2 IRQ_TYPE_NONE>,
                                <0x2 0x12 0x3 IRQ_TYPE_NONE>,
                                <0x2 0x12 0x4 IRQ_TYPE_NONE>,
                                <0x2 0x12 0x5 IRQ_TYPE_NONE>;

                interrupt-names =       "bat-temp",
                                        "bat-ocp",
                                        "bat-ov",
                                        "bat-low",
                                        "bat-therm-or-id-missing",
                                        "bat-terminal-missing";
        };

        qcom,usb-chgpth@1300 {
                reg = <0x1300 0x100>;
                interrupts =    <0x2 0x13 0x0 IRQ_TYPE_NONE>,
                                <0x2 0x13 0x1 IRQ_TYPE_NONE>,
                                <0x2 0x13 0x2 IRQ_TYPE_NONE>,
                                <0x2 0x13 0x3 IRQ_TYPE_NONE>,
                                <0x2 0x13 0x4 IRQ_TYPE_NONE>,
                                <0x2 0x13 0x5 IRQ_TYPE_NONE>,
                                <0x2 0x13 0x6 IRQ_TYPE_NONE>,
                                <0x2 0x13 0x7 IRQ_TYPE_NONE>;

                interrupt-names =       "usbin-collapse",
                                        "usbin-lt-3p6v",
                                        "usbin-uv",
                                        "usbin-ov",
                                        "usbin-plugin",
                                        "usbin-src-change",
                                        "usbin-icl-change",
                                        "type-c-change";
        };

        qcom,dc-chgpth@1400 {
                reg = <0x1400 0x100>;
                interrupts =    <0x2 0x14 0x0 IRQ_TYPE_NONE>,
                                <0x2 0x14 0x1 IRQ_TYPE_NONE>,
                                <0x2 0x14 0x2 IRQ_TYPE_NONE>,
                                <0x2 0x14 0x3 IRQ_TYPE_NONE>,
                                <0x2 0x14 0x4 IRQ_TYPE_NONE>,
                                <0x2 0x14 0x5 IRQ_TYPE_NONE>,
                                <0x2 0x14 0x6 IRQ_TYPE_NONE>;

                interrupt-names =       "dcin-collapse",
                                        "dcin-lt-3p6v",
                                        "dcin-uv",
                                        "dcin-ov",
                                        "dcin-plugin",
                                        "div2-en-dg",
                                        "dcin-icl-change";
        };

        qcom,chgr-misc@1600 {
                reg = <0x1600 0x100>;
                interrupts =    <0x2 0x16 0x0 IRQ_TYPE_NONE>,
                                <0x2 0x16 0x1 IRQ_TYPE_NONE>,
                                <0x2 0x16 0x2 IRQ_TYPE_NONE>,
                                <0x2 0x16 0x3 IRQ_TYPE_NONE>,
                                <0x2 0x16 0x4 IRQ_TYPE_NONE>,
                                <0x2 0x16 0x5 IRQ_TYPE_NONE>,
                                <0x2 0x16 0x6 IRQ_TYPE_NONE>,
                                <0x2 0x16 0x7 IRQ_TYPE_NONE>;

                interrupt-names =       "wdog-snarl",
                                        "wdog-bark",
                                        "aicl-fail",
                                        "aicl-done",
                                        "high-duty-cycle",
                                        "input-current-limiting",
                                        "temperature-change",
                                        "switcher-power-ok";
        };
};

kernel\msm-4.4\Documentation\devicetree\bindings\power\supply\qcom\ qpnp-fg-gen3.txt

qpnp-fg-gen3

通过debug_mask控制调试信息

echo 0xff >/sys/module/qpnp_fg_gen3/parameters/debug_mask

pmi8998_fg: qpnp,fg {
        compatible = "qcom,fg-gen3";
        #address-cells = <1>;
        #size-cells = <1>;
        qcom,pmic-revid = <&pmi8998_revid>;
        io-channels = <&pmi8998_rradc 3>;
        io-channel-names = "rradc_batt_id";
        qcom,rradc-base = <0x4500>;
        qcom,ki-coeff-soc-dischg = <30 60 90>;
        qcom,ki-coeff-med-dischg = <800 1000 1400>;
        qcom,ki-coeff-hi-dischg = <1200 1500 2100>;
        qcom,slope-limit-temp-threshold = <100>;
        qcom,slope-limit-coeffs = <10 11 12 13>;
        qcom,battery-thermal-coefficients = [9d 50 ff];
        status = "okay";

        qcom,fg-batt-soc@4000 {
                status = "okay";
                reg = <0x4000 0x100>;
                interrupts = <0x2 0x40 0x0 IRQ_TYPE_EDGE_BOTH>,
                             <0x2 0x40 0x1 IRQ_TYPE_EDGE_BOTH>,
                             <0x2 0x40 0x2 IRQ_TYPE_EDGE_BOTH>,
                             <0x2 0x40 0x3 IRQ_TYPE_EDGE_BOTH>;
                interrupt-names = "soc-update",
                                  "soc-ready",
                                  "bsoc-delta",
                                  "msoc-delta";

        };

        qcom,fg-batt-info@4100 {
                status = "okay";
                reg = <0x4100 0x100>;
                interrupts = <0x2 0x41 0x3 IRQ_TYPE_EDGE_BOTH>;
                interrupt-names = "batt-missing";
        };

        qcom,fg-memif@4400 {
                status = "okay";
                reg = <0x4400 0x100>;
        };
};

6,编译和下载

make –jn bootimage   (“n” means the thread numbers of CPU)

download Kernel Images by Fastboot

adb reboot bootloader
fastboot flash boot android\out\target\product\sdm660_64\boot.img
fastboot reboot

7,QC3.0/2.0   快充识别升压典型电路

易百纳社区

8,高通PD快充

代码位置:kernel/msm-4.4/drivers/usb/pd

易百纳社区

查看PD-phy的状态

cat /sys/kernel/debug/usb-pdphy/status

易百纳社区

cat /sys/kernel/debug/ipc_logging/usb_pd/log    协议交互过程

易百纳社区

设备树配置

 pm660_pdphy: qcom,usb-pdphy@1700 {
            compatible = "qcom,qpnp-pdphy";
            reg = <0x1700 0x100>;
            vdd-pdphy-supply = <&pm660l_l7>;
            vbus-supply = <&smb2_vbus>;
            vconn-supply = <&smb2_vconn>;
            interrupts = <0x0 0x17 0x0 IRQ_TYPE_EDGE_RISING>,
                     <0x0 0x17 0x1 IRQ_TYPE_EDGE_RISING>,
                     <0x0 0x17 0x2 IRQ_TYPE_EDGE_RISING>,
                     <0x0 0x17 0x3 IRQ_TYPE_EDGE_RISING>,
                     <0x0 0x17 0x4 IRQ_TYPE_EDGE_RISING>,
                     <0x0 0x17 0x5 IRQ_TYPE_EDGE_RISING>,
                     <0x0 0x17 0x6 IRQ_TYPE_EDGE_RISING>;

            interrupt-names = "sig-tx",
                      "sig-rx",
                      "msg-tx",
                      "msg-rx",
                      "msg-tx-failed",
                      "msg-tx-discarded",
                      "msg-rx-discarded";

            qcom,default-sink-caps = <5000 3000>, /* 5V @ 3A */
                                     <9000 3000>; /* 9V @ 3A */
        };

充电驱动

调试信息

/sys/kernel/debug/charger/force_batt_psy_update

/sys/kernel/debug/charger/force_dc_psy_update 


/sys/kernel/debug/charger/force_usb_psy_updatepm660_charger: qcom,qpnp-smb2 {
            compatible = "qcom,qpnp-smb2";
            #address-cells = <1>;
            #size-cells = <1>;
            //qcom,batteryless-platform;
            qcom,pmic-revid = <&pm660_revid>;
            //qcom,micro-usb;
            //qcom,float-option = <1>;
            io-channels = <&pm660_rradc 8>,
                      <&pm660_rradc 10>,
                      <&pm660_rradc 3>,
                      <&pm660_rradc 4>;
            io-channel-names = "charger_temp",
                       "charger_temp_max",
                       "usbin_i",
                       "usbin_v";

            qcom,wipower-max-uw = <5000000>;
            dpdm-supply = <&qusb_phy0>;

            qcom,thermal-mitigation
                    = <3000000 2500000 2000000 1500000
                        1000000 500000>;

            qcom,chgr@1000 {
                reg = <0x1000 0x100>;
                interrupts =
                    <0x0 0x10 0x0 IRQ_TYPE_EDGE_RISING>,
                    <0x0 0x10 0x1 IRQ_TYPE_EDGE_RISING>,
                    <0x0 0x10 0x2 IRQ_TYPE_EDGE_RISING>,
                    <0x0 0x10 0x3 IRQ_TYPE_EDGE_RISING>,
                    <0x0 0x10 0x4 IRQ_TYPE_EDGE_RISING>;

                interrupt-names = "chg-error",
                          "chg-state-change",
                          "step-chg-state-change",
                          "step-chg-soc-update-fail",
                          "step-chg-soc-update-request";
            };

电池驱动

 qcom,bat-if@1200 {
                reg = <0x1200 0x100>;
                interrupts =
                    <0x0 0x12 0x0 IRQ_TYPE_EDGE_RISING>,
                    <0x0 0x12 0x1 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x12 0x2 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x12 0x3 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x12 0x4 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x12 0x5 IRQ_TYPE_EDGE_BOTH>;

                interrupt-names = "bat-temp",
                          "bat-ocp",
                          "bat-ov",
                          "bat-low",
                          "bat-therm-or-id-missing",
                          "bat-terminal-missing";
            };

USB和DC充电路径

qcom,usb-chgpth@1300 {
                reg = <0x1300 0x100>;
                interrupts =
                    <0x0 0x13 0x0 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x13 0x1 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x13 0x2 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x13 0x3 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x13 0x4 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x13 0x5 IRQ_TYPE_EDGE_RISING>,
                    <0x0 0x13 0x6 IRQ_TYPE_EDGE_RISING>,
                    <0x0 0x13 0x7 IRQ_TYPE_EDGE_RISING>;

                interrupt-names = "usbin-collapse",
                          "usbin-lt-3p6v",
                          "usbin-uv",
                          "usbin-ov",
                          "usbin-plugin",
                          "usbin-src-change",
                          "usbin-icl-change",
                          "type-c-change";
            };

            qcom,dc-chgpth@1400 {
                reg = <0x1400 0x100>;
                interrupts =
                    <0x0 0x14 0x0 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x14 0x1 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x14 0x2 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x14 0x3 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x14 0x4 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x14 0x5 IRQ_TYPE_EDGE_BOTH>,
                    <0x0 0x14 0x6 IRQ_TYPE_EDGE_RISING>;

                interrupt-names = "dcin-collapse",
                          "dcin-lt-3p6v",
                          "dcin-uv",
                          "dcin-ov",
                          "dcin-plugin",
                          "div2-en-dg",
                          "dcin-icl-change";
            };


9,设置安卓系统电池百分之3自动关机

--- a/frameworks/base/services/core/java/com/android/server/BatteryService.java
+++ b/frameworks/base/services/core/java/com/android/server/BatteryService.java
@@ -258,7 +258,7 @@ public final class BatteryService extends SystemService {
     private void shutdownIfNoPowerLocked() {
         // shut down gracefully if our battery is critically low and we are not powered.
         // wait until the system has booted before attempting to display the shutdown dialog.
-        if (mBatteryProps.batteryLevel <= 3 && !isPoweredLocked(BatteryManager.BATTERY_PLUGGED_ANY)) {
+        if (mBatteryProps.batteryLevel <= 5 && !isPoweredLocked(BatteryManager.BATTERY_PLUGGED_ANY)) {
             mHandler.post(new Runnable() {
                 @Override
                 public void run() {

vim frameworks/base/services/core/java/com/android/server/BatteryService.java

mmm frameworks/base/services/core

uild/make/core/base_rules.mk:412: warning: ignoring old commands for target `out/target/product/sdm660_64/vendor/lib64/libnetd_client.so'
[100% 83/83] Copy: out/target/product/sdm660_64/system/framework/oat/arm64/services.odex

#### build completed successfully (11:30 (mm:ss)) ####
adb push .\services.odex /system/framework/
mmm framework/base/services
编译完成后将out目录下的services.jar推送到system/framework/目录下,重启后即可生效。
如果resource也有相关更新,如要编译以下路径。
mmm frameworks/base/core/res/
cp out/target/product/sdm660_64/system/framework/services.jar  .

adb push .\services.jar   /system/framework/
编译 framework-res.apk(原生或高通)
编译完后com.android.internal.R中会生成资源的引用。
adb root
adb remount
adb push .\services.jar   /system/framework/
adb reboot

验证
adb shell
su
logcat | grep +++

10,高通电池检测服务

动态调试


echo -n 'file drivers/usb/pd/qpnp-pdphy.c  +p'  >   /sys/kernel/debug/dynamic_debug/controlecho -n 'file drivers/usb/pd/qpnp-pdphy.c  +p'  >   /sys/kernel/debug/dynamic_debug/control

打开动态调试

echo 'file policy_engine.c +p' > /sys/kernel/debug/dynamic_debug/control \n
echo 'file qpnp-pdphy.c +p' > /sys/kernel/debug/dynamic_debug/control \n
echo 'file smb-lib.c +p' > /sys/kernel/debug/dynamic_debug/control \n
echo 'file qpnp-smb2.c +p' > /sys/kernel/debug/dynamic_debug/control \n

关闭动态调试

echo 'file policy_engine.c -p' > /sys/kernel/debug/dynamic_debug/control \n
echo 'file qpnp-pdphy.c -p' > /sys/kernel/debug/dynamic_debug/control \n
echo 'file smb-lib.c -p' > /sys/kernel/debug/dynamic_debug/control \n
echo 'file qpnp-smb2.c -p' > /sys/kernel/debug/dynamic_debug/control \n

打开debug_mask

adb root && adb wait-for-device
adb shell
echo 0xFF > /sys/module/qpnp_smb2/parameters/debug_mask


11,电池服务log解析

[  277.111375] POWER_SUPPLY_PROP_ONLINEhealthd: battery l=78 v=4251 t=25.0 h=2 st=3 c=-1358 fc=2878000 cc=0 chg=a

l=78          当前电量

v=4251     电池电压

t=25          表示温度

h=2            batteryHealth

st=             batteryStatus

    { "Unknown", BATTERY_STATUS_UNKNOWN },1
    { "Charging", BATTERY_STATUS_CHARGING },2
    { "Discharging", BATTERY_STATUS_DISCHARGING },3
    { "Not charging", BATTERY_STATUS_NOT_CHARGING },4
    { "Full", BATTERY_STATUS_FULL },5
    { NULL, 0 },

c=              batteryCurrent

fc=             batteryFullCharge

cc=    batteryCycleCount

chg =     a    chargerAcOnline

              u     chargerUsbOnline

              w    chargerWirelessOnline


12,查看电池状态

#dumpsys battery
Current Battery Service state:
  AC powered: true
  USB powered: false
  Wireless powered: false
  Max charging current: 750000
  Max charging voltage: 5000000
  Charge counter: 484028
  status: 2
  health: 2
  present: true
  level: 4
  scale: 100
  voltage: 3642
  temperature: 250
  technology: Li-ion

查看当前电池电压

cat /sys/class/power_supply/battery/voltage_now

易百纳社区

声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
红包 2 1 评论 打赏
评论
0个
内容存在敏感词
手气红包
    易百纳技术社区暂无数据
相关专栏
置顶时间设置
结束时间
删除原因
  • 广告/SPAM
  • 恶意灌水
  • 违规内容
  • 文不对题
  • 重复发帖
打赏作者
易百纳技术社区
艾编程的鲁小班
您的支持将鼓励我继续创作!
打赏金额:
¥1易百纳技术社区
¥5易百纳技术社区
¥10易百纳技术社区
¥50易百纳技术社区
¥100易百纳技术社区
支付方式:
微信支付
支付宝支付
易百纳技术社区微信支付
易百纳技术社区
打赏成功!

感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~

举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

审核成功

发布时间设置
发布时间:
是否关联周任务-专栏模块

审核失败

失败原因
备注
拼手气红包 红包规则
祝福语
恭喜发财,大吉大利!
红包金额
红包最小金额不能低于5元
红包数量
红包数量范围10~50个
余额支付
当前余额:
可前往问答、专栏板块获取收益 去获取
取 消 确 定

小包子的红包

恭喜发财,大吉大利

已领取20/40,共1.6元 红包规则

    易百纳技术社区