Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
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".

Change-Id: I8cfce1f827602d53bbcb90abd76723074281d270
Signed-off-by: Kuba Wojciechowski <[email protected]>
Signed-off-by: UtsavBalar1231 <[email protected]>
  • Loading branch information
nullbytepl authored and UtsavBalar1231 committed Aug 2, 2021
1 parent c7862b9 commit 3cbbc49
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/power/supply/qcom/qpnp-smb5.c
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,16 @@ 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))
#ifdef CONFIG_BOARD_CAS
val->intval = 12000000;
#elif defined CONFIG_BOARD_CMI
val->intval = 10000000;
#else
val->intval = 6000000;
#endif
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 3cbbc49

Please sign in to comment.