From nobody Thu Dec 18 13:48:13 2025 Received: from mail.monolithicpower.com (unknown [12.33.0.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ADB48834; Mon, 15 Dec 2025 02:26:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=12.33.0.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765765601; cv=none; b=mmkOcs6OVQxg3/l1ltNXEnk+aiJ6V8d1NTgcs649MD8Fn1oFsSJGh+mhSSRRyFscdptjgauVeIpYfy6Gh6Ia7JTRkctEYAjpmOwLLPgNWJdWAeqxU3/WFFxPD5/DnvQT7UfBfkbgUTGAboTeJOesLMVHqaRKNaOzCasrRaNTvyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765765601; c=relaxed/simple; bh=bL4J/1MC0f6IgvRrU3E11SbBwtlUY01btldktjXiVtg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F9dLv6hhkCO2Xlzzga+fhU5KKgnK5U2INsuwfjQVr7dwBexWL1nXzZ/cMzghLhqA+vzdLxWOBZHmn71HDDJrSC1phaqXCLkNKM0gLmJ/PzOhL7EJS96WeuN7QxqYqgpx2+VGtzscPmjW+BUtbQUDU0PCela53CQo9cLpvR8fdqo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=monolithicpower.com; spf=pass smtp.mailfrom=monolithicpower.com; arc=none smtp.client-ip=12.33.0.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=monolithicpower.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=monolithicpower.com Received: from CD-MSH04.monolithicpower.com (10.10.70.213) by mps-mslbn03.monolithicpower.com (10.10.10.245) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.6; Sun, 14 Dec 2025 18:26:32 -0800 Received: from HZ-200D-C0727.monolithicpower.com (10.53.66.137) by CD-MSH04.monolithicpower.com (10.10.70.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.57; Mon, 15 Dec 2025 10:26:30 +0800 From: Yuxi Wang To: , , , , , CC: , , , , Subject: [PATCH v2 RESEND 1/2] dt-bindings: hwmon: Add mps mp5926 driver bindings Date: Mon, 15 Dec 2025 10:25:04 +0800 Message-ID: <20251215022505.1602-2-Yuxi.Wang@monolithicpower.com> X-Mailer: git-send-email 2.51.0.windows.1 In-Reply-To: <20251215022505.1602-1-Yuxi.Wang@monolithicpower.com> References: <20251215022505.1602-1-Yuxi.Wang@monolithicpower.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: CD-MSLBN02.monolithicpower.com (192.168.86.32) To CD-MSH04.monolithicpower.com (10.10.70.213) Content-Type: text/plain; charset="utf-8" Add a device tree bindings for mp5926 device. Signed-off-by: Yuxi Wang Acked-by: Rob Herring (Arm) --- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Docum= entation/devicetree/bindings/trivial-devices.yaml index d0f7dbf15d6f..df3f74b9dd28 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -319,6 +319,8 @@ properties: - mps,mp5023 # Monolithic Power Systems Inc. multi-phase hot-swap controlle= r mp5920 - mps,mp5920 + # Monolithic Power Systems Inc. multi-phase hot-swap controlle= r mp5926 + - mps,mp5926 # Monolithic Power Systems Inc. multi-phase hot-swap controlle= r mp5990 - mps,mp5990 # Monolithic Power Systems Inc. multi-phase hot-swap controlle= r mp5998 --=20 2.39.2 From nobody Thu Dec 18 13:48:13 2025 Received: from mail.monolithicpower.com (unknown [12.33.0.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCB89288522; Mon, 15 Dec 2025 02:26:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=12.33.0.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765765615; cv=none; b=XVZotFFbGGrogekvaMSNXKWeaEd5Ndmt6MXhMCDuSpQZoGern4KNNWZxNbRhT7ABQZlMswwxWObiXk5Yp8BdGZgYPUBnLpDZ6mYvBvL8cfx/1Ci1BgjoXGmJntrFIqGHsrPKxty9tr4dqP/zIL5uJy1H70z6GmFvoeixx9cXSwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765765615; c=relaxed/simple; bh=sNFvxUCFzUXLt7rzYsZUhxnmYe93UZVuqdCJlsyljzE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E8iGHOjFeXWb1HdN4cinzfw5z2A5A3vOH0Ew56QAnT6pLDK1TW3vN8y08hZ3ZiHRla3uCNrgudmXYKSAtazOLiRGz1phEo34k6aNzVHIoaMiTVqccIbrQzeDkNlFB/EHvNfTXd+06hXTmHMGIV+c36Acu2UnIPLvx9lfwf5x4BI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=monolithicpower.com; spf=pass smtp.mailfrom=monolithicpower.com; arc=none smtp.client-ip=12.33.0.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=monolithicpower.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=monolithicpower.com Received: from CD-MSH04.monolithicpower.com (10.10.70.213) by mps-mslbn03.monolithicpower.com (10.10.10.245) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.6; Sun, 14 Dec 2025 18:26:52 -0800 Received: from HZ-200D-C0727.monolithicpower.com (10.53.66.137) by CD-MSH04.monolithicpower.com (10.10.70.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.57; Mon, 15 Dec 2025 10:26:50 +0800 From: Yuxi Wang To: , , , , , CC: , , , , Subject: [PATCH v2 RESEND 2/2] hwmon: add mp5926 driver Date: Mon, 15 Dec 2025 10:25:05 +0800 Message-ID: <20251215022505.1602-3-Yuxi.Wang@monolithicpower.com> X-Mailer: git-send-email 2.51.0.windows.1 In-Reply-To: <20251215022505.1602-1-Yuxi.Wang@monolithicpower.com> References: <20251215022505.1602-1-Yuxi.Wang@monolithicpower.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: CD-MSLBN02.monolithicpower.com (192.168.86.32) To CD-MSH04.monolithicpower.com (10.10.70.213) Content-Type: text/plain; charset="utf-8" Add support for mps mp5926. Signed-off-by: Yuxi Wang --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/mp5926.rst | 92 ++++++++++++++++ MAINTAINERS | 7 ++ drivers/hwmon/pmbus/Kconfig | 9 ++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/mp5926.c | 190 +++++++++++++++++++++++++++++++++ 6 files changed, 300 insertions(+) create mode 100644 Documentation/hwmon/mp5926.rst create mode 100644 drivers/hwmon/pmbus/mp5926.c diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 85d7a686883e..6181c3f62177 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -185,6 +185,7 @@ Hardware Monitoring Kernel Drivers mp2993 mp5023 mp5920 + mp5926 mp5990 mp9941 mp9945 diff --git a/Documentation/hwmon/mp5926.rst b/Documentation/hwmon/mp5926.rst new file mode 100644 index 000000000000..4b64a7e24ae6 --- /dev/null +++ b/Documentation/hwmon/mp5926.rst @@ -0,0 +1,92 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver mp5926 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Supported chips: + + * MPS mp5926 + + Prefix: 'mp5926' + + * Datasheet + https://www.monolithicpower.com/en/ + +Author: + + Yuxi Wang + +Description +----------- + +This driver implements support for Monolithic Power Systems, Inc. (MPS) +MP5926 Hot-Swap Controller. + +Device compliant with: + +- PMBus rev 1.3 interface. + +The driver exports the following attributes via the 'sysfs' files +for input voltage: + +**in1_input** + +**in1_label** + +**in1_crit** + +**in1_crit_alarm** + +The driver provides the following attributes for output voltage: + +**in2_input** + +**in2_label** + +**in2_lcrit** + +**in2_lcrit_alarm** + +**in2_rated_max** + +**in2_rated_min** + +The driver provides the following attributes for input current: + +**curr1_input** + +**curr1_label** + +**curr1_max** + +**curr1_max_alarm** + +The driver provides the following attributes for output current: + +**curr2_input** + +**curr2_label** + +The driver provides the following attributes for input power: + +**power1_input** + +**power1_label** + +The driver provides the following attributes for output power: + +**power2_input** + +**power2_label** + +The driver provides the following attributes for temperature: + +**temp1_input** + +**temp1_crit** + +**temp1_crit_alarm** + +**temp1_max** + +**temp1_max_alarm** diff --git a/MAINTAINERS b/MAINTAINERS index d701a4d5b00e..fea710aab535 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17708,6 +17708,13 @@ S: Maintained F: Documentation/hwmon/mp2993.rst F: drivers/hwmon/pmbus/mp2993.c =20 +MPS MP5926 DRIVER +M: Yuxi Wang +L: linux-hwmon@vger.kernel.org +S: Maintained +F: Documentation/hwmon/mp5926.rst +F: drivers/hwmon/pmbus/mp5926.c + MPS MP9941 DRIVER M: Noah Wang L: linux-hwmon@vger.kernel.org diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index f3fb94cebf1a..d0aa460abdc9 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -472,6 +472,15 @@ config SENSORS_MP5920 This driver can also be built as a module. If so, the module will be called mp5920. =20 +config SENSORS_MP5926 + tristate "MPS MP5926" + help + If you say yes here you get hardware monitoring support for Monolithic + MP5926. + + This driver can also be built as a module. If so, the module will + be called mp5926. + config SENSORS_MP5990 tristate "MPS MP5990" help diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile index 349a89b6d92e..75ec4956ca8d 100644 --- a/drivers/hwmon/pmbus/Makefile +++ b/drivers/hwmon/pmbus/Makefile @@ -47,6 +47,7 @@ obj-$(CONFIG_SENSORS_MP2975) +=3D mp2975.o obj-$(CONFIG_SENSORS_MP2993) +=3D mp2993.o obj-$(CONFIG_SENSORS_MP5023) +=3D mp5023.o obj-$(CONFIG_SENSORS_MP5920) +=3D mp5920.o +obj-$(CONFIG_SENSORS_MP5926) +=3D mp5926.o obj-$(CONFIG_SENSORS_MP5990) +=3D mp5990.o obj-$(CONFIG_SENSORS_MP9941) +=3D mp9941.o obj-$(CONFIG_SENSORS_MP9945) +=3D mp9945.o diff --git a/drivers/hwmon/pmbus/mp5926.c b/drivers/hwmon/pmbus/mp5926.c new file mode 100644 index 000000000000..3122854b07f8 --- /dev/null +++ b/drivers/hwmon/pmbus/mp5926.c @@ -0,0 +1,190 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// mp5926.c - pmbus driver for mps mp5926 +// +// Copyright 2025 Monolithic Power Systems, Inc +// +// Author: Yuxi Wang + +#include +#include +#include +#include +#include +#include +#include "pmbus.h" + +#define PAGE 0x01 +#define EFUSE_CFG 0xCF +#define I_SCALE_SEL 0xC6 +#define MP5926_FUNC (PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | \ + PMBUS_HAVE_IIN | PMBUS_HAVE_PIN | \ + PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_INPUT | \ + PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_STATUS_VOUT) + +struct mp5926_data { + struct pmbus_driver_info info; + u8 vout_mode; + u8 vout_linear_exponent; +}; + +#define to_mp5926_data(x) container_of(x, struct mp5926_data, info) + +static int mp5926_read_byte_data(struct i2c_client *client, int page, + int reg) +{ + const struct pmbus_driver_info *info =3D pmbus_get_driver_info(client); + struct mp5926_data *data =3D to_mp5926_data(info); + int ret; + + switch (reg) { + case PMBUS_VOUT_MODE: + if (data->vout_mode =3D=3D linear) { + /* + * The VOUT format used by the chip is linear11, + * not linear16. Report that VOUT is in linear mode + * and return exponent value extracted while probing + * the chip. + */ + return data->vout_linear_exponent; + } else { + return PB_VOUT_MODE_DIRECT; + } + break; + default: + ret =3D -ENODATA; + break; + } + return ret; +} + +static int mp5926_read_word_data(struct i2c_client *client, int page, int = phase, + int reg) +{ + const struct pmbus_driver_info *info =3D pmbus_get_driver_info(client); + struct mp5926_data *data =3D to_mp5926_data(info); + int ret; + s32 mantissa; + + switch (reg) { + case PMBUS_READ_VOUT: + ret =3D pmbus_read_word_data(client, page, phase, reg); + if (ret < 0) + return ret; + /* + * Because the VOUT format used by the chip is linear11 and not + * linear16, we disregard bits[15:11]. The exponent is reported + * as part of the VOUT_MODE command. + */ + if (data->vout_mode =3D=3D linear) { + mantissa =3D ((s16)((ret & 0x7ff) << 5)) >> 5; + ret =3D mantissa; + } + break; + default: + ret =3D -ENODATA; + break; + } + return ret; +} + +static struct pmbus_driver_info mp5926_info =3D { + .pages =3D PAGE, + .format[PSC_VOLTAGE_IN] =3D direct, + .format[PSC_CURRENT_IN] =3D direct, + .format[PSC_VOLTAGE_OUT] =3D direct, + .format[PSC_TEMPERATURE] =3D direct, + .format[PSC_POWER] =3D direct, + + .m[PSC_VOLTAGE_IN] =3D 16, + .b[PSC_VOLTAGE_IN] =3D 0, + .R[PSC_VOLTAGE_IN] =3D 0, + + .m[PSC_CURRENT_IN] =3D 16, + .b[PSC_CURRENT_IN] =3D 0, + .R[PSC_CURRENT_IN] =3D 0, + + .m[PSC_VOLTAGE_OUT] =3D 16, + .b[PSC_VOLTAGE_OUT] =3D 0, + .R[PSC_VOLTAGE_OUT] =3D 0, + + .m[PSC_TEMPERATURE] =3D 4, + .b[PSC_TEMPERATURE] =3D 0, + .R[PSC_TEMPERATURE] =3D 0, + + .m[PSC_POWER] =3D 25, + .b[PSC_POWER] =3D 0, + .R[PSC_POWER] =3D -2, + + .read_word_data =3D mp5926_read_word_data, + .read_byte_data =3D mp5926_read_byte_data, + .func[0] =3D MP5926_FUNC, +}; + +static int mp5926_probe(struct i2c_client *client) +{ + struct mp5926_data *data; + struct pmbus_driver_info *info; + int ret; + + data =3D devm_kzalloc(&client->dev, sizeof(struct mp5926_data), + GFP_KERNEL); + if (!data) + return -ENOMEM; + + memcpy(&data->info, &mp5926_info, sizeof(*info)); + info =3D &data->info; + ret =3D i2c_smbus_read_word_data(client, EFUSE_CFG); + if (ret < 0) + return ret; + if (ret & BIT(12)) { + data->vout_mode =3D linear; + data->info.format[PSC_VOLTAGE_IN] =3D linear; + data->info.format[PSC_CURRENT_IN] =3D linear; + data->info.format[PSC_VOLTAGE_OUT] =3D linear; + data->info.format[PSC_TEMPERATURE] =3D linear; + data->info.format[PSC_POWER] =3D linear; + ret =3D i2c_smbus_read_word_data(client, PMBUS_READ_VOUT); + if (ret < 0) { + dev_err(&client->dev, "Can't get vout exponent."); + return ret; + } + data->vout_linear_exponent =3D (u8)((ret >> 11) & 0x1f); + } else { + data->vout_mode =3D direct; + ret =3D i2c_smbus_read_word_data(client, I_SCALE_SEL); + if (ret < 0) + return ret; + if (ret & BIT(6)) + data->info.m[PSC_CURRENT_IN] =3D 4; + } + + return pmbus_do_probe(client, info); +} + +static const struct i2c_device_id mp5926_id[] =3D { + { "mp5926", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, mp5926_id); + +static const struct of_device_id mp5926_of_match[] =3D { + { .compatible =3D "mps,mp5926" }, + {} +}; +MODULE_DEVICE_TABLE(of, mp5926_of_match); + +static struct i2c_driver mp5926_driver =3D { + .probe =3D mp5926_probe, + .driver =3D { + .name =3D "mp5926", + .of_match_table =3D mp5926_of_match, + }, + .id_table =3D mp5926_id, +}; + +module_i2c_driver(mp5926_driver); +MODULE_AUTHOR("Yuxi Wang "); +MODULE_DESCRIPTION("MPS MP5926 pmbus driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("PMBUS"); --=20 2.39.2