hwmon: (pmbus/mp2975) Add regulator support
authorPatrick Rudolph <patrick.rudolph@9elements.com>
Fri, 14 Jul 2023 13:51:15 +0000 (15:51 +0200)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 21 Aug 2023 13:04:30 +0000 (06:04 -0700)
Add support to expose the PMBUS regulator.

Tested on MP2973 and MP2971.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
Link: https://lore.kernel.org/r/20230714135124.2645339-7-Naresh.Solanki@9elements.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/pmbus/Kconfig
drivers/hwmon/pmbus/mp2975.c

index 270b6336b76da312ff7cda5481cad92b7f2f7f54..b4e93bd5835e1cce32a479d28991e1677358950a 100644 (file)
@@ -317,6 +317,13 @@ config SENSORS_MP2975
          This driver can also be built as a module. If so, the module will
          be called mp2975.
 
+config SENSORS_MP2975_REGULATOR
+       depends on SENSORS_MP2975 && REGULATOR
+       bool "Regulator support for MPS MP2975"
+       help
+         If you say yes here you get regulator support for MPS MP2975
+         Dual Loop Digital Multi-Phase Controller.
+
 config SENSORS_MP5023
        tristate "MPS MP5023"
        help
index 634369ebec43c314ed79e3b0ddceecff1a14f0d1..5fb21b9f4ab3db702a36154642ce786cdf8e25e2 100644 (file)
@@ -115,6 +115,11 @@ static const struct i2c_device_id mp2975_id[] = {
 
 MODULE_DEVICE_TABLE(i2c, mp2975_id);
 
+static const struct regulator_desc __maybe_unused mp2975_reg_desc[] = {
+       PMBUS_REGULATOR("vout", 0),
+       PMBUS_REGULATOR("vout", 1),
+};
+
 #define to_mp2975_data(x)  container_of(x, struct mp2975_data, info)
 
 static int
@@ -806,6 +811,10 @@ static struct pmbus_driver_info mp2975_info = {
                PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_POUT |
                PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT | PMBUS_PHASE_VIRTUAL,
        .read_word_data = mp2975_read_word_data,
+#if IS_ENABLED(CONFIG_SENSORS_MP2975_REGULATOR)
+       .num_regulators = 1,
+       .reg_desc = mp2975_reg_desc,
+#endif
 };
 
 static struct pmbus_driver_info mp2973_info = {
@@ -823,6 +832,10 @@ static struct pmbus_driver_info mp2973_info = {
                PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_POUT |
                PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT,
        .read_word_data = mp2973_read_word_data,
+#if IS_ENABLED(CONFIG_SENSORS_MP2975_REGULATOR)
+       .num_regulators = 1,
+       .reg_desc = mp2975_reg_desc,
+#endif
 };
 
 static int mp2975_probe(struct i2c_client *client)
@@ -861,6 +874,8 @@ static int mp2975_probe(struct i2c_client *client)
                data->info.pages = MP2975_PAGE_NUM;
                data->info.phases[1] = ret;
                data->info.func[1] = MP2975_RAIL2_FUNC;
+               if (IS_ENABLED(CONFIG_SENSORS_MP2975_REGULATOR))
+                       data->info.num_regulators = MP2975_PAGE_NUM;
        }
 
        if (data->chip_id == mp2975) {