| From 0cd9db4531769ad522dc0aca6def1884cfbe0826 Mon Sep 17 00:00:00 2001 |
| From: Charles Hsu <charles.hsu@quanta.corp-partner.google.com> |
| Date: Wed, 20 Aug 2025 05:22:42 +0000 |
| Subject: [PATCH] Add STEF48H28 driver |
| |
| --- |
| drivers/hwmon/pmbus/Kconfig | 9 ++++ |
| drivers/hwmon/pmbus/Makefile | 1 + |
| drivers/hwmon/pmbus/stef48h28.c | 77 +++++++++++++++++++++++++++++++++ |
| 3 files changed, 87 insertions(+) |
| create mode 100644 drivers/hwmon/pmbus/stef48h28.c |
| |
| diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig |
| index e6a7daf761e3..9556ebc3ce02 100644 |
| --- a/drivers/hwmon/pmbus/Kconfig |
| +++ b/drivers/hwmon/pmbus/Kconfig |
| @@ -340,6 +340,15 @@ config SENSORS_Q54SJ108A2 |
| This driver can also be built as a module. If so, the module will |
| be called q54sj108a2. |
| |
| +config SENSORS_STEF48H28 |
| + tristate "ST STEF48H28" |
| + help |
| + If you say yes here you get hardware monitoring support for ST |
| + STEF48H28. |
| + |
| + This driver can also be built as a module. If so, the module will |
| + be called stef48h28. |
| + |
| config SENSORS_STPDDC60 |
| tristate "ST STPDDC60" |
| help |
| diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile |
| index 9029ff89daf6..b7ec2ddd5b22 100644 |
| --- a/drivers/hwmon/pmbus/Makefile |
| +++ b/drivers/hwmon/pmbus/Makefile |
| @@ -37,6 +37,7 @@ obj-$(CONFIG_SENSORS_MPQ8785) += mpq8785.o |
| obj-$(CONFIG_SENSORS_PM6764TR) += pm6764tr.o |
| obj-$(CONFIG_SENSORS_PXE1610) += pxe1610.o |
| obj-$(CONFIG_SENSORS_Q54SJ108A2) += q54sj108a2.o |
| +obj-$(CONFIG_SENSORS_STEF48H28) += stef48h28.o |
| obj-$(CONFIG_SENSORS_STPDDC60) += stpddc60.o |
| obj-$(CONFIG_SENSORS_TDA38740) += tda38740.o |
| obj-$(CONFIG_SENSORS_TPS40422) += tps40422.o |
| diff --git a/drivers/hwmon/pmbus/stef48h28.c b/drivers/hwmon/pmbus/stef48h28.c |
| new file mode 100644 |
| index 000000000000..88437a6ec803 |
| --- /dev/null |
| +++ b/drivers/hwmon/pmbus/stef48h28.c |
| @@ -0,0 +1,77 @@ |
| +// SPDX-License-Identifier: GPL-2.0+ |
| +/* |
| + * Hardware monitoring driver for STMicroelectronics digital controller stef48h28 |
| + */ |
| + |
| +#include <linux/err.h> |
| +#include <linux/i2c.h> |
| +#include <linux/init.h> |
| +#include <linux/kernel.h> |
| +#include <linux/module.h> |
| +#include <linux/pmbus.h> |
| +#include "pmbus.h" |
| + |
| +static struct pmbus_driver_info stef48h28_info = { |
| + .pages = 1, |
| + .format[PSC_VOLTAGE_IN] = direct, |
| + .format[PSC_VOLTAGE_OUT] = direct, |
| + .format[PSC_CURRENT_IN] = direct, |
| + .format[PSC_CURRENT_OUT] = direct, |
| + .format[PSC_POWER] = direct, |
| + .format[PSC_TEMPERATURE] = direct, |
| + .m[PSC_VOLTAGE_IN] = 50, |
| + .b[PSC_VOLTAGE_IN] = 0, |
| + .R[PSC_VOLTAGE_IN] = 0, |
| + .m[PSC_VOLTAGE_OUT] = 50, |
| + .b[PSC_VOLTAGE_OUT] = 0, |
| + .R[PSC_VOLTAGE_OUT] = 0, |
| + .m[PSC_CURRENT_IN] = 100, |
| + .b[PSC_CURRENT_IN] = 0, |
| + .R[PSC_CURRENT_IN] = 0, |
| + .m[PSC_CURRENT_OUT] = 100, |
| + .b[PSC_CURRENT_OUT] = 0, |
| + .R[PSC_CURRENT_OUT] = 0, |
| + .m[PSC_POWER] = 9765, |
| + .b[PSC_POWER] = 0, |
| + .R[PSC_POWER] = -3, |
| + .m[PSC_TEMPERATURE] = 25, |
| + .b[PSC_TEMPERATURE] = 500, |
| + .R[PSC_TEMPERATURE] = 0, |
| + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | PMBUS_HAVE_PIN |
| + | PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 |
| + | PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
| + | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT |
| +}; |
| + |
| +static int stef48h28_probe(struct i2c_client *client) |
| +{ |
| + return pmbus_do_probe(client, &stef48h28_info); |
| +} |
| + |
| +static const struct i2c_device_id stef48h28_id[] = { |
| + {"stef48h28"}, |
| + {} |
| +}; |
| +MODULE_DEVICE_TABLE(i2c, stef48h28_id); |
| + |
| +static const struct of_device_id __maybe_unused stef48h28_of_match[] = { |
| + {.compatible = "st,stef48h28"}, |
| + {} |
| +}; |
| + |
| +/* This is the driver that will be inserted */ |
| +static struct i2c_driver stef48h28_driver = { |
| + .driver = { |
| + .name = "stef48h28", |
| + .of_match_table = of_match_ptr(stef48h28_of_match), |
| + }, |
| + .probe_new = stef48h28_probe, |
| + .id_table = stef48h28_id, |
| +}; |
| + |
| +module_i2c_driver(stef48h28_driver); |
| + |
| +MODULE_AUTHOR("Charles Hsu <ythsu0511@gmail.com>"); |
| +MODULE_DESCRIPTION("PMBus driver for ST stef48h28"); |
| +MODULE_LICENSE("GPL"); |
| +MODULE_IMPORT_NS(PMBUS); |
| -- |
| 2.34.1 |
| |