[PATCH 2/3] hwmon: (pmbus) add BEL PFE3000 power supply driver

Guenter Roeck linux at roeck-us.net
Tue Oct 29 23:50:48 AEDT 2019


On Mon, Oct 28, 2019 at 04:49:03PM -0700, rentao.bupt at gmail.com wrote:
> From: Tao Ren <rentao.bupt at gmail.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 at gmail.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},
>  	{}
>  };
>  


More information about the openbmc mailing list