mirror of
https://github.com/dikeckaan/mu300-linux.git
synced 2026-12-05 08:02:40 +00:00
fix: align U30 Air charging and restore initialized SIM radios
This commit is contained in:
1 parent
edcdeb279b
commit
c031a58aed
9 files changed
+435
-3
No files matched your search
@@ -7,6 +7,9 @@
|
||||
U30 Air 网页充电控制另见 [接口、机型隔离与测试记录](U30AIR-WEB-CHARGING-20261016.zh-CN.md)。
|
||||
先检查已有驱动的可写控制接口,不复制 Android 专有 sysfs 路径,不用 inotify 冒充 SOC 事件。
|
||||
|
||||
充电 CV/硬件计时器另见 [提前停充原厂对照](U30AIR-CHARGING-EARLY-FULL-20261022.zh-CN.md)。
|
||||
使用本机 battery-info 和原厂初始化证据;不要把某次寄存器电压快照当成固定充电上限。
|
||||
|
||||
## 先识别机器与原厂基线
|
||||
|
||||
1. 保存型号、板号、Android 内核版本、原厂 DT/DTBO、模块哈希、实际启动槽和根分区类型。
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
# U30 Air 提前停充与慢充:原厂参数对照(2026-10-22)
|
||||
|
||||
用户报告:设置 90% 上限,约 84% 就显示 Full;另一台约 91% 停充,需要拔插才能继续。
|
||||
本轮连接的 U30 Air 当时为 91%、Charging,尚未现场捕获提前 Full 或超时故障。
|
||||
|
||||
## 已确认的驱动差异
|
||||
|
||||
1. 旧补丁把 vendor BQ 的充电电压上限固定为 4.208 V,并按芯片默认值初始化。
|
||||
本机原厂 battery 节点配置是 4.3 V,SDP/CDP/DCP 的有效 JEITA 档位也为 4.3 V;
|
||||
原厂驱动从 battery-info 读取该值。旧值来源于单次寄存器快照,不能作为完整充电策略。
|
||||
过低的 CV 会提前进入恒压小电流阶段,也可能在电量百分比尚低时终止充电。
|
||||
2. 原厂 BQ probe 关闭 REG05 bit 3(硬件充电安全计时器),现有主线适配却没有关闭。
|
||||
长时间慢充触发超时可以解释需要拔插的部分现象,但本轮没有捕获到实际超时状态,
|
||||
不能把用户所有停充都归因于计时器。
|
||||
3. 本机限充服务当时 `enabled=0, paused=0`,运行状态没有 owned/stopped;
|
||||
因此该快照不是网页 90% 上限主动停充。离线回归另验证了 84%/Full 不应触发 90% 限充。
|
||||
|
||||
## 原厂证据
|
||||
|
||||
机型 U30 Air SSV,已有固件记录 `U30Air_SSV1.0.0B14`;原厂模块 vermagic
|
||||
`5.4.254-android12-9-g9444efdc6885`。从本机 Android A 槽 `vendor_dlkm_a`
|
||||
只读提取(super 内单个 5.2 MiB EROFS extent),未写入 Android、NV 或电量校准区。
|
||||
|
||||
| 模块 | SHA-256 |
|
||||
| --- | --- |
|
||||
| sqc_bq2560x.ko | ce42c87c42f9ed7e5b5aba8277d4245c03c2c41a569e8ca24d749f07bc3a0efc |
|
||||
| charger_policy_service.ko | 808b23dce5aee9886df868cd796c8382105b9d99cc80bd2240f8a93fc7b2ac1e |
|
||||
| sc27xx_fuel_gauge.ko | b677aef2019ac95da686bbf80ce72f2a3f12f22bc5a151e9f6bd187f1e13f074 |
|
||||
|
||||
`sqc_bq2560x.ko` 的 `bq2560x_charger_probe` 起点 0xd30,
|
||||
0x1b08(probe+0xdd8)执行 `and w2,w8,#0xfffffff7` 后写回 REG05,关闭安全计时器。
|
||||
对应原厂源码 `sqc_bq2560x.c` 的硬件初始化同样从 battery-info 取 CV、关闭安全计时器。
|
||||
本机实时 REG04=0x58(4.208 V)、REG05=0x8f(终止开启、安全计时器开启),印证旧行为。
|
||||
|
||||
## 修复范围
|
||||
|
||||
新增公共构建补丁 `0023-power-bq256xx-stock-battery-cv-and-timer.patch`,用于 7.2.8、6.18.54:
|
||||
|
||||
- 仅原有 battery-policy 隔离的 `ti,bq2560x_chg` 路径使用本机 battery-info 的 CV,
|
||||
限于芯片能力;缺少有效配置时保留芯片默认值,低压电池不会被统一提高到 4.3 V。
|
||||
- 本机 4.3 V 按 BQ 的 32 mV 步进向下编码为 **4.272 V**。
|
||||
- 对齐原厂关闭硬件安全计时器,保留 EN_TERM、TS/NTC、过压/过温保护和其他寄存器位。
|
||||
- 保留现有 1.98 A 充电电流上限、USB 输入识别/限流、用户上限、暂停和一次充满操作。
|
||||
电脑 SDP 的 500 mA 不应被强行提高到充电器电流。
|
||||
- 不强制改百分比、不添加循环重启充电、不修改回充电压、不增加后台轮询。
|
||||
- F50/V50 仍在首次硬件访问前排除电池路径,普通上游 BQ 节点保持原初始化行为。
|
||||
|
||||
## 验证
|
||||
|
||||
- `tests/bq256xx_stock_cv.py KERNEL_TREE` 编译实际驱动初始化/CV 函数,覆盖 4.3 V、
|
||||
低压电池、芯片上限、无效/缺少 battery-info、I/O 失败及非 vendor 节点;核验
|
||||
终止、温度、回充、输入及升压位不被误改。
|
||||
- `tests/stock_power_driver.py KERNEL_TREE` 回归原厂电量编码、满电电气条件与无电池板隔离。
|
||||
- `tests/test_charge_control.py` 使用隔离 OpenWrt 容器执行真实 ucode,覆盖用户限充、
|
||||
暂停、一次充满、插拔/OTG、无电池板,以及提前 Full 不能冒充用户上限的场景。
|
||||
|
||||
完整充电周期、90% 上限停充点、低电量起充及原故障的长期不再出现仍需实物验证。
|
||||
内核/模块的编译和短时检查不等同于上述验证完成。
|
||||
|
||||
## 本轮编译与实机部署结果
|
||||
|
||||
- 7.2.8、6.18.54 完整 Image 和所有配套模块编译通过,两个实际准备树的驱动测试通过。
|
||||
- 实际 ucode 限充回归 **12 项通过**,包含新增的 84%/Full、90% 上限边界。
|
||||
- 核验 U30 Air 身份、eMMC CID 和动态启动槽后部署 7.2.8。全部根模块及 initramfs
|
||||
同内核版本模块记录一起替换;原 init、cmdline、vendor fallback、启动日志区保留。
|
||||
写入回读、配置哈希及 misc 未改变校验通过,随后正常重启。
|
||||
- 重启后所有部署模块哈希校验通过;BQ REG04=`0x68`(4.272 V)、REG05=`0x87`
|
||||
(终止开启、安全计时器关闭)。电池 92%、约 4.199 V、+145 mA、25.4°C、Charging/Good。
|
||||
对比前值只证明设置生效,不把电脑 USB、近满电时的电流当成充电器最大速度测试。
|
||||
- 电脑 SDP 输入仍为 500 mA,充电电流上限仍为 1.98 A;用户限充、暂停、热点及网络
|
||||
配置哈希不变。5 GHz/80 MHz 热点恢复 ENABLED,WAN 自动获取 IPv4,USB 管理恢复。
|
||||
未见新的 BTF、Oops 或存储 I/O 错误;原有 SIPA 组播告警不属于本轮充电修复结论。
|
||||
- 实机备份:`/root/hotfix-backups/u30-stock-charge-20261022`。
|
||||
电脑端寄存器、只读原厂模块及部署回执:`work/u30air-charge-early-full-20261022/`。
|
||||
构建日志:`out/build-logs/20261022-112207-u30-stock-charge-49312/`。
|
||||
|
||||
本轮未生成发行包、未提交 commit,F50/V50 未刷写;6.18 为编译验证,未刷入本机。
|
||||
|
||||
## 尚未移植:原厂长时间插电保护
|
||||
|
||||
用户补充原厂长期插电会主动停充。继续核对后确认,这与 BQ REG05 的芯片安全计时器
|
||||
是两套机制,不能用重新打开芯片计时器代替原厂软件策略。
|
||||
|
||||
本机原厂 DT 的 `charger_policy_service` 启用了 `expired-mode-enable=1`,
|
||||
`timeout-seconds=57600`(16 小时)、`expired-max-capacity=90`、
|
||||
`expired-min-capacity=70`、`have-power-path=1`、`low-temp-enable=1`。
|
||||
原厂模块存在 expired 状态、超时处理、禁充及恢复的实现。
|
||||
|
||||
对应厂商源码 `drivers/vendor/common/power/charger_policy_service.c` 以 boottime
|
||||
维护 `charging_begin`,超时进入 overtime 策略,另有拔电、低温及恢复充电分支。
|
||||
**不能仅凭 DT 的 90/70 两个值就简化成“16 小时后 90% 停充”**:有 power-path
|
||||
的源码分支在部分状态使用上下阈值的中点,还区分充电开关与输入路径开关。
|
||||
具体状态转换应继续与本机原厂二进制核对后移植。
|
||||
|
||||
当前 OpenWrt `charge.uc` 只有用户限充、手动暂停和一次充满,**没有原厂 16 小时
|
||||
软件保护**。本轮关闭芯片计时器符合原厂芯片初始化,但不代表这层长期插电保护已完整
|
||||
对齐。它是明确待补的功能,不把长期插电后的原厂主动停充全部判作硬件故障。
|
||||
@@ -0,0 +1,44 @@
|
||||
# V50 升级后射频恢复、切卡反馈(2026-10-22)
|
||||
|
||||
## 用户反馈与证据边界
|
||||
|
||||
两张内置卡的 V50:升级前关闭过一张射频,升级后打开两张,SIM2 无网,切 SIM1 报错;
|
||||
Android 可用。尚无该用户的实际切卡错误、AT/注册日志、board_id、固件版本。
|
||||
不能由“电信卡能搜到基站”推断为电信 APN、运营商限制或卡故障。
|
||||
|
||||
默认关闭 SIM2 是既有用户要求;显式开启和主动切 SIM2 应能恢复并持久化。
|
||||
网页 RF 开关当前读取的是保存的权限,**不是实时 CFUN 回读**,保存为开启不等于硬件操作成功。
|
||||
|
||||
## 本轮确认的源码缺口
|
||||
|
||||
`mu300-sim-radio` 在 CFUN=0 且 CPIN 暂未就绪时,调用既有 `mobile-data radio-on`。
|
||||
后者委托 `mu300-dual-radio`。即使本次启动已完成双卡初始化(ready 标记存在),旧代码
|
||||
仍把需要恢复的 0/1、1/0 等混合状态当成冷启动不一致,退出 4、要求重启。
|
||||
射频权限已先保存,所以此时网页可能显示开启,但恢复命令未执行。
|
||||
|
||||
隔离测试复现:先保存 `0 1`,硬件状态模拟为 CFUN 0/1;开启第一张时第一次 CPIN
|
||||
返回 SIM busy、随后恢复 READY。原有路径进入以上拒绝分支;修正后按槽仅发送 SFUN=4。
|
||||
这是可复现的逻辑缺陷,**不是该群友整套故障的实机定因**。
|
||||
|
||||
## 修改
|
||||
|
||||
- 只有本次启动双卡 ready 已存在,才将后续混合状态视为射频恢复。
|
||||
- 按既有 SFUN=4/CFUN 回读流程恢复允许且存在的卡;另一张已开启的卡不重复操作。
|
||||
- 不发送 SFUN=2/3,不重复 SPTESTMODEM,不重新选择数据卡,不重放已完成的启动初始化。
|
||||
- 无 ready 的真正冷启动仍保留原顺序和混合状态拒绝;无卡、禁用权限、URC reader
|
||||
尚未就绪时不额外启动射频。AT 失败原样返回,不复位另一张卡。
|
||||
- 适用于 MU300/F50/V50 既有双栈路径;U30 Air 原生单活动栈路径不变。E5 仓库未改动。
|
||||
|
||||
## 验证
|
||||
|
||||
使用真实 shell 控制脚本、隔离 AT/网络 stub 验证,不访问设备。新增覆盖初始化后的
|
||||
0/1、1/0、2/1、1/2、旧飞行模式恢复、无卡/禁用同伴、恢复失败,以及射频控制器到
|
||||
真实双栈初始化器的调用链。继续回归 V50 四种物理卡板型、mux 顺序、数据卡切换与回滚。
|
||||
|
||||
未部署到任何 V50,未修改 NV、卡片物理映射、用户配置,未编译或打包。
|
||||
用户恢复在线后仍应取得切 SIM1 的实际报错,核对 CFUN、CPIN、SPSWDATA、
|
||||
数据卡及 APN 的同槽信息,再判断剩余的不能拨号是否为同一原因。
|
||||
|
||||
本轮结果:双栈初始化 13 项、独立射频 15 项、逻辑数据卡切换 11 项、V50 物理卡
|
||||
管理 13 项,共 **52 项通过**(每项包含可用的 dash/bash/BusyBox ash/sh 分支);
|
||||
`git diff --check` 通过。没有把隔离环境通过写成群友实机故障已解决。
|
||||
@@ -72,6 +72,26 @@ if { [ "$present0" = 0 ] || { [ "$allowed0:$cf0" = 1:1 ] || { [ "$allowed0" = 0
|
||||
case "$actual" in 0|1) printf '%s\n' "$actual" > "$root/mu300-data-sim-actual" ;; *) fail 'data SIM readback unavailable' ;; esac
|
||||
: > "$root/mu300-dual-radio-ready"; exit 0
|
||||
fi
|
||||
# After this boot's dual initialization, a mixed RF state is a normal
|
||||
# per-card off/on transition, not a reason to repeat cold initialization.
|
||||
# Resume only permitted, present cards; never power-cycle the live peer.
|
||||
# A genuinely cold mixed state without the ready marker remains rejected.
|
||||
if [ -e "$root/mu300-dual-radio-ready" ]; then
|
||||
for card in 0 1; do
|
||||
present "$card" && allowed "$card" || continue
|
||||
if [ "$card" = 0 ]; then state=$cf0; else state=$cf1; fi
|
||||
case "$state" in
|
||||
1) continue ;;
|
||||
0|2|4) ;;
|
||||
*) fail "SIM $card radio state unreadable" ;;
|
||||
esac
|
||||
ok "$card" 'AT+SFUN=4' 20 || fail "SIM $card radio-on rejected"
|
||||
[ "$(cfun "$card")" = 1 ] || fail "SIM $card radio-on readback mismatch"
|
||||
done
|
||||
actual=$(query 0 'AT+SPSWDATA?' | sed -n 's/^+SPSWDATA: *\([01]\)$/\1/p')
|
||||
case "$actual" in 0|1) printf '%s\n' "$actual" > "$root/mu300-data-sim-actual" ;; *) fail 'data SIM readback unavailable' ;; esac
|
||||
exit 0
|
||||
fi
|
||||
check0=$cf0; check1=$cf1
|
||||
[ "$allowed0:$check0" != 0:2 ] || check0=0
|
||||
[ "$allowed1:$check1" != 0:2 ] || check1=0
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
"""Compile real charger initialization and CV encoding against register mocks.
|
||||
|
||||
Usage: python3 tests/bq256xx_stock_cv.py PREPARED_KERNEL
|
||||
No hardware or battery calibration writes are performed.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
driver = Path(sys.argv[1])
|
||||
source = (driver if driver.is_file() else driver / 'drivers/power/supply/bq256xx_charger.c').read_text()
|
||||
|
||||
|
||||
def function(name):
|
||||
start = re.search(r'^static int ' + name + r'\(', source, re.M).start()
|
||||
end = source.index('{', start) + 1
|
||||
depth = 1
|
||||
while depth:
|
||||
depth += (source[end] == '{') - (source[end] == '}')
|
||||
end += 1
|
||||
return source[start:end] + '\n'
|
||||
|
||||
|
||||
model = r'''
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
typedef uint32_t u32;
|
||||
#define clamp(v,l,h) ((v)<(l)?(l):((v)>(h)?(h):(v)))
|
||||
#define min_t(t,a,b) ((t)(a)<(t)(b)?(t)(a):(t)(b))
|
||||
#define dev_warn(...) ((void)0)
|
||||
#define BQ256XX_NUM_WD_VAL 4
|
||||
#define BQ256XX_WATCHDOG_DIS 0
|
||||
#define BQ256XX_WATCHDOG_MASK 0x30
|
||||
#define BQ256XX_WDT_BIT_SHIFT 4
|
||||
#define BQ256XX_CHARGER_CONTROL_1 5
|
||||
#define BQ256XX_EN_TERM 0x80
|
||||
#define BQ2560X_CHG_EN_TIMER 8
|
||||
#define BQ2560X_CHG_ICHG_MAX_uA 1980000
|
||||
#define BQ2560X_VBATREG_MIN_uV 3856000
|
||||
#define BQ2560X_VBATREG_OFFSET_uV 3856000
|
||||
#define BQ2560X_VBATREG_STEP_uV 32000
|
||||
#define BQ256XX_VBATREG_MASK 0xf8
|
||||
#define BQ256XX_VBATREG_BIT_SHIFT 3
|
||||
#define BQ256XX_BATTERY_VOLTAGE_LIMIT 4
|
||||
static const int bq256xx_watchdog_time[]={0,40,80,160};
|
||||
struct bq256xx_device;
|
||||
struct power_supply_battery_info {
|
||||
int constant_charge_current_max_ua,constant_charge_voltage_max_uv;
|
||||
int precharge_current_ua,charge_term_current_ua;
|
||||
};
|
||||
struct bq256xx_chip_info {
|
||||
int bq256xx_def_ichg,bq256xx_def_vbatreg,bq256xx_def_iprechg,bq256xx_def_iterm;
|
||||
int bq256xx_max_ichg,bq256xx_max_vbatreg;
|
||||
int (*bq256xx_set_vindpm)(struct bq256xx_device*,int);
|
||||
int (*bq256xx_set_iindpm)(struct bq256xx_device*,int);
|
||||
int (*bq256xx_set_ichg)(struct bq256xx_device*,int);
|
||||
int (*bq256xx_set_iprechg)(struct bq256xx_device*,int);
|
||||
int (*bq256xx_set_vbatreg)(struct bq256xx_device*,int);
|
||||
int (*bq256xx_set_iterm)(struct bq256xx_device*,int);
|
||||
int (*bq256xx_set_ts_ignore)(struct bq256xx_device*,int);
|
||||
};
|
||||
struct bq256xx_device {
|
||||
int dev,regmap,charger,watchdog_timer;bool bq2560x_chg;
|
||||
struct { int ichg_max,vbatreg_max,vindpm,iindpm,ts_ignore; } init_data;
|
||||
struct bq256xx_chip_info *chip_info;
|
||||
};
|
||||
static struct power_supply_battery_info battery;
|
||||
static unsigned regs[12];
|
||||
static int io_error,info_error,voltage_requests;
|
||||
static int regmap_update_bits(int map,int reg,unsigned mask,unsigned value) {
|
||||
(void)map;if(io_error)return io_error;regs[reg]=(regs[reg]&~mask)|(value&mask);return 0;
|
||||
}
|
||||
static int power_supply_get_battery_info(int chg,struct power_supply_battery_info **p) {
|
||||
(void)chg;*p=&battery;return info_error;
|
||||
}
|
||||
static void power_supply_put_battery_info(int chg,struct power_supply_battery_info*p){(void)chg;(void)p;}
|
||||
static int unchanged(struct bq256xx_device*b,int val){(void)b;(void)val;return 0;}
|
||||
'''
|
||||
tests = r'''
|
||||
static int set_voltage(struct bq256xx_device*b,int val){voltage_requests++;return bq2560x_set_chrg_volt(b,val);}
|
||||
static struct bq256xx_chip_info chip = {
|
||||
.bq256xx_def_ichg=2040000,.bq256xx_def_vbatreg=4208000,.bq256xx_def_iprechg=180000,
|
||||
.bq256xx_def_iterm=180000,.bq256xx_max_ichg=3000000,.bq256xx_max_vbatreg=4624000,
|
||||
.bq256xx_set_vindpm=unchanged,.bq256xx_set_iindpm=unchanged,.bq256xx_set_ichg=unchanged,
|
||||
.bq256xx_set_iprechg=unchanged,.bq256xx_set_vbatreg=set_voltage,.bq256xx_set_iterm=unchanged,
|
||||
};
|
||||
static int actual_voltage(void){return ((regs[4]&0xf8)>>3)*32000+3856000;}
|
||||
static void reset(void){
|
||||
memset(regs,0,sizeof(regs));regs[4]=0x5b;regs[5]=0xcf;regs[1]=0x1a;regs[0]=0x04;
|
||||
battery=(struct power_supply_battery_info){3000000,4300000,180000,300000};
|
||||
io_error=info_error=voltage_requests=0;
|
||||
}
|
||||
int main(void){
|
||||
struct bq256xx_device b={.chip_info=&chip,.bq2560x_chg=true};
|
||||
reset();assert(!bq256xx_hw_init(&b));
|
||||
assert(b.init_data.vbatreg_max==4300000&&actual_voltage()==4272000);
|
||||
assert(b.init_data.ichg_max==1980000);
|
||||
assert(regs[5]==0xc7); /* TERM on, timer off, TS bit and other bits retained. */
|
||||
assert((regs[4]&7)==3&®s[1]==0x1a&®s[0]==0x04);
|
||||
/* A lower-voltage cell is not raised to this board's 4.3 V setting. */
|
||||
reset();battery.constant_charge_voltage_max_uv=4100000;
|
||||
assert(!bq256xx_hw_init(&b));assert(actual_voltage()==4080000);
|
||||
reset();battery.constant_charge_voltage_max_uv=9000000;
|
||||
assert(!bq256xx_hw_init(&b));assert(actual_voltage()==4624000);
|
||||
reset();battery.constant_charge_voltage_max_uv=-EINVAL;
|
||||
assert(!bq256xx_hw_init(&b));assert(actual_voltage()==4208000);
|
||||
/* Missing battery information keeps the default rather than chip maximum. */
|
||||
reset();info_error=-ENODEV;assert(!bq256xx_hw_init(&b));assert(actual_voltage()==4208000);
|
||||
reset();info_error=-ENOMEM;assert(bq256xx_hw_init(&b)==-ENOMEM&&!voltage_requests);
|
||||
reset();io_error=-EIO;assert(bq256xx_hw_init(&b)==-EIO&&!voltage_requests);
|
||||
/* Generic bq users do not inherit the U30 policy or battery CV request. */
|
||||
reset();b.bq2560x_chg=false;assert(!bq256xx_hw_init(&b));
|
||||
assert(actual_voltage()==4208000&®s[5]==0xcf&&b.init_data.ichg_max==3000000);
|
||||
return 0;
|
||||
}
|
||||
'''
|
||||
with tempfile.TemporaryDirectory(prefix='bq-stock-cv-') as directory:
|
||||
root = Path(directory)
|
||||
code = model + function('bq2560x_set_chrg_volt') + function('bq256xx_hw_init') + tests
|
||||
(root / 'test.c').write_text(code)
|
||||
subprocess.run(['cc','-Wall','-Werror',str(root/'test.c'),'-o',str(root/'test')],check=True)
|
||||
subprocess.run([str(root/'test')],check=True)
|
||||
print('PASS: stock CV, register quantization/preservation, timer policy, lower-voltage battery, missing info, I/O errors and generic-board isolation')
|
||||
@@ -118,6 +118,17 @@ class ChargeControl(unittest.TestCase):
|
||||
full=self.call('apply')
|
||||
self.assertFalse(full['full_once']);self.assertTrue(full['stopped'])
|
||||
|
||||
def test_early_hardware_full_is_not_the_user_limit(self):
|
||||
# A charger reporting Full below the configured SOC threshold must
|
||||
# not become a policy-owned stop or clear a one-time full request.
|
||||
self.write(self.battery/'capacity',84)
|
||||
self.write(self.charger/'status','Full')
|
||||
result=self.call('configure',dict(enabled='1',start='70',stop='90'))
|
||||
self.assertFalse(result['stopped'])
|
||||
self.assertEqual((self.charger/'charge_type').read_text().strip(),'Fast')
|
||||
self.assertFalse(self.call('full_once')['stopped'])
|
||||
self.assertTrue(self.call('apply')['full_once'])
|
||||
|
||||
def test_disable_limit_releases_owned_pause(self):
|
||||
self.write(self.battery/'capacity',90)
|
||||
self.configure()
|
||||
|
||||
@@ -23,7 +23,9 @@ elif cmd.endswith('+CPIN?'):print('+CPIN: READY' if slot in s.get('present',[0,1
|
||||
elif cmd.endswith('+SPTESTMODE?'):print('+SPTESTMODE: 134,128,1,20,3,1')
|
||||
elif cmd.endswith('+SPSWDATA?'):print('+SPSWDATA: '+str(s['data']))
|
||||
elif cmd.endswith('+SPSWDATA'):s['data']=slot
|
||||
elif cmd.endswith('+SFUN=4'):s['cfun'][slot]=1
|
||||
elif cmd.endswith('+SFUN=4'):
|
||||
if os.getenv('FAIL_RESUME')=='1':print('ERROR');sys.exit(1)
|
||||
s['cfun'][slot]=1
|
||||
elif cmd.endswith('+SFUN=2'):s['cfun'][slot]=0
|
||||
elif cmd.endswith('+SFUN=5'):s['cfun'][slot]=int(os.getenv('OFF_STATE','2'))
|
||||
f.write_text(json.dumps(s));print('OK')
|
||||
@@ -67,6 +69,48 @@ f.write_text(json.dumps(s));print('OK')
|
||||
if not ok: self.assertEqual(r.returncode,4)
|
||||
self.assertNotIn('SFUN=',(self.tmp/'commands').read_text())
|
||||
|
||||
def test_initialized_mixed_state_resumes_only_the_requested_off_radio(self):
|
||||
for shell in self.each_shell():
|
||||
for cfun in ([1,0],[0,1],[1,2],[2,1],[1,4]):
|
||||
self.reset(cfun)
|
||||
(self.tmp/'sim-radio-policy').write_text('1 1\n')
|
||||
(self.run/'mu300-dual-radio-ready').touch()
|
||||
r=self.script(shell,SCRIPT,**self.extra)
|
||||
self.assertEqual(r.returncode,0,r.stderr)
|
||||
self.assertEqual(json.loads((self.tmp/'radio.json').read_text())['cfun'],[1,1])
|
||||
writes=[c for c in (self.tmp/'commands').read_text().splitlines() if not c.endswith('?')]
|
||||
off=0 if cfun[0]!=1 else 1
|
||||
self.assertEqual(writes,[f'AT+SPACTCARD={off};+SFUN=4'])
|
||||
|
||||
def test_initialized_resume_keeps_disabled_or_absent_peer_off(self):
|
||||
for shell in self.each_shell():
|
||||
self.reset([0,0])
|
||||
(self.tmp/'sim-radio-policy').write_text('1 0\n')
|
||||
(self.run/'mu300-dual-radio-ready').touch()
|
||||
r=self.script(shell,SCRIPT,**self.extra)
|
||||
self.assertEqual(r.returncode,0,r.stderr)
|
||||
self.assertEqual(json.loads((self.tmp/'radio.json').read_text())['cfun'],[1,0])
|
||||
self.assertNotIn('AT+SPACTCARD=1;+SFUN',(self.tmp/'commands').read_text())
|
||||
self.reset([0,1])
|
||||
(self.tmp/'radio.json').write_text(json.dumps(dict(cfun=[0,1],data=1,present=[1])))
|
||||
(self.tmp/'sim-radio-policy').write_text('1 1\n')
|
||||
(self.run/'mu300-dual-radio-ready').touch()
|
||||
r=self.script(shell,SCRIPT,**self.extra)
|
||||
self.assertEqual(r.returncode,0,r.stderr)
|
||||
self.assertNotIn('SFUN=',(self.tmp/'commands').read_text())
|
||||
|
||||
def test_initialized_resume_failure_does_not_reset_or_select_another_card(self):
|
||||
for shell in self.each_shell():
|
||||
self.reset([0,1])
|
||||
(self.tmp/'sim-radio-policy').write_text('1 1\n')
|
||||
(self.run/'mu300-dual-radio-ready').touch()
|
||||
r=self.script(shell,SCRIPT,**dict(self.extra,FAIL_RESUME='1'))
|
||||
self.assertNotEqual(r.returncode,0)
|
||||
self.assertIn('radio-on rejected',r.stderr)
|
||||
self.assertEqual(json.loads((self.tmp/'radio.json').read_text())['cfun'],[0,1])
|
||||
writes=[c for c in (self.tmp/'commands').read_text().splitlines() if not c.endswith('?')]
|
||||
self.assertEqual(writes,['AT+SPACTCARD=0;+SFUN=4'])
|
||||
|
||||
def test_no_urc_reader_means_no_at_traffic(self):
|
||||
for shell in self.each_shell():
|
||||
self.reset([0,0])
|
||||
|
||||
+30
-2
@@ -2,6 +2,7 @@
|
||||
import json
|
||||
import re
|
||||
import fcntl
|
||||
import os
|
||||
from helpers import ShellTest, TOP
|
||||
|
||||
SCRIPT=TOP/'rootfs/overlay/opt/mu300/bin/mu300-sim-radio'
|
||||
@@ -28,13 +29,20 @@ n=int(re.search(r"SPACTCARD=(\\d)",cmd)[1])
|
||||
if "SFUN=" in cmd:
|
||||
if os.getenv("FAIL_RF")=="1":print("ERROR");sys.exit(1)
|
||||
s[n]=1 if cmd.endswith("=4") else int(os.getenv("OFF_STATE","2"));p.write_text(json.dumps(s))
|
||||
elif cmd.endswith("+CPIN?"): print("+CPIN: READY" if os.getenv("SIM_POWERED")=="1" else "+CME ERROR: 10")
|
||||
elif cmd.endswith("+CPIN?"):
|
||||
delay=r/"pin-delay"
|
||||
if os.getenv("PIN_FIRST_BUSY")=="1" and not delay.exists():
|
||||
delay.touch();print("+CME ERROR: 14")
|
||||
else: print("+CPIN: READY" if os.getenv("SIM_POWERED")=="1" else "+CME ERROR: 10")
|
||||
elif cmd.endswith("+SPSWDATA?"): print("+SPSWDATA: 0")
|
||||
else: print("+CFUN: "+str(s[n]))
|
||||
print("OK")' "$@"''')
|
||||
self.stub('mobile-data', '''printf '%s\n' "$*" >> "$STUBLOG/mobile"
|
||||
case $1 in
|
||||
radio-policy) exec sh "$CONTROLLER" --locked "$2" "$3";;
|
||||
radio-on) printf '[1,2]' > "$STUBLOG/state";;
|
||||
radio-on)
|
||||
if [ -n "${DUAL_CONTROLLER:-}" ]; then exec sh "$DUAL_CONTROLLER"; fi
|
||||
printf '[1,2]' > "$STUBLOG/state";;
|
||||
*) exit 2;;
|
||||
esac''')
|
||||
self.controller=self.tmp/'controller'
|
||||
@@ -124,6 +132,26 @@ esac''')
|
||||
self.assertEqual(result.returncode,0,result.stderr)
|
||||
self.assertFalse((self.tmp/'at').exists())
|
||||
|
||||
def test_busy_pin_during_rf_resume_does_not_reject_initialized_live_peer(self):
|
||||
root=self.tmp/'dual-run'
|
||||
for directory,n in [('mu300-at',0),('mu300-at4',3)]:
|
||||
stream=root/directory/'urc';stream.mkdir(parents=True)
|
||||
(stream/f'stty_nr{n}.ready').write_text(str(os.getpid()))
|
||||
(root/'mu300-dual-radio-ready').touch()
|
||||
for shell in self.each_shell():
|
||||
(self.tmp/'state').write_text('[0,1]')
|
||||
(self.tmp/'sim-radio-policy').write_text('0 1\n')
|
||||
(self.tmp/'pin-delay').unlink(missing_ok=True)
|
||||
(self.tmp/'at').unlink(missing_ok=True)
|
||||
result=self.call(shell,'apply','0','1',SIM_POWERED='1',PIN_FIRST_BUSY='1',
|
||||
DUAL_CONTROLLER=TOP/'rootfs/overlay/opt/mu300/bin/mu300-dual-radio',
|
||||
MU300_DUAL_RUN=root,MU300_DUAL_AT_CLIENT=self.stubs/'mu300-at')
|
||||
self.assertEqual(result.returncode,0,result.stderr)
|
||||
self.assertEqual(json.loads((self.tmp/'state').read_text()),[1,1])
|
||||
writes=[c for c in (self.tmp/'at').read_text().splitlines() if not c.endswith('?')]
|
||||
self.assertEqual(writes,['AT+SPACTCARD=0;+SFUN=4'])
|
||||
self.assertEqual((self.tmp/'sim-radio-policy').read_text(),'1 1\n')
|
||||
|
||||
def test_sfun_off_zero_and_two_reenable_without_resetting_powered_sim(self):
|
||||
for shell in self.each_shell():
|
||||
for off in ('0','2'):
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
power: supply: bq256xx: use the battery CV and stock U30 Air timer policy
|
||||
|
||||
The vendor node used a 4.208 V cap copied from an Android register snapshot,
|
||||
not its battery configuration (4.3 V on the tested SSV board). Honor the
|
||||
battery CV at probe and bound it to the chip capability; generic boards
|
||||
keep their existing default initialization. Leave current budgets unchanged.
|
||||
|
||||
Stock sqc_bq2560x.ko SHA256 ce42c87c42f9ed7e5b5aba8277d4245c03c2c41a569e8ca24d749f07bc3a0efc
|
||||
clears REG05 bit 3 at probe+0xdd8 (0x1b08), as the matching source's
|
||||
bq2560x_charger_set_safety_timer(..., DISABLE) does. Do the same only for
|
||||
the battery-isolated vendor node. EN_TERM and TS/NTC remain intact.
|
||||
No SOC rewrite, forced restart/recharge, new polling, or input-current change.
|
||||
|
||||
--- a/drivers/power/supply/bq256xx_charger.c
|
||||
+++ b/drivers/power/supply/bq256xx_charger.c
|
||||
@@ -162,7 +162,7 @@
|
||||
#define BQ256XX_IINDET_EN BIT(7) /* CHARGER_CONTROL_3: force input detection, clears when done */
|
||||
#define BQ256XX_VBUS_STAT_NONSTD (BIT(7) | BIT(6))
|
||||
#define BQ2560X_CHG_ICHG_MAX_uA 1980000 /* what Android charges the U30 Air's 4050 mAh cell with */
|
||||
-#define BQ2560X_CHG_VBATREG_MAX_uV 4208000 /* Android's VREG; the battery node says 4.3 V */
|
||||
+#define BQ2560X_CHG_EN_TIMER BIT(3) /* REG05: stock driver disables the hardware safety timer */
|
||||
|
||||
/*
|
||||
* The SGM41513 that ZTE's driver (sqc_bq2560x.c) looks for when nothing answers at the node's address: the same
|
||||
@@ -2023,9 +2023,19 @@
|
||||
|
||||
if (bq->bq2560x_chg) {
|
||||
bq->init_data.ichg_max = min_t(u32, bq->init_data.ichg_max, BQ2560X_CHG_ICHG_MAX_uA);
|
||||
- bq->init_data.vbatreg_max = min_t(u32, bq->init_data.vbatreg_max,
|
||||
- BQ2560X_CHG_VBATREG_MAX_uV);
|
||||
- ret = regmap_update_bits(bq->regmap, BQ256XX_CHARGER_CONTROL_1, BQ256XX_EN_TERM,
|
||||
+ /* A boot-time register snapshot is not the stock charging policy.
|
||||
+ * Use this battery's declared CV, bounded by the charger capability;
|
||||
+ * fall back to the chip default only when no valid value was supplied.
|
||||
+ */
|
||||
+ bq->init_data.vbatreg_max = bat_info->constant_charge_voltage_max_uv > 0 ?
|
||||
+ min_t(u32, bat_info->constant_charge_voltage_max_uv,
|
||||
+ bq->chip_info->bq256xx_max_vbatreg) :
|
||||
+ bq->chip_info->bq256xx_def_vbatreg;
|
||||
+ /* Stock sqc_bq2560x probe clears REG05 EN_TIMER (0x1b08).
|
||||
+ * Keep termination enabled; this does not disable TS/NTC protection.
|
||||
+ */
|
||||
+ ret = regmap_update_bits(bq->regmap, BQ256XX_CHARGER_CONTROL_1,
|
||||
+ BQ256XX_EN_TERM | BQ2560X_CHG_EN_TIMER,
|
||||
BQ256XX_EN_TERM);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -2050,7 +2060,8 @@
|
||||
return ret;
|
||||
|
||||
ret = bq->chip_info->bq256xx_set_vbatreg(bq,
|
||||
- bq->chip_info->bq256xx_def_vbatreg);
|
||||
+ bq->bq2560x_chg ? bq->init_data.vbatreg_max :
|
||||
+ bq->chip_info->bq256xx_def_vbatreg);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
Reference in new issue
Block a user