From 3cbbc49b33b7beadabfe17b2770b4a66d820402e Mon Sep 17 00:00:00 2001 From: Kuba Wojciechowski Date: Sun, 6 Jun 2021 15:31:33 +0200 Subject: [PATCH] smb5: report fast charging when a proprietary charger is attached 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 Signed-off-by: UtsavBalar1231 --- drivers/power/supply/qcom/qpnp-smb5.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/qcom/qpnp-smb5.c b/drivers/power/supply/qcom/qpnp-smb5.c index 065a03d817b3..d78ad5e017dd 100644 --- a/drivers/power/supply/qcom/qpnp-smb5.c +++ b/drivers/power/supply/qcom/qpnp-smb5.c @@ -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;