Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Raj Aryan" <raj.aryan@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/2] power: supply: qcom_smbx: Add SMBLite charger support
Date: Tue, 24 Nov 2026 09:32:20 +0000	[thread overview]
Message-ID: <sashiko-outbox-230842@kernel.org> (raw)
In-Reply-To: <20261124-smblite-charger-for-pm4125-v1-2-2132c9f0601f@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 13 potential
issues to consider:
- [High] power: supply: qcom_smbx: missing chip->base in
  smb_apsd_get_charger_type()
- [High] power: supply: qcom_smbx: wrong register written in
  smblite_enable_jeita()
- [High] power: supply: qcom_smbx: unsafe 4.54V float voltage write in
  smb_init_hw()
- [High] power: supply: qcom_smbx: watchdog disables charging during
  system suspend
- [Medium] power: supply: qcom_smbx: invalid status and rechg writes in
  smb_init_hw()
- [Medium] power: supply: qcom_smbx: stale charge_status in
  smb_get_property()
- [Medium] power: supply: qcom_smbx: missing SMBLite rerun in
  smb_status_change_work()
- [Medium] power: supply: qcom_smbx: unused resources and ABI mismatches
  in smb_probe()
- [Medium] power: supply: qcom_smbx: missing BAT_OV check in
  smb_get_prop_health()
- [Medium] power: supply: qcom_smbx: watchdog left armed on probe
  failure or unbind
- [Medium] power: supply: qcom_smbx: stale usb_type_override on replug
  in smb_handle_usb_plugin()
- [Medium] power: supply: qcom_smbx: race on usb_type_override and ICL
  in smb_status_change_work()
- [Medium] power: supply: qcom_smbx: smblite_init_typec() clobbers
  Type-C peripheral at 0x1500
--

commit 2884aa25bff648d3cce68c70d47efa2d6630bb25
Author: Raj Aryan <raj.aryan@oss.qualcomm.com>

power: supply: qcom_smbx: Add SMBLite charger support

This commit extends the qcom_smbx charger driver to support the SMBLite
charger block found on the PM4125 PMIC alongside existing SMB2 PMICs.

> diff --git a/drivers/power/supply/qcom_smbx.c b/drivers/power/supply/qcom_smbx.c
> index 52bb5a6eb145d..54b2942e2f5ad 100644
> --- a/drivers/power/supply/qcom_smbx.c
> +++ b/drivers/power/supply/qcom_smbx.c
[ ... ]
> @@ -451,7 +665,15 @@ static int smb_apsd_get_charger_type(struct smb_chip *chip, int *val)
>  		return rc;
>  	}
>  
> -	rc = regmap_read(chip->regmap, chip->base + APSD_STATUS, &apsd_stat);
> +	if (chip->type == SMBLITE) {
> +		apsd_reg   = SMBLITE_USBIN_BASE + SMBLITE_APSD_STATUS;
> +		result_reg = SMBLITE_USBIN_BASE + SMBLITE_APSD_RESULT_STATUS;
> +	} else {
> +		apsd_reg   = APSD_STATUS;
> +		result_reg = APSD_RESULT_STATUS;
> +	}
> +
> +	rc = regmap_read(chip->regmap, apsd_reg, &apsd_stat);

[Severity: High]
Does the else branch omit chip->base when computing apsd_reg and
result_reg?

On SMB2 (PMI8998 and PM660), APSD_STATUS (0x307) and APSD_RESULT_STATUS
(0x308) are offsets relative to chip->base (0x1000).  Reading bare 0x0307
and 0x0308 breaks APSD charger type detection and POWER_SUPPLY_PROP_USB_TYPE
on existing SMB2 devices, and causes smb_status_change_work() to spin in a
1 Hz retry loop without setting the input current limit.

[ ... ]
> @@ -562,8 +883,17 @@ static void smb_status_change_work(struct work_struct *work)
>  	chip = container_of(work, struct smb_chip, status_change_work.work);
>  
>  	smb_get_prop_usb_online(chip, &usb_online);
> -	if (!usb_online)
> +	if (!usb_online) {
> +		chip->usb_type_override = false;
> +		chip->usb_type = POWER_SUPPLY_USB_TYPE_UNKNOWN;
>  		return;
> +	}
> +
> +	if (chip->type == SMBLITE && chip->usb_type_override) {
> +		smb_set_current_limit(chip, smb_usb_type_current_ua(chip->usb_type));
> +		power_supply_changed(chip->chg_psy);
> +		return;
> +	}
>  
>  	for (count = 0; count < 3; count++) {
>  		dev_dbg(chip->dev, "get charger type retry %d\n", count);
> @@ -579,27 +909,16 @@ static void smb_status_change_work(struct work_struct *work)
>  	}
>  
>  	if (rc < 0) {
> -		rc = regmap_update_bits(chip->regmap, chip->base + CMD_APSD,
> -					APSD_RERUN_BIT, APSD_RERUN_BIT);
> +		if (chip->type != SMBLITE)
> +			rc = regmap_update_bits(chip->regmap, chip->base + CMD_APSD,
> +						APSD_RERUN_BIT, APSD_RERUN_BIT);
>  		schedule_delayed_work(&chip->status_change_work,
>  				      msecs_to_jiffies(1000));
>  		dev_dbg(chip->dev, "get charger type failed, rerun apsd\n");
>  		return;
>  	}

[Severity: Medium]
Should SMBLite trigger an APSD rerun via SMBLITE_USBIN_BASE +
SMBLITE_CMD_APSD here instead of skipping the write?

When smb_apsd_get_charger_type() returns -EAGAIN after three retries,
skipping the rerun command leaves SMBLITE_CMD_APSD unused while
status_change_work reschedules itself every second waiting for APSD to
complete.

> -	switch (charger_type) {
> -	case POWER_SUPPLY_USB_TYPE_CDP:
> -		current_ua = CDP_CURRENT_UA;
> -		break;
> -	case POWER_SUPPLY_USB_TYPE_DCP:
> -		current_ua = DCP_CURRENT_UA;
> -		break;
> -	case POWER_SUPPLY_USB_TYPE_SDP:
> -	default:
> -		current_ua = SDP_CURRENT_UA;
> -		break;
> -	}
> -
> +	current_ua = smb_usb_type_current_ua(charger_type);
>  	smb_set_current_limit(chip, current_ua);
>  	power_supply_changed(chip->chg_psy);
>  }

[Severity: Medium]
Can smb_status_change_work() race with smb_set_property() and overwrite an
active usb_type_override current limit?

kworker (status_change_work)      CPU1 (smb_set_property)
----------------------------      -----------------------
if (chip->usb_type_override)
  /* false */
for (count = 0; count < 3; ...)
  msleep(100)
                                  case POWER_SUPPLY_PROP_USB_TYPE:
                                    chip->usb_type = ..._DCP;
                                    chip->usb_type_override = true;
                                    smb_set_current_limit(chip, 1500000);
smb_set_current_limit(chip,
                      current_ua) <-- overwrites 1.5 A with APSD limit

Nothing serializes chip->usb_type_override, chip->usb_type, and
smb_set_current_limit() between smb_set_property() and
smb_status_change_work().  In addition, setting POWER_SUPPLY_PROP_USB_TYPE
to POWER_SUPPLY_USB_TYPE_UNKNOWN in smb_set_property() clears
chip->usb_type_override without updating the hardware current limit or
rescheduling status_change_work.

[ ... ]
> @@ -625,11 +949,48 @@ static int smb_get_iio_chan(struct smb_chip *chip, struct iio_channel *chan,
>  	return iio_read_channel_processed(chan, val);
>  }
>  
> +/*
> + * smb_get_prop_health - battery health based on temperature status.
> + *
> + * SMBLite: BATTERY_TEMP_STATUS_REG = batif_base + 0x0C (smblite-reg.h)
> + * SMB2:    BATTERY_CHARGER_STATUS_2 = chip->base + 0x07
> + */
>  static int smb_get_prop_health(struct smb_chip *chip, int *val)
>  {
>  	int rc;
>  	unsigned int stat;
>  
> +	if (chip->type == SMBLITE) {
> +		rc = regmap_read(chip->regmap,
> +				 SMBLITE_BATIF_BASE + SMBLITE_BATIF_JEITA_COMP_STATUS,
> +				 &stat);
> +		if (rc < 0) {
> +			dev_err(chip->dev,
> +				"Couldn't read SMBLITE JEITA status rc=%d\n", rc);
> +			return rc;
> +		}
> +		if (stat & (SMBLITE_JEITA_ADC_THOT_AFP_BIT |
> +			    SMBLITE_JEITA_ADC_THOT_BIT)) {
> +			*val = POWER_SUPPLY_HEALTH_OVERHEAT;
> +			return 0;
> +		}
> +		if (stat & (SMBLITE_JEITA_ADC_TCOLD_AFP_BIT |
> +			    SMBLITE_JEITA_ADC_TCOLD_BIT)) {
> +			*val = POWER_SUPPLY_HEALTH_COLD;
> +			return 0;
> +		}
> +		if (stat & SMBLITE_JEITA_ADC_WARM_BIT) {
> +			*val = POWER_SUPPLY_HEALTH_WARM;
> +			return 0;
> +		}
> +		if (stat & SMBLITE_JEITA_ADC_COOL_BIT) {
> +			*val = POWER_SUPPLY_HEALTH_COOL;
> +			return 0;
> +		}
> +		*val = POWER_SUPPLY_HEALTH_GOOD;
> +		return 0;
> +	}

[Severity: Medium]
Does the SMBLite path in smb_get_prop_health() miss battery overvoltage
faults?

Unlike the SMB2 path below it, which checks CHARGER_ERROR_STATUS_BAT_OV_BIT
and reports POWER_SUPPLY_HEALTH_OVERVOLTAGE, the SMBLite branch never checks
SMBLITE_BAT_OV_BIT in SMBLITE_CHGR_BASE + SMBLITE_CHARGER_VBAT_STATUS, so
POWER_SUPPLY_PROP_HEALTH reports POWER_SUPPLY_HEALTH_GOOD during an active
overvoltage event.

[ ... ]
> @@ -681,7 +1044,32 @@ static int smb_get_property(struct power_supply *psy,
>  	case POWER_SUPPLY_PROP_HEALTH:
>  		return smb_get_prop_health(chip, &val->intval);
>  	case POWER_SUPPLY_PROP_USB_TYPE:
> +		if (chip->type == SMBLITE && chip->usb_type_override) {
> +			int usb_online = 0;
> +
> +			smb_get_prop_usb_online(chip, &usb_online);
> +			if (usb_online) {
> +				val->intval = chip->usb_type;
> +				return 0;
> +			}
> +		}
>  		return smb_apsd_get_charger_type(chip, &val->intval);
> +	case POWER_SUPPLY_PROP_CHARGE_TYPE:
> +		if (chip->type != SMBLITE)
> +			return -EOPNOTSUPP;
> +		switch (chip->charge_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;

[Severity: Medium]
Can POWER_SUPPLY_PROP_CHARGE_TYPE report stale state from
chip->charge_status?

smb_get_property() does not refresh the hardware state before reading
chip->charge_status, and smb_get_prop_status() returns early when
!usb_online without updating chip->charge_status:

drivers/power/supply/qcom_smbx.c:smb_get_prop_status() {
	rc = smb_get_prop_usb_online(chip, &usb_online);
	if (!usb_online) {
		*val = POWER_SUPPLY_STATUS_DISCHARGING;
		return rc;
	}
}

After unplugging a charger while charging, POWER_SUPPLY_PROP_STATUS reports
POWER_SUPPLY_STATUS_DISCHARGING while POWER_SUPPLY_PROP_CHARGE_TYPE stays
stuck at POWER_SUPPLY_CHARGE_TYPE_STANDARD.

[ ... ]
> @@ -709,44 +1121,93 @@ static int smb_set_property(struct power_supply *psy,
>  static int smb_property_is_writable(struct power_supply *psy,
>  				     enum power_supply_property psp)
>  {
> +	struct smb_chip *chip = power_supply_get_drvdata(psy);
> +
>  	switch (psp) {
>  	case POWER_SUPPLY_PROP_STATUS:
> +		return chip->type != SMBLITE;
>  	case POWER_SUPPLY_PROP_CURRENT_MAX:
>  		return 1;
> +	case POWER_SUPPLY_PROP_USB_TYPE:
> +		return chip->type == SMBLITE;
>  	default:
>  		return 0;
>  	}
>  }
[ ... ]
>  static irqreturn_t smb_handle_usb_plugin(int irq, void *data)
>  {
>  	struct smb_chip *chip = data;
> +	int usb_online = 0;
>  
>  	power_supply_changed(chip->chg_psy);
> +	smb_get_prop_usb_online(chip, &usb_online);
>  
> +	if (!usb_online)
> +		goto schedule_work;

[Severity: Medium]
Does leaving chip->usb_type_override set on unplug cause a stale USB type
and current limit to be applied if a cable is replugged within 1500 ms?

When a charger is unplugged, smb_handle_usb_plugin() leaves
chip->usb_type_override set until status_change_work runs 1500 ms later.
If a different cable (for example, a 500 mA SDP host port after a 1.5 A DCP
charger) is connected before that 1500 ms timer fires, usb_online is true
when status_change_work runs, so the !usb_online reset is skipped and the
previous charger's current limit is programmed onto the new port.

[ ... ]
>  static irqreturn_t smb_handle_wdog_bark(int irq, void *data)
>  {
>  	struct smb_chip *chip = data;
> +	u16 reg;
>  	int rc;
>  
>  	power_supply_changed(chip->chg_psy);
>  
> -	rc = regmap_write(chip->regmap, chip->base + BARK_BITE_WDOG_PET,
> -			  BARK_BITE_WDOG_PET_BIT);
> +	if (chip->type == SMBLITE)
> +		reg = SMBLITE_MISC_BASE + SMBLITE_BARK_BITE_WDOG_PET;
> +	else
> +		reg = chip->base + BARK_BITE_WDOG_PET;
> +
> +	rc = regmap_write(chip->regmap, reg, BARK_BITE_WDOG_PET_BIT);
>  	if (rc < 0)
>  		dev_err(chip->dev, "Couldn't pet the dog rc=%d\n", rc);
>  
>  	return IRQ_HANDLED;
>  }
[ ... ]
> +static int smblite_init_typec(struct smb_chip *chip)
> +{
> +	unsigned int val;
> +	int rc;
> +
> +	if (chip->type != SMBLITE)
> +		return 0;
> +	if (chip->connector_type != CONNECTOR_TYPE_TYPEC)
> +		return 0;
> +
> +	rc = regmap_read(chip->regmap,
> +			 SMBLITE_TYPEC_BASE + SMBLITE_LEGACY_CABLE_STATUS, &val);
> +	if (rc < 0)
> +		return rc;
> +
> +	if (val & SMBLITE_TYPEC_LEGACY_CABLE_STATUS_BIT) {
> +		dev_dbg(chip->dev, "Resetting legacy cable detection\n");
> +		rc = regmap_update_bits(chip->regmap,
> +					SMBLITE_TYPEC_BASE + SMBLITE_TYPE_C_MODE_CFG,
> +					EN_TRY_SNK_BIT | EN_SNK_ONLY_BIT, 0);
> +		if (rc < 0)
> +			return rc;
> +		msleep(50);
> +	}
> +
> +	rc = regmap_update_bits(chip->regmap,
> +				SMBLITE_TYPEC_BASE + SMBLITE_TYPE_C_MODE_CFG,
> +				EN_TRY_SNK_BIT | EN_SNK_ONLY_BIT,
> +				EN_TRY_SNK_BIT);
> +	if (rc < 0)
> +		return rc;
> +
> +	return regmap_update_bits(chip->regmap,
> +				  SMBLITE_TYPEC_BASE + SMBLITE_TYPE_C_EXIT_STATE_CFG,
> +				  SEL_SRC_UPPER_REF_BIT, SEL_SRC_UPPER_REF_BIT);
> +}

[Severity: Medium]
Does smblite_init_typec() overwrite registers owned by the PM4125 Type-C
driver at 0x1500?

On PM4125, the SPMI Type-C peripheral at 0x1500 is a separate devicetree
node (typec@1500) managed by qcom_pmic_typec, which controls
TYPE_C_MODE_CFG (0x1544) and TYPE_C_EXIT_STATE_CFG (0x1550) under
pmic_typec_port->lock.  Modifying 0x1544 and 0x1550 directly through the
parent PMIC regmap during charger probe clobbers the TCPM port state if
qcom_pmic_typec has already started.

[ ... ]
> +/*
> + * smblite_enable_jeita - enable JEITA hardware comparators.
> + *
> + * Downstream smblite_init_hw() uses a masked write on
> + * CHGR_FAST_CHARGE_SAFETY_TIMER_CFG_REG (chg_base + 0x90):
> + *   mask = 0x0B  (bits [3:1] = timer select, bit[0] = enable)
> + *   val  = 0x0A  (FAST_CHARGE_SAFETY_TIMER_768_MIN | enable)
> + * Use regmap_update_bits to touch only those bits.
> + */
> +static int smblite_enable_jeita(struct smb_chip *chip)
> +{
> +	if (chip->type != SMBLITE)
> +		return 0;
> +
> +	return regmap_update_bits(chip->regmap,
> +				  SMBLITE_CHGR_BASE + 0x90,
> +				  0x0B, 0x0A);
> +}

[Severity: High]
Does smblite_enable_jeita() write to the fast-charge safety timer register
(SMBLITE_CHGR_BASE + 0x90) instead of SMBLITE_BATIF_BASE +
SMBLITE_BATIF_JEITA_EN_CFG (0x127F)?

On SMB2, offset 0x90 in the charger block is JEITA_EN_CFG, whereas on
SMBLite JEITA enable is in BATIF at SMBLITE_BATIF_BASE +
SMBLITE_BATIF_JEITA_EN_CFG (0x127F), which smb_init_hw() explicitly clears
to 0x00.  Because 0x127F is never re-enabled, hardware JEITA thermal
protection and SMBLITE_BATIF_JEITA_COMP_STATUS health reporting remain
disabled (and even for the safety timer at 0x1090, val 0x0A clears bit 0).
Also, smb_probe() calls smblite_enable_jeita() unconditionally even when
the DT threshold properties are absent, and ignores the return values of
both smblite_enable_jeita() and smblite_write_jeita_16().

[ ... ]
> +	/*
> +	 * 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 },

[Severity: High]
Will the SMBLite watchdog bite and disable charging 24 seconds after the
system enters suspend?

smblite_init_seq enables the watchdog on plugin with a 16-second bark
timeout, an 8-second bite timeout, and
SMBLITE_BITE_WDOG_DISABLE_CHARGING_CFG_BIT set, but the driver defines no
PM suspend/resume callbacks to disable the watchdog during suspend and only
marks cable_irq as a wake IRQ.  When the system suspends while plugged in,
wdog-bark is not serviced and the watchdog disables charging after 24
seconds.  While awake, smb_handle_wdog_bark() also calls
power_supply_changed() on every 16-second bark, causing unnecessary
pm_stay_awake() wakeups and userspace uevents even when nothing changed.

[ ... ]
> +	/*
> +	 * SMBLite vendor bring-up register writes.
> +	 * These are undocumented initialisation values derived from the
> +	 * downstream qpnp-smblite driver.  They are SMBLITE-only.
> +	 */
> +	if (chip->type == SMBLITE) {
> +		regmap_write(chip->regmap,
> +			     SMBLITE_CHGR_BASE + SMBLITE_CHGR_FLOAT_VOLTAGE_CFG, 0x2F);
> +		regmap_write(chip->regmap,
> +			     SMBLITE_BATIF_BASE + SMBLITE_BATIF_BPD_CFG, 0x00);
> +		regmap_write(chip->regmap,
> +			     SMBLITE_BATIF_BASE + SMBLITE_BATIF_JEITA_EN_CFG, 0x00);
> +		regmap_write(chip->regmap,
> +			     SMBLITE_CHGR_BASE + SMBLITE_CHGR_CHG_INHIBIT_CFG, 0x00);
> +		regmap_write(chip->regmap,
> +			     SMBLITE_CHGR_BASE + SMBLITE_CHGR_RECHG_CFG, 0xC2);
> +		/* SOC recharge threshold = 250 (0xFA) -- aligned with
> +		 * SOC-based recharge strategy set at SMBLITE_CHGR_RECHG_CFG=0xC2
> +		 */
> +		regmap_write(chip->regmap,
> +			     SMBLITE_CHGR_BASE + SMBLITE_CHGR_RECHG_SOC_THD_CFG, 0xFA);
> +		regmap_write(chip->regmap,
> +			     SMBLITE_CHGR_BASE + SMBLITE_CHGR_CHG_TERM_CFG, 0x80);
> +		regmap_write(chip->regmap,
> +			     SMBLITE_USBIN_BASE + SMBLITE_USB_APSD_EN, 0x10);
> +		regmap_write(chip->regmap,
> +			     SMBLITE_USBIN_BASE + SMBLITE_USB_APSD_CFG, 0x00);
> +		/* 0x130c, 0x1340: no documented register at this offset */
> +		regmap_write(chip->regmap,
> +			     SMBLITE_CHGR_BASE + SMBLITE_CHGR_IBAT_STATUS, 0xc1);
> +		regmap_write(chip->regmap,
> +			     SMBLITE_CHGR_BASE + SMBLITE_CHGR_VFLT_STATUS, 0x82);
> +	}

[Severity: Medium]
Why does smb_init_hw() write 0xc1 and 0x82 to the read-only charger status
registers SMBLITE_CHGR_IBAT_STATUS (0x100A) and SMBLITE_CHGR_VFLT_STATUS
(0x100B)?

The comment right above those writes mentions USBIN offsets 0x130c and
0x1340, whereas the code writes to read-only CHGR status registers 0x100A
and 0x100B.  Also, writing 0xC2 to SMBLITE_CHGR_RECHG_CFG sets
SMBLITE_VBAT_BASED_RECHG_BIT (BIT(7)), which contradicts the comment and
commit message stating that SOC-based recharge is selected, and none of the
regmap_write() calls in this block check for errors.

>  
>  	return 0;
>  }
>  
>  static void smb_restore_charge_enable(void *data)
>  {
>  	struct smb_chip *chip = data;
> +	u16 reg;
>  	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;
> +
> +	rc = regmap_update_bits(chip->regmap, reg,
>  				CHARGING_ENABLE_CMD_BIT,
>  				chip->initial_charge_enable);
>  	if (rc < 0)

[Severity: Medium]
Does smb_restore_charge_enable() leave the SMBLite hardware watchdog armed
if smb_probe() fails after smb_init_hw() or if the driver is unbound?

smblite_init_seq enables SMBLITE_WD_CFG with
SMBLITE_BITE_WDOG_DISABLE_CHARGING_CFG_BIT set, but
smb_restore_charge_enable() only restores SMBLITE_CHARGING_ENABLE_CMD (and
is removed before probe returns).  Without the wdog-bark handler running to
pet the watchdog, it will bite 24 seconds after USB plugin and disable
charging in hardware.

[ ... ]
> @@ -1025,9 +1855,11 @@ static int smb_probe(struct platform_device *pdev)
>  				     "failed to register power supply\n");
>  
>  	rc = power_supply_get_battery_info(chip->chg_psy, &chip->batt_info);
> -	if (rc)
> -		return dev_err_probe(chip->dev, rc,
> -				     "Failed to get battery info\n");
> +	if (rc || !chip->batt_info) {
> +		dev_warn(chip->dev,
> +			 "No battery info, skipping float voltage configuration\n");
> +		chip->batt_info = NULL;
> +	}
>  
>  	rc = devm_delayed_work_autocancel(chip->dev, &chip->status_change_work,
>  					  smb_status_change_work);
> @@ -1035,6 +1867,9 @@ static int smb_probe(struct platform_device *pdev)
>  		return dev_err_probe(chip->dev, rc,
>  				     "Failed to init status change work\n");
>  
> +	if (!chip->batt_info)
> +		goto init_irqs;
> +
>  	if (power_supply_battery_info_has_prop(chip->batt_info,
>  					       POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX)) {
>  		float_voltage_uv =
> @@ -1043,27 +1878,50 @@ static int smb_probe(struct platform_device *pdev)
>  					      POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN)) {
>  		float_voltage_uv = chip->batt_info->voltage_max_design_uv;
>  	} else {
> -		dev_warn(chip->dev, "No battery float voltage; preserving hardware setting\n");
> -		goto skip_float_voltage;
> +		dev_warn(chip->dev,
> +			 "No battery float voltage; preserving hardware setting\n");
> +		goto init_irqs;
> +	}

[Severity: High]
Does skipping float voltage configuration here leave SMBLite charging
enabled at 4.54 V?

In smb_init_hw(), the SMBLite path enables charging at 1.5 A and
unconditionally writes 0x2F (3600000 + 47 * 20000 = 4540000 uV) to
SMBLITE_CHGR_FLOAT_VOLTAGE_CFG before smb_probe() reads the battery info.
If monitored-battery is omitted, has no voltage property, or
power_supply_get_battery_info() fails, jumping to init_irqs does not
preserve the hardware setting—it leaves the charger active at 4.54 V, which
can overcharge standard 4.2 V / 4.35 V / 4.4 V Li-ion cells.  Downgrading
power_supply_get_battery_info() errors to a warning also masks real errors
such as -ENOMEM or malformed battery DT nodes on both SMB2 and SMBLite.

[ ... ]
> @@ -1087,6 +1945,15 @@ static int smb_probe(struct platform_device *pdev)
>  	if (rc < 0)
>  		return dev_err_probe(chip->dev, rc, "Couldn't set wake irq\n");
>  
> +	chip->vbus_reg = devm_regulator_get_optional(chip->dev, "vbus");
> +	if (IS_ERR(chip->vbus_reg)) {
> +		rc = PTR_ERR(chip->vbus_reg);
> +		if (rc == -EPROBE_DEFER)
> +			return -EPROBE_DEFER;
> +		dev_warn(chip->dev, "vbus regulator not found, ignoring\n");
> +		chip->vbus_reg = NULL;
> +	}
> +
>  	devm_remove_action(chip->dev, smb_restore_charge_enable, chip);

[Severity: Medium]
Why does smb_probe() request a "vbus" regulator and a "chg_temp" IIO
channel that are never used anywhere in the driver?

Neither resource is documented in the DT bindings, and because
devm_regulator_get_optional() returns ERR_PTR(-ENODEV) when vbus-supply is
absent, every board prints a false "vbus regulator not found, ignoring"
warning at boot (or can return -EPROBE_DEFER after IRQs are already live).
Conversely, the PM4125 binding documents the "usbin_i" IIO channel, which
smb_probe() skips on SMBLite, and smb_property_is_writable() marks
POWER_SUPPLY_PROP_USB_TYPE writable in sysfs even though
Documentation/ABI/testing/sysfs-class-power defines usb_type as read-only
for USB charger supplies (in-kernel callers of power_supply_set_property()
do not check property_is_writeable()).  The struct smb_chip fields
ldo_mode, fcc_step_ua, fcc_max_ua, and charge_done are also written but
never read.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124-smblite-charger-for-pm4125-v1-0-2132c9f0601f@oss.qualcomm.com?part=2

      reply	other threads:[~2026-11-24  9:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  9:15 [PATCH 0/2] arm64: qcom: Add SMBLite charger support for PM4125 Raj Aryan
2026-11-24  9:15 ` [PATCH 1/2] dt-bindings: power: supply: Add qcom,pm4125-charger binding Raj Aryan
2026-11-24  9:26   ` sashiko-bot
2026-11-24  9:15 ` [PATCH 2/2] power: supply: qcom_smbx: Add SMBLite charger support Raj Aryan
2026-11-24  9:32   ` 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-230842@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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