Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Raj Aryan" <raj.aryan@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, mfd@lists.linux.dev, robh@kernel.org,
	conor+dt@kernel.org, lee@kernel.org
Subject: Re: [PATCH v2 2/2] power: supply: qcom_smbx: Add PM4125 SMBLite charger support
Date: Thu, 26 Nov 2026 11:18:10 +0000	[thread overview]
Message-ID: <sashiko-outbox-235359@kernel.org> (raw)
In-Reply-To: <20261126-smblite-charger-for-pm4125-v2-2-20656509518b@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] power: supply: qcom_smbx: wrong CHARGE_TYPE mapping in
  smb_get_property()
- [Medium] power: supply: qcom_smbx: watchdog left armed on fail/unbind
  and bad rollback
- [Low] power: supply: qcom_smbx: write-only fields and unused includes
  in smb_probe()
--

commit 2afb04355c7bbe435f2e20cc7c837c7b9cdd0e1c
Author: Raj Aryan <raj.aryan@oss.qualcomm.com>

power: supply: qcom_smbx: Add PM4125 SMBLite charger support

This commit extends the qcom_smbx charger driver to support the SMBLite
charger IP found in the PM4125 PMIC alongside the existing SMB2 support.

> diff --git a/drivers/power/supply/qcom_smbx.c b/drivers/power/supply/qcom_smbx.c
> index c6188c915703a..d23e5ec858586 100644
> --- a/drivers/power/supply/qcom_smbx.c
> +++ b/drivers/power/supply/qcom_smbx.c

[ ... ]

> @@ -680,6 +997,30 @@ static int smb_get_property(struct power_supply *psy,
>  		return smb_get_prop_health(chip, &val->intval);
>  	case POWER_SUPPLY_PROP_USB_TYPE:
>  		return smb_apsd_get_charger_type(chip, &val->intval);
> +	case POWER_SUPPLY_PROP_CHARGE_TYPE: {
> +		int status, rc;
> +
> +		if (chip->type != SMBLITE)
> +			return -EOPNOTSUPP;
> +
> +		rc = smb_get_prop_status(chip, &status);
> +		if (rc < 0)
> +			return rc;
> +
> +		switch (status) {
> +		case POWER_SUPPLY_STATUS_FULL:
> +			val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE;
> +			break;
> +		case POWER_SUPPLY_STATUS_CHARGING:
> +			val->intval = POWER_SUPPLY_CHARGE_TYPE_STANDARD;
> +			break;
> +		default:
> +			val->intval = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
> +			break;
> +		}
> +
> +		return 0;
> +	}
>  	default:
>  		dev_err(chip->dev, "invalid property: %d\n", psp);
>  		return -EINVAL;

[Severity: Medium]
Should POWER_SUPPLY_PROP_CHARGE_TYPE inspect the hardware charge phase in
SMBLITE_BATTERY_CHARGER_STATUS_1 directly instead of deriving the value
from smb_get_prop_status()?

When USB is unplugged or charging is inhibited, paused, disabled, or
stopped due to battery overvoltage, smb_get_prop_status() returns
POWER_SUPPLY_STATUS_DISCHARGING or POWER_SUPPLY_STATUS_NOT_CHARGING, which
falls into the default case here and reports
POWER_SUPPLY_CHARGE_TYPE_UNKNOWN instead of POWER_SUPPLY_CHARGE_TYPE_NONE.
Because smb_get_prop_status() also folds SMBLITE_TRICKLE_CHARGE,
SMBLITE_PRE_CHARGE, SMBLITE_FULLON_CHARGE, and SMBLITE_TAPER_CHARGE into
POWER_SUPPLY_STATUS_CHARGING, this never reports
POWER_SUPPLY_CHARGE_TYPE_TRICKLE or POWER_SUPPLY_CHARGE_TYPE_FAST.

[ ... ]

> @@ -904,37 +1464,216 @@ static const struct smb_init_register smb_init_seq[] = {
> +	/*
> +	 * Enable watchdog: WDOG_TIMER_EN_ON_PLUGIN + BARK_WDOG_INT_EN
> +	 * + BITE_WDOG_DISABLE_CHARGING (misc_base + 0x58)
> +	 * Matches downstream WD_CFG_REG enable sequence.
> +	 */
> +	{ .addr = SMBLITE_MISC_BASE + SMBLITE_WD_CFG,
> +	  .mask = SMBLITE_WDOG_TIMER_EN_BIT | SMBLITE_WDOG_TIMER_EN_ON_PLUGIN_BIT |
> +		  SMBLITE_BARK_WDOG_INT_EN_BIT |
> +		  SMBLITE_BITE_WDOG_DISABLE_CHARGING_CFG_BIT,
> +	  .val = SMBLITE_WDOG_TIMER_EN_ON_PLUGIN_BIT |
> +		  SMBLITE_BARK_WDOG_INT_EN_BIT |
> +		  SMBLITE_BITE_WDOG_DISABLE_CHARGING_CFG_BIT },

[ ... ]

> -static void smb_restore_charge_enable(void *data)
> +static void smb_restore_charge_state(void *data)
>  {
>  	struct smb_chip *chip = data;
> +	u16 reg;
> +	u8 charge_enable;
>  	int rc;
>  
> -	rc = regmap_update_bits(chip->regmap,
> -				chip->base + CHARGING_ENABLE_CMD,
> +	if (chip->type == SMBLITE)
> +		reg = SMBLITE_CHGR_BASE + SMBLITE_CHARGING_ENABLE_CMD;
> +	else
> +		reg = chip->base + CHARGING_ENABLE_CMD;
> +
> +	/* Keep SMBLite charging disabled if probe fails partway through setup. */
> +	charge_enable = chip->type == SMBLITE ? 0 : chip->initial_charge_enable;
> +	rc = regmap_update_bits(chip->regmap, reg,
>  				CHARGING_ENABLE_CMD_BIT,
> -				chip->initial_charge_enable);
> +				charge_enable);
> +	if (rc < 0)
> +		dev_err(chip->dev, "Couldn't set probe-failure charging state: %d\n",
> +			rc);
> +}

[Severity: Medium]
Does enabling SMBLITE_WD_CFG in smblite_init_seq leave the hardware
watchdog armed when smb_probe() fails after smb_init_hw() or when the
driver is later unbound?

Once SMBLITE_WDOG_TIMER_EN_ON_PLUGIN_BIT and
SMBLITE_BITE_WDOG_DISABLE_CHARGING_CFG_BIT are set, the hardware expects
smb_handle_wdog_bark() to pet SMBLITE_BARK_BITE_WDOG_PET every 16 seconds;
if probe fails or the driver is detached, no handler services the bark IRQ
and the bite timer disables charging in hardware 24 seconds after USB is
plugged in.  In addition, smb_probe() saves chip->initial_charge_enable
for SMBLite before disabling charging for setup, but
smb_restore_charge_state() ignores it and unconditionally writes 0 on
probe failure or deferral.

[ ... ]

> @@ -973,45 +1713,89 @@ static int smb_probe(struct platform_device *pdev)
>  	chip->dev = &pdev->dev;
> -	chip->name = pdev->name;
> +
> +	pmic_name = device_get_match_data(&pdev->dev);
> +	if (!pmic_name)
> +		return -EINVAL;
> +	chip->name = pmic_name;
> +
> +	if (strcmp(pmic_name, "pm4125") == 0) {
> +		chip->type        = SMBLITE;
> +		chip->icl_step_ua = SMBLITE_ICL_STEP_UA;
> +		chip->icl_max_ua  = SMBLITE_ICL_MAX_UA;
> +		/* Use the charger peripheral as the base for SMBLite accesses. */
> +		chip->base = SMBLITE_CHGR_BASE;
> +	} else {

[Severity: Low]
This isn't a bug, but several additions in this patch appear to be unused:
chip->base is assigned SMBLITE_CHGR_BASE here without reading the DT reg
property even though all SMBLite accesses use the SMBLITE_*_BASE constants
directly, chip->charge_status and chip->ldo_mode are written but never
read to drive any behaviour, smblite_init_hw_specific() is a redundant
wrapper around smblite_detect_ldo_mode(), and linux/regulator/consumer.h
is included without any regulator consumer calls.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-smblite-charger-for-pm4125-v2-0-20656509518b@oss.qualcomm.com?part=2

      reply	other threads:[~2026-11-26 11:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 11:00 [PATCH v2 0/2] power: supply: Add SMBLite charger support for PM4125 Raj Aryan
2026-11-26 11:00 ` [PATCH v2 1/2] dt-bindings: power: supply: Add qcom,pm4125-charger Raj Aryan
2026-11-26 11:10   ` sashiko-bot
2026-11-26 11:00 ` [PATCH v2 2/2] power: supply: qcom_smbx: Add PM4125 SMBLite charger support Raj Aryan
2026-11-26 11:18   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-235359@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=mfd@lists.linux.dev \
    --cc=raj.aryan@oss.qualcomm.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox