Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp532673imu; Fri, 4 Jan 2019 02:28:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN6YT4fS/3YBg17N52OPWzX3wFl8f0WTfmMcRbuiPsD3af+aWZlaNdteSkgJhefK4OFxnEWu X-Received: by 2002:a63:a41:: with SMTP id z1mr1138647pgk.117.1546597697036; Fri, 04 Jan 2019 02:28:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546597696; cv=none; d=google.com; s=arc-20160816; b=hyjHo1YUhS2EgWCx+rGA8pbfzAb9ZSBR3v8nMmSEYVD3syBHjh2T+jyaJs8pzjiNy2 03cAfODra43uu29y7vMJ/L2417sSwm8nR8dECXC5nQVEbTnBMZqzUvEpLDILTMfNN5i6 eCBfLiBnD5vN0UCmLk+NXnKDH90MNeZ24T5o6/WDvcJ9mO43SP3F16obbicI8j+iJeUs BL/FlwnWE72mXk5Oe5Ys1r34BbenyKkXKSFQ3knRwun7jG/EpvIjV9vKBkWo1j1HUuVh ystAPyIsXAUl//ef0ZIvTCQuiX9flYw58H9sFqRE9iB9nEeZ9aHfNayqJ7UMdGDNBEj/ DKkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Mum7/cy4Pfre2KnjQL/QHZED/xhCXOBQHBuPWQOLkAE=; b=vMlb7UZ6R8OjJ9XZOWFbSB3pxvS5ts5uuJiiYvX2570TrQ8B+w8VqTIsa4e8Zj5TE6 1lDWjFfz5EBjDlU83bht/noyhd3B9i1xBw3CDNJyFI6C+U1OrHra75z+vZGqzW5ovOZG UK1weocRVdS3WUe0XEwaLK3yjfh3Ko6vC8ygYxRg9VDJGbmXmUt1AkfHPHLUa3OG4apV FUcBfN8lLoC3VIHHoMNn3mffY0gpIRuMgjedTkXROvecw5tyass9jB74CJA9Z/n9tsfb NMsnUNB6pndl+4w8hETdk/iIjMED2rKiqyv13MQvGan3Mq5RtfBzSQvK3l4w1u+hSe9s ti5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m35si41529816pgb.246.2019.01.04.02.28.01; Fri, 04 Jan 2019 02:28:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726907AbfADJFy convert rfc822-to-8bit (ORCPT + 99 others); Fri, 4 Jan 2019 04:05:54 -0500 Received: from mx01.hxt-semitech.com ([223.203.96.7]:46852 "EHLO barracuda.hxt-semitech.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726227AbfADJFx (ORCPT ); Fri, 4 Jan 2019 04:05:53 -0500 X-ASG-Debug-ID: 1546592732-093b7e2d8806e40001-xx1T2L 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 Content-Type: text/plain X-Originating-IP: [10.5.21.169] X-ClientProxiedBy: HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) To HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) Content-Transfer-Encoding: 8BIT 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) 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