lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191029125048.GA32552@roeck-us.net>
Date:   Tue, 29 Oct 2019 05:50:48 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     rentao.bupt@...il.com
Cc:     Jean Delvare <jdelvare@...e.com>, Jonathan Corbet <corbet@....net>,
        linux-hwmon@...r.kernel.org, linux-doc@...r.kernel.org,
        linux-kernel@...r.kernel.org, openbmc@...ts.ozlabs.org,
        taoren@...com
Subject: Re: [PATCH 2/3] hwmon: (pmbus) add BEL PFE3000 power supply driver

On Mon, Oct 28, 2019 at 04:49:03PM -0700, rentao.bupt@...il.com wrote:
> From: Tao Ren <rentao.bupt@...il.com>
> 
> Add the driver to support BEL PFE3000 which is 3000 Wat AC to DC power

which is a ...

Watt

> supply. The chip has 8 pages.

FWIW, that is a bit misleading here. It isn't really 8 pages. I would suggest
to drop that comment (or, if you insist, at least add "two of which are
reserved").

> 
> Signed-off-by: Tao Ren <rentao.bupt@...il.com>
> ---
>  drivers/hwmon/pmbus/bel-pfe.c | 65 ++++++++++++++++++++++++++++++++++-
>  1 file changed, 64 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pmbus/bel-pfe.c b/drivers/hwmon/pmbus/bel-pfe.c
> index 117f9af21bf3..7b6c90b056c9 100644
> --- a/drivers/hwmon/pmbus/bel-pfe.c
> +++ b/drivers/hwmon/pmbus/bel-pfe.c
> @@ -10,9 +10,21 @@
>  #include <linux/init.h>
>  #include <linux/err.h>
>  #include <linux/i2c.h>
> +#include <linux/pmbus.h>
> +
>  #include "pmbus.h"
>  
> -enum chips {pfe1100};
> +enum chips {pfe1100, pfe3000};
> +
> +/*
> + * Disable status check for pfe3000 devices, because some devices report
> + * communication error (invalid command) for VOUT_MODE command (0x20)
> + * although correct VOUT_MODE (0x16) is returned: it leads to incorrect
> + * exponent in linear mode.
> + */
> +static struct pmbus_platform_data pfe3000_plat_data = {
> +	.flags = PMBUS_SKIP_STATUS_CHECK,
> +};
>  
>  static struct pmbus_driver_info pfe_driver_info[] = {
>  	[pfe1100] = {
> @@ -34,6 +46,45 @@ static struct pmbus_driver_info pfe_driver_info[] = {
>  			   PMBUS_HAVE_STATUS_TEMP |
>  			   PMBUS_HAVE_FAN12,
>  	},
> +
> +	[pfe3000] = {
> +		.pages = 8,
> +		.format[PSC_VOLTAGE_IN] = linear,
> +		.format[PSC_VOLTAGE_OUT] = linear,
> +		.format[PSC_CURRENT_IN] = linear,
> +		.format[PSC_CURRENT_OUT] = linear,
> +		.format[PSC_POWER] = linear,
> +		.format[PSC_TEMPERATURE] = linear,
> +		.format[PSC_FAN] = linear,
> +
> +		/* Page 0: V1. */
> +		.func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> +			   PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
> +			   PMBUS_HAVE_POUT | PMBUS_HAVE_FAN12 |
> +			   PMBUS_HAVE_VIN | PMBUS_HAVE_IIN |
> +			   PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT |
> +			   PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 |
> +			   PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_TEMP |
> +			   PMBUS_HAVE_VCAP,
> +
> +		/* Page 1: Vsb. */
> +		.func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> +			   PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
> +			   PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT |
> +			   PMBUS_HAVE_POUT,
> +
> +		/*
> +		 * Page 2: V1 Ishare.
> +		 * Page 4: V1 Cathode.
> +		 * Page 5: Vsb Cathode.
> +		 * Page 6: V1 Sense.
> +		 * Page 3 and 7 are reserved.

If page 7 is reserved, and doesn't have any attributes, it doesn't really
make sense to claim support for 8 pages above. I would suugest to make it 7.

> +		 */
> +		.func[2] = PMBUS_HAVE_VOUT,
> +		.func[4] = PMBUS_HAVE_VOUT,
> +		.func[5] = PMBUS_HAVE_VOUT,
> +		.func[6] = PMBUS_HAVE_VOUT,
> +	},
>  };
>  
>  static int pfe_pmbus_probe(struct i2c_client *client,
> @@ -42,11 +93,23 @@ static int pfe_pmbus_probe(struct i2c_client *client,
>  	int model;
>  
>  	model = (int)id->driver_data;
> +
> +	/*
> +	 * PFE3000-12-069RA devices may not stay in page 0 during device
> +	 * probe which leads to probe failure (read status word failed).
> +	 * So let's set the device to page 0 at the beginning.
> +	 */
> +	if (model == pfe3000) {
> +		client->dev.platform_data = &pfe3000_plat_data;
> +		i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
> +	}
> +
>  	return pmbus_do_probe(client, id, &pfe_driver_info[model]);
>  }
>  
>  static const struct i2c_device_id pfe_device_id[] = {
>  	{"pfe1100", pfe1100},
> +	{"pfe3000", pfe3000},
>  	{}
>  };
>  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ