All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux dev-4.10] hwmon: max31785: Enable dual rotor if functionality is detected
@ 2017-06-20  2:39 Andrew Jeffery
  2017-06-21  4:54 ` Joel Stanley
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Jeffery @ 2017-06-20  2:39 UTC (permalink / raw)
  To: joel; +Cc: Andrew Jeffery, openbmc, msbarth, cbostic, spinler

The MFR_FAN_CONFIG command contains a bit (12) to enable or disable the
second rotor measurement. Ensure we set it if we detect the 0x3040
MFR_REVISION_ID.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
 drivers/hwmon/max31785.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/hwmon/max31785.c b/drivers/hwmon/max31785.c
index ecece346be28..73680954f664 100644
--- a/drivers/hwmon/max31785.c
+++ b/drivers/hwmon/max31785.c
@@ -39,6 +39,7 @@
 #define MAX31785_REG_MFR_MODEL			0x9a
 #define MAX31785_REG_MFR_REVISION		0x9b
 #define MAX31785_REG_MFR_FAN_CONFIG		0xf1
+#define	 MAX31785_REG_MFR_FAN_CONFIG_DUAL_TACH	BIT(12)
 #define MAX31785_REG_READ_FAN_PWM		0xf3
 
 /* Fan Config register bits */
@@ -81,13 +82,13 @@ struct max31785 {
 	/* Registers */
 	u8	fan_config[NR_CHANNEL];
 	u16	fan_command[NR_CHANNEL];
-	u8	mfr_fan_config[NR_CHANNEL];
+	u16	mfr_fan_config[NR_CHANNEL];
 	u8	fault_status[NR_CHANNEL];
 	u16	pwm[NR_CHANNEL];
 	u16	tach_rpm[NR_CHANNEL * 2];
 };
 
-static inline bool max31785_has_fast_rotor(struct max31785 *data)
+static inline bool max31785_has_dual_rotor(struct max31785 *data)
 {
 	return !!(data->capabilities & MAX31785_CAP_FAST_ROTOR);
 }
@@ -188,7 +189,7 @@ static int max31785_update_fan_speed(struct max31785 *data, u8 fan)
 	if (rc)
 		return rc;
 
-	if (max31785_has_fast_rotor(data)) {
+	if (max31785_has_dual_rotor(data)) {
 		rc = max31785_smbus_read_long_data(data->client,
 				MAX31785_REG_FAN_SPEED_1);
 		if (rc < 0)
@@ -429,12 +430,23 @@ static int max31785_init_fans(struct max31785 *data)
 			return rv;
 		data->fan_command[i] = rv;
 
-		rv = max31785_read_fan_byte(client, i,
+		rv = max31785_read_fan_word(client, i,
 				MAX31785_REG_MFR_FAN_CONFIG);
 		if (rv < 0)
 			return rv;
 		data->mfr_fan_config[i] = rv;
 
+		if (max31785_has_dual_rotor(data)) {
+			rv |= MAX31785_REG_MFR_FAN_CONFIG_DUAL_TACH;
+			data->mfr_fan_config[i] = rv;
+
+			rv = max31785_write_fan_word(client, i,
+					MAX31785_REG_MFR_FAN_CONFIG,
+					data->mfr_fan_config[i]);
+			if (rv < 0)
+				return rv;
+		}
+
 		if (!((data->fan_config[i]
 			& MAX31785_FAN_CFG_CONTROL_MODE_RPM)
 			|| is_automatic_control_mode(data, i))) {
@@ -799,7 +811,7 @@ static int max31785_probe(struct i2c_client *client,
 	if (rc < 0)
 		return rc;
 
-	if (max31785_has_fast_rotor(data))
+	if (max31785_has_dual_rotor(data))
 		chip = &max31785_chip_info_0x3040;
 	else
 		chip = &max31785_chip_info_0x3030;
-- 
2.11.0

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

* Re: [PATCH linux dev-4.10] hwmon: max31785: Enable dual rotor if functionality is detected
  2017-06-20  2:39 [PATCH linux dev-4.10] hwmon: max31785: Enable dual rotor if functionality is detected Andrew Jeffery
@ 2017-06-21  4:54 ` Joel Stanley
  0 siblings, 0 replies; 2+ messages in thread
From: Joel Stanley @ 2017-06-21  4:54 UTC (permalink / raw)
  To: Andrew Jeffery
  Cc: OpenBMC Maillist, msbarth, Christopher Bostic, Matt Spinler

On Tue, Jun 20, 2017 at 12:09 PM, Andrew Jeffery <andrew@aj.id.au> wrote:
> The MFR_FAN_CONFIG command contains a bit (12) to enable or disable the
> second rotor measurement. Ensure we set it if we detect the 0x3040
> MFR_REVISION_ID.
>
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

Applied to dev-4.10.

Cheers,

Joel

> ---
>  drivers/hwmon/max31785.c | 22 +++++++++++++++++-----
>  1 file changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hwmon/max31785.c b/drivers/hwmon/max31785.c
> index ecece346be28..73680954f664 100644
> --- a/drivers/hwmon/max31785.c
> +++ b/drivers/hwmon/max31785.c
> @@ -39,6 +39,7 @@
>  #define MAX31785_REG_MFR_MODEL                 0x9a
>  #define MAX31785_REG_MFR_REVISION              0x9b
>  #define MAX31785_REG_MFR_FAN_CONFIG            0xf1
> +#define         MAX31785_REG_MFR_FAN_CONFIG_DUAL_TACH  BIT(12)
>  #define MAX31785_REG_READ_FAN_PWM              0xf3
>
>  /* Fan Config register bits */
> @@ -81,13 +82,13 @@ struct max31785 {
>         /* Registers */
>         u8      fan_config[NR_CHANNEL];
>         u16     fan_command[NR_CHANNEL];
> -       u8      mfr_fan_config[NR_CHANNEL];
> +       u16     mfr_fan_config[NR_CHANNEL];
>         u8      fault_status[NR_CHANNEL];
>         u16     pwm[NR_CHANNEL];
>         u16     tach_rpm[NR_CHANNEL * 2];
>  };
>
> -static inline bool max31785_has_fast_rotor(struct max31785 *data)
> +static inline bool max31785_has_dual_rotor(struct max31785 *data)
>  {
>         return !!(data->capabilities & MAX31785_CAP_FAST_ROTOR);
>  }
> @@ -188,7 +189,7 @@ static int max31785_update_fan_speed(struct max31785 *data, u8 fan)
>         if (rc)
>                 return rc;
>
> -       if (max31785_has_fast_rotor(data)) {
> +       if (max31785_has_dual_rotor(data)) {
>                 rc = max31785_smbus_read_long_data(data->client,
>                                 MAX31785_REG_FAN_SPEED_1);
>                 if (rc < 0)
> @@ -429,12 +430,23 @@ static int max31785_init_fans(struct max31785 *data)
>                         return rv;
>                 data->fan_command[i] = rv;
>
> -               rv = max31785_read_fan_byte(client, i,
> +               rv = max31785_read_fan_word(client, i,
>                                 MAX31785_REG_MFR_FAN_CONFIG);
>                 if (rv < 0)
>                         return rv;
>                 data->mfr_fan_config[i] = rv;
>
> +               if (max31785_has_dual_rotor(data)) {
> +                       rv |= MAX31785_REG_MFR_FAN_CONFIG_DUAL_TACH;
> +                       data->mfr_fan_config[i] = rv;
> +
> +                       rv = max31785_write_fan_word(client, i,
> +                                       MAX31785_REG_MFR_FAN_CONFIG,
> +                                       data->mfr_fan_config[i]);
> +                       if (rv < 0)
> +                               return rv;
> +               }
> +
>                 if (!((data->fan_config[i]
>                         & MAX31785_FAN_CFG_CONTROL_MODE_RPM)
>                         || is_automatic_control_mode(data, i))) {
> @@ -799,7 +811,7 @@ static int max31785_probe(struct i2c_client *client,
>         if (rc < 0)
>                 return rc;
>
> -       if (max31785_has_fast_rotor(data))
> +       if (max31785_has_dual_rotor(data))
>                 chip = &max31785_chip_info_0x3040;
>         else
>                 chip = &max31785_chip_info_0x3030;
> --
> 2.11.0
>

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

end of thread, other threads:[~2017-06-21  4:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-20  2:39 [PATCH linux dev-4.10] hwmon: max31785: Enable dual rotor if functionality is detected Andrew Jeffery
2017-06-21  4:54 ` Joel Stanley

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.