Skip to contentSkip to conversation

pmbus: associate PMBUS_SKIP_STATUS_CHECK with driver_data

PATCH Superseded Xiaoting Liu 4 participants 15 messages Jan 4, 2019 – Jan 14, 2019 1 message not in the archive

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/4 pmbus: associate PMBUS_SKIP_STATUS_CHECK with driver_data

In reply to a message not in the archive

Current code compares device name with name in i2c_device_id to decide whether PMBUS_SKIP_STATUS_CHECK should be set in pmbus_platform_data, which makes adding new devices with PMBUS_SKIP_STATUS_CHECK should also modify code in pmbus_probe().

This patch adds pmbus_device_info to save pages and flags. Its pointer is put in driver_data of i2c_device_id, which makes adding new device more straightforward.

---
 drivers/hwmon/pmbus/pmbus.c | 54 +++++++++++++++++++++++++++------------------
 include/linux/pmbus.h       |  5 +++++
 2 files changed, 37 insertions(+), 22 deletions(-)
drivers/hwmon/pmbus/pmbus.c +32 -22
index 7688dab32f6e..aa4cf9636e99 100644
@@ -172,13 +172,15 @@ static int pmbus_probe(struct i2c_client *client,
        struct pmbus_driver_info *info;
        struct pmbus_platform_data *pdata = NULL;
        struct device *dev = &client->dev;
+       struct pmbus_device_info *device_info;
 
        info = devm_kzalloc(dev, sizeof(struct pmbus_driver_info), GFP_KERNEL);
        if (!info)
                return -ENOMEM;
 
-       if (!strcmp(id->name, "dps460") || !strcmp(id->name, "dps800") ||
-           !strcmp(id->name, "sgd009")) {
+       device_info = (struct pmbus_device_info *)id->driver_data;
+
+       if (device_info->flags & PMBUS_SKIP_STATUS_CHECK) {
                pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data),
                                     GFP_KERNEL);
                if (!pdata)
@@ -187,36 +189,44 @@ static int pmbus_probe(struct i2c_client *client,
                pdata->flags = PMBUS_SKIP_STATUS_CHECK;
        }
 
-       info->pages = id->driver_data;
+       info->pages = device_info->pages;
        info->identify = pmbus_identify;
        dev->platform_data = pdata;
 
        return pmbus_do_probe(client, id, info);
 }
 
+static const struct pmbus_device_info default_pmbus_info = {1, 0};
+static const struct pmbus_device_info dps460_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};
+static const struct pmbus_device_info dps800_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};
+static const struct pmbus_device_info sgd009_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};
+static const struct pmbus_device_info pmbus_info = {0, 0};
 /*
  * Use driver_data to set the number of pages supported by the chip.
  */
 static const struct i2c_device_id pmbus_id[] = {
-       {"adp4000", 1},
-       {"bmr453", 1},
-       {"bmr454", 1},
-       {"dps460", 1},
-       {"dps800", 1},
-       {"mdt040", 1},
-       {"ncp4200", 1},
-       {"ncp4208", 1},
-       {"pdt003", 1},
-       {"pdt006", 1},
-       {"pdt012", 1},
-       {"pmbus", 0},
-       {"sgd009", 1},
-       {"tps40400", 1},
-       {"tps544b20", 1},
-       {"tps544b25", 1},
-       {"tps544c20", 1},
-       {"tps544c25", 1},
-       {"udt020", 1},
+       {"adp4000", (kernel_ulong_t)&default_pmbus_info},
+       {"bmr453", (kernel_ulong_t)&default_pmbus_info},
+       {"bmr454", (kernel_ulong_t)&default_pmbus_info},
+       {"dps460", (kernel_ulong_t)&dps460_pmbus_info},
+       {"dps800", (kernel_ulong_t)&dps800_pmbus_info},
+       {"mdt040", (kernel_ulong_t)&default_pmbus_info},
+       {"ncp4200", (kernel_ulong_t)&default_pmbus_info},
+       {"ncp4208", (kernel_ulong_t)&default_pmbus_info},
+       {"pdt003", (kernel_ulong_t)&default_pmbus_info},
+       {"pdt006", (kernel_ulong_t)&default_pmbus_info},
+       {"pdt012", (kernel_ulong_t)&default_pmbus_info},
+       {"pmbus", (kernel_ulong_t)&pmbus_info},
+       {"sgd009", (kernel_ulong_t)&sgd009_pmbus_info},
+       {"tps40400", (kernel_ulong_t)&default_pmbus_info},
+       {"tps544b20", (kernel_ulong_t)&default_pmbus_info},
+       {"tps544b25", (kernel_ulong_t)&default_pmbus_info},
+       {"tps544c20", (kernel_ulong_t)&default_pmbus_info},
+       {"tps544c25", (kernel_ulong_t)&default_pmbus_info},
+       {"udt020", (kernel_ulong_t)&default_pmbus_info},
        {}
 };
 
include/linux/pmbus.h +5 -0
index ee3c2aba2a8e..3c05edad7666 100644
@@ -46,4 +46,9 @@ struct pmbus_platform_data {
        struct regulator_init_data *reg_init_data;
 };
 
+struct pmbus_device_info {
+       int pages;
+       u32 flags;
+};
+
 #endif /* _PMBUS_H_ */

--
1.8.3.1

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

#4 lore raw

PATCH 2/4 dt-bindings: power supply: Document dps650ab

In reply to a message not in the archive

Bindings for DPS650AB power, voltage, temperature, and fan monitering.

---
 Documentation/devicetree/bindings/hwmon/dps650ab.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/hwmon/dps650ab.txt new file +11 -0
new file mode 100644
index 000000000000..bbd601100e66
@@ -0,0 +1,11 @@
+Bindings for DPS650AB power, voltage, temperature, and fan monitering
+
+Required properties:
+- compatible : "dps650ab"
+- reg        : I2C address, one of 0x58, 0x59.
+
+Example:
+       dps650ab@58 {
+                   compatible = "dps650ab";
+                   reg = <0x58>;
+       };

--
1.8.3.1

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

#10 lore raw

PATCH 3/4 dts: dps650ab: add dps650ab device tree

In reply to a message not in the archive

Add dps650ab device tree to support power supply dps650ab driver.

---
 arch/arm/boot/dts/aspeed-bmc-arm-stardragon4800-rep2.dts | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/dts/aspeed-bmc-arm-stardragon4800-rep2.dts +10 -0
index bdfd8c9f3a7c..e7e59da6c9ae 100644
@@ -173,6 +173,16 @@
                        };
                };
        };
+
+       dps650ab at 58 {
+               compatible = "dps650ab";
+               reg = <0x58>;
+       };
+
+       dps650ab at 59 {
+               compatible = "dps650ab";
+               reg = <0x59>;
+       };
 };
 
 &i2c9 {

--
1.8.3.1

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

#11 lore raw

PATCH 4/4 pmbus (dps650ab): add power supply driver

In reply to a message not in the archive

The Delta dps650ab provides main power and standby power to server. dps650ab can be detected by MFR_ID and MFR_MODEL referring to manufacturer's feedback. This patch adds driver to moniter power supply status.

---
 drivers/hwmon/pmbus/Kconfig    |  10 +++++
 drivers/hwmon/pmbus/Makefile   |   1 +
 drivers/hwmon/pmbus/dps650ab.c | 100 +++++++++++++++++++++++++++++++++++++++++
 drivers/hwmon/pmbus/pmbus.c    |   3 ++
 4 files changed, 114 insertions(+)
drivers/hwmon/pmbus/Kconfig +10 -0
index 629cb45f8557..de4638396592 100644
@@ -184,4 +184,14 @@ config SENSORS_ZL6100
          This driver can also be built as a module. If so, the module will
          be called zl6100.
 
+config SENSORS_DPS650AB
+       tristate "Delta DPS650AB"
+       default n
+       help
+         If you say yes here you get hardware monitoring support for the
+         Delta DPS650AB controller.
+
+         This driver can also be built as a module. If so, the module will
+         be called dps650ab.
+
 endif # PMBUS
drivers/hwmon/pmbus/Makefile +1 -0
index ea0e39518c21..414818230a26 100644
@@ -21,3 +21,4 @@ obj-$(CONFIG_SENSORS_TPS53679)        += tps53679.o
 obj-$(CONFIG_SENSORS_UCD9000)  += ucd9000.o
 obj-$(CONFIG_SENSORS_UCD9200)  += ucd9200.o
 obj-$(CONFIG_SENSORS_ZL6100)   += zl6100.o
+obj-$(CONFIG_SENSORS_DPS650AB) += dps650ab.o
drivers/hwmon/pmbus/dps650ab.c new file +100 -0

100 lines not on this page · raw message

drivers/hwmon/pmbus/pmbus.c +3 -0
index aa4cf9636e99..930e8a3e2366 100644
@@ -204,6 +204,8 @@ static int pmbus_probe(struct i2c_client *client,
 static const struct pmbus_device_info sgd009_pmbus_info = {
                                1, PMBUS_SKIP_STATUS_CHECK};
 static const struct pmbus_device_info pmbus_info = {0, 0};
+static const struct pmbus_device_info dps650ab_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};
 /*
  * Use driver_data to set the number of pages supported by the chip.
  */
@@ -227,6 +229,7 @@ static int pmbus_probe(struct i2c_client *client,
        {"tps544c20", (kernel_ulong_t)&default_pmbus_info},
        {"tps544c25", (kernel_ulong_t)&default_pmbus_info},
        {"udt020", (kernel_ulong_t)&default_pmbus_info},
+       {"dps650ab", (kernel_ulong_t)&dps650ab_pmbus_info},
        {}
 };
 

--
1.8.3.1

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

maintainer
#12 lore raw

Re: [PATCH 4/4] pmbus (dps650ab): add power supply driver

Quoted 63 lines · Xiaoting Liu

The Delta dps650ab provides main power and standby power to server. dps650ab can be detected by MFR_ID and MFR_MODEL referring to manufacturer's feedback. This patch adds driver to moniter power supply status.

---
  drivers/hwmon/pmbus/Kconfig    |  10 +++++
  drivers/hwmon/pmbus/Makefile   |   1 +
  drivers/hwmon/pmbus/dps650ab.c | 100 +++++++++++++++++++++++++++++++++++++++++
  drivers/hwmon/pmbus/pmbus.c    |   3 ++
  4 files changed, 114 insertions(+)
drivers/hwmon/pmbus/Kconfig +10 -0
index 629cb45f8557..de4638396592 100644
@@ -184,4 +184,14 @@ config SENSORS_ZL6100
           This driver can also be built as a module. If so, the module will
           be called zl6100.
 
+config SENSORS_DPS650AB
+       tristate "Delta DPS650AB"
+       default n
+       help
+         If you say yes here you get hardware monitoring support for the
+         Delta DPS650AB controller.
+
+         This driver can also be built as a module. If so, the module will
+         be called dps650ab.
+
  endif # PMBUS
drivers/hwmon/pmbus/Makefile +1 -0
index ea0e39518c21..414818230a26 100644
@@ -21,3 +21,4 @@ obj-$(CONFIG_SENSORS_TPS53679)        += tps53679.o
  obj-$(CONFIG_SENSORS_UCD9000)  += ucd9000.o
  obj-$(CONFIG_SENSORS_UCD9200)  += ucd9200.o
  obj-$(CONFIG_SENSORS_ZL6100)   += zl6100.o
+obj-$(CONFIG_SENSORS_DPS650AB) += dps650ab.o
drivers/hwmon/pmbus/dps650ab.c new file +16 -0
new file mode 100644
index 000000000000..3c300e621f5a
@@ -0,0 +1,100 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Hardware monitoring driver for DELTA DPS650AB
+ *
+ * Copyright (c) 2018 Huaxintong Semiconductor Technology Co., Ltd.
+ */
+
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include "pmbus.h"
+
+#define DPS650AB_MFR_ID                        "DELTA"
+#define DPS650AB_MFR_MODEL             "DPS-650AB-16 A"

drivers/hwmon/pmbus/dps650ab.c line 26

Quoted 10 lines
drivers/hwmon/pmbus/dps650ab.c new file +10 -0
+
+static int dps650ab_probe(struct i2c_client *client,
+                        const struct i2c_device_id *id)
+{
+       struct pmbus_driver_info *info;
+       u8 buf[I2C_SMBUS_BLOCK_MAX];
+       int ret;
+
+       memset(buf, 0, I2C_SMBUS_BLOCK_MAX);
+

I don't think this is needed.

drivers/hwmon/pmbus/dps650ab.c line 39

Quoted 13 lines
drivers/hwmon/pmbus/dps650ab.c new file +13 -0
+       if (!i2c_check_functionality(client->adapter,
+                                    I2C_FUNC_SMBUS_READ_BYTE_DATA
+                               | I2C_FUNC_SMBUS_READ_WORD_DATA
+                               | I2C_FUNC_SMBUS_READ_BLOCK_DATA))
+               return -ENODEV;
+
+       ret = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
+       if (ret < 0) {
+               dev_err(&client->dev, "Failed to read PMBUS_MFR_ID\n");
+               return ret;
+       }
+
+       if (strncmp(buf, DPS650AB_MFR_ID, strlen(DPS650AB_MFR_ID))) {

It might make sense to verify the length of the returned string as well, unless strings such as "DELTAX" are accepted on purpose. But even if that is the case I would prefer an added check of "ret < strlen(DPS650AB_MFR_ID)" over the memset() above....

drivers/hwmon/pmbus/dps650ab.c line 50

Quoted 11 lines
drivers/hwmon/pmbus/dps650ab.c new file +11 -0
+               dev_err(&client->dev, "DPS650AB_MFR_ID unrecognised\n");
+               return -ENODEV;
+       }
+
+       ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
+       if (ret < 0) {
+               dev_err(&client->dev, "Failed to read PMBUS_MFR_MODEL\n");
+               return ret;
+       }
+
+       if (strncmp(buf, DPS650AB_MFR_MODEL, strlen(DPS650AB_MFR_MODEL))) {

... to ensure that nothing bad slips through here. As currently written, the code accepts a MFR_ID of "DELTA50AB-16 A" combined with a MFR_MODEL "DPS-6" as valid.

drivers/hwmon/pmbus/dps650ab.c line 51

Quoted 1 line
drivers/hwmon/pmbus/dps650ab.c new file +1 -0
+               dev_err(&client->dev, "DPS650AB_MFR_MODEL unrecognised\n");

It would be a nice touch to actually list the unrecognized model. Otherwise the message is quite useless. Same for MFR_ID.

Quoted 54 lines
drivers/hwmon/pmbus/dps650ab.c new file +49 -0
+               return -ENODEV;
+       }
+
+       info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL);
+       if (!info)
+               return -ENOMEM;
+
+       info->pages = 1;
+       info->format[PSC_VOLTAGE_IN] = linear;
+       info->format[PSC_VOLTAGE_OUT] = linear;
+       info->format[PSC_CURRENT_IN] = linear;
+       info->format[PSC_CURRENT_OUT] = linear;
+       info->format[PSC_POWER] = linear;
+       info->format[PSC_TEMPERATURE] = linear;
+
+       info->func[0] = PMBUS_HAVE_VIN
+               | PMBUS_HAVE_IIN | PMBUS_HAVE_PIN
+               | PMBUS_HAVE_STATUS_INPUT
+               | PMBUS_HAVE_POUT | PMBUS_HAVE_FAN12
+               | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
+               | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
+               | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2
+               | PMBUS_HAVE_STATUS_TEMP;
+       info->func[1] = info->func[0];
+
+       return pmbus_do_probe(client, id, info);
+}
+
+static const struct i2c_device_id dps650ab_id[] = {
+       {"dps650ab", 1},
+       {}
+};
+
+MODULE_DEVICE_TABLE(i2c, dps650ab_id);
+
+static struct i2c_driver dps650ab_driver = {
+       .driver = {
+               .name   = "dps650ab",
+       },
+       .probe          = dps650ab_probe,
+       .remove         = pmbus_do_remove,
+       .id_table       = dps650ab_id,
+};
+
+module_i2c_driver(dps650ab_driver);
+
+MODULE_AUTHOR("Liuxiaoting <[email protected]");
+MODULE_DESCRIPTION("PMBus driver for DPS650AB");
+MODULE_LICENSE("GPL v2");
drivers/hwmon/pmbus/pmbus.c +0 -0
index aa4cf9636e99..930e8a3e2366 100644

drivers/hwmon/pmbus/pmbus.c static int pmbus_probe(struct i2c_client *client, · line 208

Quoted 5 lines
drivers/hwmon/pmbus/pmbus.c +2 -0
@@ -204,6 +204,8 @@ static int pmbus_probe(struct i2c_client *client,
  static const struct pmbus_device_info sgd009_pmbus_info = {
                                 1, PMBUS_SKIP_STATUS_CHECK};
  static const struct pmbus_device_info pmbus_info = {0, 0};
+static const struct pmbus_device_info dps650ab_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};

Something is conceptually wrong here. Either this change or a new driver, but not both.

drivers/hwmon/pmbus/pmbus.c static int pmbus_probe(struct i2c_client *client, · line 232

Quoted 8 lines
drivers/hwmon/pmbus/pmbus.c +1 -0
  /*
   * Use driver_data to set the number of pages supported by the chip.
   */
@@ -227,6 +229,7 @@ static int pmbus_probe(struct i2c_client *client,
         {"tps544c20", (kernel_ulong_t)&default_pmbus_info},
         {"tps544c25", (kernel_ulong_t)&default_pmbus_info},
         {"udt020", (kernel_ulong_t)&default_pmbus_info},
+       {"dps650ab", (kernel_ulong_t)&dps650ab_pmbus_info},

Also, FWIW, this should be kept in alphabetic order.

Quoted 13 lines
drivers/hwmon/pmbus/pmbus.c +0 -1
         {}
  };
 
--

1.8.3.1

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

maintainer
#2 lore raw
In reply to Xiaoting Liu
Quoted 9 lines · Xiaoting Liu

Current code compares device name with name in i2c_device_id to decide whether PMBUS_SKIP_STATUS_CHECK should be set in pmbus_platform_data, which makes adding new devices with PMBUS_SKIP_STATUS_CHECK should also modify code in pmbus_probe().

This patch adds pmbus_device_info to save pages and flags. Its pointer is put in driver_data of i2c_device_id, which makes adding new device more straightforward.

Good idea, but I don't see at this time where the patch is needed. Maybe in patch 3/4 which is missing from the series ?

Quoted 38 lines
---
  drivers/hwmon/pmbus/pmbus.c | 54 +++++++++++++++++++++++++++------------------
  include/linux/pmbus.h       |  5 +++++
  2 files changed, 37 insertions(+), 22 deletions(-)
drivers/hwmon/pmbus/pmbus.c +5 -3
index 7688dab32f6e..aa4cf9636e99 100644
@@ -172,13 +172,15 @@ static int pmbus_probe(struct i2c_client *client,
         struct pmbus_driver_info *info;
         struct pmbus_platform_data *pdata = NULL;
         struct device *dev = &client->dev;
+       struct pmbus_device_info *device_info;
 
         info = devm_kzalloc(dev, sizeof(struct pmbus_driver_info), GFP_KERNEL);
         if (!info)
                 return -ENOMEM;
 
-       if (!strcmp(id->name, "dps460") || !strcmp(id->name, "dps800") ||
-           !strcmp(id->name, "sgd009")) {
+       device_info = (struct pmbus_device_info *)id->driver_data;
+
+       if (device_info->flags & PMBUS_SKIP_STATUS_CHECK) {
                 pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data),
                                      GFP_KERNEL);
                 if (!pdata)
@@ -187,36 +189,44 @@ static int pmbus_probe(struct i2c_client *client,
                 pdata->flags = PMBUS_SKIP_STATUS_CHECK;
         }
 
-       info->pages = id->driver_data;
+       info->pages = device_info->pages;
         info->identify = pmbus_identify;
         dev->platform_data = pdata;
 

drivers/hwmon/pmbus/pmbus.c static int pmbus_probe(struct i2c_client *client, · line 205

Quoted 10 lines
drivers/hwmon/pmbus/pmbus.c +7 -0
         return pmbus_do_probe(client, id, info);
  }
 
+static const struct pmbus_device_info default_pmbus_info = {1, 0};
+static const struct pmbus_device_info dps460_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};
+static const struct pmbus_device_info dps800_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};
+static const struct pmbus_device_info sgd009_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};

Three structures with exactly the same content does not add value. Please merge into one with a common name that reflects its use.

drivers/hwmon/pmbus/pmbus.c static int pmbus_probe(struct i2c_client *client, · line 206

Quoted 1 line
drivers/hwmon/pmbus/pmbus.c +1 -0
+static const struct pmbus_device_info pmbus_info = {0, 0};

default_pmbus_info and pmbus_info are badly named and ordered. The name should reflect that one sets one page and that the other leaves the number of pages unset.

I would suggest three structures and names, such as

pmbus_info_one
pmbus_info_one_skip
pmbus_info_zero

though I am open to better names.

Quoted 50 lines
drivers/hwmon/pmbus/pmbus.c +19 -19
  /*
   * Use driver_data to set the number of pages supported by the chip.
   */
  static const struct i2c_device_id pmbus_id[] = {
-       {"adp4000", 1},
-       {"bmr453", 1},
-       {"bmr454", 1},
-       {"dps460", 1},
-       {"dps800", 1},
-       {"mdt040", 1},
-       {"ncp4200", 1},
-       {"ncp4208", 1},
-       {"pdt003", 1},
-       {"pdt006", 1},
-       {"pdt012", 1},
-       {"pmbus", 0},
-       {"sgd009", 1},
-       {"tps40400", 1},
-       {"tps544b20", 1},
-       {"tps544b25", 1},
-       {"tps544c20", 1},
-       {"tps544c25", 1},
-       {"udt020", 1},
+       {"adp4000", (kernel_ulong_t)&default_pmbus_info},
+       {"bmr453", (kernel_ulong_t)&default_pmbus_info},
+       {"bmr454", (kernel_ulong_t)&default_pmbus_info},
+       {"dps460", (kernel_ulong_t)&dps460_pmbus_info},
+       {"dps800", (kernel_ulong_t)&dps800_pmbus_info},
+       {"mdt040", (kernel_ulong_t)&default_pmbus_info},
+       {"ncp4200", (kernel_ulong_t)&default_pmbus_info},
+       {"ncp4208", (kernel_ulong_t)&default_pmbus_info},
+       {"pdt003", (kernel_ulong_t)&default_pmbus_info},
+       {"pdt006", (kernel_ulong_t)&default_pmbus_info},
+       {"pdt012", (kernel_ulong_t)&default_pmbus_info},
+       {"pmbus", (kernel_ulong_t)&pmbus_info},
+       {"sgd009", (kernel_ulong_t)&sgd009_pmbus_info},
+       {"tps40400", (kernel_ulong_t)&default_pmbus_info},
+       {"tps544b20", (kernel_ulong_t)&default_pmbus_info},
+       {"tps544b25", (kernel_ulong_t)&default_pmbus_info},
+       {"tps544c20", (kernel_ulong_t)&default_pmbus_info},
+       {"tps544c25", (kernel_ulong_t)&default_pmbus_info},
+       {"udt020", (kernel_ulong_t)&default_pmbus_info},
         {}
  };
 
include/linux/pmbus.h +0 -0
index ee3c2aba2a8e..3c05edad7666 100644

include/linux/pmbus.h struct pmbus_platform_data { · line 53

Quoted 8 lines
include/linux/pmbus.h +5 -0
@@ -46,4 +46,9 @@ struct pmbus_platform_data {
         struct regulator_init_data *reg_init_data;
  };
 
+struct pmbus_device_info {
+       int pages;
+       u32 flags;
+};
+

This should not be needed here. The structure can be declared locally in pmbus.c (its use in patch 4/4 is wrong).

Quoted 11 lines
include/linux/pmbus.h +0 -1
  #endif /* _PMBUS_H_ */
--

1.8.3.1

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

maintainer
#5 lore raw

Re: [PATCH 2/4] dt-bindings: power supply: Document dps650ab

In reply to Xiaoting Liu
Quoted 2 lines · Xiaoting Liu

Bindings for DPS650AB power, voltage, temperature, and fan monitering.

Misleading subject. While the DPS650AB may ber a power supply, it is a PMBus hwmon driver, and should be marked accordingly in the subject.

Guenter

Quoted 30 lines
---
 Documentation/devicetree/bindings/hwmon/dps650ab.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)

--
1.8.3.1

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

Documentation/devicetree/bindings/hwmon/dps650ab.txt new file +11 -0
new file mode 100644
index 000000000000..bbd601100e66
@@ -0,0 +1,11 @@
+Bindings for DPS650AB power, voltage, temperature, and fan monitering
+
+Required properties:
+- compatible : "dps650ab"
+- reg        : I2C address, one of 0x58, 0x59.
+
+Example:
+       dps650ab@58 {
+                   compatible = "dps650ab";
+                   reg = <0x58>;
+       };
maintainer
#13 lore raw

Re: [PATCH 4/4] pmbus (dps650ab): add power supply driver

In reply to Xiaoting Liu
Quoted 5 lines · Xiaoting Liu

The Delta dps650ab provides main power and standby power to server. dps650ab can be detected by MFR_ID and MFR_MODEL referring to manufacturer's feedback. This patch adds driver to moniter power supply status.

Another comment: The subject should be something like
hwmon: (pmbus) Add driver for DPS650AB power supply

Additional comments inline below.

Thanks,
Guenter

Quoted 24 lines
---
 drivers/hwmon/pmbus/Kconfig    |  10 +++++
 drivers/hwmon/pmbus/Makefile   |   1 +
 drivers/hwmon/pmbus/dps650ab.c | 100 +++++++++++++++++++++++++++++++++++++++++
 drivers/hwmon/pmbus/pmbus.c    |   3 ++
 4 files changed, 114 insertions(+)

--
1.8.3.1

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

drivers/hwmon/pmbus/Kconfig +0 -0
index 629cb45f8557..de4638396592 100644
@@ -184,4 +184,14 @@ config SENSORS_ZL6100
          This driver can also be built as a module. If so, the module will
          be called zl6100.
 

drivers/hwmon/pmbus/Kconfig config SENSORS_ZL6100 · line 196

Quoted 10 lines
drivers/hwmon/pmbus/Kconfig +10 -0
+config SENSORS_DPS650AB
+       tristate "Delta DPS650AB"
+       default n
+       help
+         If you say yes here you get hardware monitoring support for the
+         Delta DPS650AB controller.
+
+         This driver can also be built as a module. If so, the module will
+         be called dps650ab.
+

Ahplabetic order, please.

drivers/hwmon/pmbus/Makefile obj-$(CONFIG_SENSORS_TPS53679) += tps53679.o · line 24

Quoted 10 lines
drivers/hwmon/pmbus/Kconfig +0 -0
 endif # PMBUS
drivers/hwmon/pmbus/Makefile +1 -0
index ea0e39518c21..414818230a26 100644
@@ -21,3 +21,4 @@ obj-$(CONFIG_SENSORS_TPS53679)        += tps53679.o
 obj-$(CONFIG_SENSORS_UCD9000)  += ucd9000.o
 obj-$(CONFIG_SENSORS_UCD9200)  += ucd9200.o
 obj-$(CONFIG_SENSORS_ZL6100)   += zl6100.o
+obj-$(CONFIG_SENSORS_DPS650AB) += dps650ab.o

Alphabetic order, please.

Quoted 126 lines
drivers/hwmon/pmbus/dps650ab.c new file +100 -0
new file mode 100644
index 000000000000..3c300e621f5a
@@ -0,0 +1,100 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Hardware monitoring driver for DELTA DPS650AB
+ *
+ * Copyright (c) 2018 Huaxintong Semiconductor Technology Co., Ltd.
+ */
+
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include "pmbus.h"
+
+#define DPS650AB_MFR_ID                        "DELTA"
+#define DPS650AB_MFR_MODEL             "DPS-650AB-16 A"
+
+static int dps650ab_probe(struct i2c_client *client,
+                        const struct i2c_device_id *id)
+{
+       struct pmbus_driver_info *info;
+       u8 buf[I2C_SMBUS_BLOCK_MAX];
+       int ret;
+
+       memset(buf, 0, I2C_SMBUS_BLOCK_MAX);
+
+       if (!i2c_check_functionality(client->adapter,
+                                    I2C_FUNC_SMBUS_READ_BYTE_DATA
+                               | I2C_FUNC_SMBUS_READ_WORD_DATA
+                               | I2C_FUNC_SMBUS_READ_BLOCK_DATA))
+               return -ENODEV;
+
+       ret = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
+       if (ret < 0) {
+               dev_err(&client->dev, "Failed to read PMBUS_MFR_ID\n");
+               return ret;
+       }
+
+       if (strncmp(buf, DPS650AB_MFR_ID, strlen(DPS650AB_MFR_ID))) {
+               dev_err(&client->dev, "DPS650AB_MFR_ID unrecognised\n");
+               return -ENODEV;
+       }
+
+       ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
+       if (ret < 0) {
+               dev_err(&client->dev, "Failed to read PMBUS_MFR_MODEL\n");
+               return ret;
+       }
+
+       if (strncmp(buf, DPS650AB_MFR_MODEL, strlen(DPS650AB_MFR_MODEL))) {
+               dev_err(&client->dev, "DPS650AB_MFR_MODEL unrecognised\n");
+               return -ENODEV;
+       }
+
+       info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL);
+       if (!info)
+               return -ENOMEM;
+
+       info->pages = 1;
+       info->format[PSC_VOLTAGE_IN] = linear;
+       info->format[PSC_VOLTAGE_OUT] = linear;
+       info->format[PSC_CURRENT_IN] = linear;
+       info->format[PSC_CURRENT_OUT] = linear;
+       info->format[PSC_POWER] = linear;
+       info->format[PSC_TEMPERATURE] = linear;
+
+       info->func[0] = PMBUS_HAVE_VIN
+               | PMBUS_HAVE_IIN | PMBUS_HAVE_PIN
+               | PMBUS_HAVE_STATUS_INPUT
+               | PMBUS_HAVE_POUT | PMBUS_HAVE_FAN12
+               | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
+               | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
+               | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2
+               | PMBUS_HAVE_STATUS_TEMP;
+       info->func[1] = info->func[0];
+
+       return pmbus_do_probe(client, id, info);
+}
+
+static const struct i2c_device_id dps650ab_id[] = {
+       {"dps650ab", 1},
+       {}
+};
+
+MODULE_DEVICE_TABLE(i2c, dps650ab_id);
+
+static struct i2c_driver dps650ab_driver = {
+       .driver = {
+               .name   = "dps650ab",
+       },
+       .probe          = dps650ab_probe,
+       .remove         = pmbus_do_remove,
+       .id_table       = dps650ab_id,
+};
+
+module_i2c_driver(dps650ab_driver);
+
+MODULE_AUTHOR("Liuxiaoting <[email protected]");
+MODULE_DESCRIPTION("PMBus driver for DPS650AB");
+MODULE_LICENSE("GPL v2");
drivers/hwmon/pmbus/pmbus.c +3 -0
index aa4cf9636e99..930e8a3e2366 100644
@@ -204,6 +204,8 @@ static int pmbus_probe(struct i2c_client *client,
 static const struct pmbus_device_info sgd009_pmbus_info = {
                                1, PMBUS_SKIP_STATUS_CHECK};
 static const struct pmbus_device_info pmbus_info = {0, 0};
+static const struct pmbus_device_info dps650ab_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};
 /*
  * Use driver_data to set the number of pages supported by the chip.
  */
@@ -227,6 +229,7 @@ static int pmbus_probe(struct i2c_client *client,
        {"tps544c20", (kernel_ulong_t)&default_pmbus_info},
        {"tps544c25", (kernel_ulong_t)&default_pmbus_info},
        {"udt020", (kernel_ulong_t)&default_pmbus_info},
+       {"dps650ab", (kernel_ulong_t)&dps650ab_pmbus_info},
        {}
 };
#3 lore raw
In reply to Guenter Roeck

Hi, Guenter,
Thanks for reply.

Quoted 6 lines · Guenter Roeck
Quoted 5 lines · Xiaoting Liu

Current code compares device name with name in i2c_device_id to decide whether PMBUS_SKIP_STATUS_CHECK should be set in pmbus_platform_data, which makes adding new devices with PMBUS_SKIP_STATUS_CHECK should also modify code in pmbus_probe().

Quoted 7 lines
Quoted 4 lines

This patch adds pmbus_device_info to save pages and flags. Its pointer is put in driver_data of i2c_device_id, which makes adding new device more straightforward.

Good idea, but I don't see at this time where the patch is needed. Maybe in patch 3/4 which is missing from the series ?

The reason we figure out this patch is that we want to add dps650ab to pmbus_id[] in pmbus.c. As dps650ab has flag of PMBUS_SKIP_STATUS_CHECK and we don't want to change pmbus_probe(), so make this patch as a premise patch.
As you stated that adding both dps650ab in pmbus.c and adding a separate dps650ab driver file is a conceptional mistake, I will work with Xiaoting to decide which approach we should use.

Quoted 42 lines
Quoted 42 lines
---
  drivers/hwmon/pmbus/pmbus.c | 54 +++++++++++++++++++++++++++------------------
  include/linux/pmbus.h       |  5 +++++
  2 files changed, 37 insertions(+), 22 deletions(-)
drivers/hwmon/pmbus/pmbus.c +5 -3
index 7688dab32f6e..aa4cf9636e99 100644
@@ -172,13 +172,15 @@ static int pmbus_probe(struct i2c_client *client,
         struct pmbus_driver_info *info;
         struct pmbus_platform_data *pdata = NULL;
         struct device *dev = &client->dev;
+       struct pmbus_device_info *device_info;
 
         info = devm_kzalloc(dev, sizeof(struct pmbus_driver_info), GFP_KERNEL);
         if (!info)
                 return -ENOMEM;
 
-       if (!strcmp(id->name, "dps460") || !strcmp(id->name, "dps800") ||
-           !strcmp(id->name, "sgd009")) {
+       device_info = (struct pmbus_device_info *)id->driver_data;
+
+       if (device_info->flags & PMBUS_SKIP_STATUS_CHECK) {
                 pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data),
                                      GFP_KERNEL);
                 if (!pdata)
@@ -187,36 +189,44 @@ static int pmbus_probe(struct i2c_client *client,
                 pdata->flags = PMBUS_SKIP_STATUS_CHECK;
         }
 
-       info->pages = id->driver_data;
+       info->pages = device_info->pages;
         info->identify = pmbus_identify;
         dev->platform_data = pdata;
 
         return pmbus_do_probe(client, id, info);
  }
 
Quoted 11 lines

drivers/hwmon/pmbus/pmbus.c static int pmbus_probe(struct i2c_client *client, · line 205

Quoted 7 lines
drivers/hwmon/pmbus/pmbus.c +7 -0
+static const struct pmbus_device_info default_pmbus_info = {1, 0};
+static const struct pmbus_device_info dps460_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};
+static const struct pmbus_device_info dps800_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};
+static const struct pmbus_device_info sgd009_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};

Three structures with exactly the same content does not add value. Please merge into one with a common name that reflects its use.

Thanks. we will following you suggestion to use common name as pmbus_info_one_skip.

Quoted 6 lines

drivers/hwmon/pmbus/pmbus.c static int pmbus_probe(struct i2c_client *client, · line 206

Quoted 1 line
drivers/hwmon/pmbus/pmbus.c +1 -0
+static const struct pmbus_device_info pmbus_info = {0, 0};

default_pmbus_info and pmbus_info are badly named and ordered. The name should reflect that one sets one page and that the other leaves the number of pages unset.

Quoted 7 lines

I would suggest three structures and names, such as

pmbus_info_one
pmbus_info_one_skip
pmbus_info_zero

though I am open to better names.

Thanks. We will change.

Quoted 54 lines
Quoted 54 lines
drivers/hwmon/pmbus/pmbus.c +19 -19
  /*
   * Use driver_data to set the number of pages supported by the chip.
   */
  static const struct i2c_device_id pmbus_id[] = {
-       {"adp4000", 1},
-       {"bmr453", 1},
-       {"bmr454", 1},
-       {"dps460", 1},
-       {"dps800", 1},
-       {"mdt040", 1},
-       {"ncp4200", 1},
-       {"ncp4208", 1},
-       {"pdt003", 1},
-       {"pdt006", 1},
-       {"pdt012", 1},
-       {"pmbus", 0},
-       {"sgd009", 1},
-       {"tps40400", 1},
-       {"tps544b20", 1},
-       {"tps544b25", 1},
-       {"tps544c20", 1},
-       {"tps544c25", 1},
-       {"udt020", 1},
+       {"adp4000", (kernel_ulong_t)&default_pmbus_info},
+       {"bmr453", (kernel_ulong_t)&default_pmbus_info},
+       {"bmr454", (kernel_ulong_t)&default_pmbus_info},
+       {"dps460", (kernel_ulong_t)&dps460_pmbus_info},
+       {"dps800", (kernel_ulong_t)&dps800_pmbus_info},
+       {"mdt040", (kernel_ulong_t)&default_pmbus_info},
+       {"ncp4200", (kernel_ulong_t)&default_pmbus_info},
+       {"ncp4208", (kernel_ulong_t)&default_pmbus_info},
+       {"pdt003", (kernel_ulong_t)&default_pmbus_info},
+       {"pdt006", (kernel_ulong_t)&default_pmbus_info},
+       {"pdt012", (kernel_ulong_t)&default_pmbus_info},
+       {"pmbus", (kernel_ulong_t)&pmbus_info},
+       {"sgd009", (kernel_ulong_t)&sgd009_pmbus_info},
+       {"tps40400", (kernel_ulong_t)&default_pmbus_info},
+       {"tps544b20", (kernel_ulong_t)&default_pmbus_info},
+       {"tps544b25", (kernel_ulong_t)&default_pmbus_info},
+       {"tps544c20", (kernel_ulong_t)&default_pmbus_info},
+       {"tps544c25", (kernel_ulong_t)&default_pmbus_info},
+       {"udt020", (kernel_ulong_t)&default_pmbus_info},
         {}
  };
 
include/linux/pmbus.h +0 -0
index ee3c2aba2a8e..3c05edad7666 100644
@@ -46,4 +46,9 @@ struct pmbus_platform_data {
         struct regulator_init_data *reg_init_data;
  };
 
Quoted 9 lines

include/linux/pmbus.h struct pmbus_platform_data { · line 53

Quoted 5 lines
include/linux/pmbus.h +5 -0
+struct pmbus_device_info {
+       int pages;
+       u32 flags;
+};
+

This should not be needed here. The structure can be declared locally in pmbus.c (its use in patch 4/4 is wrong).

OK. We will move the structure back to pmbus.c. And we will decide whether we need 4/4.

Thanks.
Shunyong.

Quoted 13 lines
Quoted 11 lines
include/linux/pmbus.h +0 -1
  #endif /* _PMBUS_H_ */
--

1.8.3.1

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

#14 lore raw

Re: [PATCH 4/4] pmbus (dps650ab): add power supply driver

In reply to Guenter Roeck

Hi Guenter Roeck,

Thanks for your apply, we will drop this patch and add the struct pmbus_device_info in PMBus.c.

Thanks,
Xiaoting.

On 2019/1/6 1:08, Guenter Roeck wrote:

On Fri, Jan 04, 2019 at 05:05:27PM +0800, Xiaoting Liu wrote:

The Delta dps650ab provides main power and standby power to server. dps650ab can be detected by MFR_ID and MFR_MODEL referring to manufacturer's feedback. This patch adds driver to moniter power supply status.

Another comment: The subject should be something like
hwmon: (pmbus) Add driver for DPS650AB power supply

Additional comments inline below.

Thanks,
Guenter

---
 drivers/hwmon/pmbus/Kconfig    |  10 +++++
 drivers/hwmon/pmbus/Makefile   |   1 +
 drivers/hwmon/pmbus/dps650ab.c | 100 +++++++++++++++++++++++++++++++++++++++++
 drivers/hwmon/pmbus/pmbus.c    |   3 ++
 4 files changed, 114 insertions(+)

--
1.8.3.1

drivers/hwmon/pmbus/Kconfig +10 -0
index 629cb45f8557..de4638396592 100644
@@ -184,4 +184,14 @@ config SENSORS_ZL6100
          This driver can also be built as a module. If so, the module will
          be called zl6100.
 
+config SENSORS_DPS650AB
+       tristate "Delta DPS650AB"
+       default n
+       help
+         If you say yes here you get hardware monitoring support for the
+         Delta DPS650AB controller.
+
+         This driver can also be built as a module. If so, the module will
+         be called dps650ab.
+
 

Ahplabetic order, please.

endif # PMBUS

drivers/hwmon/pmbus/Makefile +1 -0
index ea0e39518c21..414818230a26 100644
@@ -21,3 +21,4 @@ obj-$(CONFIG_SENSORS_TPS53679)        += tps53679.o
 obj-$(CONFIG_SENSORS_UCD9000)  += ucd9000.o
 obj-$(CONFIG_SENSORS_UCD9200)  += ucd9200.o
 obj-$(CONFIG_SENSORS_ZL6100)   += zl6100.o
+obj-$(CONFIG_SENSORS_DPS650AB) += dps650ab.o

Alphabetic order, please.

drivers/hwmon/pmbus/dps650ab.c new file +100 -0

100 lines not on this page · raw message

drivers/hwmon/pmbus/pmbus.c +3 -0
index aa4cf9636e99..930e8a3e2366 100644
@@ -204,6 +204,8 @@ static int pmbus_probe(struct i2c_client *client,
 static const struct pmbus_device_info sgd009_pmbus_info = {
                                1, PMBUS_SKIP_STATUS_CHECK};
 static const struct pmbus_device_info pmbus_info = {0, 0};
+static const struct pmbus_device_info dps650ab_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};
 /*
  * Use driver_data to set the number of pages supported by the chip.
  */
@@ -227,6 +229,7 @@ static int pmbus_probe(struct i2c_client *client,
        {"tps544c20", (kernel_ulong_t)&default_pmbus_info},
        {"tps544c25", (kernel_ulong_t)&default_pmbus_info},
        {"udt020", (kernel_ulong_t)&default_pmbus_info},
+       {"dps650ab", (kernel_ulong_t)&dps650ab_pmbus_info},
        {}
 };
 

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

#6 lore raw

Re: [PATCH 2/4] dt-bindings: power supply: Document dps650ab

In reply to Guenter Roeck

Hi Guenter Roeck,

Thanks for your reply.

Quoted 7 lines · Guenter Roeck
Quoted 2 lines · Xiaoting Liu

Bindings for DPS650AB power, voltage, temperature, and fan monitering.

Misleading subject. While the DPS650AB may ber a power supply, it is a PMBus hwmon driver, and should be marked accordingly in the subject.

Guenter

We will change the subject as "dt-bindings: hwmon: Add dps650ab documentation", is that okey?

Thanks,

Xiaoting.

Quoted 19 lines
Quoted 19 lines
---
 Documentation/devicetree/bindings/hwmon/dps650ab.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)

--
1.8.3.1

Documentation/devicetree/bindings/hwmon/dps650ab.txt new file +3 -0
new file mode 100644
index 000000000000..bbd601100e66
@@ -0,0 +1,11 @@
+Bindings for DPS650AB power, voltage, temperature, and fan monitering
+
+Required properties:
Quoted 8 lines

Documentation/devicetree/bindings/hwmon/dps650ab.txt line 11

Quoted 8 lines
Documentation/devicetree/bindings/hwmon/dps650ab.txt new file +8 -0
+- compatible : "dps650ab"
+- reg        : I2C address, one of 0x58, 0x59.
+
+Example:
+       dps650ab@58 {
+                   compatible = "dps650ab";
+                   reg = <0x58>;
+       };

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

maintainer
#15 lore raw

Re: [PATCH 4/4] pmbus (dps650ab): add power supply driver

In reply to Liu, Xiaoting
Quoted 4 lines · Xiaoting

Hi Guenter Roeck,

Thanks for your apply, we will drop this patch and add the structpmbus_device_info in PMBus.c.

NP. Make sure though that the auto-detection finds all properties. If it does, there is really no reason to have an extra driver.

Thanks,
Guenter

Quoted 196 lines

Thanks,
Xiaoting.

Quoted 175 lines · Guenter Roeck
Quoted 5 lines · Xiaoting Liu

The Delta dps650ab provides main power and standby power to server. dps650ab can be detected by MFR_ID and MFR_MODEL referring to manufacturer's feedback. This patch adds driver to moniter power supply status.

Another comment: The subject should be something like
hwmon: (pmbus) Add driver for DPS650AB power supply

Additional comments inline below.

Thanks,
Guenter

Quoted 20 lines
---
  drivers/hwmon/pmbus/Kconfig    |  10 +++++
  drivers/hwmon/pmbus/Makefile   |   1 +
  drivers/hwmon/pmbus/dps650ab.c | 100 +++++++++++++++++++++++++++++++++++++++++
  drivers/hwmon/pmbus/pmbus.c    |   3 ++
  4 files changed, 114 insertions(+)

--
1.8.3.1

drivers/hwmon/pmbus/Kconfig +0 -0
index 629cb45f8557..de4638396592 100644
@@ -184,4 +184,14 @@ config SENSORS_ZL6100
           This driver can also be built as a module. If so, the module will
           be called zl6100.
 

drivers/hwmon/pmbus/Kconfig config SENSORS_ZL6100 · line 196

Quoted 10 lines
drivers/hwmon/pmbus/Kconfig +10 -0
+config SENSORS_DPS650AB
+       tristate "Delta DPS650AB"
+       default n
+       help
+         If you say yes here you get hardware monitoring support for the
+         Delta DPS650AB controller.
+
+         This driver can also be built as a module. If so, the module will
+         be called dps650ab.
+

Ahplabetic order, please.

drivers/hwmon/pmbus/Makefile obj-$(CONFIG_SENSORS_TPS53679) += tps53679.o · line 24

Quoted 10 lines
drivers/hwmon/pmbus/Kconfig +0 -0
  endif # PMBUS
drivers/hwmon/pmbus/Makefile +1 -0
index ea0e39518c21..414818230a26 100644
@@ -21,3 +21,4 @@ obj-$(CONFIG_SENSORS_TPS53679)        += tps53679.o
  obj-$(CONFIG_SENSORS_UCD9000)  += ucd9000.o
  obj-$(CONFIG_SENSORS_UCD9200)  += ucd9200.o
  obj-$(CONFIG_SENSORS_ZL6100)   += zl6100.o
+obj-$(CONFIG_SENSORS_DPS650AB) += dps650ab.o

Alphabetic order, please.

Quoted 118 lines
drivers/hwmon/pmbus/dps650ab.c new file +100 -0
new file mode 100644
index 000000000000..3c300e621f5a
@@ -0,0 +1,100 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Hardware monitoring driver for DELTA DPS650AB
+ *
+ * Copyright (c) 2018 Huaxintong Semiconductor Technology Co., Ltd.
+ */
+
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include "pmbus.h"
+
+#define DPS650AB_MFR_ID                        "DELTA"
+#define DPS650AB_MFR_MODEL             "DPS-650AB-16 A"
+
+static int dps650ab_probe(struct i2c_client *client,
+                        const struct i2c_device_id *id)
+{
+       struct pmbus_driver_info *info;
+       u8 buf[I2C_SMBUS_BLOCK_MAX];
+       int ret;
+
+       memset(buf, 0, I2C_SMBUS_BLOCK_MAX);
+
+       if (!i2c_check_functionality(client->adapter,
+                                    I2C_FUNC_SMBUS_READ_BYTE_DATA
+                               | I2C_FUNC_SMBUS_READ_WORD_DATA
+                               | I2C_FUNC_SMBUS_READ_BLOCK_DATA))
+               return -ENODEV;
+
+       ret = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
+       if (ret < 0) {
+               dev_err(&client->dev, "Failed to read PMBUS_MFR_ID\n");
+               return ret;
+       }
+
+       if (strncmp(buf, DPS650AB_MFR_ID, strlen(DPS650AB_MFR_ID))) {
+               dev_err(&client->dev, "DPS650AB_MFR_ID unrecognised\n");
+               return -ENODEV;
+       }
+
+       ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
+       if (ret < 0) {
+               dev_err(&client->dev, "Failed to read PMBUS_MFR_MODEL\n");
+               return ret;
+       }
+
+       if (strncmp(buf, DPS650AB_MFR_MODEL, strlen(DPS650AB_MFR_MODEL))) {
+               dev_err(&client->dev, "DPS650AB_MFR_MODEL unrecognised\n");
+               return -ENODEV;
+       }
+
+       info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL);
+       if (!info)
+               return -ENOMEM;
+
+       info->pages = 1;
+       info->format[PSC_VOLTAGE_IN] = linear;
+       info->format[PSC_VOLTAGE_OUT] = linear;
+       info->format[PSC_CURRENT_IN] = linear;
+       info->format[PSC_CURRENT_OUT] = linear;
+       info->format[PSC_POWER] = linear;
+       info->format[PSC_TEMPERATURE] = linear;
+
+       info->func[0] = PMBUS_HAVE_VIN
+               | PMBUS_HAVE_IIN | PMBUS_HAVE_PIN
+               | PMBUS_HAVE_STATUS_INPUT
+               | PMBUS_HAVE_POUT | PMBUS_HAVE_FAN12
+               | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
+               | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
+               | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2
+               | PMBUS_HAVE_STATUS_TEMP;
+       info->func[1] = info->func[0];
+
+       return pmbus_do_probe(client, id, info);
+}
+
+static const struct i2c_device_id dps650ab_id[] = {
+       {"dps650ab", 1},
+       {}
+};
+
+MODULE_DEVICE_TABLE(i2c, dps650ab_id);
+
+static struct i2c_driver dps650ab_driver = {
+       .driver = {
+               .name   = "dps650ab",
+       },
+       .probe          = dps650ab_probe,
+       .remove         = pmbus_do_remove,
+       .id_table       = dps650ab_id,
+};
+
+module_i2c_driver(dps650ab_driver);
+
+MODULE_AUTHOR("Liuxiaoting <[email protected]");
+MODULE_DESCRIPTION("PMBus driver for DPS650AB");
+MODULE_LICENSE("GPL v2");
drivers/hwmon/pmbus/pmbus.c +2 -0
index aa4cf9636e99..930e8a3e2366 100644
@@ -204,6 +204,8 @@ static int pmbus_probe(struct i2c_client *client,
  static const struct pmbus_device_info sgd009_pmbus_info = {
                                 1, PMBUS_SKIP_STATUS_CHECK};
  static const struct pmbus_device_info pmbus_info = {0, 0};
+static const struct pmbus_device_info dps650ab_pmbus_info = {
+                               1, PMBUS_SKIP_STATUS_CHECK};
  /*
   * Use driver_data to set the number of pages supported by the chip.
Quoted 8 lines

drivers/hwmon/pmbus/pmbus.c static int pmbus_probe(struct i2c_client *client, · line 234

Quoted 8 lines
drivers/hwmon/pmbus/pmbus.c +1 -0
   */
@@ -227,6 +229,7 @@ static int pmbus_probe(struct i2c_client *client,
         {"tps544c20", (kernel_ulong_t)&default_pmbus_info},
         {"tps544c25", (kernel_ulong_t)&default_pmbus_info},
         {"udt020", (kernel_ulong_t)&default_pmbus_info},
+       {"dps650ab", (kernel_ulong_t)&dps650ab_pmbus_info},
         {}
  };

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

maintainer
#7 lore raw

Re: [PATCH 2/4] dt-bindings: power supply: Document dps650ab

In reply to Liu, Xiaoting
Quoted 8 lines · Xiaoting

Hi Guenter Roeck,

Thanks for your reply.

Quoted 3 lines · Guenter Roeck
Quoted 2 lines · Xiaoting Liu

Bindings for DPS650AB power, voltage, temperature, and fan monitering.

Quoted 8 lines
Quoted 4 lines

Misleading subject. While the DPS650AB may ber a power supply, it is a PMBus hwmon driver, and should be marked accordingly in the subject.

Guenter

We will change the subject as "dt-bindings: hwmon: Add dps650ab documentation", is that okey?

Sure.

Thanks,
Guenter

Quoted 40 lines

Thanks,

Xiaoting.

Quoted 19 lines
Quoted 19 lines
---
  Documentation/devicetree/bindings/hwmon/dps650ab.txt | 11 +++++++++++
  1 file changed, 11 insertions(+)

--
1.8.3.1

Documentation/devicetree/bindings/hwmon/dps650ab.txt new file +3 -0
new file mode 100644
index 000000000000..bbd601100e66
@@ -0,0 +1,11 @@
+Bindings for DPS650AB power, voltage, temperature, and fan monitering
+
+Required properties:
Quoted 8 lines

Documentation/devicetree/bindings/hwmon/dps650ab.txt line 11

Quoted 8 lines
Documentation/devicetree/bindings/hwmon/dps650ab.txt new file +8 -0
+- compatible : "dps650ab"
+- reg        : I2C address, one of 0x58, 0x59.
+
+Example:
+       dps650ab@58 {
+                   compatible = "dps650ab";
+                   reg = <0x58>;
+       };

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

maintainer
#8 lore raw

Re: [PATCH 2/4] dt-bindings: power supply: Document dps650ab

In reply to Xiaoting Liu
Quoted 1 line · Xiaoting Liu

Bindings for DPS650AB power, voltage, temperature, and fan monitering.

s/monitering/monitoring/

Quoted 12 lines
---
 Documentation/devicetree/bindings/hwmon/dps650ab.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/hwmon/dps650ab.txt new file +0 -0
new file mode 100644
index 000000000000..bbd601100e66

Documentation/devicetree/bindings/hwmon/dps650ab.txt line 4

Quoted 4 lines
Documentation/devicetree/bindings/hwmon/dps650ab.txt new file +4 -0
@@ -0,0 +1,11 @@
+Bindings for DPS650AB power, voltage, temperature, and fan monitering
+
+Required properties:
+- compatible : "dps650ab"

Needs a vendor prefix.

Quoted 13 lines
Documentation/devicetree/bindings/hwmon/dps650ab.txt new file +7 -1
+- reg        : I2C address, one of 0x58, 0x59.
+
+Example:
+       dps650ab@58 {
+                   compatible = "dps650ab";
+                   reg = <0x58>;
+       };
--

1.8.3.1

Quoted 1 line

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

We can't accept emails with these clauses.

Rob

#9 lore raw

Re: [PATCH 2/4] dt-bindings: power supply: Document dps650ab

Hi Rob Herring,

Thanks for your reply.

Quoted 3 lines · Rob Herring
Quoted 1 line · Xiaoting Liu

Bindings for DPS650AB power, voltage, temperature, and fan monitering.

s/monitering/monitoring/

I delivered the latest v3 patch and updated the subject. you can refer to the following link:

https://patchwork.ozlabs.org/patch/1022664/

Quoted 6 lines
Quoted 6 lines
---
 Documentation/devicetree/bindings/hwmon/dps650ab.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)
Quoted 11 lines

Documentation/devicetree/bindings/hwmon/dps650ab.txt line 4

Quoted 10 lines
Documentation/devicetree/bindings/hwmon/dps650ab.txt new file +4 -0
new file mode 100644
index 000000000000..bbd601100e66
@@ -0,0 +1,11 @@
+Bindings for DPS650AB power, voltage, temperature, and fan monitering
+
+Required properties:
+- compatible : "dps650ab"

Needs a vendor prefix.g

Add vendor delta on v3 patch.

Quoted 14 lines
Quoted 14 lines
Documentation/devicetree/bindings/hwmon/dps650ab.txt new file +7 -1
+- reg        : I2C address, one of 0x58, 0x59.
+
+Example:
+       dps650ab@58 {
+                   compatible = "dps650ab";
+                   reg = <0x58>;
+       };
--

1.8.3.1

Quoted 4 lines
Quoted 1 line

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

We can't accept emails with these clauses.

Rob

Delete the message on v3 patch.

Thanks,

Xiaoting