Skip to content

Commit bef3c79

Browse files
cchouxgroeck
authored andcommitted
hwmon: (pmbus/mp5990) add support for MP5998
Add support for the MPS MP5998 hot-swap controller. Like MP5990, MP5998 uses EFUSE_CFG (0xC4) bit 9 to indicate linear/direct data format. Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com> Link: https://lore.kernel.org/r/20250916095026.800164-2-chou.cosmo@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent bca9b66 commit bef3c79

2 files changed

Lines changed: 85 additions & 12 deletions

File tree

Documentation/hwmon/mp5990.rst

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ Supported chips:
99

1010
Prefix: 'mp5990'
1111

12-
* Datasheet
12+
Datasheet: Publicly available at the MPS website: https://www.monolithicpower.com/en/mp5990.html
1313

14-
Publicly available at the MPS website : https://www.monolithicpower.com/en/mp5990.html
14+
* MPS MP5998
15+
16+
Prefix: 'mp5998'
17+
18+
Datasheet: Not publicly available
1519

1620
Author:
1721

@@ -21,7 +25,7 @@ Description
2125
-----------
2226

2327
This driver implements support for Monolithic Power Systems, Inc. (MPS)
24-
MP5990 Hot-Swap Controller.
28+
MP5990 and MP5998 Hot-Swap Controller.
2529

2630
Device compliant with:
2731

@@ -53,7 +57,7 @@ The driver provides the following attributes for output voltage:
5357

5458
**in2_alarm**
5559

56-
The driver provides the following attributes for output current:
60+
The driver provides the following attributes for current:
5761

5862
**curr1_input**
5963

@@ -63,6 +67,14 @@ The driver provides the following attributes for output current:
6367

6468
**curr1_max**
6569

70+
**curr2_input**
71+
72+
**curr2_label**
73+
74+
**curr2_max**
75+
76+
**curr2_max_alarm**
77+
6678
The driver provides the following attributes for input power:
6779

6880
**power1_input**
@@ -71,6 +83,16 @@ The driver provides the following attributes for input power:
7183

7284
**power1_alarm**
7385

86+
The driver provides the following attributes for output power:
87+
88+
**power2_input**
89+
90+
**power2_label**
91+
92+
**power2_max**
93+
94+
**power2_max_alarm**
95+
7496
The driver provides the following attributes for temperature:
7597

7698
**temp1_input**

drivers/hwmon/pmbus/mp5990.c

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <linux/of_device.h>
99
#include "pmbus.h"
1010

11+
enum chips { mp5990, mp5998 };
12+
1113
#define MP5990_EFUSE_CFG (0xC4)
1214
#define MP5990_VOUT_FORMAT BIT(9)
1315

@@ -110,18 +112,69 @@ static struct pmbus_driver_info mp5990_info = {
110112
.read_word_data = mp5990_read_word_data,
111113
};
112114

115+
static struct pmbus_driver_info mp5998_info = {
116+
.pages = 1,
117+
.format[PSC_VOLTAGE_IN] = direct,
118+
.format[PSC_VOLTAGE_OUT] = direct,
119+
.format[PSC_CURRENT_IN] = direct,
120+
.format[PSC_CURRENT_OUT] = direct,
121+
.format[PSC_POWER] = direct,
122+
.format[PSC_TEMPERATURE] = direct,
123+
.m[PSC_VOLTAGE_IN] = 64,
124+
.b[PSC_VOLTAGE_IN] = 0,
125+
.R[PSC_VOLTAGE_IN] = 0,
126+
.m[PSC_VOLTAGE_OUT] = 64,
127+
.b[PSC_VOLTAGE_OUT] = 0,
128+
.R[PSC_VOLTAGE_OUT] = 0,
129+
.m[PSC_CURRENT_IN] = 16,
130+
.b[PSC_CURRENT_IN] = 0,
131+
.R[PSC_CURRENT_IN] = 0,
132+
.m[PSC_CURRENT_OUT] = 16,
133+
.b[PSC_CURRENT_OUT] = 0,
134+
.R[PSC_CURRENT_OUT] = 0,
135+
.m[PSC_POWER] = 2,
136+
.b[PSC_POWER] = 0,
137+
.R[PSC_POWER] = 0,
138+
.m[PSC_TEMPERATURE] = 1,
139+
.b[PSC_TEMPERATURE] = 0,
140+
.R[PSC_TEMPERATURE] = 0,
141+
.func[0] =
142+
PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
143+
PMBUS_HAVE_IIN | PMBUS_HAVE_PIN | PMBUS_HAVE_POUT |
144+
PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_IOUT |
145+
PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP,
146+
.read_byte_data = mp5990_read_byte_data,
147+
.read_word_data = mp5990_read_word_data,
148+
};
149+
150+
static const struct i2c_device_id mp5990_id[] = {
151+
{"mp5990", mp5990},
152+
{"mp5998", mp5998},
153+
{ }
154+
};
155+
MODULE_DEVICE_TABLE(i2c, mp5990_id);
156+
113157
static int mp5990_probe(struct i2c_client *client)
114158
{
115159
struct pmbus_driver_info *info;
116160
struct mp5990_data *data;
161+
enum chips chip;
117162
int ret;
118163

119164
data = devm_kzalloc(&client->dev, sizeof(struct mp5990_data),
120165
GFP_KERNEL);
121166
if (!data)
122167
return -ENOMEM;
123168

124-
memcpy(&data->info, &mp5990_info, sizeof(*info));
169+
if (client->dev.of_node)
170+
chip = (uintptr_t)of_device_get_match_data(&client->dev);
171+
else
172+
chip = i2c_match_id(mp5990_id, client)->driver_data;
173+
174+
if (chip == mp5990)
175+
memcpy(&data->info, &mp5990_info, sizeof(*info));
176+
else
177+
memcpy(&data->info, &mp5998_info, sizeof(*info));
125178
info = &data->info;
126179

127180
/* Read Vout Config */
@@ -140,6 +193,9 @@ static int mp5990_probe(struct i2c_client *client)
140193
data->info.format[PSC_VOLTAGE_OUT] = linear;
141194
data->info.format[PSC_CURRENT_OUT] = linear;
142195
data->info.format[PSC_POWER] = linear;
196+
if (chip == mp5998)
197+
data->info.format[PSC_CURRENT_IN] = linear;
198+
143199
ret = i2c_smbus_read_word_data(client, PMBUS_READ_VOUT);
144200
if (ret < 0) {
145201
dev_err(&client->dev, "Can't get vout exponent.");
@@ -153,16 +209,11 @@ static int mp5990_probe(struct i2c_client *client)
153209
}
154210

155211
static const struct of_device_id mp5990_of_match[] = {
156-
{ .compatible = "mps,mp5990" },
212+
{ .compatible = "mps,mp5990", .data = (void *)mp5990 },
213+
{ .compatible = "mps,mp5998", .data = (void *)mp5998 },
157214
{}
158215
};
159216

160-
static const struct i2c_device_id mp5990_id[] = {
161-
{"mp5990"},
162-
{ }
163-
};
164-
MODULE_DEVICE_TABLE(i2c, mp5990_id);
165-
166217
static struct i2c_driver mp5990_driver = {
167218
.driver = {
168219
.name = "mp5990",

0 commit comments

Comments
 (0)