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>
This commit is contained in:
parent
bca9b6633f
commit
bef3c79354
|
@ -9,9 +9,13 @@ Supported chips:
|
|||
|
||||
Prefix: 'mp5990'
|
||||
|
||||
* Datasheet
|
||||
Datasheet: Publicly available at the MPS website: https://www.monolithicpower.com/en/mp5990.html
|
||||
|
||||
Publicly available at the MPS website : https://www.monolithicpower.com/en/mp5990.html
|
||||
* MPS MP5998
|
||||
|
||||
Prefix: 'mp5998'
|
||||
|
||||
Datasheet: Not publicly available
|
||||
|
||||
Author:
|
||||
|
||||
|
@ -21,7 +25,7 @@ Description
|
|||
-----------
|
||||
|
||||
This driver implements support for Monolithic Power Systems, Inc. (MPS)
|
||||
MP5990 Hot-Swap Controller.
|
||||
MP5990 and MP5998 Hot-Swap Controller.
|
||||
|
||||
Device compliant with:
|
||||
|
||||
|
@ -53,7 +57,7 @@ The driver provides the following attributes for output voltage:
|
|||
|
||||
**in2_alarm**
|
||||
|
||||
The driver provides the following attributes for output current:
|
||||
The driver provides the following attributes for current:
|
||||
|
||||
**curr1_input**
|
||||
|
||||
|
@ -63,6 +67,14 @@ The driver provides the following attributes for output current:
|
|||
|
||||
**curr1_max**
|
||||
|
||||
**curr2_input**
|
||||
|
||||
**curr2_label**
|
||||
|
||||
**curr2_max**
|
||||
|
||||
**curr2_max_alarm**
|
||||
|
||||
The driver provides the following attributes for input power:
|
||||
|
||||
**power1_input**
|
||||
|
@ -71,6 +83,16 @@ The driver provides the following attributes for input power:
|
|||
|
||||
**power1_alarm**
|
||||
|
||||
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**
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include <linux/of_device.h>
|
||||
#include "pmbus.h"
|
||||
|
||||
enum chips { mp5990, mp5998 };
|
||||
|
||||
#define MP5990_EFUSE_CFG (0xC4)
|
||||
#define MP5990_VOUT_FORMAT BIT(9)
|
||||
|
||||
|
@ -110,10 +112,53 @@ static struct pmbus_driver_info mp5990_info = {
|
|||
.read_word_data = mp5990_read_word_data,
|
||||
};
|
||||
|
||||
static struct pmbus_driver_info mp5998_info = {
|
||||
.pages = 1,
|
||||
.format[PSC_VOLTAGE_IN] = direct,
|
||||
.format[PSC_VOLTAGE_OUT] = direct,
|
||||
.format[PSC_CURRENT_IN] = direct,
|
||||
.format[PSC_CURRENT_OUT] = direct,
|
||||
.format[PSC_POWER] = direct,
|
||||
.format[PSC_TEMPERATURE] = direct,
|
||||
.m[PSC_VOLTAGE_IN] = 64,
|
||||
.b[PSC_VOLTAGE_IN] = 0,
|
||||
.R[PSC_VOLTAGE_IN] = 0,
|
||||
.m[PSC_VOLTAGE_OUT] = 64,
|
||||
.b[PSC_VOLTAGE_OUT] = 0,
|
||||
.R[PSC_VOLTAGE_OUT] = 0,
|
||||
.m[PSC_CURRENT_IN] = 16,
|
||||
.b[PSC_CURRENT_IN] = 0,
|
||||
.R[PSC_CURRENT_IN] = 0,
|
||||
.m[PSC_CURRENT_OUT] = 16,
|
||||
.b[PSC_CURRENT_OUT] = 0,
|
||||
.R[PSC_CURRENT_OUT] = 0,
|
||||
.m[PSC_POWER] = 2,
|
||||
.b[PSC_POWER] = 0,
|
||||
.R[PSC_POWER] = 0,
|
||||
.m[PSC_TEMPERATURE] = 1,
|
||||
.b[PSC_TEMPERATURE] = 0,
|
||||
.R[PSC_TEMPERATURE] = 0,
|
||||
.func[0] =
|
||||
PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
|
||||
PMBUS_HAVE_IIN | PMBUS_HAVE_PIN | PMBUS_HAVE_POUT |
|
||||
PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_IOUT |
|
||||
PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP,
|
||||
.read_byte_data = mp5990_read_byte_data,
|
||||
.read_word_data = mp5990_read_word_data,
|
||||
};
|
||||
|
||||
static const struct i2c_device_id mp5990_id[] = {
|
||||
{"mp5990", mp5990},
|
||||
{"mp5998", mp5998},
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, mp5990_id);
|
||||
|
||||
static int mp5990_probe(struct i2c_client *client)
|
||||
{
|
||||
struct pmbus_driver_info *info;
|
||||
struct mp5990_data *data;
|
||||
enum chips chip;
|
||||
int ret;
|
||||
|
||||
data = devm_kzalloc(&client->dev, sizeof(struct mp5990_data),
|
||||
|
@ -121,7 +166,15 @@ static int mp5990_probe(struct i2c_client *client)
|
|||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
if (client->dev.of_node)
|
||||
chip = (uintptr_t)of_device_get_match_data(&client->dev);
|
||||
else
|
||||
chip = i2c_match_id(mp5990_id, client)->driver_data;
|
||||
|
||||
if (chip == mp5990)
|
||||
memcpy(&data->info, &mp5990_info, sizeof(*info));
|
||||
else
|
||||
memcpy(&data->info, &mp5998_info, sizeof(*info));
|
||||
info = &data->info;
|
||||
|
||||
/* Read Vout Config */
|
||||
|
@ -140,6 +193,9 @@ static int mp5990_probe(struct i2c_client *client)
|
|||
data->info.format[PSC_VOLTAGE_OUT] = linear;
|
||||
data->info.format[PSC_CURRENT_OUT] = linear;
|
||||
data->info.format[PSC_POWER] = linear;
|
||||
if (chip == mp5998)
|
||||
data->info.format[PSC_CURRENT_IN] = linear;
|
||||
|
||||
ret = i2c_smbus_read_word_data(client, PMBUS_READ_VOUT);
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev, "Can't get vout exponent.");
|
||||
|
@ -153,16 +209,11 @@ static int mp5990_probe(struct i2c_client *client)
|
|||
}
|
||||
|
||||
static const struct of_device_id mp5990_of_match[] = {
|
||||
{ .compatible = "mps,mp5990" },
|
||||
{ .compatible = "mps,mp5990", .data = (void *)mp5990 },
|
||||
{ .compatible = "mps,mp5998", .data = (void *)mp5998 },
|
||||
{}
|
||||
};
|
||||
|
||||
static const struct i2c_device_id mp5990_id[] = {
|
||||
{"mp5990"},
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, mp5990_id);
|
||||
|
||||
static struct i2c_driver mp5990_driver = {
|
||||
.driver = {
|
||||
.name = "mp5990",
|
||||
|
|
Loading…
Reference in New Issue