Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: Add driver for MPS MPQ8785 Synchronous Step-Down Converter

Add support for mpq8785 device from Monolithic Power Systems, Inc.
(MPS) vendor. This is synchronous step-down controller.

Signed-off-by: Charles Hsu <ythsu0511@gmail.com>
Link: https://lore.kernel.org/r/20240131074822.2962078-2-ythsu0511@gmail.com
[groeck: probe_new --> probe; add MODULE_IMPORT_NS(PMBUS)]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Charles Hsu and committed by
Guenter Roeck
f20b4a93 7e6707f7

+195
+1
Documentation/hwmon/index.rst
··· 164 164 mp2975 165 165 mp5023 166 166 mp5990 167 + mpq8785 167 168 nct6683 168 169 nct6775 169 170 nct7802
+94
Documentation/hwmon/mpq8785.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0-only 2 + 3 + Kernel driver mpq8785 4 + ======================= 5 + 6 + Supported chips: 7 + 8 + * MPS MPQ8785 9 + 10 + Prefix: 'mpq8785' 11 + 12 + Author: Charles Hsu <ythsu0511@gmail.com> 13 + 14 + Description 15 + ----------- 16 + 17 + The MPQ8785 is a fully integrated, PMBus-compatible, high-frequency, synchronous 18 + buck converter. The MPQ8785 offers a very compact solution that achieves up to 19 + 40A output current per phase, with excellent load and line regulation over a 20 + wide input supply range. The MPQ8785 operates at high efficiency over a wide 21 + output current load range. 22 + 23 + The PMBus interface provides converter configurations and key parameters 24 + monitoring. 25 + 26 + The MPQ8785 adopts MPS's proprietary multi-phase digital constant-on-time (MCOT) 27 + control, which provides fast transient response and eases loop stabilization. 28 + The MCOT scheme also allows multiple MPQ8785 devices to be connected in parallel 29 + with excellent current sharing and phase interleaving for high-current 30 + applications. 31 + 32 + Fully integrated protection features include over-current protection (OCP), 33 + over-voltage protection (OVP), under-voltage protection (UVP), and 34 + over-temperature protection (OTP). 35 + 36 + The MPQ8785 requires a minimal number of readily available, standard external 37 + components, and is available in a TLGA (5mmx6mm) package. 38 + 39 + Device compliant with: 40 + 41 + - PMBus rev 1.3 interface. 42 + 43 + The driver exports the following attributes via the 'sysfs' files 44 + for input voltage: 45 + 46 + **in1_input** 47 + 48 + **in1_label** 49 + 50 + **in1_max** 51 + 52 + **in1_max_alarm** 53 + 54 + **in1_min** 55 + 56 + **in1_min_alarm** 57 + 58 + **in1_crit** 59 + 60 + **in1_crit_alarm** 61 + 62 + The driver provides the following attributes for output voltage: 63 + 64 + **in2_input** 65 + 66 + **in2_label** 67 + 68 + **in2_alarm** 69 + 70 + The driver provides the following attributes for output current: 71 + 72 + **curr1_input** 73 + 74 + **curr1_label** 75 + 76 + **curr1_max** 77 + 78 + **curr1_max_alarm** 79 + 80 + **curr1_crit** 81 + 82 + **curr1_crit_alarm** 83 + 84 + The driver provides the following attributes for temperature: 85 + 86 + **temp1_input** 87 + 88 + **temp1_max** 89 + 90 + **temp1_max_alarm** 91 + 92 + **temp1_crit** 93 + 94 + **temp1_crit_alarm**
+9
drivers/hwmon/pmbus/Kconfig
··· 377 377 This driver can also be built as a module. If so, the module will 378 378 be called mpq7932. 379 379 380 + config SENSORS_MPQ8785 381 + tristate "MPS MPQ8785" 382 + help 383 + If you say yes here you get hardware monitoring functionality support 384 + for power management IC MPS MPQ8785. 385 + 386 + This driver can also be built as a module. If so, the module will 387 + be called mpq8785. 388 + 380 389 config SENSORS_PIM4328 381 390 tristate "Flex PIM4328 and compatibles" 382 391 help
+1
drivers/hwmon/pmbus/Makefile
··· 39 39 obj-$(CONFIG_SENSORS_MP5023) += mp5023.o 40 40 obj-$(CONFIG_SENSORS_MP5990) += mp5990.o 41 41 obj-$(CONFIG_SENSORS_MPQ7932) += mpq7932.o 42 + obj-$(CONFIG_SENSORS_MPQ8785) += mpq8785.o 42 43 obj-$(CONFIG_SENSORS_PLI1209BC) += pli1209bc.o 43 44 obj-$(CONFIG_SENSORS_PM6764TR) += pm6764tr.o 44 45 obj-$(CONFIG_SENSORS_PXE1610) += pxe1610.o
+90
drivers/hwmon/pmbus/mpq8785.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Driver for MPS MPQ8785 Step-Down Converter 4 + */ 5 + 6 + #include <linux/i2c.h> 7 + #include <linux/module.h> 8 + #include <linux/of_device.h> 9 + #include "pmbus.h" 10 + 11 + static int mpq8785_identify(struct i2c_client *client, 12 + struct pmbus_driver_info *info) 13 + { 14 + int vout_mode; 15 + 16 + vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); 17 + if (vout_mode < 0 || vout_mode == 0xff) 18 + return vout_mode < 0 ? vout_mode : -ENODEV; 19 + switch (vout_mode >> 5) { 20 + case 0: 21 + info->format[PSC_VOLTAGE_OUT] = linear; 22 + break; 23 + case 1: 24 + case 2: 25 + info->format[PSC_VOLTAGE_OUT] = direct, 26 + info->m[PSC_VOLTAGE_OUT] = 64; 27 + info->b[PSC_VOLTAGE_OUT] = 0; 28 + info->R[PSC_VOLTAGE_OUT] = 1; 29 + break; 30 + default: 31 + return -ENODEV; 32 + } 33 + 34 + return 0; 35 + }; 36 + 37 + static struct pmbus_driver_info mpq8785_info = { 38 + .pages = 1, 39 + .format[PSC_VOLTAGE_IN] = direct, 40 + .format[PSC_CURRENT_OUT] = direct, 41 + .format[PSC_TEMPERATURE] = direct, 42 + .m[PSC_VOLTAGE_IN] = 4, 43 + .b[PSC_VOLTAGE_IN] = 0, 44 + .R[PSC_VOLTAGE_IN] = 1, 45 + .m[PSC_CURRENT_OUT] = 16, 46 + .b[PSC_CURRENT_OUT] = 0, 47 + .R[PSC_CURRENT_OUT] = 0, 48 + .m[PSC_TEMPERATURE] = 1, 49 + .b[PSC_TEMPERATURE] = 0, 50 + .R[PSC_TEMPERATURE] = 0, 51 + .func[0] = 52 + PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT | 53 + PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | 54 + PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | 55 + PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, 56 + .identify = mpq8785_identify, 57 + }; 58 + 59 + static int mpq8785_probe(struct i2c_client *client) 60 + { 61 + return pmbus_do_probe(client, &mpq8785_info); 62 + }; 63 + 64 + static const struct i2c_device_id mpq8785_id[] = { 65 + { "mpq8785", 0 }, 66 + { }, 67 + }; 68 + MODULE_DEVICE_TABLE(i2c, mpq8785_id); 69 + 70 + static const struct of_device_id __maybe_unused mpq8785_of_match[] = { 71 + { .compatible = "mps,mpq8785" }, 72 + {} 73 + }; 74 + MODULE_DEVICE_TABLE(of, mpq8785_of_match); 75 + 76 + static struct i2c_driver mpq8785_driver = { 77 + .driver = { 78 + .name = "mpq8785", 79 + .of_match_table = of_match_ptr(mpq8785_of_match), 80 + }, 81 + .probe = mpq8785_probe, 82 + .id_table = mpq8785_id, 83 + }; 84 + 85 + module_i2c_driver(mpq8785_driver); 86 + 87 + MODULE_AUTHOR("Charles Hsu <ythsu0511@gmail.com>"); 88 + MODULE_DESCRIPTION("PMBus driver for MPS MPQ8785"); 89 + MODULE_LICENSE("GPL"); 90 + MODULE_IMPORT_NS(PMBUS);