diff options
| author | Alexis Czezar Torreno <alexisczezar.torreno@analog.com> | 2026-07-30 09:03:36 +0800 |
|---|---|---|
| committer | Guenter Roeck <linux@roeck-us.net> | 2026-08-10 08:59:42 -0700 |
| commit | 4cdcd4789fb6d43939680ff5ac0eb8af49ca1d84 (patch) | |
| tree | 0684b9a13b74af1dc66f8eb07b1c89da70fd34c0 /drivers | |
| parent | b60e4b3ae17a7e906a882da38bc2b91e9a9835b7 (diff) | |
| download | linux-4cdcd4789fb6d43939680ff5ac0eb8af49ca1d84.tar.gz linux-4cdcd4789fb6d43939680ff5ac0eb8af49ca1d84.zip | |
hwmon: (pmbus/max20830): add support for max20830c and max20840c
Add support for MAX20830C and MAX20840 step-down DC-DC switching
regulator with PMBus interface. MAX20830C is a different packaging
for MAX20830, and MAX20840C supports 40A regulation compared to
MAX20830 that is only 30A.
Signed-off-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
Link: https://lore.kernel.org/r/20260730-dev-max20830c-v5-4-a7553f84ee74@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/hwmon/pmbus/Kconfig | 4 | ||||
| -rw-r--r-- | drivers/hwmon/pmbus/max20830.c | 36 |
2 files changed, 25 insertions, 15 deletions
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index becc311dacc6..2758f9695577 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -394,10 +394,10 @@ config SENSORS_MAX20751 be called max20751. config SENSORS_MAX20830 - tristate "Analog Devices MAX20830" + tristate "Analog Devices MAX20830 and compatibles" help If you say yes here you get hardware monitoring support for Analog - Devices MAX20830. + Devices MAX20830, MAX20830C, and MAX20840C. This driver can also be built as a module. If so, the module will be called max20830. diff --git a/drivers/hwmon/pmbus/max20830.c b/drivers/hwmon/pmbus/max20830.c index 5129fc2dbaea..689fc6f0fe01 100644 --- a/drivers/hwmon/pmbus/max20830.c +++ b/drivers/hwmon/pmbus/max20830.c @@ -20,6 +20,12 @@ struct max20830_data { u32 vout_rfb2; }; +static const char * const supported_chip_ids[] = { + "MAX20830", + "MAX20830C", + "MAX20840C", +}; + /* * MAX20830 only supports READ_VOUT for VOUT monitoring. * @@ -83,7 +89,7 @@ static int max20830_probe(struct i2c_client *client) { u8 buf[I2C_SMBUS_BLOCK_MAX + 1] = {}; struct max20830_data *data; - int ret; + int i, ret; data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); if (!data) @@ -105,13 +111,12 @@ static int max20830_probe(struct i2c_client *client) * which do not support SMBus block reads. */ if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BLOCK_DATA)) { - /* Reads 9 Data bytes from MAX20830 */ ret = i2c_smbus_read_block_data(client, PMBUS_IC_DEVICE_ID, buf); if (ret < 0) return dev_err_probe(&client->dev, ret, "Failed to read IC_DEVICE_ID\n"); } else { - /* Reads 1 length byte + 9 Data bytes from MAX20830 */ + /* Reads 1 length byte + data bytes */ ret = i2c_smbus_read_i2c_block_data(client, PMBUS_IC_DEVICE_ID, MAX20830_IC_DEVICE_ID_LENGTH + 1, buf); @@ -127,20 +132,25 @@ static int max20830_probe(struct i2c_client *client) ret = ret - 1; } - /* - * MAX20830 IC_DEVICE_ID sends string data "MAX20830\0". - * Return value should at least be 9 bytes of data. - */ + /* Verify we read the expected number of bytes */ if (ret < MAX20830_IC_DEVICE_ID_LENGTH) return dev_err_probe(&client->dev, -ENODEV, - "IC_DEVICE_ID too short: expected at least 9 bytes, got %d\n", - ret); + "IC_DEVICE_ID too short: expected %d bytes, got %d\n", + MAX20830_IC_DEVICE_ID_LENGTH, ret); + + /* Null-terminate the string */ + buf[ret] = '\0'; + + /* Verify the device ID matches what we expect */ + for (i = 0; i < ARRAY_SIZE(supported_chip_ids); i++) { + if (!strcmp(buf, supported_chip_ids[i])) + break; + } - /* 9 bytes of data, buf[0]-buf[7] = "MAX20830", buf[8] = '\0' */ - buf[MAX20830_IC_DEVICE_ID_LENGTH - 1] = '\0'; - if (strncmp(buf, "MAX20830", MAX20830_IC_DEVICE_ID_LENGTH - 1)) + /* No match found - unsupported device */ + if (i == ARRAY_SIZE(supported_chip_ids)) return dev_err_probe(&client->dev, -ENODEV, - "Unsupported device: '%s'\n", buf); + "Unsupported device: '%*pE'\n", ret, buf); return pmbus_do_probe(client, &data->info); } |
