hwmon: (xdpe12284) Add regulator support
authorMarcello Sylvester Bauer <sylv@sylv.io>
Wed, 2 Mar 2022 09:49:21 +0000 (10:49 +0100)
committerGuenter Roeck <linux@roeck-us.net>
Wed, 2 Mar 2022 17:51:15 +0000 (09:51 -0800)
Add simple on/off regulator support for xdpe12284 and
other pmbus parts supported by the xdpe12284 driver.

Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
Link: https://lore.kernel.org/r/f69b8e7fa32cd2bad9516d8fa590abb87c7e4869.1646214248.git.sylv@sylv.io
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/pmbus/Kconfig
drivers/hwmon/pmbus/xdpe12284.c

index 6552467c588d108160068ae17cba9429748dbe93..a2ea1d5a87650df2426d620a5acbbc0e65f27a5b 100644 (file)
@@ -417,6 +417,12 @@ config SENSORS_XDPE122
          This driver can also be built as a module. If so, the module will
          be called xdpe12284.
 
+config SENSORS_XDPE122_REGULATOR
+       bool "Regulator support for XDPE122 and compatibles"
+       depends on SENSORS_XDPE122 && REGULATOR
+       help
+         Uses the xdpe12284 or compatible as regulator.
+
 config SENSORS_ZL6100
        tristate "Intersil ZL6100 and compatibles"
        help
index b979c88d2e870a52c5db172b418bafd9c25a4c06..18fffc5d749bd98c4cff3ff6bd4a05bfcd3452c1 100644 (file)
@@ -10,6 +10,8 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/regulator/driver.h>
+
 #include "pmbus.h"
 
 #define XDPE122_PROT_VR12_5MV          0x01 /* VR12.0 mode, 5-mV DAC */
@@ -122,6 +124,11 @@ static int xdpe122_identify(struct i2c_client *client,
        return 0;
 }
 
+static const struct regulator_desc xdpe122_reg_desc[] = {
+       PMBUS_REGULATOR("vout", 0),
+       PMBUS_REGULATOR("vout", 1),
+};
+
 static struct pmbus_driver_info xdpe122_info = {
        .pages = XDPE122_PAGE_NUM,
        .format[PSC_VOLTAGE_IN] = linear,
@@ -138,6 +145,10 @@ static struct pmbus_driver_info xdpe122_info = {
                PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP |
                PMBUS_HAVE_POUT | PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT,
        .identify = xdpe122_identify,
+#if IS_ENABLED(CONFIG_SENSORS_XDPE122_REGULATOR)
+       .num_regulators = 2,
+       .reg_desc = xdpe122_reg_desc,
+#endif
 };
 
 static int xdpe122_probe(struct i2c_client *client)