Skip to content

Commit e1c5cd7

Browse files
Howard.Chiu@quantatw.comgroeck
authored andcommitted
hwmon: (pmbus) Add support for MPS Multi-phase mp5023
Add support for mp5023 device from Monolithic Power Systems, Inc. (MPS) vendor. This is a Hot-Swap Controller. Signed-off-by: Howard Chiu <howard.chiu@quantatw.com> Link: https://lore.kernel.org/r/HKAPR04MB400349AA406694FB976D78D096709@HKAPR04MB4003.apcprd04.prod.outlook.com [groeck: Added MODULE_IMPORT_NS, entry in index.rst] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 0710e2b commit e1c5cd7

5 files changed

Lines changed: 162 additions & 0 deletions

File tree

Documentation/hwmon/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ Hardware Monitoring Kernel Drivers
145145
mlxreg-fan
146146
mp2888
147147
mp2975
148+
mp5023
148149
nct6683
149150
nct6775
150151
nct7802

Documentation/hwmon/mp5023.rst

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
Kernel driver mp5023
4+
====================
5+
6+
Supported chips:
7+
8+
* MPS MP5023
9+
10+
Prefix: 'mp5023'
11+
12+
* Datasheet
13+
14+
Publicly available at the MPS website : https://www.monolithicpower.com/en/mp5023.html
15+
16+
Author:
17+
18+
Howard Chiu <howard.chiu@quantatw.com>
19+
20+
Description
21+
-----------
22+
23+
This driver implements support for Monolithic Power Systems, Inc. (MPS)
24+
MP5023 Hot-Swap Controller.
25+
26+
Device complaint with:
27+
28+
- PMBus rev 1.3 interface.
29+
30+
Device supports direct format for reading input voltage, output voltage,
31+
output current, input power and temperature.
32+
33+
The driver exports the following attributes via the 'sysfs' files
34+
for input voltage:
35+
36+
**in1_input**
37+
38+
**in1_label**
39+
40+
**in1_max**
41+
42+
**in1_max_alarm**
43+
44+
**in1_min**
45+
46+
**in1_min_alarm**
47+
48+
The driver provides the following attributes for output voltage:
49+
50+
**in2_input**
51+
52+
**in2_label**
53+
54+
**in2_alarm**
55+
56+
The driver provides the following attributes for output current:
57+
58+
**curr1_input**
59+
60+
**curr1_label**
61+
62+
**curr1_alarm**
63+
64+
**curr1_max**
65+
66+
The driver provides the following attributes for input power:
67+
68+
**power1_input**
69+
70+
**power1_label**
71+
72+
**power1_alarm**
73+
74+
The driver provides the following attributes for temperature:
75+
76+
**temp1_input**
77+
78+
**temp1_max**
79+
80+
**temp1_max_alarm**
81+
82+
**temp1_crit**
83+
84+
**temp1_crit_alarm**

drivers/hwmon/pmbus/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,15 @@ config SENSORS_MP2975
286286
This driver can also be built as a module. If so, the module will
287287
be called mp2975.
288288

289+
config SENSORS_MP5023
290+
tristate "MPS MP5023"
291+
help
292+
If you say yes here you get hardware monitoring support for MPS
293+
MP5023.
294+
295+
This driver can also be built as a module. If so, the module will
296+
be called mp5023.
297+
289298
config SENSORS_PIM4328
290299
tristate "Flex PIM4328 and compatibles"
291300
help

drivers/hwmon/pmbus/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ obj-$(CONFIG_SENSORS_MAX34440) += max34440.o
3232
obj-$(CONFIG_SENSORS_MAX8688) += max8688.o
3333
obj-$(CONFIG_SENSORS_MP2888) += mp2888.o
3434
obj-$(CONFIG_SENSORS_MP2975) += mp2975.o
35+
obj-$(CONFIG_SENSORS_MP5023) += mp5023.o
3536
obj-$(CONFIG_SENSORS_PM6764TR) += pm6764tr.o
3637
obj-$(CONFIG_SENSORS_PXE1610) += pxe1610.o
3738
obj-$(CONFIG_SENSORS_Q54SJ108A2) += q54sj108a2.o

drivers/hwmon/pmbus/mp5023.c

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* Driver for MPS MP5023 Hot-Swap Controller
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 struct pmbus_driver_info mp5023_info = {
12+
.pages = 1,
13+
14+
.format[PSC_VOLTAGE_IN] = direct,
15+
.format[PSC_VOLTAGE_OUT] = direct,
16+
.format[PSC_CURRENT_OUT] = direct,
17+
.format[PSC_POWER] = direct,
18+
.format[PSC_TEMPERATURE] = direct,
19+
20+
.m[PSC_VOLTAGE_IN] = 32,
21+
.b[PSC_VOLTAGE_IN] = 0,
22+
.R[PSC_VOLTAGE_IN] = 0,
23+
.m[PSC_VOLTAGE_OUT] = 32,
24+
.b[PSC_VOLTAGE_OUT] = 0,
25+
.R[PSC_VOLTAGE_OUT] = 0,
26+
.m[PSC_CURRENT_OUT] = 16,
27+
.b[PSC_CURRENT_OUT] = 0,
28+
.R[PSC_CURRENT_OUT] = 0,
29+
.m[PSC_POWER] = 1,
30+
.b[PSC_POWER] = 0,
31+
.R[PSC_POWER] = 0,
32+
.m[PSC_TEMPERATURE] = 2,
33+
.b[PSC_TEMPERATURE] = 0,
34+
.R[PSC_TEMPERATURE] = 0,
35+
36+
.func[0] =
37+
PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_PIN |
38+
PMBUS_HAVE_TEMP | PMBUS_HAVE_IOUT |
39+
PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP,
40+
};
41+
42+
static int mp5023_probe(struct i2c_client *client)
43+
{
44+
return pmbus_do_probe(client, &mp5023_info);
45+
}
46+
47+
static const struct of_device_id __maybe_unused mp5023_of_match[] = {
48+
{ .compatible = "mps,mp5023", },
49+
{}
50+
};
51+
52+
MODULE_DEVICE_TABLE(of, mp5023_of_match);
53+
54+
static struct i2c_driver mp5023_driver = {
55+
.driver = {
56+
.name = "mp5023",
57+
.of_match_table = of_match_ptr(mp5023_of_match),
58+
},
59+
.probe_new = mp5023_probe,
60+
};
61+
62+
module_i2c_driver(mp5023_driver);
63+
64+
MODULE_AUTHOR("Howard Chiu <howard.chiu@quantatw.com>");
65+
MODULE_DESCRIPTION("PMBus driver for MPS MP5023 HSC");
66+
MODULE_LICENSE("GPL");
67+
MODULE_IMPORT_NS(PMBUS);

0 commit comments

Comments
 (0)