From a5639a4d7bc53bf8e9a132f4e48eb0237fa588b3 Mon Sep 17 00:00:00 2001 From: Vincent Jardin Date: Sun, 12 Jul 2026 20:20:47 +0200 Subject: thermal: pmbus: add PMBus die-temp driver The driver is a thin UCLASS_THERMAL: its get_temp reads the temperature of its parent regulator through the pmbus helper (READ_TEMPERATURE_1), without any chip-specific code. Signed-off-by: Vincent Jardin Signed-off-by: Peng Fan --- MAINTAINERS | 1 + drivers/thermal/Kconfig | 8 ++++++++ drivers/thermal/Makefile | 1 + drivers/thermal/pmbus_thermal.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 drivers/thermal/pmbus_thermal.c diff --git a/MAINTAINERS b/MAINTAINERS index 4c9d33f5b3a..f60c58ed353 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1541,6 +1541,7 @@ F: drivers/power/regulator/mpq8785.c F: drivers/power/regulator/pmbus_generic.c F: drivers/power/regulator/pmbus_helper.c F: drivers/power/regulator/pmbus_helper.h +F: drivers/thermal/pmbus_thermal.c F: include/pmbus.h F: lib/pmbus.c diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 9ad0d699850..3b7e807a024 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -63,4 +63,12 @@ config DM_THERMAL_JC42 Enable support for the JEDEC JC-42.4 temperature sensor found on the SPD bus of DDR3 and DDR4 DIMMs (TSE2004av and compatible). +config PMBUS_THERMAL + bool "Generic PMBus temperature" + depends on DM_REGULATOR_PMBUS_HELPER + help + Expose the die-temperature reading of any PMBus voltage + regulator bound by a pmbus_helper based chip driver + as a UCLASS_THERMAL device. + endif # if DM_THERMAL diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index c9fa7561b45..475026a5ab2 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -12,3 +12,4 @@ obj-$(CONFIG_SANDBOX) += thermal_sandbox.o obj-$(CONFIG_TI_DRA7_THERMAL) += ti-bandgap.o obj-$(CONFIG_TI_LM74_THERMAL) += ti-lm74.o obj-$(CONFIG_DM_THERMAL_JC42) += jc42.o +obj-$(CONFIG_PMBUS_THERMAL) += pmbus_thermal.o diff --git a/drivers/thermal/pmbus_thermal.c b/drivers/thermal/pmbus_thermal.c new file mode 100644 index 00000000000..c251cea8ddf --- /dev/null +++ b/drivers/thermal/pmbus_thermal.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2026 Free Mobile - Vincent Jardin + * + * Generic UCLASS_THERMAL companion for PMBus voltage regulators. + * + * Works with any chip bound by a pmbus_helper based regulator driver + * (drivers/power/regulator/.c calling + * pmbus_regulator_probe_common()). It auto-spawns one + * of these thermal devices per regulator. + * + * The reading is the chip's READ_TEMPERATURE_1 (PMBus 0x8D), decoded + * through the parent's pmbus_driver_info. + */ + +#include +#include +#include + +static int pmbus_thermal_get_temp(struct udevice *dev, int *temp) +{ + return pmbus_regulator_read_temp(dev_get_parent(dev), temp); +} + +static const struct dm_thermal_ops pmbus_thermal_ops = { + .get_temp = pmbus_thermal_get_temp, +}; + +U_BOOT_DRIVER(pmbus_thermal) = { + .name = "pmbus_thermal", + .id = UCLASS_THERMAL, + .ops = &pmbus_thermal_ops, +}; -- cgit v1.3.1