All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] hwmon: (pmbus) lm25066: Add regulator support
@ 2022-02-19  0:07 Zev Weiss
  2022-02-19 14:33 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Zev Weiss @ 2022-02-19  0:07 UTC (permalink / raw)
  To: Guenter Roeck, Jean Delvare, linux-hwmon; +Cc: linux-kernel, Zev Weiss

While these chips aren't strictly advertised as voltage regulators per
se, they (aside from the lm25056) support the PMBus OPERATION command
to enable and disable their outputs and have status bits for reporting
various warnings and faults, and can hence usefully support all the
pmbus_regulator_ops operations.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
---

Changes since v1 [0]:
 - split out of power-efuse driver series

[0] https://lore.kernel.org/openbmc/20220217104444.7695-3-zev@bewilderbeest.net/

 drivers/hwmon/pmbus/Kconfig   |  7 +++++++
 drivers/hwmon/pmbus/lm25066.c | 14 ++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index c96f7b7338bd..c73aa50c7615 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -174,6 +174,13 @@ config SENSORS_LM25066
 	  This driver can also be built as a module. If so, the module will
 	  be called lm25066.
 
+config SENSORS_LM25066_REGULATOR
+	bool "Regulator support for LM25066 and compatibles"
+	depends on SENSORS_LM25066 && REGULATOR
+	help
+	  If you say yes here you get regulator support for National
+	  Semiconductor LM25066, LM5064, and LM5066.
+
 config SENSORS_LTC2978
 	tristate "Linear Technologies LTC2978 and compatibles"
 	help
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index 8402b41520eb..09792cd03d9f 100644
--- a/drivers/hwmon/pmbus/lm25066.c
+++ b/drivers/hwmon/pmbus/lm25066.c
@@ -435,6 +435,12 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg,
 	return ret;
 }
 
+#if IS_ENABLED(CONFIG_SENSORS_LM25066_REGULATOR)
+static const struct regulator_desc lm25066_reg_desc[] = {
+	PMBUS_REGULATOR("vout", 0),
+};
+#endif
+
 static const struct i2c_device_id lm25066_id[] = {
 	{"lm25056", lm25056},
 	{"lm25066", lm25066},
@@ -545,6 +551,14 @@ static int lm25066_probe(struct i2c_client *client)
 	info->m[PSC_CURRENT_IN] = info->m[PSC_CURRENT_IN] * shunt / 1000;
 	info->m[PSC_POWER] = info->m[PSC_POWER] * shunt / 1000;
 
+#if IS_ENABLED(CONFIG_SENSORS_LM25066_REGULATOR)
+	/* LM25056 doesn't support OPERATION */
+	if (data->id != lm25056) {
+		info->num_regulators = ARRAY_SIZE(lm25066_reg_desc);
+		info->reg_desc = lm25066_reg_desc;
+	}
+#endif
+
 	return pmbus_do_probe(client, info);
 }
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] hwmon: (pmbus) lm25066: Add regulator support
  2022-02-19  0:07 [PATCH v2] hwmon: (pmbus) lm25066: Add regulator support Zev Weiss
@ 2022-02-19 14:33 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2022-02-19 14:33 UTC (permalink / raw)
  To: Zev Weiss; +Cc: Jean Delvare, linux-hwmon, linux-kernel

On Fri, Feb 18, 2022 at 04:07:42PM -0800, Zev Weiss wrote:
> While these chips aren't strictly advertised as voltage regulators per
> se, they (aside from the lm25056) support the PMBus OPERATION command
> to enable and disable their outputs and have status bits for reporting
> various warnings and faults, and can hence usefully support all the
> pmbus_regulator_ops operations.
> 
> Signed-off-by: Zev Weiss <zev@bewilderbeest.net>

Applied to hwmon-next.

Thanks,
Guenter

> ---
> 
> Changes since v1 [0]:
>  - split out of power-efuse driver series
> 
> [0] https://lore.kernel.org/openbmc/20220217104444.7695-3-zev@bewilderbeest.net/
> 
>  drivers/hwmon/pmbus/Kconfig   |  7 +++++++
>  drivers/hwmon/pmbus/lm25066.c | 14 ++++++++++++++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> index c96f7b7338bd..c73aa50c7615 100644
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -174,6 +174,13 @@ config SENSORS_LM25066
>  	  This driver can also be built as a module. If so, the module will
>  	  be called lm25066.
>  
> +config SENSORS_LM25066_REGULATOR
> +	bool "Regulator support for LM25066 and compatibles"
> +	depends on SENSORS_LM25066 && REGULATOR
> +	help
> +	  If you say yes here you get regulator support for National
> +	  Semiconductor LM25066, LM5064, and LM5066.
> +
>  config SENSORS_LTC2978
>  	tristate "Linear Technologies LTC2978 and compatibles"
>  	help
> diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
> index 8402b41520eb..09792cd03d9f 100644
> --- a/drivers/hwmon/pmbus/lm25066.c
> +++ b/drivers/hwmon/pmbus/lm25066.c
> @@ -435,6 +435,12 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg,
>  	return ret;
>  }
>  
> +#if IS_ENABLED(CONFIG_SENSORS_LM25066_REGULATOR)
> +static const struct regulator_desc lm25066_reg_desc[] = {
> +	PMBUS_REGULATOR("vout", 0),
> +};
> +#endif
> +
>  static const struct i2c_device_id lm25066_id[] = {
>  	{"lm25056", lm25056},
>  	{"lm25066", lm25066},
> @@ -545,6 +551,14 @@ static int lm25066_probe(struct i2c_client *client)
>  	info->m[PSC_CURRENT_IN] = info->m[PSC_CURRENT_IN] * shunt / 1000;
>  	info->m[PSC_POWER] = info->m[PSC_POWER] * shunt / 1000;
>  
> +#if IS_ENABLED(CONFIG_SENSORS_LM25066_REGULATOR)
> +	/* LM25056 doesn't support OPERATION */
> +	if (data->id != lm25056) {
> +		info->num_regulators = ARRAY_SIZE(lm25066_reg_desc);
> +		info->reg_desc = lm25066_reg_desc;
> +	}
> +#endif
> +
>  	return pmbus_do_probe(client, info);
>  }
>  

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-19 14:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-19  0:07 [PATCH v2] hwmon: (pmbus) lm25066: Add regulator support Zev Weiss
2022-02-19 14:33 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.