All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] hwmon:Driver for Delta power supplies
       [not found] <tencent_DCB41AD18DD01711F62248CD7CBAC7F48A08@qq.com>
@ 2020-09-19  5:30 ` Guenter Roeck
  0 siblings, 0 replies; only message in thread
From: Guenter Roeck @ 2020-09-19  5:30 UTC (permalink / raw)
  To: xiao.mx.ma, Jean Delvare, linux-hwmon, linux-kernel, xiao.mx.ma,
	jiajia.feng

On 9/18/20 12:18 AM, xiao.mx.ma wrote:
> Add delta.rst in Documentation/hwmon
> Tristate "DELTA" in Kconfig is changed to "DELTA_POWER_SUPPLIES"
> Modify code: drop the excessive empty lines, correct the comment content,
> adjust indent, remove extra brackets.
> 
Description goes here.

> Signed-off-by: xiao.mx.ma <734056705@qq.com>
> ---

Change log goes here.

Other than that, this is a patch on top of the previous patch.
Please combine the two patches into one.

>  Documentation/hwmon/delta.rst |  52 ++++++++++

delta.rst needs to be added to Documentation/hwmon/index.rst.

>  drivers/hwmon/pmbus/Kconfig   |   2 +-
>  drivers/hwmon/pmbus/delta.c   | 172 ++++++++--------------------------
>  3 files changed, 90 insertions(+), 136 deletions(-)
>  create mode 100644 Documentation/hwmon/delta.rst
> 
> diff --git a/Documentation/hwmon/delta.rst b/Documentation/hwmon/delta.rst
> new file mode 100644
> index 000000000000..790701d310e3
> --- /dev/null
> +++ b/Documentation/hwmon/delta.rst
> @@ -0,0 +1,52 @@
> +Kernel driver delta
> +=====================
> +
> +Supported chips:
> +
> +  * DELTA Q54SJ108A2NCAH, Q54SJ108A2NCDH, Q54SJ108A2NCPG, Q54SJ108A2NCPH
> +
> +    Prefix: 'Q54SJ108A2'
> +
> +    Addresses scanned: -
> +
> +    Datasheet: https://filecenter.delta-china.com.cn/products/download/01/0102/datasheet/DS_Q54SJ108A2.pdf
> +
> +Authors:
> +    xiao.mx.ma <734056705@qq.com>
> +
> +
> +Description
> +-----------
> +
> +This driver implements support for DELTA Q54SJ108A2NCAH, Q54SJ108A2NCDH, 
> +Q54SJ108A2NCPG, and Q54SJ108A2NCPH 1/4 Brick DC/DC Regulated Power Module 
> +with PMBus support.
> +
> +The driver is a client driver to the core PMBus driver.
> +Please see Documentation/hwmon/pmbus.rst for details on PMBus client drivers.
> +
> +
> +Usage Notes
> +-----------
> +
> +This driver does not auto-detect devices. You will have to instantiate the
> +devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for
> +details.
> +
> +
> +Sysfs entries
> +-------------
> +
> +=================== ===== =======================================================
> +curr1_alarm         RO    Output current alarm
> +curr1_input         RO    Output current
> +curr1_label         RO    'iout1'
> +in1_alarm           RO    Input voltage alarm
> +in1_input           RO    Input voltage
> +in1_label           RO    'vin'
> +in2_alarm           RO    Output voltage alarm
> +in2_input           RO    Output voltage
> +in2_label           RO    'vout1'
> +temp1_alarm         RO    Temeperature alarm
> +temp1_input         RO    Chip temperature
> +=================== ===== =======================================================
> diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> index a9468be10d7e..b03311340add 100644
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -46,7 +46,7 @@ config SENSORS_BEL_PFE
>  	  be called bel-pfe.
>  
>  config SENSORS_DELTA
> -	tristate "DELTA"
> +	tristate "DELTA_POWER_SUPPLIES"

This can be some text.

>  	help
>  	  If you say yes here you get hardware monitoring support for Delta Power Supplies.
>  
> diff --git a/drivers/hwmon/pmbus/delta.c b/drivers/hwmon/pmbus/delta.c
> index 090429881c45..04f09767921c 100644
> --- a/drivers/hwmon/pmbus/delta.c
> +++ b/drivers/hwmon/pmbus/delta.c
> @@ -1,234 +1,136 @@
>  // SPDX-License-Identifier: GPL-2.0-or-later
> -
>  /*
> - * Driver for Q54SJ108A2, Q50SN12050, and Q50SN12072 Integrated, Step-Down
> - * Switching Regulators
> + * Driver for Delta modules, Q54SJ108A2 series 1/4 Brick DC/DC
> + * Regulated Power Module
>   *
>   * Copyright 2020 Delta LLC.
>   */
>  
> -
>  #include <linux/bits.h>
> -
>  #include <linux/err.h>
> -
>  #include <linux/i2c.h>
> -
>  #include <linux/init.h>
> -
>  #include <linux/kernel.h>
> -
>  #include <linux/module.h>
> -
>  #include <linux/mutex.h>
> -
>  #include <linux/of_device.h>
> -
>  #include <linux/pmbus.h>
> -
>  #include <linux/util_macros.h>
> -
>  #include "pmbus.h"
>  
>  enum chips {
> -
>  	Q54SJ108A2
>  };
>  
>  static const struct pmbus_driver_info delta_info[] = {
> -
> -[Q54SJ108A2] = {
> -
> -.pages = 1,
> -
> -/* Source : Delta Q54SJ108A2 */
> -
> -.format[PSC_TEMPERATURE] = linear,
> -
> -.format[PSC_VOLTAGE_IN] = linear,
> -
> -.format[PSC_CURRENT_OUT] = linear,
> -
> -
> -.func[0] = PMBUS_HAVE_VIN |
> -
> -PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> -
> -PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
> -
> -PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP |
> -
> -PMBUS_HAVE_STATUS_INPUT,
> -
> -},
> -
> +	[Q54SJ108A2] = {
> +		.pages = 1,
> +
> +		/* Source : Delta Q54SJ108A2 */
> +		.format[PSC_TEMPERATURE] = linear,
> +		.format[PSC_VOLTAGE_IN] = linear,
> +		.format[PSC_CURRENT_OUT] = linear,
> +
> +		.func[0] = PMBUS_HAVE_VIN |
> +		PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> +		PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
> +		PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP |
> +		PMBUS_HAVE_STATUS_INPUT,
> +	},
>  };
>  
>  
>  
>  static int delta_probe(struct i2c_client *client, const struct i2c_device_id *id)
>  {
> -
>  	struct device *dev = &client->dev;
> -
>  	u8 buf[I2C_SMBUS_BLOCK_MAX + 1];
> -
>  	struct pmbus_driver_info *info;
> -
>  	enum chips chip_id;
> -
>  	int ret;
>  
>  	if (!i2c_check_functionality(client->adapter,
> -
> -		I2C_FUNC_SMBUS_BYTE_DATA |
> -
> -		I2C_FUNC_SMBUS_WORD_DATA |
> -
> -		I2C_FUNC_SMBUS_BLOCK_DATA))
> -
> +				     I2C_FUNC_SMBUS_BYTE_DATA |
> +				     I2C_FUNC_SMBUS_WORD_DATA |
> +				     I2C_FUNC_SMBUS_BLOCK_DATA))
>  		return -ENODEV;
>  
>  	if (client->dev.of_node)
> -
>  		chip_id = (enum chips)of_device_get_match_data(dev);
> -
>  	else
> -
>  		chip_id = id->driver_data;
>  
>  	ret = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
> -
>  	if (ret < 0) {
> -
>  		dev_err(&client->dev, "Failed to read Manufacturer ID\n");
> -
>  		return ret;
> -
>  	}
> -
> -	if (ret != 5 || strncmp((buf), "DELTA", 5)) {
> -
> +	if (ret != 5 || strncmp(buf, "DELTA", 5)) {
>  		buf[ret] = '\0';
> -
>  		dev_err(dev, "Unsupported Manufacturer ID '%s'\n", buf);
> -
>  		return -ENODEV;
> -
>  	}
>  
> -/*
> - * The chips support reading PMBUS_MFR_MODEL.
> - */
> -
> +	/*
> +	 * The chips support reading PMBUS_MFR_MODEL.
> +	 */
>  	ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
> -
>  	if (ret < 0) {
> -
>  		dev_err(dev, "Failed to read Manufacturer Model\n");
> -
>  		return ret;
> -
>  	}
> -
> -	if (ret != 14 || strncmp((buf), "Q54SJ108A2", 10)) {
> -
> +	if (ret != 14 || strncmp(buf, "Q54SJ108A2", 10)) {
>  		buf[ret] = '\0';
> -
>  		dev_err(dev, "Unsupported Manufacturer Model '%s'\n", buf);
> -
>  		return -ENODEV;
> -
>  	}
>  
>  	ret = i2c_smbus_read_block_data(client, PMBUS_MFR_REVISION, buf);
> -
>  	if (ret < 0) {
> -
>  		dev_err(dev, "Failed to read Manufacturer Revision\n");
> -
>  		return ret;
> -
>  	}
> -
>  	if (ret != 4 || buf[0] != 'S') {
> -
>  		buf[ret] = '\0';
> -
>  		dev_err(dev, "Unsupported Manufacturer Revision '%s'\n", buf);
> -
>  		return -ENODEV;
> -
>  	}
>  
>  	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
> -
>  	if (!info)
> -
>  		return -ENOMEM;
>  
>  	memcpy(info, &delta_info[chip_id], sizeof(*info));
>  
>  	return pmbus_do_probe(client, id, info);
> -
>  }
>  
> -
> -
>  static const struct i2c_device_id delta_id[] = {
> -
> -{ "Q54SJ108A2", Q54SJ108A2 },
> -
> -{ },
> -
> +	{ "Q54SJ108A2", Q54SJ108A2 },
> +	{ },
>  };
>  
> -
> -
>  MODULE_DEVICE_TABLE(i2c, delta_id);
>  
> -
> -
>  static const struct of_device_id delta_of_match[] = {
> -
> -{ .compatible = "delta,Q54SJ108A2", .data = (void *)Q54SJ108A2 },
> -
> -{ },
> -
> +	{ .compatible = "delta,Q54SJ108A2", .data = (void *)Q54SJ108A2 },
> +	{ },
>  };
>  
> -
> -
>  MODULE_DEVICE_TABLE(of, delta_of_match);
>  
> -
> -
>  static struct i2c_driver delta_driver = {
> -
> -.driver = {
> -
> -.name = "Q54SJ108A2",
> -
> -.of_match_table = delta_of_match,
> -
> -},
> -
> -.probe = delta_probe,
> -
> -.remove = pmbus_do_remove,
> -
> -.id_table = delta_id,
> -
> +	.driver = {
> +		.name = "Q54SJ108A2",
> +		.of_match_table = delta_of_match,
> +	},
> +	.probe = delta_probe,
> +	.remove = pmbus_do_remove,
> +	.id_table = delta_id,
>  };
>  
> -
> -
>  module_i2c_driver(delta_driver);
>  
> -
> -
> -MODULE_AUTHOR("Delta <734056705@qq.com>");
> -
> -MODULE_DESCRIPTION("PMBus driver for Delta Q54SJ108A2NCAH / Q54SJ108A2NCDH / Q54SJ108A2NCPG / Q54SJ108A2NCPH");
> -
> +MODULE_AUTHOR("xiao.mx.ma <734056705@qq.com>");
> +MODULE_DESCRIPTION("PMBus driver for Delta Q54SJ108A2 series modules");
>  MODULE_LICENSE("GPL");
> 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-19  5:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <tencent_DCB41AD18DD01711F62248CD7CBAC7F48A08@qq.com>
2020-09-19  5:30 ` [PATCH v2] hwmon:Driver for Delta power supplies Guenter Roeck

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.