问题描述
BQ25703充电IC+CW2017电量计调试
解决方案:
附上dts配置文件
&i2c6 {
clock-frequency = <400000>;
status = "okay";
// CONFIG_BATTERY_CW2017
cw2017: cw2017@63 {
status = "okay";
compatible = "cellwise,cw2017";
reg = <0x63>;
// CW2015是68个bytes CW2017是需要80个bytes
// RK原厂默认参数
// cellwise,battery-profile = /bits/ 8
// <0x3C 0x00 0x00 0x00 0x00 0x00 0x00 0x00
// 0xB0 0xC4 0xBF 0xB9 0x9B 0x97 0xE0 0xCF
// 0xC1 0xCD 0xBB 0x9D 0x88 0x7C 0x65 0x56
// 0x52 0x50 0x4E 0x97 0x79 0xD2 0xDE 0xFF
// 0xE5 0xB4 0x71 0x7C 0xB0 0xC5 0xAE 0x93
// 0x9D 0xB5 0xCF 0xD5 0xC6 0xB0 0x99 0x89
// 0x82 0x85 0x91 0xA8 0xC1 0xC9 0xB0 0x43
// 0x00 0x00 0x90 0x02 0x00 0x00 0x00 0x00
// 0x00 0x00 0x64 0x00 0x00 0x00 0x00 0x00
// 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xA2>;
// 电量计那边给的一组默认参数
cellwise,battery-profile = /bits/ 8
<0x5A 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x9E 0xC8 0xD2 0xC5 0xC2 0xCF 0x53 0x25
0x10 0xF5 0xEB 0xE1 0xB7 0x93 0x83 0x6E
0x5D 0x4D 0x42 0x54 0x94 0xDC 0x76 0xD7
0xD7 0xD2 0xD2 0xD0 0xCE 0xCC 0xC4 0xCD
0xC3 0xBD 0xCB 0xAE 0x96 0x8A 0x83 0x75
0x67 0x61 0x76 0x8C 0xA4 0x96 0x50 0x66
0x00 0x00 0x90 0x02 0x00 0x00 0x00 0x00
0x00 0x00 0x64 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x22>;
cellwise,dual-cell = <1>;
cellwise,monitor-interval-ms = <5000>;
//设置低电量提醒,当电池电量到10%的时候会发出中断
cellwise,alert-level = <10>;
//电池容量,5000mah
cellwise,design-capacity-amh = <5000>;
//充电IC节点
power-supplies = <&bq25703>;
monitored-battery = <&battery>;
};
// 我这里充电走的是DC,没有走Typc充电。所以PD部分舍弃了
bq25703: bq25703@6b {
status = "okay";
compatible = "ti,bq25703";
reg = <0x6b>;
//ti,usb-charger-detection = <&usbc0>;
// CHRG_OK_H GPIO0_B7_D
interrupt-parent = <&gpio0>;
interrupts = <RK_PB7 IRQ_TYPE_LEVEL_LOW>;
// BQ_OTG_EN_H GPIO3_D2_D
// otg-mode-en-gpios = <&gpio3 RK_PD2 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&charger_ok>;
extcon = <&u2phy0>;
// 充电电流 样机没关系 标准1A 最大2.5A
ti,charge-current = <2500000>;
ti,max-input-voltage = <20000000>;
ti,max-input-current = <6000000>;
// 充电电压
ti,max-charge-voltage = <8750000>;
// 输入电流
ti,input-current = <2000000>;
ti,input-current-sdp = <500000>;
ti,input-current-dcp = <2000000>;
ti,input-current-cdp = <2000000>;
ti,minimum-sys-voltage = <7400000>;
ti,otg-voltage = <5000000>;
ti,otg-current = <1500000>;
pd-charge-only = <0>;
regulators {
vbus5v0_typecc: vbus5v0-typecc {
regulator-compatible = "otg-vbus";
regulator-name = "vbus5v0_typecc";
};
};
};
};
遇到的第一个问题是:
bq25703驱动一直打印:
console:/ # dmesg | grep bq
[ 10.068822] bq25700-charger 6-006d: Error applying setting, reverse things back
[ 10.068830] bq25700-charger: probe of 6-006d failed with error -22
这里是dts配置中有冲突配置,经过查找是pinctrl-0 = <&charger_ok>;的gpio被vcc_3v3_sd_s0占用了,导致驱动打印, reverse things back。
而cw2017驱动一直打印:
console:/ # dmesg | grep cw2017
[ 10.068681] cw2017 6-0063: battery-profile must be 80 bytes
[ 10.068685] cw2017 6-0063: Failed to parse cw2017 properties
[ 10.068692] cw2017: probe of 6-0063 failed with error -22
在上网没找到2017的电池配置,直接写了一组CW2015的配置参数导致的。
CW2015是68个bytes CW2017是需要80个bytes 这里需要注意。
接下来遇到的问题是:
bq25703驱动一直打印:
console:/ # dmesg | grep bq
[ 18.446271] wgf:bq25700 —> Chip ID : -6
[ 18.446277] bq25700-charger 6-006d: Cannot read chip ID.
打印的Chip ID值是-6-- 这是I2C通信失败,可以测量下I2C波形。
示波器测量下I2C波形,看Clock和波形都正常。降低clock-frequency从400降到10,还是报Chip ID : -6。
最后发现是 I2C地址是6b 不是规格书的6d。相当坑爹。所有有时候不能相信规格书。