* [PATCH 1/2] dt-bindings: trivial-devices: add mps,mp9945
@ 2025-10-05 20:48 Cosmo Chou
2025-10-05 20:48 ` [PATCH 2/2] hwmon: (pmbus) add driver for MPS MP9945 Cosmo Chou
2025-10-07 19:38 ` [PATCH 1/2] dt-bindings: trivial-devices: add mps,mp9945 Conor Dooley
0 siblings, 2 replies; 4+ messages in thread
From: Cosmo Chou @ 2025-10-05 20:48 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, linux, corbet
Cc: devicetree, linux-kernel, linux-hwmon, linux-doc, cosmo.chou,
Cosmo Chou
Add dt-bindings for MPS mp9945 controller.
Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com>
---
Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
index 58ff948d93c9..08e2ca1b573e 100644
--- a/Documentation/devicetree/bindings/trivial-devices.yaml
+++ b/Documentation/devicetree/bindings/trivial-devices.yaml
@@ -317,6 +317,8 @@ properties:
- mps,mp5998
# Monolithic Power Systems Inc. digital step-down converter mp9941
- mps,mp9941
+ # Monolithic Power Systems Inc. digital step-down converter mp9945
+ - mps,mp9945
# Temperature sensor with integrated fan control
- national,lm63
# Temperature sensor with integrated fan control
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] hwmon: (pmbus) add driver for MPS MP9945
2025-10-05 20:48 [PATCH 1/2] dt-bindings: trivial-devices: add mps,mp9945 Cosmo Chou
@ 2025-10-05 20:48 ` Cosmo Chou
2025-10-09 18:03 ` kernel test robot
2025-10-07 19:38 ` [PATCH 1/2] dt-bindings: trivial-devices: add mps,mp9945 Conor Dooley
1 sibling, 1 reply; 4+ messages in thread
From: Cosmo Chou @ 2025-10-05 20:48 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, linux, corbet
Cc: devicetree, linux-kernel, linux-hwmon, linux-doc, cosmo.chou,
Cosmo Chou
Add support for mp9945 device from Monolithic Power Systems, Inc.
(MPS) vendor. This is a single phase digital step down converter.
Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com>
---
Documentation/hwmon/index.rst | 1 +
Documentation/hwmon/mp9945.rst | 117 ++++++++++++++++
MAINTAINERS | 7 +
drivers/hwmon/pmbus/Kconfig | 9 ++
drivers/hwmon/pmbus/Makefile | 1 +
drivers/hwmon/pmbus/mp9945.c | 243 +++++++++++++++++++++++++++++++++
6 files changed, 378 insertions(+)
create mode 100644 Documentation/hwmon/mp9945.rst
create mode 100644 drivers/hwmon/pmbus/mp9945.c
diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index 51a5bdf75b08..c75486c9cd4a 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -184,6 +184,7 @@ Hardware Monitoring Kernel Drivers
mp5920
mp5990
mp9941
+ mp9945
mpq8785
nct6683
nct6775
diff --git a/Documentation/hwmon/mp9945.rst b/Documentation/hwmon/mp9945.rst
new file mode 100644
index 000000000000..f406f96efcf9
--- /dev/null
+++ b/Documentation/hwmon/mp9945.rst
@@ -0,0 +1,117 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Kernel driver mp9945
+=====================
+
+Supported chips:
+
+ * MPS mp9945
+
+ Prefix: 'mp9945'
+
+Author:
+
+ Cosmo Chou <chou.cosmo@gmail.com>
+
+Description
+-----------
+
+This driver implements support for Monolithic Power Systems, Inc. (MPS)
+MP9945 Digital Single-phase 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**
+
+**in1_lcrit**
+
+**in1_lcrit_alarm**
+
+**in1_max**
+
+**in1_max_alarm**
+
+**in1_min**
+
+**in1_min_alarm**
+
+The driver provides the following attributes for output voltage:
+
+**in2_input**
+
+**in2_label**
+
+**in2_crit**
+
+**in2_crit_alarm**
+
+**in2_lcrit**
+
+**in2_lcrit_alarm**
+
+**in2_min**
+
+**in2_min_alarm**
+
+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**
+
+**curr2_crit**
+
+**curr2_crit_alarm**
+
+**curr2_max**
+
+**curr2_max_alarm**
+
+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**
+
+**power2_max**
+
+**power2_max_alarm**
+
+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 8f5208ad442b..62eb5e01c9df 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17463,6 +17463,13 @@ S: Maintained
F: Documentation/hwmon/mp9941.rst
F: drivers/hwmon/pmbus/mp9941.c
+MPS MP9945 DRIVER
+M: Cosmo Chou <chou.cosmo@gmail.com>
+L: linux-hwmon@vger.kernel.org
+S: Maintained
+F: Documentation/hwmon/mp9945.rst
+F: drivers/hwmon/pmbus/mp9945.c
+
MR800 AVERMEDIA USB FM RADIO DRIVER
M: Alexey Klimov <alexey.klimov@linaro.org>
L: linux-media@vger.kernel.org
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index da04ff6df28b..9829c7a37333 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -471,6 +471,15 @@ config SENSORS_MP9941
This driver can also be built as a module. If so, the module will
be called mp9941.
+config SENSORS_MP9945
+ tristate "MPS MP9945"
+ help
+ If you say yes here you get hardware monitoring support for MPS
+ MP9945.
+
+ This driver can also be built as a module. If so, the module will
+ be called mp9945.
+
config SENSORS_MPQ7932_REGULATOR
bool "Regulator support for MPQ7932"
depends on SENSORS_MPQ7932 && REGULATOR
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
index 4c5ff3f32c5e..1629c8b71ac5 100644
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_SENSORS_MP5023) += mp5023.o
obj-$(CONFIG_SENSORS_MP5920) += mp5920.o
obj-$(CONFIG_SENSORS_MP5990) += mp5990.o
obj-$(CONFIG_SENSORS_MP9941) += mp9941.o
+obj-$(CONFIG_SENSORS_MP9945) += mp9945.o
obj-$(CONFIG_SENSORS_MPQ7932) += mpq7932.o
obj-$(CONFIG_SENSORS_MPQ8785) += mpq8785.o
obj-$(CONFIG_SENSORS_PLI1209BC) += pli1209bc.o
diff --git a/drivers/hwmon/pmbus/mp9945.c b/drivers/hwmon/pmbus/mp9945.c
new file mode 100644
index 000000000000..b38209e00e64
--- /dev/null
+++ b/drivers/hwmon/pmbus/mp9945.c
@@ -0,0 +1,243 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Hardware monitoring driver for MPS Single-phase Digital VR Controllers(MP9945)
+ */
+
+#include <linux/bitfield.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include "pmbus.h"
+
+#define MFR_VR_MULTI_CONFIG_R1 0x08
+#define MFR_SVID_CFG_R1 0xBD
+
+/* VOUT_MODE register values */
+#define VOUT_MODE_LINEAR16 0x17
+#define VOUT_MODE_VID 0x21
+#define VOUT_MODE_DIRECT 0x40
+
+#define MP9945_PAGE_NUM 1
+
+#define MP9945_RAIL1_FUNC (PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | \
+ PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | \
+ PMBUS_HAVE_PIN | PMBUS_HAVE_POUT | \
+ PMBUS_HAVE_TEMP | \
+ PMBUS_HAVE_STATUS_VOUT | \
+ PMBUS_HAVE_STATUS_IOUT | \
+ PMBUS_HAVE_STATUS_TEMP | \
+ PMBUS_HAVE_STATUS_INPUT)
+
+enum mp9945_vout_mode {
+ MP9945_VOUT_MODE_VID,
+ MP9945_VOUT_MODE_DIRECT,
+ MP9945_VOUT_MODE_LINEAR16,
+};
+
+struct mp9945_data {
+ struct pmbus_driver_info info;
+ enum mp9945_vout_mode vout_mode;
+ int vid_resolution;
+ int vid_offset;
+};
+
+#define to_mp9945_data(x) container_of(x, struct mp9945_data, info)
+
+static int mp9945_read_vout(struct i2c_client *client, struct mp9945_data *data)
+{
+ int ret;
+
+ ret = i2c_smbus_read_word_data(client, PMBUS_READ_VOUT);
+ if (ret < 0)
+ return ret;
+
+ ret &= GENMASK(11, 0);
+
+ switch (data->vout_mode) {
+ case MP9945_VOUT_MODE_VID:
+ if (ret > 0)
+ ret = (ret + data->vid_offset) * data->vid_resolution;
+ break;
+ case MP9945_VOUT_MODE_DIRECT:
+ break;
+ case MP9945_VOUT_MODE_LINEAR16:
+ /* LSB: 1000 * 2^-9 (mV) */
+ ret = DIV_ROUND_CLOSEST(ret * 125, 64);
+ break;
+ default:
+ return -ENODEV;
+ }
+
+ return ret;
+}
+
+static int mp9945_read_byte_data(struct i2c_client *client, int page, int reg)
+{
+ int ret;
+
+ ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
+ if (ret < 0)
+ return ret;
+
+ switch (reg) {
+ case PMBUS_VOUT_MODE:
+ /*
+ * Override VOUT_MODE to DIRECT as the driver handles custom
+ * VOUT format conversions internally.
+ */
+ return PB_VOUT_MODE_DIRECT;
+ default:
+ return -ENODATA;
+ }
+}
+
+static int mp9945_read_word_data(struct i2c_client *client, int page, int phase,
+ int reg)
+{
+ const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
+ struct mp9945_data *data = to_mp9945_data(info);
+ int ret;
+
+ ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
+ if (ret < 0)
+ return ret;
+
+ switch (reg) {
+ case PMBUS_READ_VOUT:
+ ret = mp9945_read_vout(client, data);
+ break;
+ case PMBUS_VOUT_OV_FAULT_LIMIT:
+ case PMBUS_VOUT_UV_FAULT_LIMIT:
+ ret = i2c_smbus_read_word_data(client, reg);
+ if (ret < 0)
+ return ret;
+
+ /* LSB: 1.95 (mV) */
+ ret = DIV_ROUND_CLOSEST((ret & GENMASK(11, 0)) * 39, 20);
+ break;
+ case PMBUS_VOUT_UV_WARN_LIMIT:
+ ret = i2c_smbus_read_word_data(client, reg);
+ if (ret < 0)
+ return ret;
+
+ ret &= GENMASK(9, 0);
+ if (ret > 0)
+ ret = (ret + data->vid_offset) * data->vid_resolution;
+ break;
+ default:
+ ret = -ENODATA;
+ break;
+ }
+
+ return ret;
+}
+
+static int mp9945_identify(struct i2c_client *client,
+ struct pmbus_driver_info *info)
+{
+ struct mp9945_data *data = to_mp9945_data(info);
+ int ret;
+
+ ret = i2c_smbus_read_byte_data(client, PMBUS_VOUT_MODE);
+ if (ret < 0)
+ return ret;
+
+ switch (ret) {
+ case VOUT_MODE_LINEAR16:
+ data->vout_mode = MP9945_VOUT_MODE_LINEAR16;
+ break;
+ case VOUT_MODE_VID:
+ data->vout_mode = MP9945_VOUT_MODE_VID;
+ break;
+ case VOUT_MODE_DIRECT:
+ data->vout_mode = MP9945_VOUT_MODE_DIRECT;
+ break;
+ default:
+ return -ENODEV;
+ }
+
+ ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 3);
+ if (ret < 0)
+ return ret;
+
+ ret = i2c_smbus_read_word_data(client, MFR_VR_MULTI_CONFIG_R1);
+ if (ret < 0)
+ return ret;
+
+ data->vid_resolution = (FIELD_GET(BIT(2), ret)) ? 5 : 10;
+
+ ret = i2c_smbus_read_word_data(client, MFR_SVID_CFG_R1);
+ if (ret < 0)
+ return ret;
+
+ data->vid_offset = (FIELD_GET(BIT(15), ret)) ? 19 : 49;
+
+ return i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
+}
+
+static struct pmbus_driver_info mp9945_info = {
+ .pages = MP9945_PAGE_NUM,
+ .format[PSC_VOLTAGE_IN] = linear,
+ .format[PSC_VOLTAGE_OUT] = direct,
+ .format[PSC_CURRENT_IN] = linear,
+ .format[PSC_CURRENT_OUT] = linear,
+ .format[PSC_POWER] = linear,
+ .format[PSC_TEMPERATURE] = linear,
+ .m[PSC_VOLTAGE_OUT] = 1,
+ .R[PSC_VOLTAGE_OUT] = 3,
+ .b[PSC_VOLTAGE_OUT] = 0,
+ .func[0] = MP9945_RAIL1_FUNC,
+ .read_word_data = mp9945_read_word_data,
+ .read_byte_data = mp9945_read_byte_data,
+ .identify = mp9945_identify,
+};
+
+static int mp9945_probe(struct i2c_client *client)
+{
+ struct mp9945_data *data;
+ int ret;
+
+ data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ memcpy(&data->info, &mp9945_info, sizeof(mp9945_info));
+
+ /*
+ * Set page 0 before probe. The core reads paged registers which are
+ * only on page 0 for this device.
+ */
+ ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
+ if (ret < 0)
+ return ret;
+
+ return pmbus_do_probe(client, &data->info);
+}
+
+static const struct i2c_device_id mp9945_id[] = {
+ {"mp9945"},
+ {}
+};
+MODULE_DEVICE_TABLE(i2c, mp9945_id);
+
+static const struct of_device_id __maybe_unused mp9945_of_match[] = {
+ {.compatible = "mps,mp9945"},
+ {}
+};
+MODULE_DEVICE_TABLE(of, mp9945_of_match);
+
+static struct i2c_driver mp9945_driver = {
+ .driver = {
+ .name = "mp9945",
+ .of_match_table = of_match_ptr(mp9945_of_match),
+ },
+ .probe = mp9945_probe,
+ .id_table = mp9945_id,
+};
+
+module_i2c_driver(mp9945_driver);
+
+MODULE_AUTHOR("Cosmo Chou <chou.cosmo@gmail.com>");
+MODULE_DESCRIPTION("PMBus driver for MPS MP9945");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(PMBUS);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] dt-bindings: trivial-devices: add mps,mp9945
2025-10-05 20:48 [PATCH 1/2] dt-bindings: trivial-devices: add mps,mp9945 Cosmo Chou
2025-10-05 20:48 ` [PATCH 2/2] hwmon: (pmbus) add driver for MPS MP9945 Cosmo Chou
@ 2025-10-07 19:38 ` Conor Dooley
1 sibling, 0 replies; 4+ messages in thread
From: Conor Dooley @ 2025-10-07 19:38 UTC (permalink / raw)
To: Cosmo Chou
Cc: robh, krzk+dt, conor+dt, linux, corbet, devicetree, linux-kernel,
linux-hwmon, linux-doc, cosmo.chou
[-- Attachment #1: Type: text/plain, Size: 1095 bytes --]
On Mon, Oct 06, 2025 at 04:48:54AM +0800, Cosmo Chou wrote:
> Add dt-bindings for MPS mp9945 controller.
>
> Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
> ---
> Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
> index 58ff948d93c9..08e2ca1b573e 100644
> --- a/Documentation/devicetree/bindings/trivial-devices.yaml
> +++ b/Documentation/devicetree/bindings/trivial-devices.yaml
> @@ -317,6 +317,8 @@ properties:
> - mps,mp5998
> # Monolithic Power Systems Inc. digital step-down converter mp9941
> - mps,mp9941
> + # Monolithic Power Systems Inc. digital step-down converter mp9945
> + - mps,mp9945
> # Temperature sensor with integrated fan control
> - national,lm63
> # Temperature sensor with integrated fan control
> --
> 2.43.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] hwmon: (pmbus) add driver for MPS MP9945
2025-10-05 20:48 ` [PATCH 2/2] hwmon: (pmbus) add driver for MPS MP9945 Cosmo Chou
@ 2025-10-09 18:03 ` kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-10-09 18:03 UTC (permalink / raw)
To: Cosmo Chou, robh, krzk+dt, conor+dt, linux, corbet
Cc: oe-kbuild-all, devicetree, linux-kernel, linux-hwmon, linux-doc,
cosmo.chou, Cosmo Chou
Hi Cosmo,
kernel test robot noticed the following build errors:
[auto build test ERROR on groeck-staging/hwmon-next]
[also build test ERROR on robh/for-next linus/master v6.17 next-20251009]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Cosmo-Chou/hwmon-pmbus-add-driver-for-MPS-MP9945/20251009-153602
base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
patch link: https://lore.kernel.org/r/20251005204855.190270-2-chou.cosmo%40gmail.com
patch subject: [PATCH 2/2] hwmon: (pmbus) add driver for MPS MP9945
config: x86_64-randconfig-r072-20251009 (https://download.01.org/0day-ci/archive/20251010/202510100100.uGBElhsf-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251010/202510100100.uGBElhsf-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510100100.uGBElhsf-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/hwmon/pmbus/mp9945.c:243:18: error: expected ';' after top level declarator
243 | MODULE_IMPORT_NS(PMBUS);
| ^
1 error generated.
vim +243 drivers/hwmon/pmbus/mp9945.c
239
240 MODULE_AUTHOR("Cosmo Chou <chou.cosmo@gmail.com>");
241 MODULE_DESCRIPTION("PMBus driver for MPS MP9945");
242 MODULE_LICENSE("GPL");
> 243 MODULE_IMPORT_NS(PMBUS);
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-09 18:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-05 20:48 [PATCH 1/2] dt-bindings: trivial-devices: add mps,mp9945 Cosmo Chou
2025-10-05 20:48 ` [PATCH 2/2] hwmon: (pmbus) add driver for MPS MP9945 Cosmo Chou
2025-10-09 18:03 ` kernel test robot
2025-10-07 19:38 ` [PATCH 1/2] dt-bindings: trivial-devices: add mps,mp9945 Conor Dooley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).