Re: [PATCH v4 2/2] power: supply: qcom_smbx: add SMB5 support
From: David Heidelberg
Date: Tue Oct 27 2026 - 13:24:01 EST
On 20/08/2026 12:03, Robin Snyders via B4 Relay wrote:
From: Casey Connolly <casey.connolly@xxxxxxxxxx>
Introduce support for the SMB5 charger found on PM7250B, PM8150B and
related Qualcomm PMICs.
SMB5 uses different DCDC status offsets, charger-state encodings and
electrical ranges. Select these from per-PMIC match data, with PM7250B
using the PM8150B compatible fallback and parameter block. Read
overvoltage from the SMB5 status bit, use the already-prescaled IIO
voltage reading, and convert the SMB5 current-sense voltage to microamps.
Use battery-info property presence when selecting voltage and current
targets.
Keep Type-C power-role and VBUS control with the dedicated TCPM and
regulator drivers. Clear the unsupported HVDCP negotiation modes so stale
firmware settings cannot raise VBUS. Leave the firmware recharge policy
unchanged and match the downstream default of ADC-based AICL disabled,
while enabling periodic hardware AICL with its twelve-second SMB5 rerun
interval. Preserve the existing three-second SMB2 interval.
PM8150B places the charger and VBUS regulator in the same DCDC peripheral,
but the SMB5 path does not write the regulator registers. qcom_smbx reads
0x1108 and 0x110b, while qcom_usb_vbus-regulator writes 0x1140, 0x1152
and 0x1153. The SMB2-only OTG configuration write to 0x1153 is not part
of the SMB5 initialization sequence. The TCPM port and PD PHY use the
separate 0x15xx and 0x17xx peripherals. Name the USBIN BC1.2 integration
register and SMB2-only OTG definitions accordingly to make this ownership
boundary explicit.
Program the battery limits and complete SMB5 input and charging setup
from the power-supply registration init callback before device_add
publishes the properties. This makes all public callbacks safe without
driver-specific probe synchronization.
Suspend USB input and charging before SMB5 initialization. On a later
failure, restore the original charging-enable state before the
input-suspend state; leave the input suspended if charging cannot be
restored. Cancel status work before unregistering the power supply during
managed teardown. Update the Kconfig description to cover both charger
generations.
On a OnePlus 7T Pro, register reads from the initial implementation
confirmed the programmed 4.40 V, 1.50 A and 500 mA limits. A 180-second
guarded charging trace and a subsequent 600-second runtime trace
completed without crossing the voltage guard.
Signed-off-by: Casey Connolly <casey.connolly@xxxxxxxxxx>
Co-developed-by: Joel Selvaraj <foss@xxxxxxxxxxxxxxxx>
Signed-off-by: Joel Selvaraj <foss@xxxxxxxxxxxxxxxx>
Co-developed-by: Robin Snyders <robin@xxxxxxxxxxx>
Signed-off-by: Robin Snyders <robin@xxxxxxxxxxx>
---
drivers/power/supply/Kconfig | 8 +-
drivers/power/supply/qcom_smbx.c | 757 ++++++++++++++++++++++++++++++---------
2 files changed, 598 insertions(+), 167 deletions(-)
diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index b89ef40df7f8..1159a7711919 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -1173,13 +1173,13 @@ config BATTERY_CHARGER_SURFACE_RT
will be called surface-rt-ec.
config CHARGER_QCOM_SMB2
- tristate "Qualcomm PMI8998 PMIC charger driver"
+ tristate "Qualcomm SMB2 and SMB5 charger driver"
depends on MFD_SPMI_PMIC
depends on IIO
help
- Say Y here to enable the Qualcomm PMIC Charger driver. This
- adds support for the SMB2 switch mode battery charger found
- in PMI8998 and related PMICs.
+ Say Y here to enable the Qualcomm PMIC charger driver. This adds
+ support for the SMB2 and SMB5 switch-mode battery chargers found
+ in PMI8998, PM660, PM7250B and PM8150B PMICs.
config FUEL_GAUGE_MM8013
tristate "Mitsumi MM8013 fuel gauge driver"
diff --git a/drivers/power/supply/qcom_smbx.c b/drivers/power/supply/qcom_smbx.c
index 71f5a4859412..bc2b1cd3ed68 100644
--- a/drivers/power/supply/qcom_smbx.c
+++ b/drivers/power/supply/qcom_smbx.c
@@ -23,6 +23,13 @@
#include <linux/types.h>
#include <linux/workqueue.h>
+enum smb_generation {
+ SMB2,
+ SMB5,
+};
+
+#define SMB_REG_OFFSET(smb) ((smb)->gen == SMB2 ? 0x600 : 0x100)
+
More and more as I look at it, this shouldn't be here, but within the device-tree as
charger@1000 {
reg = <0x1000>, <0x1600>; # SMB2, or
reg = <0x1000>, <0x1100>; # SMB5
};
But see also:
https://lore.kernel.org/all/eodzuccugtdn42basgpczett4yatyirog4nxwe5rhg5xf46ibp@jzcjmje4aqc3/
I'll try to do some basic separation so we know what bits belongs into which blog, keep you in CC.
David
[...]