From patchwork Tue Oct 29 18:20:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ren X-Patchwork-Id: 11218421 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C7691515 for ; Tue, 29 Oct 2019 18:21:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70448208E3 for ; Tue, 29 Oct 2019 18:21:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M+qU0iVJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731236AbfJ2SV1 (ORCPT ); Tue, 29 Oct 2019 14:21:27 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37997 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731200AbfJ2SV0 (ORCPT ); Tue, 29 Oct 2019 14:21:26 -0400 Received: by mail-pf1-f195.google.com with SMTP id c13so10157841pfp.5; Tue, 29 Oct 2019 11:21:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Clfao4MVfwGCKR4XCTV4NJFDPI9oRu0IBr+PjR38taY=; b=M+qU0iVJbGu6eocJhpsmlmI3VM3sLtX/nbW/2eqHj19XeNkwhYbnHWpVGn7oEXEcSt bs617WGfD3jdSfUIkwQnfOI8QW8VCNj0cfZ6bbB7KeJhy+BGJewfE+KpxdeguCn/eY20 Uxxdjw8JiTuUAiodTVp4iwRDY8Tq/wZTgvvVOn/Zm8XVinTKtWlz5T3N7qAaMxBQY23v nw7QvVjwDUJkbng/f53NDqCPNd9CHRTbbzCbn8qE4nAndkynvAaqHR3GQGJr2lrb4oz8 8Sr2QOW+fJKeXm8xGBeqom5w2eABXXgJ5kONrmYdaEm+F4MJV2Mo8vJ+sNSjvtd2INeq QJ4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Clfao4MVfwGCKR4XCTV4NJFDPI9oRu0IBr+PjR38taY=; b=WBfVpzdhSDpweTTrKDpQNRrdcxHEhv84c8G8hyjUemNlDqDQg+63NnjtrNht3tbSFB fCIXf2fjcZcllGwUUiJZc79tPefSi2tz63QShSH9XiG6Qh4FIXUAqTeOmD3yVksypp6N O3z0jMR2UUK+f9vE/KH9DoeJMdxyBaDYBkx+GZdbNrQgtL9pZSNp1CR1WkGAmnbwHVAo 3+wV9ZBv5LlUP7LCvmIOJDYqv9LxIY57pIo/O3YoPzunyqqvkU2srO99/Tf+zSjc8hbl 8OiZ1F7uowxArB5SVA9nigupYwrjnMnPE6Tih43herOcYxypMMEUWkWXXc4dMVz7EBfv e0WA== X-Gm-Message-State: APjAAAUpXRhjUJ70NMx6dVJfDq2dIMkhOm+CpuiTZNIUvNSXazNYOz+f 7jk6+Gz36GPO4ZNF/k30hIk= X-Google-Smtp-Source: APXvYqznjuwg+B00bepasMaHeTHS+v7IKuM7Ivz/IZ7YKTnSACmkS0/cTFPZvZVVm8kYjOB557Cb9A== X-Received: by 2002:aa7:97b3:: with SMTP id d19mr28670644pfq.50.1572373284537; Tue, 29 Oct 2019 11:21:24 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com ([2620:10d:c090:200::1:3a3e]) by smtp.gmail.com with ESMTPSA id j10sm13488418pfn.128.2019.10.29.11.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2019 11:21:24 -0700 (PDT) From: rentao.bupt@gmail.com To: Guenter Roeck , Jean Delvare , Jonathan Corbet , linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, taoren@fb.com Cc: Tao Ren Subject: [PATCH v2 1/2] hwmon: (pmbus) add driver for BEL PFE1100 and PFE3000 Date: Tue, 29 Oct 2019 11:20:53 -0700 Message-Id: <20191029182054.32279-2-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191029182054.32279-1-rentao.bupt@gmail.com> References: <20191029182054.32279-1-rentao.bupt@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Tao Ren Add "bel-pfe" pmbus driver to support hardware monitoring for BEL PFE1100 and PFE3000 power supplies. Signed-off-by: Tao Ren --- Changes in v2: - combined PFE1100 and PFE3000 driver logic into the single patch. - adjusted includes to alphabetic order. - updated PFE3000's page number from 8 to 7 because the last page is reserved. - fixed/removed typo in commit description. drivers/hwmon/pmbus/Kconfig | 9 +++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/bel-pfe.c | 131 ++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 drivers/hwmon/pmbus/bel-pfe.c diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index d62d69bb7e49..59859979571d 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -36,6 +36,15 @@ config SENSORS_ADM1275 This driver can also be built as a module. If so, the module will be called adm1275. +config SENSORS_BEL_PFE + tristate "Bel PFE Compatible Power Supplies" + help + If you say yes here you get hardware monitoring support for BEL + PFE1100 and PFE3000 Power Supplies. + + This driver can also be built as a module. If so, the module will + be called bel-pfe. + config SENSORS_IBM_CFFPS tristate "IBM Common Form Factor Power Supply" depends on LEDS_CLASS diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile index 03bacfcfd660..3f8c1014938b 100644 --- a/drivers/hwmon/pmbus/Makefile +++ b/drivers/hwmon/pmbus/Makefile @@ -6,6 +6,7 @@ obj-$(CONFIG_PMBUS) += pmbus_core.o obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o obj-$(CONFIG_SENSORS_ADM1275) += adm1275.o +obj-$(CONFIG_SENSORS_BEL_PFE) += bel-pfe.o obj-$(CONFIG_SENSORS_IBM_CFFPS) += ibm-cffps.o obj-$(CONFIG_SENSORS_INSPUR_IPSPS) += inspur-ipsps.o obj-$(CONFIG_SENSORS_IR35221) += ir35221.o diff --git a/drivers/hwmon/pmbus/bel-pfe.c b/drivers/hwmon/pmbus/bel-pfe.c new file mode 100644 index 000000000000..f236e18f45a5 --- /dev/null +++ b/drivers/hwmon/pmbus/bel-pfe.c @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Hardware monitoring driver for BEL PFE family power supplies. + * + * Copyright (c) 2019 Facebook Inc. + */ + +#include +#include +#include +#include +#include +#include + +#include "pmbus.h" + +enum chips {pfe1100, pfe3000}; + +/* + * Disable status check for pfe3000 devices, because some devices report + * communication error (invalid command) for VOUT_MODE command (0x20) + * although correct VOUT_MODE (0x16) is returned: it leads to incorrect + * exponent in linear mode. + */ +static struct pmbus_platform_data pfe3000_plat_data = { + .flags = PMBUS_SKIP_STATUS_CHECK, +}; + +static struct pmbus_driver_info pfe_driver_info[] = { + [pfe1100] = { + .pages = 1, + .format[PSC_VOLTAGE_IN] = linear, + .format[PSC_VOLTAGE_OUT] = linear, + .format[PSC_CURRENT_IN] = linear, + .format[PSC_CURRENT_OUT] = linear, + .format[PSC_POWER] = linear, + .format[PSC_TEMPERATURE] = linear, + .format[PSC_FAN] = linear, + + .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_POUT | + PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | + PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT | + PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | + PMBUS_HAVE_STATUS_TEMP | + PMBUS_HAVE_FAN12, + }, + + [pfe3000] = { + .pages = 7, + .format[PSC_VOLTAGE_IN] = linear, + .format[PSC_VOLTAGE_OUT] = linear, + .format[PSC_CURRENT_IN] = linear, + .format[PSC_CURRENT_OUT] = linear, + .format[PSC_POWER] = linear, + .format[PSC_TEMPERATURE] = linear, + .format[PSC_FAN] = linear, + + /* Page 0: V1. */ + .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_POUT | PMBUS_HAVE_FAN12 | + PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | + PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT | + PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | + PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_TEMP | + PMBUS_HAVE_VCAP, + + /* Page 1: Vsb. */ + .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT | + PMBUS_HAVE_POUT, + + /* + * Page 2: V1 Ishare. + * Page 3: Reserved. + * Page 4: V1 Cathode. + * Page 5: Vsb Cathode. + * Page 6: V1 Sense. + */ + .func[2] = PMBUS_HAVE_VOUT, + .func[4] = PMBUS_HAVE_VOUT, + .func[5] = PMBUS_HAVE_VOUT, + .func[6] = PMBUS_HAVE_VOUT, + }, +}; + +static int pfe_pmbus_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int model; + + model = (int)id->driver_data; + + /* + * PFE3000-12-069RA devices may not stay in page 0 during device + * probe which leads to probe failure (read status word failed). + * So let's set the device to page 0 at the beginning. + */ + if (model == pfe3000) { + client->dev.platform_data = &pfe3000_plat_data; + i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0); + } + + return pmbus_do_probe(client, id, &pfe_driver_info[model]); +} + +static const struct i2c_device_id pfe_device_id[] = { + {"pfe1100", pfe1100}, + {"pfe3000", pfe3000}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, pfe_device_id); + +static struct i2c_driver pfe_pmbus_driver = { + .driver = { + .name = "bel-pfe", + }, + .probe = pfe_pmbus_probe, + .remove = pmbus_do_remove, + .id_table = pfe_device_id, +}; + +module_i2c_driver(pfe_pmbus_driver); + +MODULE_AUTHOR("Tao Ren "); +MODULE_DESCRIPTION("PMBus driver for BEL PFE Family Power Supplies"); +MODULE_LICENSE("GPL"); From patchwork Tue Oct 29 18:20:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ren X-Patchwork-Id: 11218419 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BDC1E1515 for ; Tue, 29 Oct 2019 18:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 91B3E21734 for ; Tue, 29 Oct 2019 18:21:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HVDOx6Sp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731241AbfJ2SV1 (ORCPT ); Tue, 29 Oct 2019 14:21:27 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45943 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727257AbfJ2SV0 (ORCPT ); Tue, 29 Oct 2019 14:21:26 -0400 Received: by mail-pg1-f195.google.com with SMTP id r1so10113962pgj.12; Tue, 29 Oct 2019 11:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=71OLTh41XrKOgl2b277xHxckY89HIxO01AHDWRPgmpQ=; b=HVDOx6SpM3iNoabX6kbFg8wVXEL7fQYdvrcfljTSfGQv1BcHl95QQPafoBrA3RQpBm d8ukeqaLVeYLTDzfPqc3BfkSk/Igy6rdUPTRF3s0Jt41s7U/wlNGo3EJoCuXffEP0+hd YVJUhgi3RqwkTdj8oyAArB3ERCUeG1SHRkkS55g32s89MinQZtg92aBgFEKOhf+Xp+dJ fmiBEoKzgJ/UELxLK1GJy/PwhZTDA5vU2Q3/7Rx2t3/Q9oXuy8YJzXdjCimY5nFJvTxu U8z28v7X8SgBixQ7aiPTaLqb/0CUcaCF8i9niyIac/+Q3Ku3ZaGnZEynjzq1dOXVSFe/ OO0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=71OLTh41XrKOgl2b277xHxckY89HIxO01AHDWRPgmpQ=; b=RCfA5DESViF9akojFPi/jjXWsyxZK1FIRsABXpPpbhmmHhkeHieb/rablFps8u0QZ5 oaSKYPfhwrhesfA9evchN3lIcALFPrweTGoNDQyFobqStPNLpsxSvIx5B/0AbdRf262C o4yd9+etY94g9tquGMM3+sAwt77puTbaHnpijKzJrXL3EXdj5ZWRjWQO5t2IX5Q3L838 jRIYtDLy9C6/K7Iml4RdIIuooYFVvbNow0Ro+QkaDLyF8bJEaXmmsu9Aj5Ay8qOGXAoG A2OVdF9O4NRZlEqqhsKTHe+61Nlsx1JdDZcJRWWcSRh0KEvDPM8fVZF85bi/kpVOrpWs ZQ8Q== X-Gm-Message-State: APjAAAWijic6jTxCA6h87IK6zTHfZfgCo15uXiKwnkn8X71L57JbVaT6 ksbttrCZFTT4ATd1A7CwO/XJEsXJD1Q= X-Google-Smtp-Source: APXvYqx8/f20Koaa9igAtGwiT6Fa2k/qo+Kax/K+OlebL05JtE02KjKFn+X4YH1sFALw4hbn8dqL0A== X-Received: by 2002:a17:90a:c097:: with SMTP id o23mr8477800pjs.41.1572373285690; Tue, 29 Oct 2019 11:21:25 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com ([2620:10d:c090:200::1:3a3e]) by smtp.gmail.com with ESMTPSA id j10sm13488418pfn.128.2019.10.29.11.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2019 11:21:25 -0700 (PDT) From: rentao.bupt@gmail.com To: Guenter Roeck , Jean Delvare , Jonathan Corbet , linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, taoren@fb.com Cc: Tao Ren Subject: [PATCH v2 2/2] docs: hwmon: Document bel-pfe pmbus driver Date: Tue, 29 Oct 2019 11:20:54 -0700 Message-Id: <20191029182054.32279-3-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191029182054.32279-1-rentao.bupt@gmail.com> References: <20191029182054.32279-1-rentao.bupt@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Tao Ren Add documentation for bel-pfe pmbus driver which supports BEL PFE1100 and PFE3000 power supplies. Signed-off-by: Tao Ren --- No change in v2. Documentation/hwmon/bel-pfe.rst | 112 ++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 Documentation/hwmon/bel-pfe.rst diff --git a/Documentation/hwmon/bel-pfe.rst b/Documentation/hwmon/bel-pfe.rst new file mode 100644 index 000000000000..4b4a7d67854c --- /dev/null +++ b/Documentation/hwmon/bel-pfe.rst @@ -0,0 +1,112 @@ +Kernel driver bel-pfe +====================== + +Supported chips: + + * BEL PFE1100 + + Prefixes: 'pfe1100' + + Addresses scanned: - + + Datasheet: https://www.belfuse.com/resources/datasheets/powersolutions/ds-bps-pfe1100-12-054xa.pdf + + * BEL PFE3000 + + Prefixes: 'pfe3000' + + Addresses scanned: - + + Datasheet: https://www.belfuse.com/resources/datasheets/powersolutions/ds-bps-pfe3000-series.pdf + +Author: Tao Ren + + +Description +----------- + +This driver supports hardware monitoring for below power supply devices +which support PMBus Protocol: + + * BEL PFE1100 + + 1100 Watt AC to DC power-factor-corrected (PFC) power supply. + PMBus Communication Manual is not publicly available. + + * BEL PFE3000 + + 3000 Watt AC/DC power-factor-corrected (PFC) and DC-DC power supply. + PMBus Communication Manual is not publicly available. + +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. + +Example: the following will load the driver for an PFE3000 at address 0x20 +on I2C bus #1:: + + $ modprobe bel-pfe + $ echo pfe3000 0x20 > /sys/bus/i2c/devices/i2c-1/new_device + + +Platform data support +--------------------- + +The driver supports standard PMBus driver platform data. + + +Sysfs entries +------------- + +======================= ======================================================= +curr1_label "iin" +curr1_input Measured input current +curr1_max Input current max value +curr1_max_alarm Input current max alarm + +curr[2-3]_label "iout[1-2]" +curr[2-3]_input Measured output current +curr[2-3]_max Output current max value +curr[2-3]_max_alarm Output current max alarm + +fan[1-2]_input Fan 1 and 2 speed in RPM +fan1_target Set fan speed reference for both fans + +in1_label "vin" +in1_input Measured input voltage +in1_crit Input voltage critical max value +in1_crit_alarm Input voltage critical max alarm +in1_lcrit Input voltage critical min value +in1_lcrit_alarm Input voltage critical min alarm +in1_max Input voltage max value +in1_max_alarm Input voltage max alarm + +in2_label "vcap" +in2_input Hold up capacitor voltage + +in[3-8]_label "vout[1-3,5-7]" +in[3-8]_input Measured output voltage +in[3-4]_alarm vout[1-2] output voltage alarm + +power[1-2]_label "pin[1-2]" +power[1-2]_input Measured input power +power[1-2]_alarm Input power high alarm + +power[3-4]_label "pout[1-2]" +power[3-4]_input Measured output power + +temp[1-3]_input Measured temperature +temp[1-3]_alarm Temperature alarm +======================= ======================================================= + +.. note:: + + - curr3, fan2, vout[2-7], vcap, pin2, pout2 and temp3 attributes only + exist for PFE3000.