]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
power: supply: qcom_smbx: allow disabling charging
authorCasey Connolly <casey.connolly@linaro.org>
Sun, 15 Mar 2026 19:40:16 +0000 (20:40 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Thu, 2 Apr 2026 22:40:54 +0000 (00:40 +0200)
Hook up USBIN_CMD_IL so that writing "0" to the status register will
disable charging, this is useful to let users limit charging
automatically.

Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20260315-smb2-cherry-pick-v1-1-b2710e470490@ixit.cz
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/qcom_smbx.c

index b1cb925581ec6b8cfca3897be2de5b00a336c920..bf2e2ccc454a6dc712a4532adc509df672a1ec60 100644 (file)
 #define OCP_CHARGER_BIT                                        BIT(1)
 #define SDP_CHARGER_BIT                                        BIT(0)
 
+#define USBIN_CMD_IL                                   0x340
+#define USBIN_SUSPEND_BIT                              BIT(0)
+
 #define TYPE_C_STATUS_1                                        0x30B
 #define UFP_TYPEC_MASK                                 GENMASK(7, 5)
 #define UFP_TYPEC_RDSTD_BIT                            BIT(7)
@@ -693,6 +696,9 @@ static int smb_set_property(struct power_supply *psy,
        struct smb_chip *chip = power_supply_get_drvdata(psy);
 
        switch (psp) {
+       case POWER_SUPPLY_PROP_STATUS:
+               return regmap_update_bits(chip->regmap, chip->base + USBIN_CMD_IL,
+                                         USBIN_SUSPEND_BIT, !val->intval);
        case POWER_SUPPLY_PROP_CURRENT_MAX:
                return smb_set_current_limit(chip, val->intval);
        default:
@@ -705,6 +711,7 @@ static int smb_property_is_writable(struct power_supply *psy,
                                     enum power_supply_property psp)
 {
        switch (psp) {
+       case POWER_SUPPLY_PROP_STATUS:
        case POWER_SUPPLY_PROP_CURRENT_MAX:
                return 1;
        default: