From patchwork Mon Oct 24 11:29:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9343 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp466866wru; Mon, 24 Oct 2022 06:56:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7jVmuodIp+cqTes6F/j/3la5E3ZaKuBIckpvuCGCOTjNomYvNS9zJR4Bqa5A8MpQEo7P1U X-Received: by 2002:a05:6a00:b54:b0:566:917:e57e with SMTP id p20-20020a056a000b5400b005660917e57emr33494350pfo.26.1666619769968; Mon, 24 Oct 2022 06:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666619769; cv=none; d=google.com; s=arc-20160816; b=rOxSxUXDPN7BP6jJ324zyzpSsnL/5XmczzjLCH1J1frx69Txx8b6pTXh06r3OHQTFl KA8e3B1D6iLsLw/DB7zuJ5TeQYeFRkz6Y0OtjI2WBjvtIdxceRpMrcI8a//gz1NKgBQI VaMoEn7QFvDyILabGr23eqxkx5hcMSD9xxGX4dkUrqzS1I8VX5SsZpHf+Y0AXmHqkPz5 AZsSwm+GxU163mOz1ESDK9cF/94aeyJ9vNJTNrtgNG8ps2qE+WEW3C+PwLppEPFlEDqw Drqo2caqfjZ8k3IijfFY1nXuRL51RwYXe7V8zYynnqeVijJP7iAsLv89rrCVNs3Ix98Z exeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2Zbb8w+LmaZVDpJVt0ahQZ3eHBRJJKPNOm/xBC0g4yQ=; b=cZ+5sHOJB+gPuhwMtyphl8muHKQFr8bjeMfSxYnNStt2mVQBdlTCqMgNJyVPCww9PL JR7l2FXd69IhR0AK/5D1kW1I5P2l2kfTVyWWcyCPQOTtVMhOvAMR9KREQMbuX1w1+4fc FDu7ocxpSgk9zqglwR94L2xIZEKP0Hf8ybrPW0Mut7eD5kMLTbjuLvYMs3UMjlPsbj4j bplQ8ZIXVkvKNMbYVfXBXP4iiifxpXqLC5ipnGBE3tw6l0T0v007hMPcgpwx0QrJiZcM 4sj4ULAd9z1yJpeh4qtAQSXG+r7jf1FoAzGidKoFhqiBlXswALIYOQdTUsUTxklkBDPG ywLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=08TjDNxj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l190-20020a6391c7000000b0046b127a88d5si33211552pge.552.2022.10.24.06.55.56; Mon, 24 Oct 2022 06:56:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=08TjDNxj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232329AbiJXNzf (ORCPT + 99 others); Mon, 24 Oct 2022 09:55:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236437AbiJXNxl (ORCPT ); Mon, 24 Oct 2022 09:53:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37967BC466; Mon, 24 Oct 2022 05:43:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9C575612B3; Mon, 24 Oct 2022 12:43:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B204CC433D6; Mon, 24 Oct 2022 12:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615390; bh=HZaN/LuBXVRxq6KpjERBiJycbpJDZKdsXB0MQGoEFeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=08TjDNxjNkBCXxfKmMJTCLZF5FrVnozWNReXorZPYJ7M6pXnqSearYuLAGshFNbJo 9mFbyIWKnxe1wlRJMlWA7IUdH8+TR+Zl/WdZ0NV7PqJfTZlq7pnSZ+Na6rJjvVXSYK OMg99vGkYieq7D6YtazYC14aDZDRKtQLGC6vUs5o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleksandr Shamray , Vadim Pasternak , Guenter Roeck , Sasha Levin Subject: [PATCH 5.15 201/530] hwmon: (pmbus/mp2888) Fix sensors readouts for MPS Multi-phase mp2888 controller Date: Mon, 24 Oct 2022 13:29:05 +0200 Message-Id: <20221024113054.151557603@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747577492027434088?= X-GMAIL-MSGID: =?utf-8?q?1747577492027434088?= From: Oleksandr Shamray [ Upstream commit 525dd5aed67a2f4f7278116fb92a24e6a53e2622 ] Fix scale factors for reading MPS Multi-phase mp2888 controller. Fixed sensors: - PIN/POUT: based on vendor documentation, set bscale factor 0.5W/LSB - IOUT: based on vendor documentation, set scale factor 0.25 A/LSB Fixes: e4db7719d037 ("hwmon: (pmbus) Add support for MPS Multi-phase mp2888 controller") Signed-off-by: Oleksandr Shamray Reviewed-by: Vadim Pasternak Link: https://lore.kernel.org/r/20220929121642.63051-1-oleksandrs@nvidia.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/pmbus/mp2888.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/hwmon/pmbus/mp2888.c b/drivers/hwmon/pmbus/mp2888.c index 8ecd4adfef40..24e5194706cf 100644 --- a/drivers/hwmon/pmbus/mp2888.c +++ b/drivers/hwmon/pmbus/mp2888.c @@ -34,7 +34,7 @@ struct mp2888_data { int curr_sense_gain; }; -#define to_mp2888_data(x) container_of(x, struct mp2888_data, info) +#define to_mp2888_data(x) container_of(x, struct mp2888_data, info) static int mp2888_read_byte_data(struct i2c_client *client, int page, int reg) { @@ -109,7 +109,7 @@ mp2888_read_phase(struct i2c_client *client, struct mp2888_data *data, int page, * - Kcs is the DrMOS current sense gain of power stage, which is obtained from the * register MP2888_MFR_VR_CONFIG1, bits 13-12 with the following selection of DrMOS * (data->curr_sense_gain): - * 00b - 5µA/A, 01b - 8.5µA/A, 10b - 9.7µA/A, 11b - 10µA/A. + * 00b - 8.5µA/A, 01b - 9.7µA/A, 1b - 10µA/A, 11b - 5µA/A. * - Rcs is the internal phase current sense resistor. This parameter depends on hardware * assembly. By default it is set to 1kΩ. In case of different assembly, user should * scale this parameter by dividing it by Rcs. @@ -118,10 +118,9 @@ mp2888_read_phase(struct i2c_client *client, struct mp2888_data *data, int page, * because sampling of current occurrence of bit weight has a big deviation, especially for * light load. */ - ret = DIV_ROUND_CLOSEST(ret * 100 - 9800, data->curr_sense_gain); - ret = (data->phase_curr_resolution) ? ret * 2 : ret; + ret = DIV_ROUND_CLOSEST(ret * 200 - 19600, data->curr_sense_gain); /* Scale according to total current resolution. */ - ret = (data->total_curr_resolution) ? ret * 8 : ret * 4; + ret = (data->total_curr_resolution) ? ret * 2 : ret; return ret; } @@ -212,7 +211,7 @@ static int mp2888_read_word_data(struct i2c_client *client, int page, int phase, ret = pmbus_read_word_data(client, page, phase, reg); if (ret < 0) return ret; - ret = data->total_curr_resolution ? ret * 2 : ret; + ret = data->total_curr_resolution ? ret : DIV_ROUND_CLOSEST(ret, 2); break; case PMBUS_POUT_OP_WARN_LIMIT: ret = pmbus_read_word_data(client, page, phase, reg); @@ -223,7 +222,7 @@ static int mp2888_read_word_data(struct i2c_client *client, int page, int phase, * set 1. Actual power is reported with 0.5W or 1W respectively resolution. Scaling * is needed to match both. */ - ret = data->total_curr_resolution ? ret * 4 : ret * 2; + ret = data->total_curr_resolution ? ret * 2 : ret; break; /* * The below registers are not implemented by device or implemented not according to the