Commit 88fc1efc authored by Patrick Rudolph's avatar Patrick Rudolph Committed by Guenter Roeck
Browse files

hwmon: (pmbus/mp2975) Add regulator support



Add support to expose the PMBUS regulator.

Tested on MP2973 and MP2971.

Signed-off-by: default avatarPatrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: default avatarNaresh Solanki <Naresh.Solanki@9elements.com>
Link: https://lore.kernel.org/r/20230714135124.2645339-7-Naresh.Solanki@9elements.com


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 5239277e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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
+15 −0
Original line number Diff line number Diff line
@@ -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) {