Skip to content

Commit

Permalink
power: smb5: report fast charging when a proprietary charger is attached
Browse files Browse the repository at this point in the history
Android figures out if charging is "rapid" by checking
POWER_SUPPLY_PROP_CURRENT_MAX and when the proprietary charger tech
Xiaomi's using is active that value isn't always reported correctly.
Work around that by reporting an arbitrary value that's high enough to
qualify as "rapid" when a proprietary charger is attached and fully
authenticated (by checking smblib_get_fastcharge_mode() which is a
custom utility function added by Xiaomi). Other charger types (HVDCP/PD)
still use standard smblib_get_prop_input_current_max().

Test: original 33W charger is reported as "rapid" immediately after
plugging it in, a slow charger is still detected as "slow".

Signed-off-by: Kuba Wojciechowski <nullbytepl@gmail.com>
Change-Id: I84d1eaa8a0cd4b3c4406725e75abcf29bad546b2
Signed-off-by: Forenche <prahul2003@gmail.com>
  • Loading branch information
nullbytepl authored and David112x committed May 16, 2024
1 parent 2aaaae2 commit f29583f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/power/supply/qcom/qpnp-smb5.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,10 @@ static int smb5_usb_get_prop(struct power_supply *psy,
val->intval = get_client_vote(chg->usb_icl_votable, PD_VOTER);
break;
case POWER_SUPPLY_PROP_CURRENT_MAX:
rc = smblib_get_prop_input_current_max(chg, val);
if (smblib_get_fastcharge_mode(chg))
val->intval = 3000000;
else
rc = smblib_get_prop_input_current_max(chg, val);
break;
case POWER_SUPPLY_PROP_TYPE:
val->intval = POWER_SUPPLY_TYPE_USB_PD;
Expand Down

0 comments on commit f29583f

Please sign in to comment.