From patchwork Fri Jan 4 08:55:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liu, Xiaoting" X-Patchwork-Id: 10748193 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E8501575 for ; Fri, 4 Jan 2019 08:56:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F187927F94 for ; Fri, 4 Jan 2019 08:56:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E54CF27FA1; Fri, 4 Jan 2019 08:56:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 952B227FA8 for ; Fri, 4 Jan 2019 08:56:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727219AbfADI4E convert rfc822-to-8bit (ORCPT ); Fri, 4 Jan 2019 03:56:04 -0500 Received: from mx01.hxt-semitech.com ([223.203.96.7]:46671 "EHLO barracuda.hxt-semitech.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727006AbfADI4E (ORCPT ); Fri, 4 Jan 2019 03:56:04 -0500 X-ASG-Debug-ID: 1546592159-093b7e2d8806ba0001-LXWHwZ Received: from HXTBJIDCEMVIW02.hxtcorp.net ([10.128.0.15]) by barracuda.hxt-semitech.com with ESMTP id 898rFEhDEaL4TxcG (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Fri, 04 Jan 2019 16:55:59 +0800 (CST) X-Barracuda-Envelope-From: xiaoting.liu@hxt-semitech.com Received: from openbmc001.localdomain (10.5.21.169) by HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 4 Jan 2019 16:55:55 +0800 From: Xiaoting Liu To: , CC: , , , Xiaoting Liu , Shunyong Yang Subject: [PATCH 1/4] pmbus: associate PMBUS_SKIP_STATUS_CHECK with driver_data Date: Fri, 4 Jan 2019 16:55:51 +0800 X-ASG-Orig-Subj: [PATCH 1/4] pmbus: associate PMBUS_SKIP_STATUS_CHECK with driver_data Message-ID: <680b4d5659971cc4f6e1a6878837c2ce49962a7c.1546591275.git.xiaoting.liu@hxt-semitech.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.5.21.169] X-ClientProxiedBy: HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) To HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) X-Barracuda-Connect: UNKNOWN[10.128.0.15] X-Barracuda-Start-Time: 1546592159 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA384 X-Barracuda-URL: https://192.168.50.101:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at hxt-semitech.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.4997 1.0000 0.0000 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.65068 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Shunyong Yang Signed-off-by: Xiaoting Liu --- drivers/hwmon/pmbus/pmbus.c | 54 +++++++++++++++++++++++++++------------------ include/linux/pmbus.h | 5 +++++ 2 files changed, 37 insertions(+), 22 deletions(-) -- 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. diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c index 7688dab32f6e..aa4cf9636e99 100644 --- a/drivers/hwmon/pmbus/pmbus.c +++ b/drivers/hwmon/pmbus/pmbus.c @@ -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}, {} }; diff --git a/include/linux/pmbus.h b/include/linux/pmbus.h index ee3c2aba2a8e..3c05edad7666 100644 --- a/include/linux/pmbus.h +++ b/include/linux/pmbus.h @@ -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_ */ From patchwork Fri Jan 4 09:00:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liu, Xiaoting" X-Patchwork-Id: 10748205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0333E14DE for ; Fri, 4 Jan 2019 09:00:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E613A281E1 for ; Fri, 4 Jan 2019 09:00:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA152281F9; Fri, 4 Jan 2019 09:00:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA342281D2 for ; Fri, 4 Jan 2019 09:00:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726800AbfADJAm convert rfc822-to-8bit (ORCPT ); Fri, 4 Jan 2019 04:00:42 -0500 Received: from mx01.hxt-semitech.com ([223.203.96.7]:46780 "EHLO barracuda.hxt-semitech.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726169AbfADJAm (ORCPT ); Fri, 4 Jan 2019 04:00:42 -0500 X-ASG-Debug-ID: 1546592435-093b7e2d8806ce0001-LXWHwZ Received: from HXTBJIDCEMVIW02.hxtcorp.net ([10.128.0.15]) by barracuda.hxt-semitech.com with ESMTP id rQoOjMKkHviXEInX (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Fri, 04 Jan 2019 17:00:36 +0800 (CST) X-Barracuda-Envelope-From: xiaoting.liu@hxt-semitech.com Received: from openbmc001.localdomain (10.5.21.169) by HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 4 Jan 2019 17:00:32 +0800 From: Xiaoting Liu To: , , , CC: , , , , , Xiaoting Liu Subject: [PATCH 2/4] dt-bindings: power supply: Document dps650ab Date: Fri, 4 Jan 2019 17:00:30 +0800 X-ASG-Orig-Subj: [PATCH 2/4] dt-bindings: power supply: Document dps650ab Message-ID: <8540dfc96a75a6aa4bd1a7d5f24db7d36a71282c.1546591275.git.xiaoting.liu@hxt-semitech.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.5.21.169] X-ClientProxiedBy: HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) To HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) X-Barracuda-Connect: UNKNOWN[10.128.0.15] X-Barracuda-Start-Time: 1546592436 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA384 X-Barracuda-URL: https://192.168.50.101:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at hxt-semitech.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.5000 1.0000 0.0000 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.65068 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Bindings for DPS650AB power, voltage, temperature, and fan monitering. Signed-off-by: Xiaoting Liu --- 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. diff --git a/Documentation/devicetree/bindings/hwmon/dps650ab.txt b/Documentation/devicetree/bindings/hwmon/dps650ab.txt new file mode 100644 index 000000000000..bbd601100e66 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/dps650ab.txt @@ -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>; + }; From patchwork Fri Jan 4 09:05:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liu, Xiaoting" X-Patchwork-Id: 10748211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 559CD14E2 for ; Fri, 4 Jan 2019 09:05:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 451F32040D for ; Fri, 4 Jan 2019 09:05:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38F30281E1; Fri, 4 Jan 2019 09:05:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 739282040D for ; Fri, 4 Jan 2019 09:05:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726201AbfADJFx convert rfc822-to-8bit (ORCPT ); Fri, 4 Jan 2019 04:05:53 -0500 Received: from mx01.hxt-semitech.com ([223.203.96.7]:46844 "EHLO barracuda.hxt-semitech.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726053AbfADJFw (ORCPT ); Fri, 4 Jan 2019 04:05:52 -0500 X-ASG-Debug-ID: 1546592732-093b7e2d8806e40001-LXWHwZ Received: from HXTBJIDCEMVIW02.hxtcorp.net ([10.128.0.15]) by barracuda.hxt-semitech.com with ESMTP id oSRiYDxuaajOOtxM (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Fri, 04 Jan 2019 17:05:32 +0800 (CST) X-Barracuda-Envelope-From: xiaoting.liu@hxt-semitech.com Received: from openbmc001.localdomain (10.5.21.169) by HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 4 Jan 2019 17:05:28 +0800 From: Xiaoting Liu To: , CC: , , , , , Xiaoting Liu Subject: [PATCH 4/4] pmbus (dps650ab): add power supply driver Date: Fri, 4 Jan 2019 17:05:27 +0800 X-ASG-Orig-Subj: [PATCH 4/4] pmbus (dps650ab): add power supply driver Message-ID: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.5.21.169] X-ClientProxiedBy: HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) To HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) X-Barracuda-Connect: UNKNOWN[10.128.0.15] X-Barracuda-Start-Time: 1546592732 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA384 X-Barracuda-URL: https://192.168.50.101:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at hxt-semitech.com X-Barracuda-Bayes: INNOCENT GLOBAL 0.5000 1.0000 0.7500 X-Barracuda-Spam-Score: 0.75 X-Barracuda-Spam-Status: No, SCORE=0.75 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.65068 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Xiaoting Liu --- 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. diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index 629cb45f8557..de4638396592 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -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 diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile index ea0e39518c21..414818230a26 100644 --- a/drivers/hwmon/pmbus/Makefile +++ b/drivers/hwmon/pmbus/Makefile @@ -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 diff --git a/drivers/hwmon/pmbus/dps650ab.c b/drivers/hwmon/pmbus/dps650ab.c new file mode 100644 index 000000000000..3c300e621f5a --- /dev/null +++ b/drivers/hwmon/pmbus/dps650ab.c @@ -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 +#include +#include +#include +#include +#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