From patchwork Tue Sep 28 09:22:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 12522245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85BC3C43217 for ; Tue, 28 Sep 2021 09:30:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 694DD611C3 for ; Tue, 28 Sep 2021 09:30:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239951AbhI1JcY (ORCPT ); Tue, 28 Sep 2021 05:32:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239865AbhI1JcV (ORCPT ); Tue, 28 Sep 2021 05:32:21 -0400 Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [IPv6:2605:2700:0:5::4713:9cab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 383FAC061769; Tue, 28 Sep 2021 02:30:38 -0700 (PDT) Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 201DD6BF; Tue, 28 Sep 2021 02:23:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632821030; bh=ZxYTBGMf5cIw6CXTGFSPXVUjDJpCAz1J+TK7EcfCnxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KrLB+A9L4btJVsG1iAWONbdqkvmpYXQZQSXywHbjdTTxXDeVIB0Pje3O9e+ALgULG 0b2YA63vycTptTY5hMndh6zzg2xH0FejMCtrx1AQ5y0sFNNKJdsSyQzQ1kmMpC1Rle nbVguI1jOnsOw/jri+hf3fo2c5PtUDdSaRaLh5A8= From: Zev Weiss To: Guenter Roeck Cc: Zev Weiss , Jean Delvare , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] hwmon: (pmbus/lm25066) Add offset coefficients Date: Tue, 28 Sep 2021 02:22:35 -0700 Message-Id: <20210928092242.30036-2-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928092242.30036-1-zev@bewilderbeest.net> References: <20210928092242.30036-1-zev@bewilderbeest.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org With the exception of the lm5066i, all the devices handled by this driver had been missing their offset ('b') coefficients for direct format readings. Signed-off-by: Zev Weiss --- drivers/hwmon/pmbus/lm25066.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index d209e0afc2ca..1a660c4cd19f 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c @@ -55,22 +55,27 @@ static struct __coeff lm25066_coeff[6][PSC_NUM_CLASSES + 2] = { [lm25056] = { [PSC_VOLTAGE_IN] = { .m = 16296, + .b = 1343, .R = -2, }, [PSC_CURRENT_IN] = { .m = 13797, + .b = -1833, .R = -2, }, [PSC_CURRENT_IN_L] = { .m = 6726, + .b = -537, .R = -2, }, [PSC_POWER] = { .m = 5501, + .b = -2908, .R = -3, }, [PSC_POWER_L] = { .m = 26882, + .b = -5646, .R = -4, }, [PSC_TEMPERATURE] = { @@ -82,26 +87,32 @@ static struct __coeff lm25066_coeff[6][PSC_NUM_CLASSES + 2] = { [lm25066] = { [PSC_VOLTAGE_IN] = { .m = 22070, + .b = -1800, .R = -2, }, [PSC_VOLTAGE_OUT] = { .m = 22070, + .b = -1800, .R = -2, }, [PSC_CURRENT_IN] = { .m = 13661, + .b = -5200, .R = -2, }, [PSC_CURRENT_IN_L] = { .m = 6852, + .b = -3100, .R = -2, }, [PSC_POWER] = { .m = 736, + .b = -3300, .R = -2, }, [PSC_POWER_L] = { .m = 369, + .b = -1900, .R = -2, }, [PSC_TEMPERATURE] = { @@ -111,26 +122,32 @@ static struct __coeff lm25066_coeff[6][PSC_NUM_CLASSES + 2] = { [lm5064] = { [PSC_VOLTAGE_IN] = { .m = 4611, + .b = -642, .R = -2, }, [PSC_VOLTAGE_OUT] = { .m = 4621, + .b = 423, .R = -2, }, [PSC_CURRENT_IN] = { .m = 10742, + .b = 1552, .R = -2, }, [PSC_CURRENT_IN_L] = { .m = 5456, + .b = 2118, .R = -2, }, [PSC_POWER] = { .m = 1204, + .b = 8524, .R = -3, }, [PSC_POWER_L] = { .m = 612, + .b = 11202, .R = -3, }, [PSC_TEMPERATURE] = { @@ -140,26 +157,32 @@ static struct __coeff lm25066_coeff[6][PSC_NUM_CLASSES + 2] = { [lm5066] = { [PSC_VOLTAGE_IN] = { .m = 4587, + .b = -1200, .R = -2, }, [PSC_VOLTAGE_OUT] = { .m = 4587, + .b = -2400, .R = -2, }, [PSC_CURRENT_IN] = { .m = 10753, + .b = -1200, .R = -2, }, [PSC_CURRENT_IN_L] = { .m = 5405, + .b = -600, .R = -2, }, [PSC_POWER] = { .m = 1204, + .b = -6000, .R = -3, }, [PSC_POWER_L] = { .m = 605, + .b = -8000, .R = -3, }, [PSC_TEMPERATURE] = { From patchwork Tue Sep 28 09:22:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 12522239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFD4DC433FE for ; Tue, 28 Sep 2021 09:30:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0830A61130 for ; Tue, 28 Sep 2021 09:30:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239758AbhI1JcW (ORCPT ); Tue, 28 Sep 2021 05:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239858AbhI1JcV (ORCPT ); Tue, 28 Sep 2021 05:32:21 -0400 Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [IPv6:2605:2700:0:5::4713:9cab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83241C061765; Tue, 28 Sep 2021 02:30:38 -0700 (PDT) Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 750A68C0; Tue, 28 Sep 2021 02:23:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632821030; bh=70fCqkVY3hCEpVjRYy+pHiM6jsyO/PA2U039v04eomg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aTxb4lgNmJSyWNkMVEA0GmCNexMqlnuXDoaxUrKIsKPaobBgZ9/4brOkpVl7ia8yK e4tWOg2gTd4+XoaOW1++3KC28ljK+1H0sh9qq5487U3vkAR+C2WD/u2Df2Jjt6r6/u ZJliqvn73+++zD3N7ORaVvQ2pryMERNANNHhNGxw= From: Zev Weiss To: Guenter Roeck Cc: Zev Weiss , Jean Delvare , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] hwmon: (pmbus/lm25066) Adjust lm25066 PSC_CURRENT_IN_L mantissa Date: Tue, 28 Sep 2021 02:22:36 -0700 Message-Id: <20210928092242.30036-3-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928092242.30036-1-zev@bewilderbeest.net> References: <20210928092242.30036-1-zev@bewilderbeest.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org At least as of Revision J, the datasheet has a slightly different value than what we'd had in the driver. Signed-off-by: Zev Weiss --- drivers/hwmon/pmbus/lm25066.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index 1a660c4cd19f..3616705aafde 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c @@ -101,7 +101,7 @@ static struct __coeff lm25066_coeff[6][PSC_NUM_CLASSES + 2] = { .R = -2, }, [PSC_CURRENT_IN_L] = { - .m = 6852, + .m = 6854, .b = -3100, .R = -2, }, From patchwork Tue Sep 28 09:22:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 12522251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3101BC433FE for ; Tue, 28 Sep 2021 09:30:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FB2761157 for ; Tue, 28 Sep 2021 09:30:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239858AbhI1JcY (ORCPT ); Tue, 28 Sep 2021 05:32:24 -0400 Received: from thorn.bewilderbeest.net ([71.19.156.171]:60137 "EHLO thorn.bewilderbeest.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239844AbhI1JcV (ORCPT ); Tue, 28 Sep 2021 05:32:21 -0400 Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id D6014B1A; Tue, 28 Sep 2021 02:23:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632821031; bh=VBdqx6jas8pIr1PD+ePFPfJwfr9ZGcfTFBf3b03vzMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IYqp4fdlsX9u7Kdm5JsrtWc9pNTpze+dy9xFIgnDhkYNJaXESIsHmjSTvRKcucaFU tyC8mLEk6sOBuqPasKw1HQxa8pJMca3JbWeyl33mXW8vhkdRa++qRg5uYrD4Oq/DBD wMfczRyxJfzlZiCjgfMpD67kuj9sU8TV/zjyqclg= From: Zev Weiss To: Guenter Roeck Cc: Zev Weiss , Jean Delvare , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] hwmon: (pmbus/lm25066) Avoid forward declaration of lm25066_id Date: Tue, 28 Sep 2021 02:22:37 -0700 Message-Id: <20210928092242.30036-4-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928092242.30036-1-zev@bewilderbeest.net> References: <20210928092242.30036-1-zev@bewilderbeest.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Reordering things to put the table before the probe function eliminates the need for it. Signed-off-by: Zev Weiss --- drivers/hwmon/pmbus/lm25066.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index 3616705aafde..4dc003ff859e 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c @@ -234,8 +234,6 @@ struct lm25066_data { #define to_lm25066_data(x) container_of(x, struct lm25066_data, info) -static const struct i2c_device_id lm25066_id[]; - static int lm25066_read_word_data(struct i2c_client *client, int page, int phase, int reg) { @@ -436,6 +434,16 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg, return ret; } +static const struct i2c_device_id lm25066_id[] = { + {"lm25056", lm25056}, + {"lm25066", lm25066}, + {"lm5064", lm5064}, + {"lm5066", lm5066}, + {"lm5066i", lm5066i}, + { } +}; +MODULE_DEVICE_TABLE(i2c, lm25066_id); + static int lm25066_probe(struct i2c_client *client) { int config; @@ -509,17 +517,6 @@ static int lm25066_probe(struct i2c_client *client) return pmbus_do_probe(client, info); } -static const struct i2c_device_id lm25066_id[] = { - {"lm25056", lm25056}, - {"lm25066", lm25066}, - {"lm5064", lm5064}, - {"lm5066", lm5066}, - {"lm5066i", lm5066i}, - { } -}; - -MODULE_DEVICE_TABLE(i2c, lm25066_id); - /* This is the driver that will be inserted */ static struct i2c_driver lm25066_driver = { .driver = { From patchwork Tue Sep 28 09:22:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 12522247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37556C4167E for ; Tue, 28 Sep 2021 09:30:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E0DC61157 for ; Tue, 28 Sep 2021 09:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239975AbhI1Jc0 (ORCPT ); Tue, 28 Sep 2021 05:32:26 -0400 Received: from thorn.bewilderbeest.net ([71.19.156.171]:38705 "EHLO thorn.bewilderbeest.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239840AbhI1JcV (ORCPT ); Tue, 28 Sep 2021 05:32:21 -0400 X-Greylist: delayed 412 seconds by postgrey-1.27 at vger.kernel.org; Tue, 28 Sep 2021 05:32:21 EDT Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 38C3AB9A; Tue, 28 Sep 2021 02:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632821031; bh=MaatuTopxFRwd+v9AqgpfMo/zpN+SQAapzidyO5ZjZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oVO3HJL8ABpv2F2GdvQT5gVPwA4SjdeylWnhmWUkwMQ2EQboVAYrPPKSzCw2nn489 7nCP6YMy39mBJe4EWwNb4Pg61AgrVFfFDJynss+KQWg/rgSKjhulxs0MeISZXd7waU A1Yn3tkCIFqcwGQAgrS2oUnmNJbeuuiNVWe8hAH0= From: Zev Weiss To: Guenter Roeck Cc: Zev Weiss , Jean Delvare , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/8] hwmon: (pmbus/lm25066) Let compiler determine outer dimension of lm25066_coeff Date: Tue, 28 Sep 2021 02:22:38 -0700 Message-Id: <20210928092242.30036-5-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928092242.30036-1-zev@bewilderbeest.net> References: <20210928092242.30036-1-zev@bewilderbeest.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Maintaining this manually is error prone (there are currently only five chips supported, not six); gcc can do it for us automatically. Signed-off-by: Zev Weiss Fixes: 666c14906b49 ("hwmon: (pmbus/lm25066) Drop support for LM25063") --- drivers/hwmon/pmbus/lm25066.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index 4dc003ff859e..1ff5407b6977 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c @@ -51,7 +51,7 @@ struct __coeff { #define PSC_CURRENT_IN_L (PSC_NUM_CLASSES) #define PSC_POWER_L (PSC_NUM_CLASSES + 1) -static struct __coeff lm25066_coeff[6][PSC_NUM_CLASSES + 2] = { +static struct __coeff lm25066_coeff[][PSC_NUM_CLASSES + 2] = { [lm25056] = { [PSC_VOLTAGE_IN] = { .m = 16296, From patchwork Tue Sep 28 09:22:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 12522241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A608C4332F for ; Tue, 28 Sep 2021 09:30:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B4A961130 for ; Tue, 28 Sep 2021 09:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239926AbhI1JcX (ORCPT ); Tue, 28 Sep 2021 05:32:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239872AbhI1JcV (ORCPT ); Tue, 28 Sep 2021 05:32:21 -0400 Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [IPv6:2605:2700:0:5::4713:9cab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38445C06176A; Tue, 28 Sep 2021 02:30:38 -0700 (PDT) Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 8E31BC20; Tue, 28 Sep 2021 02:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632821031; bh=4P1wdSQkXGcDVZjSddgG/Ut0TaQpsgcZ1xCEifRgdLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SXKRjKb68YYJoMFO3J1WS1iQQIDZRigDhx/NvjvXE2QzSUyo/wyRPBiDY94J73QLm D32qEWdfU1WQIgwyUsFqXchiZ6s0T5J6RUWRNHpXf3kJt/8bSyJOlfm/jSqePwgfGe k+gPbM71LrCV75fA+Yvgm4h58kNG8TlH0IOpgVbA= From: Zev Weiss To: Guenter Roeck Cc: Zev Weiss , Jean Delvare , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/8] hwmon: (pmbus/lm25066) Mark lm25066_coeff array const Date: Tue, 28 Sep 2021 02:22:39 -0700 Message-Id: <20210928092242.30036-6-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928092242.30036-1-zev@bewilderbeest.net> References: <20210928092242.30036-1-zev@bewilderbeest.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Signed-off-by: Zev Weiss --- drivers/hwmon/pmbus/lm25066.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index 1ff5407b6977..dbbf8571c437 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c @@ -51,7 +51,7 @@ struct __coeff { #define PSC_CURRENT_IN_L (PSC_NUM_CLASSES) #define PSC_POWER_L (PSC_NUM_CLASSES + 1) -static struct __coeff lm25066_coeff[][PSC_NUM_CLASSES + 2] = { +static const struct __coeff lm25066_coeff[][PSC_NUM_CLASSES + 2] = { [lm25056] = { [PSC_VOLTAGE_IN] = { .m = 16296, @@ -449,7 +449,7 @@ static int lm25066_probe(struct i2c_client *client) int config; struct lm25066_data *data; struct pmbus_driver_info *info; - struct __coeff *coeff; + const struct __coeff *coeff; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) From patchwork Tue Sep 28 09:22:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 12522243 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C133C433EF for ; Tue, 28 Sep 2021 09:30:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E28F061159 for ; Tue, 28 Sep 2021 09:30:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239903AbhI1JcW (ORCPT ); Tue, 28 Sep 2021 05:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239832AbhI1JcV (ORCPT ); Tue, 28 Sep 2021 05:32:21 -0400 X-Greylist: delayed 409 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 28 Sep 2021 02:30:38 PDT Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [IPv6:2605:2700:0:5::4713:9cab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27F67C061604; Tue, 28 Sep 2021 02:30:38 -0700 (PDT) Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id E70B1C2D; Tue, 28 Sep 2021 02:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632821032; bh=tXLdw8+7XyyaNC2nx8/azLFD8tnijRO/sXuXLjMDFfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KuJx3h8+xeOXqjn30yyHApPuhrufZusIfYS8iPa+FVxQ9JuO80EkpegS3MeE7Ch2s I15GhwuMLy77uLvQkXlTpbS0ao/WpoymxODxEBEePZg43oejKsZl8OEPnpC4n/GQAm ZUAMTya33ECDRvM8YguzsWoJ4+biEduXdAH9j7Zg= From: Zev Weiss To: Guenter Roeck Cc: Zev Weiss , Jean Delvare , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/8] hwmon: (pmbus/lm25066) Add OF device ID table Date: Tue, 28 Sep 2021 02:22:40 -0700 Message-Id: <20210928092242.30036-7-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928092242.30036-1-zev@bewilderbeest.net> References: <20210928092242.30036-1-zev@bewilderbeest.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org See commit 8881a19187e4 ("hwmon: (ucd9000) Add OF device ID table") for reasoning. Signed-off-by: Zev Weiss --- drivers/hwmon/pmbus/lm25066.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index dbbf8571c437..18d5a76f346d 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "pmbus.h" enum chips { lm25056, lm25066, lm5064, lm5066, lm5066i }; @@ -444,12 +445,24 @@ static const struct i2c_device_id lm25066_id[] = { }; MODULE_DEVICE_TABLE(i2c, lm25066_id); +static const struct of_device_id __maybe_unused lm25066_of_match[] = { + { .compatible = "ti,lm25056", .data = (void*)lm25056, }, + { .compatible = "ti,lm25066", .data = (void*)lm25066, }, + { .compatible = "ti,lm5064", .data = (void*)lm5064, }, + { .compatible = "ti,lm5066", .data = (void*)lm5066, }, + { .compatible = "ti,lm5066i", .data = (void*)lm5066i, }, + { }, +}; +MODULE_DEVICE_TABLE(of, lm25066_of_match); + static int lm25066_probe(struct i2c_client *client) { int config; struct lm25066_data *data; struct pmbus_driver_info *info; const struct __coeff *coeff; + const struct of_device_id *of_id; + const struct i2c_device_id *i2c_id; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) @@ -464,7 +477,15 @@ static int lm25066_probe(struct i2c_client *client) if (config < 0) return config; - data->id = i2c_match_id(lm25066_id, client)->driver_data; + i2c_id = i2c_match_id(lm25066_id, client); + + of_id = of_match_device(lm25066_of_match, &client->dev); + if (of_id && (enum chips)of_id->data != i2c_id->driver_data) + dev_notice(&client->dev, + "Device mismatch: %s in device tree, %s detected\n", + of_id->name, i2c_id->name); + + data->id = i2c_id->driver_data; info = &data->info; info->pages = 1; @@ -521,7 +542,8 @@ static int lm25066_probe(struct i2c_client *client) static struct i2c_driver lm25066_driver = { .driver = { .name = "lm25066", - }, + .of_match_table = of_match_ptr(lm25066_of_match), + }, .probe_new = lm25066_probe, .id_table = lm25066_id, }; From patchwork Tue Sep 28 09:22:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 12522253 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 381EAC41535 for ; Tue, 28 Sep 2021 09:30:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD1E561130 for ; Tue, 28 Sep 2021 09:30:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239967AbhI1JcZ (ORCPT ); Tue, 28 Sep 2021 05:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239850AbhI1JcW (ORCPT ); Tue, 28 Sep 2021 05:32:22 -0400 X-Greylist: delayed 410 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 28 Sep 2021 02:30:38 PDT Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [IPv6:2605:2700:0:5::4713:9cab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BB70C061740; Tue, 28 Sep 2021 02:30:38 -0700 (PDT) Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 7279EC53; Tue, 28 Sep 2021 02:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632821032; bh=OL+wLYUxy0gYzafQl0tDCAxXVTFEgMWaHXWJNw47X7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I/IvhQUFC1S3knvGefzb8ZNayYDTTFr19IrAHEeDYC6Q5DfpKw3VdlTqSyzc5t5Se XulSt7S5QeHATdCj1zrjevkBi0vFd3fK80+9VW3srO+Zr29AfBgwckveDXhAkiRSjC 2UauikC7JbsZsoSNtHgRL/r2vjRlLcfSEmvdY+3E= From: Zev Weiss To: Guenter Roeck Cc: Zev Weiss , Jean Delvare , Jonathan Corbet , linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] hwmon: (pmbus/lm25066) Support configurable sense resistor values Date: Tue, 28 Sep 2021 02:22:41 -0700 Message-Id: <20210928092242.30036-8-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928092242.30036-1-zev@bewilderbeest.net> References: <20210928092242.30036-1-zev@bewilderbeest.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org The appropriate mantissa values for the lm25066 family's direct-format current and power readings are a function of the sense resistor employed between the SENSE and VIN pins of the chip. Instead of assuming that resistance is always the same 1mOhm as used in the datasheet, allow it to be configured via a device-tree property ("shunt-resistor-micro-ohms"). Signed-off-by: Zev Weiss --- Documentation/hwmon/lm25066.rst | 2 ++ drivers/hwmon/pmbus/lm25066.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Documentation/hwmon/lm25066.rst b/Documentation/hwmon/lm25066.rst index 9f1d7e4d3ca1..a2098eb24090 100644 --- a/Documentation/hwmon/lm25066.rst +++ b/Documentation/hwmon/lm25066.rst @@ -79,6 +79,8 @@ This driver does not auto-detect devices. You will have to instantiate the devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for details. +The shunt (sense) resistor value can be configured by a device tree property; +see Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml for details. Platform data support --------------------- diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index 18d5a76f346d..29e848bcd436 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c @@ -458,6 +458,7 @@ MODULE_DEVICE_TABLE(of, lm25066_of_match); static int lm25066_probe(struct i2c_client *client) { int config; + u32 shunt; struct lm25066_data *data; struct pmbus_driver_info *info; const struct __coeff *coeff; @@ -535,6 +536,17 @@ static int lm25066_probe(struct i2c_client *client) info->b[PSC_POWER] = coeff[PSC_POWER].b; } + /* + * Values in the TI datasheets are normalized for a 1mOhm sense + * resistor; assume that unless DT specifies a value explicitly. + */ + if (of_property_read_u32(client->dev.of_node, + "shunt-resistor-micro-ohms", &shunt)) + shunt = 1000; + + info->m[PSC_CURRENT_IN] = info->m[PSC_CURRENT_IN] * shunt / 1000; + info->m[PSC_POWER] = info->m[PSC_POWER] * shunt / 1000; + return pmbus_do_probe(client, info); } From patchwork Tue Sep 28 09:22:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 12522249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B699EC4332F for ; Tue, 28 Sep 2021 09:30:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3F7561130 for ; Tue, 28 Sep 2021 09:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239978AbhI1Jc0 (ORCPT ); Tue, 28 Sep 2021 05:32:26 -0400 Received: from thorn.bewilderbeest.net ([71.19.156.171]:51011 "EHLO thorn.bewilderbeest.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239827AbhI1JcW (ORCPT ); Tue, 28 Sep 2021 05:32:22 -0400 X-Greylist: delayed 408 seconds by postgrey-1.27 at vger.kernel.org; Tue, 28 Sep 2021 05:32:20 EDT Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id B0890C85; Tue, 28 Sep 2021 02:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632821034; bh=CatX71RSe4cBZ47vo+0qA9ACXKr3G52arA6l0RAFgGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OU3CiAdtMLJuCOrqBhr8ogVpJui6ITSdQiYMktK6cQlMO78+x9e4lX2yF0kGCy3M2 WmXS7tFrMzOO05gdT7pWNORCFMVuGDsw3130Lq4IAWpaoWZmPajWiHxd/K6j8+ju5/ GWTQUWn6cyFv0j3GvC7jpkCz72+k0ouw0KpulCEo= From: Zev Weiss To: Guenter Roeck Cc: Zev Weiss , Jean Delvare , Rob Herring , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/8] dt-bindings: hwmon/pmbus: Add ti,lm25066 power-management IC Date: Tue, 28 Sep 2021 02:22:42 -0700 Message-Id: <20210928092242.30036-9-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928092242.30036-1-zev@bewilderbeest.net> References: <20210928092242.30036-1-zev@bewilderbeest.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Signed-off-by: Zev Weiss Reviewed-by: Rob Herring --- .../bindings/hwmon/pmbus/ti,lm25066.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml diff --git a/Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml b/Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml new file mode 100644 index 000000000000..da8292bc32f5 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- + +$id: http://devicetree.org/schemas/hwmon/pmbus/ti,lm25066.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: National Semiconductor/Texas Instruments LM250x6/LM506x power-management ICs + +maintainers: + - Zev Weiss + +description: | + The LM25066 family of power-management ICs (a.k.a. hot-swap + controllers or eFuses in various contexts) are PMBus devices that + offer temperature, current, voltage, and power monitoring. + + Datasheet: https://www.ti.com/lit/ds/symlink/lm25066.pdf + +properties: + compatible: + enum: + - ti,lm25056 + - ti,lm25066 + - ti,lm5064 + - ti,lm5066 + - ti,lm5066i + + reg: + maxItems: 1 + + shunt-resistor-micro-ohms: + description: + Shunt (sense) resistor value in micro-Ohms + default: 1000 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@40 { + compatible = "ti,lm25066"; + reg = <0x40>; + shunt-resistor-micro-ohms = <675>; + }; + };