Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3674042ybg; Mon, 28 Oct 2019 17:04:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCCNepjTWetRMlGwI8RCD1HfTKQWaIiwPmL9tdHafen4e/CkI3XhWSE5CKKUnYDWnvKnBS X-Received: by 2002:a17:906:2793:: with SMTP id j19mr548278ejc.55.1572307482246; Mon, 28 Oct 2019 17:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572307482; cv=none; d=google.com; s=arc-20160816; b=nLk6mRyVl8DUSibbdpSIVFi/XDjz6thlSIit5COgp2cZrEEVqZmKP5U9EAGpqwIP+4 OT8tOalf4Kd/Rt1lTq1rfVnjprNwZhzRr52eR6thNvTk4flh7mkEj7vRivgb7+sPWkDy UXxMeXJT2i6WZflkDurIBHXwiecsF9X08phnKNwn2/D9n0+BTcqlwtymQdG5+o3JgICC gWmkqEh96xl6me3pIHXEwCW3tWzsUDkk6Ya43i/b47snYV3whEx5MXQa/uELFMVCbbEL DZYGYsK5s8sG1kPjZbxAxNkEO5TFoWaOoKh+7sccqFzjIOV+swxA7XLl8kf20bfgvkt8 IDnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=sDVKctYQFPQQhndxFna9vtm7wSyOf2hUQLavep1crp4=; b=WSxaGibKJqxELZsdHlqsDDqvPchEZGy9MeiBv6c9iNSDikKF6diS2s7MBwbZxfMeBJ Sqsjgf+M90ZAwgUNUEJ+vceg8MUc8Sh82+eVQ0kbGCw5S60JdLgDHgmjmcvBI62YRcMO D7EcSjbPrzh41+JYI5qydw7E2jSFeUCWb6pwCARI6EAmt8v9DyoNZ6ZIDWSOXmC9qvVM rXpmZo4+fgBXloz7PUGXgIh0Qij/3mb3S4Jg+SaipRAmRkSJrhPWWO/BaewhP56lMfNi 3Yj5eoJrjOpibunDlKhmEwEQNIJN9r6rJ1Xz0oOo+S5wpUoQaigdgz6dEMgY+JtTW23n aOBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sQNTSRDs; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3si8209068edd.54.2019.10.28.17.04.17; Mon, 28 Oct 2019 17:04:42 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sQNTSRDs; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728593AbfJ1Xt0 (ORCPT + 99 others); Mon, 28 Oct 2019 19:49:26 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34231 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728059AbfJ1XtZ (ORCPT ); Mon, 28 Oct 2019 19:49:25 -0400 Received: by mail-pg1-f194.google.com with SMTP id e4so3836543pgs.1; Mon, 28 Oct 2019 16:49:24 -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=sDVKctYQFPQQhndxFna9vtm7wSyOf2hUQLavep1crp4=; b=sQNTSRDsXZpa47r1mRwPnfJ/BlGNsD34hfuusH+Yr0xkBhZh0VRjQhIWl8hJwtheyG Gx1X7Uv+3Q4vgAC32/wwAmh52D564MMfAICCAk1FvUZpfTZqiAAnv0ylDhw1gj8ulPft psaa6COHOGy5HZyH2124EqIjdehs+b29LIKRVpEQ5bJOSjp1pjRGD/5g5T+1mYpWMX7T 6vMJsw3qV7TaIXVCOuAbGSwo6bq+WvxFchucWVNTrkfMIP2H7o39DHEkrE7OaHHc2FpQ PkBCUBuyu2JyItPrmV2qUfwm0lWb36Llj+N2RPomWix5gpE2qdlfuvIk5RfgJd4JCRbs 7vnA== 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=sDVKctYQFPQQhndxFna9vtm7wSyOf2hUQLavep1crp4=; b=E8031P5DTBqt6lJN705mJ3WEUp1XqgFa19tgWAihIO8FhNfPwhxq9whdETuBUHxE+f jnJetqGkcw7EyX6mCaTinK6VCHvFJSCCmo/wKQneKcKDIXZWeumA2IeMi89r1nw0jfpt ybQ5bcKN4De/n49XwFUCmNRU+PQ4eF1L02y178IuKb+V71CdfIbnpBBwgXD6tbWK9kwy Vc+X+LG0SCg84f0byqyGd5BCu7qtJaNl6LufQNQhvxVBKA6lTUO9EH90diHzMK0o1fBg JJPkhNhJ2Vd35meileW5e0vRRWv3zQOYZJH0UmVodM4Z17euPRONb21N7EOHyfvkl0Bc GDBw== X-Gm-Message-State: APjAAAWAcfZ/Qu1YVjJSSH9+dTO5e/8xu73zUJ/BeIHfXuAzK8FIFYBC iBMLwYAAtjfvWwQQzayRK6m6GiXv4qk= X-Received: by 2002:a17:90a:d149:: with SMTP id t9mr2403813pjw.108.1572306564400; Mon, 28 Oct 2019 16:49:24 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com ([2620:10d:c090:200::2:c0c7]) by smtp.gmail.com with ESMTPSA id d4sm597119pjs.9.2019.10.28.16.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 16:49:23 -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 2/3] hwmon: (pmbus) add BEL PFE3000 power supply driver Date: Mon, 28 Oct 2019 16:49:03 -0700 Message-Id: <20191028234904.12441-3-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028234904.12441-1-rentao.bupt@gmail.com> References: <20191028234904.12441-1-rentao.bupt@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tao Ren Add the driver to support BEL PFE3000 which is 3000 Wat AC to DC power supply. The chip has 8 pages. Signed-off-by: Tao Ren --- drivers/hwmon/pmbus/bel-pfe.c | 65 ++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/bel-pfe.c b/drivers/hwmon/pmbus/bel-pfe.c index 117f9af21bf3..7b6c90b056c9 100644 --- a/drivers/hwmon/pmbus/bel-pfe.c +++ b/drivers/hwmon/pmbus/bel-pfe.c @@ -10,9 +10,21 @@ #include #include #include +#include + #include "pmbus.h" -enum chips {pfe1100}; +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] = { @@ -34,6 +46,45 @@ static struct pmbus_driver_info pfe_driver_info[] = { PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_FAN12, }, + + [pfe3000] = { + .pages = 8, + .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 4: V1 Cathode. + * Page 5: Vsb Cathode. + * Page 6: V1 Sense. + * Page 3 and 7 are reserved. + */ + .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, @@ -42,11 +93,23 @@ static int pfe_pmbus_probe(struct i2c_client *client, 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}, {} }; -- 2.17.1