mb/google/bluey: Use safe SPMI reads for battery current telemetry
Update `get_battery_icurr_ma` to use the newly introduced `spmi_read8_safe` helper. This ensures that transient SPMI arbiter errors (0xfffffff7) are handled via retries rather than being immediately treated as zero current. By validating both the primary (SMB1) and secondary (SMB2) charger registers with retries, the system avoids entering the power-off path caused by spurious 0mA readings during early boot or rail stabilization. Additionally, using 5ms delay before charger SMB1/2 register read. BUG=b:436391478 BRANCH=none TEST=On Bluey, verify that battery current is reported correctly even if the initial SPMI read encounters a transient failure. Change-Id: I8dee77ba83798e8e50f8884604c588fe4fda0e0a Signed-off-by: Subrata Banik <subratabanik@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/91767 Reviewed-by: Kapil Porwal <kapilporwal@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
2f93e4331e
commit
3f46d6fd93
1 changed files with 11 additions and 4 deletions
|
|
@ -58,11 +58,18 @@ enum charging_status {
|
|||
static int get_battery_icurr_ma(void)
|
||||
{
|
||||
/* Read battery i-current value */
|
||||
int icurr = spmi_read8(SMB1_CHGR_CHARGING_FCC);
|
||||
if (icurr <= 0)
|
||||
icurr = spmi_read8(SMB2_CHGR_CHARGING_FCC);
|
||||
if (icurr < 0)
|
||||
mdelay(5);
|
||||
int icurr = spmi_read8_safe(SMB1_CHGR_CHARGING_FCC);
|
||||
if (icurr <= 0) {
|
||||
mdelay(5);
|
||||
icurr = spmi_read8_safe(SMB2_CHGR_CHARGING_FCC);
|
||||
}
|
||||
|
||||
/* Final safety: if both failed (still negative), treat as 0 */
|
||||
if (icurr < 0) {
|
||||
printk(BIOS_ERR, "Critical: Both SMB registers failed to read.\n");
|
||||
icurr = 0;
|
||||
}
|
||||
|
||||
icurr *= 50;
|
||||
return icurr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue