linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (adm1275) Enable adm1278 VOUT sampling
@ 2016-10-14 10:06 Joel Stanley
  2016-10-14 17:06 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Joel Stanley @ 2016-10-14 10:06 UTC (permalink / raw)
  To: linux, jdelvare; +Cc: Yi Li, linux-hwmon, linux-kernel

From: Yi Li <adamliyi@msn.com>

The adm1278 can optionally monitor the VOUT pin. This functionality is
not enabled at reset, so PMON_CONFIG needs to be modified in order to
enable it.

Signed-off-by: Yi Li <adamliyi@msn.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
---

Guenter, I'm not sure if this is a valid thing to do in the probe function. If
not, can you suggest an alternative method for enabling this?

 drivers/hwmon/pmbus/adm1275.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c
index 3baa4f4a8c5e..7d1f5f7891cc 100644
--- a/drivers/hwmon/pmbus/adm1275.c
+++ b/drivers/hwmon/pmbus/adm1275.c
@@ -500,6 +500,19 @@ static int adm1275_probe(struct i2c_client *client,
 		tindex = 3;
 
 		info->func[0] |= PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT;
+
+		/* By default when reset VOUT is not enabled */
+		if (!(config & ADM1278_VOUT_EN)) {
+			config |= ADM1278_VOUT_EN;
+			ret = i2c_smbus_write_byte_data(client,
+							ADM1275_PMON_CONFIG,
+							config);
+			if (ret < 0) {
+				dev_warn(&client->dev,
+					"Failed to enable VOUT monitoring\n");
+			}
+		}
+
 		if (config & ADM1278_TEMP1_EN)
 			info->func[0] |=
 				PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
-- 
2.9.3

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

* Re: [PATCH] hwmon: (adm1275) Enable adm1278 VOUT sampling
  2016-10-14 10:06 [PATCH] hwmon: (adm1275) Enable adm1278 VOUT sampling Joel Stanley
@ 2016-10-14 17:06 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2016-10-14 17:06 UTC (permalink / raw)
  To: Joel Stanley; +Cc: jdelvare, Yi Li, linux-hwmon, linux-kernel

On Fri, Oct 14, 2016 at 08:36:05PM +1030, Joel Stanley wrote:
> From: Yi Li <adamliyi@msn.com>
> 
> The adm1278 can optionally monitor the VOUT pin. This functionality is
> not enabled at reset, so PMON_CONFIG needs to be modified in order to
> enable it.
> 
> Signed-off-by: Yi Li <adamliyi@msn.com>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
> 
> Guenter, I'm not sure if this is a valid thing to do in the probe function. If
> not, can you suggest an alternative method for enabling this?
> 
Normally it would be set by the BIOS or ROMMON, though it doesn't seem to make
much sense to not enable it with this chip. Another option would be to enable it
through devicetree, but that would add quite some complexity which I'd rather
avoid. So doing it here is fine.

>  drivers/hwmon/pmbus/adm1275.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c
> index 3baa4f4a8c5e..7d1f5f7891cc 100644
> --- a/drivers/hwmon/pmbus/adm1275.c
> +++ b/drivers/hwmon/pmbus/adm1275.c
> @@ -500,6 +500,19 @@ static int adm1275_probe(struct i2c_client *client,
>  		tindex = 3;
>  
>  		info->func[0] |= PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT;
> +
> +		/* By default when reset VOUT is not enabled */
> +		if (!(config & ADM1278_VOUT_EN)) {
> +			config |= ADM1278_VOUT_EN;
> +			ret = i2c_smbus_write_byte_data(client,
> +							ADM1275_PMON_CONFIG,
> +							config);
> +			if (ret < 0) {
> +				dev_warn(&client->dev,
> +					"Failed to enable VOUT monitoring\n");

Two options: Either abort in this case (after all, something _is_ wrong)
and return an error (and always set PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT),
or clear ADM1278_VOUT_EN in config to make sure it is not enabled further below.

Thanks,
Guenter

> +			}
> +		}
> +
>  		if (config & ADM1278_TEMP1_EN)
>  			info->func[0] |=
>  				PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
> -- 
> 2.9.3
> 

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

end of thread, other threads:[~2016-10-14 17:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-14 10:06 [PATCH] hwmon: (adm1275) Enable adm1278 VOUT sampling Joel Stanley
2016-10-14 17:06 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).