Re: [PATCH] hwmon: (pmbus/fsp-3y) Fix FSP-3Y YH-5151E VOUT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 13, 2021 at 10:11:10PM +0200, Václav Kubernát wrote:
> After testing new YH-5151E devices, we found out that not all YH-5151E
> work the same. The newly tested devices actually report vout correctly
> in linear16 (even though they're still YH-5151E). We suspect that it is
> because these new devices have a different firmware version, but that is
> unconfirmed. The version cannot be queried through PMBus.
> 
> The compliant versions of YH-5151E report VOUT_MODE normally, so we turn
> on the linear11 workaround only if VOUT_MODE doesn't report anything.
> 
What a mess. But thanks for keeping on top of this, and for the fix.
Applied.

Thanks,
Guenter

> Signed-off-by: Václav Kubernát <kubernat@xxxxxxxxx>
> ---
>  drivers/hwmon/pmbus/fsp-3y.c | 32 +++++++++++++++++++++++++-------
>  1 file changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/hwmon/pmbus/fsp-3y.c b/drivers/hwmon/pmbus/fsp-3y.c
> index 46252b17c008..073d960a0af5 100644
> --- a/drivers/hwmon/pmbus/fsp-3y.c
> +++ b/drivers/hwmon/pmbus/fsp-3y.c
> @@ -37,6 +37,8 @@ struct fsp3y_data {
>  	struct pmbus_driver_info info;
>  	int chip;
>  	int page;
> +
> +	bool vout_linear_11;
>  };
>  
>  #define to_fsp3y_data(x) container_of(x, struct fsp3y_data, info)
> @@ -108,11 +110,9 @@ static int fsp3y_read_byte_data(struct i2c_client *client, int page, int reg)
>  	int rv;
>  
>  	/*
> -	 * YH5151-E outputs vout in linear11. The conversion is done when
> -	 * reading. Here, we have to inject pmbus_core with the correct
> -	 * exponent (it is -6).
> +	 * Inject an exponent for non-compliant YH5151-E.
>  	 */
> -	if (data->chip == yh5151e && reg == PMBUS_VOUT_MODE)
> +	if (data->vout_linear_11 && reg == PMBUS_VOUT_MODE)
>  		return 0x1A;
>  
>  	rv = set_page(client, page);
> @@ -161,10 +161,9 @@ static int fsp3y_read_word_data(struct i2c_client *client, int page, int phase,
>  		return rv;
>  
>  	/*
> -	 * YH-5151E is non-compliant and outputs output voltages in linear11
> -	 * instead of linear16.
> +	 * Handle YH-5151E non-compliant linear11 vout voltage.
>  	 */
> -	if (data->chip == yh5151e && reg == PMBUS_READ_VOUT)
> +	if (data->vout_linear_11 && reg == PMBUS_READ_VOUT)
>  		rv = sign_extend32(rv, 10) & 0xffff;
>  
>  	return rv;
> @@ -256,6 +255,25 @@ static int fsp3y_probe(struct i2c_client *client)
>  
>  	data->info = fsp3y_info[data->chip];
>  
> +	/*
> +	 * YH-5151E sometimes reports vout in linear11 and sometimes in
> +	 * linear16. This depends on the exact individual piece of hardware. One
> +	 * YH-5151E can use linear16 and another might use linear11 instead.
> +	 *
> +	 * The format can be recognized by reading VOUT_MODE - if it doesn't
> +	 * report a valid exponent, then vout uses linear11. Otherwise, the
> +	 * device is compliant and uses linear16.
> +	 */
> +	data->vout_linear_11 = false;
> +	if (data->chip == yh5151e) {
> +		rv = i2c_smbus_read_byte_data(client, PMBUS_VOUT_MODE);
> +		if (rv < 0)
> +			return rv;
> +
> +		if (rv == 0xFF)
> +			data->vout_linear_11 = true;
> +	}
> +
>  	return pmbus_do_probe(client, &data->info);
>  }
>  



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux