高通sdm660-快充调试
目录
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
- 分享
- 举报
-
浏览量:2499次2023-02-10 16:48:01
-
浏览量:2230次2023-01-31 22:43:18
-
浏览量:2532次2020-07-22 14:25:03
-
浏览量:2072次2017-12-25 14:50:05
-
浏览量:2469次2020-07-03 14:49:05
-
浏览量:2459次2018-01-22 15:24:39
-
浏览量:1575次2020-11-03 14:59:08
-
浏览量:1827次2018-02-01 19:43:47
-
浏览量:2525次2018-12-11 13:30:45
-
浏览量:1523次2020-12-29 15:08:06
-
浏览量:2848次2017-12-19 11:26:05
-
浏览量:2597次2017-12-15 18:11:30
-
浏览量:615次2023-04-26 16:58:30
-
浏览量:1940次2022-11-17 15:30:20
-
浏览量:2131次2018-03-15 17:23:04
-
浏览量:2289次2018-02-22 16:16:27
-
浏览量:1543次2020-12-14 14:30:32
-
浏览量:5255次2019-11-09 09:37:38
-
浏览量:3366次2017-12-11 20:22:05
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
艾编程的鲁小班
感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明