From patchwork Wed Aug 17 05:43:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945483 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63D49C28B2B for ; Wed, 17 Aug 2022 05:44:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238752AbiHQFod (ORCPT ); Wed, 17 Aug 2022 01:44:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238688AbiHQFoF (ORCPT ); Wed, 17 Aug 2022 01:44:05 -0400 Received: from smtp-fw-80007.amazon.com (smtp-fw-80007.amazon.com [99.78.197.218]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB0107C746; Tue, 16 Aug 2022 22:43:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715033; x=1692251033; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ULkqAHITNyNY+nb/F2KUcwZfWxaEdjYhDYRpVxQWyfI=; b=s5Y7+8+e8jDKsq5NJfba9n5GLRUpPWu7VYvjYB9fmH6RQTsgVIxtA2sL ncBkqSt8f2LckYya9zCettFii/E6Grv4qFNsNki9h2W+fwzh8ykXQtIa0 Qgkhx/BjgDluGAOj8b+P3ZMsTRux0lk5mUg+Tf3EewlUoFzAvtODrNFbY M=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="120136323" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-pdx-2a-5feb294a.us-west-2.amazon.com) ([10.25.36.214]) by smtp-border-fw-80007.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:39 +0000 Received: from EX13MTAUEE002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2a-5feb294a.us-west-2.amazon.com (Postfix) with ESMTPS id A5FC7835D8; Wed, 17 Aug 2022 05:43:37 +0000 (UTC) Received: from EX13D08UEE003.ant.amazon.com (10.43.62.118) by EX13MTAUEE002.ant.amazon.com (10.43.62.24) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from EX13MTAUEE002.ant.amazon.com (10.43.62.24) by EX13D08UEE003.ant.amazon.com (10.43.62.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:21 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.62.224) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:21 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 6BB1F4C4B; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 01/16] hwmon: (mr75203) fix VM sensor allocation when "intel,vm-map" not defined Date: Wed, 17 Aug 2022 05:43:06 +0000 Message-ID: <20220817054321.6519-2-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Fix a bug that in case "intel,vm-map" is missing 'num' is set to 0, and no voltage channel infos are allocated. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 046523d47c29..0e29877a1a9c 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -580,8 +580,6 @@ static int mr75203_probe(struct platform_device *pdev) } if (vm_num) { - u32 num = vm_num; - ret = pvt_get_regmap(pdev, "vm", pvt); if (ret) return ret; @@ -594,30 +592,28 @@ static int mr75203_probe(struct platform_device *pdev) ret = device_property_read_u8_array(dev, "intel,vm-map", pvt->vm_idx, vm_num); if (ret) { - num = 0; + /* + * Incase intel,vm-map property is not defined, we + * assume incremental channel numbers. + */ + for (i = 0; i < vm_num; i++) + pvt->vm_idx[i] = i; } else { for (i = 0; i < vm_num; i++) if (pvt->vm_idx[i] >= vm_num || - pvt->vm_idx[i] == 0xff) { - num = i; + pvt->vm_idx[i] == 0xff) break; - } - } - /* - * Incase intel,vm-map property is not defined, we assume - * incremental channel numbers. - */ - for (i = num; i < vm_num; i++) - pvt->vm_idx[i] = i; + vm_num = i; + } - in_config = devm_kcalloc(dev, num + 1, + in_config = devm_kcalloc(dev, vm_num + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) return -ENOMEM; - memset32(in_config, HWMON_I_INPUT, num); - in_config[num] = 0; + memset32(in_config, HWMON_I_INPUT, vm_num); + in_config[vm_num] = 0; pvt_in.config = in_config; pvt_info[index++] = &pvt_in; From patchwork Wed Aug 17 05:43:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945486 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E511EC32771 for ; Wed, 17 Aug 2022 05:44:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238783AbiHQFox (ORCPT ); Wed, 17 Aug 2022 01:44:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238610AbiHQFoQ (ORCPT ); Wed, 17 Aug 2022 01:44:16 -0400 Received: from smtp-fw-9102.amazon.com (smtp-fw-9102.amazon.com [207.171.184.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B9B27CB6C; Tue, 16 Aug 2022 22:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715040; x=1692251040; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9K9d4IjBMmcloaT+QG5eIvNYUR3xOoTYrU9248uTcL8=; b=dQZK134ka3Ye9p+j7oDTxSvDCKdwcW2fvQXwVPHcJcH2ubl1uZTgN/Lf hEKiMIVFXfEeB8hRcdD2Ay5lZ3F6R86AomeCND1/ASODY78BJ363KMoH+ EvN+Dh7mA0XJvWGN+BOechV6cdWpy/32862sdTQjKCYbhSFxCBJ6BfiVs Q=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="249710571" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1a-b09d0114.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-9102.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:45 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1a-b09d0114.us-east-1.amazon.com (Postfix) with ESMTPS id BD6208151C; Wed, 17 Aug 2022 05:43:42 +0000 (UTC) Received: from EX19D013UWA004.ant.amazon.com (10.13.138.207) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX19D013UWA004.ant.amazon.com (10.13.138.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 6F16B4C4F; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 02/16] hwmon: (mr75203) update pvt->v_num to the actual number of used sensors Date: Wed, 17 Aug 2022 05:43:07 +0000 Message-ID: <20220817054321.6519-3-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This issue is relevant when intel,vm-map is set, and defines a lower number of VMs than actually supported. This change is needed for all places that use pvt->v_num later on in the code. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 0e29877a1a9c..f89f7bb5d698 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -605,6 +605,7 @@ static int mr75203_probe(struct platform_device *pdev) break; vm_num = i; + pvt->v_num = i; } in_config = devm_kcalloc(dev, vm_num + 1, From patchwork Wed Aug 17 05:43:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945477 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 872DAC32771 for ; Wed, 17 Aug 2022 05:43:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238642AbiHQFnx (ORCPT ); Wed, 17 Aug 2022 01:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238611AbiHQFnm (ORCPT ); Wed, 17 Aug 2022 01:43:42 -0400 Received: from smtp-fw-80006.amazon.com (smtp-fw-80006.amazon.com [99.78.197.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B8AC7A773; Tue, 16 Aug 2022 22:43:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715021; x=1692251021; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+l0S1eFzfrFNNB93/ZUmAdO4vUxtc2g6DrjY5R7747U=; b=Xt9xZ1EvDjw00gK4+Elzyzm32/5OIuHrUs1EX9ks5udqCmJyqwv/z8SD u2mnLdZng5PUDcqzUwu+I/qOxJvtWawNfuBaxOJN3FdJb6L9vGQypJda7 ds2iL4oNiZGagnl+nzT+tPo4TGNV74WjuXHTm7CPBbiQAGc215jY/Ird3 I=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="120059344" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1e-0bfdb89e.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:26 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1e-0bfdb89e.us-east-1.amazon.com (Postfix) with ESMTPS id 53036E0088; Wed, 17 Aug 2022 05:43:23 +0000 (UTC) Received: from EX19D013UWA003.ant.amazon.com (10.13.138.202) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX19D013UWA003.ant.amazon.com (10.13.138.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:21 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 727F44C51; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 03/16] hwmon: (mr75203) update Moortec PVT controller intel,vm-map property Date: Wed, 17 Aug 2022 05:43:08 +0000 Message-ID: <20220817054321.6519-4-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org The "intel,vm-map property" is optional and not required. Signed-off-by: Eliav Farber --- Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index 6f3e3c01f717..f9e849cc73e0 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -48,12 +48,12 @@ required: - compatible - reg - reg-names - - intel,vm-map - clocks - resets - "#thermal-sensor-cells" -additionalProperties: false +additionalProperties: + - intel,vm-map examples: - | From patchwork Wed Aug 17 05:43:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945490 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BEBFC32773 for ; Wed, 17 Aug 2022 05:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238730AbiHQFpM (ORCPT ); Wed, 17 Aug 2022 01:45:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238731AbiHQFoU (ORCPT ); Wed, 17 Aug 2022 01:44:20 -0400 Received: from smtp-fw-9102.amazon.com (smtp-fw-9102.amazon.com [207.171.184.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2063B7C302; Tue, 16 Aug 2022 22:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715049; x=1692251049; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y+K+ejUZbidNdp7fNJrcGWpO2dwpzC63OfGNy7Tg6HU=; b=tYcd+vZe4M32ttAexLAr9qLuuMY7FwjeV41NHkhxnQ4w9d/XNXhbwq8R BRr4eVVFu1A/ELpoSMds+rsZ3xp7gW2WTm8wobpV1lQ+9LccI5CVc6VFw epT+ycV1a6VouUaxC4/a+RYr8PDXNwCvsd2Owz2wGxs2nIQkSk6OYY3Lv A=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="249710570" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1d-9a235a16.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-9102.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:45 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1d-9a235a16.us-east-1.amazon.com (Postfix) with ESMTPS id B94E780290; Wed, 17 Aug 2022 05:43:42 +0000 (UTC) Received: from EX19D013UWA002.ant.amazon.com (10.13.138.210) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX19D013UWA002.ant.amazon.com (10.13.138.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:21 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 75D4C4C54; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 04/16] hwmon: (mr75203) add Moortec PVT controller reset-control-skip property Date: Wed, 17 Aug 2022 05:43:09 +0000 Message-ID: <20220817054321.6519-5-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Adding a "reset-control-skip" bool property to the mr75203 node will avoid looking up and obtaining a reference to a reset controller. Signed-off-by: Eliav Farber --- .../devicetree/bindings/hwmon/moortec,mr75203.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index f9e849cc73e0..da9c3cdcb6f0 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -44,6 +44,11 @@ properties: "#thermal-sensor-cells": const: 1 + reset-control-skip: + description: + reset-control-skip bool property defines if obtaining a + reference to a reset controller should be skipped. + required: - compatible - reg @@ -54,6 +59,7 @@ required: additionalProperties: - intel,vm-map + - reset-control-skip examples: - | From patchwork Wed Aug 17 05:43:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945489 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B7E5C25B08 for ; Wed, 17 Aug 2022 05:45:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238808AbiHQFpI (ORCPT ); Wed, 17 Aug 2022 01:45:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238664AbiHQFoS (ORCPT ); Wed, 17 Aug 2022 01:44:18 -0400 Received: from smtp-fw-6001.amazon.com (smtp-fw-6001.amazon.com [52.95.48.154]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187607B2BC; Tue, 16 Aug 2022 22:44:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715042; x=1692251042; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0AQXnw93t2lwDKh5bic/I1TgdsGF0kswV/Nq4data+4=; b=HEjc3XCqlj/xyJiyeik4DpN0PUfvi1B9+kbskiFZNJEs6iC2m5oh+9g7 rM+zxFQ18vyVkT9xkHS6mtNsTgIkIT27K44SGsK98s4WeIKtBxSOQJ6ra YaSHejxIY6i82zLHF6qq1LExza4/ophDGYjieRQnsV5lhqMWZdXp2Isff g=; Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-pdx-2a-5feb294a.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-6001.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:40 +0000 Received: from EX13MTAUEE002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2a-5feb294a.us-west-2.amazon.com (Postfix) with ESMTPS id 1159A835D8; Wed, 17 Aug 2022 05:43:39 +0000 (UTC) Received: from EX13D08UEE003.ant.amazon.com (10.43.62.118) by EX13MTAUEE002.ant.amazon.com (10.43.62.24) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:23 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D08UEE003.ant.amazon.com (10.43.62.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:23 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 793EF4C55; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 05/16] hwmon: (mr75203) add option to skip reset controller Date: Wed, 17 Aug 2022 05:43:10 +0000 Message-ID: <20220817054321.6519-6-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Adding a "reset-control-skip" bool property to the mr75203 node will avoid looking up and obtaining a reference to a reset controller. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index f89f7bb5d698..bec63b611eb4 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -525,14 +526,19 @@ static int mr75203_probe(struct platform_device *pdev) return ret; } - pvt->rst = devm_reset_control_get_exclusive(dev, NULL); - if (IS_ERR(pvt->rst)) - return dev_err_probe(dev, PTR_ERR(pvt->rst), - "failed to get reset control\n"); + if (of_property_read_bool(dev->of_node, "reset-control-skip")) { + dev_info(dev, "skipping reset-control\n"); + } else { + pvt->rst = devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(pvt->rst)) + return dev_err_probe(dev, PTR_ERR(pvt->rst), + "failed to get reset control\n"); - ret = pvt_reset_control_deassert(dev, pvt); - if (ret) - return dev_err_probe(dev, ret, "cannot deassert reset control\n"); + ret = pvt_reset_control_deassert(dev, pvt); + if (ret) + return dev_err_probe(dev, ret, + "cannot deassert reset control\n"); + } ret = regmap_read(pvt->c_map, PVT_IP_CONFIG, &val); if(ret < 0) From patchwork Wed Aug 17 05:43:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945480 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B62BC25B08 for ; Wed, 17 Aug 2022 05:44:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238724AbiHQFoT (ORCPT ); Wed, 17 Aug 2022 01:44:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238666AbiHQFoD (ORCPT ); Wed, 17 Aug 2022 01:44:03 -0400 Received: from smtp-fw-9103.amazon.com (smtp-fw-9103.amazon.com [207.171.188.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D27978239; Tue, 16 Aug 2022 22:43:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715028; x=1692251028; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I4ndVs36DtLZuD0EkdTFDFSmoQQ7OUW1UMKQNUkt/6g=; b=Vf4Vzv2c07SaEfo8Cahc1Hf2/M+HF7/FNDAn/9Xl/Xetl+EtNGuma+HO 9Y++y0DEHe9oDhqG90TeebHeJhTNGSJDl8VQUUngwMBuDLR8l+ydhHrBQ busZTkVeNtrGvOXj3F4zs7OFbx7j6iynZFt5TvE3mW1MgMxPlkoAvxrKd E=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="1045102180" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-9a235a16.us-east-1.amazon.com) ([10.25.36.214]) by smtp-border-fw-9103.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:46 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1d-9a235a16.us-east-1.amazon.com (Postfix) with ESMTPS id EE071803A2; Wed, 17 Aug 2022 05:43:43 +0000 (UTC) Received: from EX19D013UWA001.ant.amazon.com (10.13.138.253) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:23 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX19D013UWA001.ant.amazon.com (10.13.138.253) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 7CBFC4C56; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 06/16] hwmon: (mr75203) fix multi-channel voltage reading Date: Wed, 17 Aug 2022 05:43:11 +0000 Message-ID: <20220817054321.6519-7-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org - Fix voltage reading to support number of channels in VM IP (CH_NUM). - Configure the ip-polling register to enable polling for all channels. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index bec63b611eb4..4419e481d47c 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -69,8 +69,9 @@ /* VM Individual Macro Register */ #define VM_COM_REG_SIZE 0x200 -#define VM_SDIF_DONE(n) (VM_COM_REG_SIZE + 0x34 + 0x200 * (n)) -#define VM_SDIF_DATA(n) (VM_COM_REG_SIZE + 0x40 + 0x200 * (n)) +#define VM_SDIF_DONE(vm) (VM_COM_REG_SIZE + 0x34 + 0x200 * (vm)) +#define VM_SDIF_DATA(vm, ch) \ + (VM_COM_REG_SIZE + 0x40 + 0x200 * (vm) + 0x4 * (ch)) /* SDA Slave Register */ #define IP_CTRL 0x00 @@ -116,6 +117,7 @@ struct pvt_device { u32 t_num; u32 p_num; u32 v_num; + u32 c_num; u32 ip_freq; u8 *vm_idx; }; @@ -181,12 +183,14 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) struct regmap *v_map = pvt->v_map; u32 n, stat; u8 vm_idx; + u8 ch_idx; int ret; - if (channel >= pvt->v_num) + if (channel >= pvt->v_num * pvt->c_num) return -EINVAL; - vm_idx = pvt->vm_idx[channel]; + vm_idx = pvt->vm_idx[channel / pvt->c_num]; + ch_idx = channel % pvt->c_num; switch (attr) { case hwmon_in_input: @@ -197,7 +201,7 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) if (ret) return ret; - ret = regmap_read(v_map, VM_SDIF_DATA(vm_idx), &n); + ret = regmap_read(v_map, VM_SDIF_DATA(vm_idx, ch_idx), &n); if(ret < 0) return ret; @@ -386,6 +390,20 @@ static int pvt_init(struct pvt_device *pvt) if (ret) return ret; + val = GENMASK(pvt->c_num - 1, 0) | VM_CH_INIT | + IP_POLL << SDIF_ADDR_SFT | + SDIF_WRN_W | SDIF_PROG; + ret = regmap_write(v_map, SDIF_W, val); + if (ret < 0) + return ret; + + ret = regmap_read_poll_timeout(v_map, SDIF_STAT, + val, !(val & SDIF_BUSY), + PVT_POLL_DELAY_US, + PVT_POLL_TIMEOUT_US); + if (ret) + return ret; + val = CFG1_VOL_MEAS_MODE | CFG1_PARALLEL_OUT | CFG1_14_BIT | IP_CFG << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; @@ -501,7 +519,7 @@ static int pvt_reset_control_deassert(struct device *dev, struct pvt_device *pvt static int mr75203_probe(struct platform_device *pdev) { const struct hwmon_channel_info **pvt_info; - u32 ts_num, vm_num, pd_num, val, index, i; + u32 ts_num, vm_num, pd_num, ch_num, val, index, i; struct device *dev = &pdev->dev; u32 *temp_config, *in_config; struct device *hwmon_dev; @@ -547,9 +565,11 @@ static int mr75203_probe(struct platform_device *pdev) ts_num = (val & TS_NUM_MSK) >> TS_NUM_SFT; pd_num = (val & PD_NUM_MSK) >> PD_NUM_SFT; vm_num = (val & VM_NUM_MSK) >> VM_NUM_SFT; + ch_num = (val & CH_NUM_MSK) >> CH_NUM_SFT; pvt->t_num = ts_num; pvt->p_num = pd_num; pvt->v_num = vm_num; + pvt->c_num = ch_num; val = 0; if (ts_num) val++; @@ -586,6 +606,8 @@ static int mr75203_probe(struct platform_device *pdev) } if (vm_num) { + u32 total_ch = ch_num * vm_num; + ret = pvt_get_regmap(pdev, "vm", pvt); if (ret) return ret; @@ -614,13 +636,13 @@ static int mr75203_probe(struct platform_device *pdev) pvt->v_num = i; } - in_config = devm_kcalloc(dev, vm_num + 1, + in_config = devm_kcalloc(dev, total_ch + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) return -ENOMEM; - memset32(in_config, HWMON_I_INPUT, vm_num); - in_config[vm_num] = 0; + memset32(in_config, HWMON_I_INPUT, total_ch); + in_config[total_ch] = 0; pvt_in.config = in_config; pvt_info[index++] = &pvt_in; From patchwork Wed Aug 17 05:43:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945482 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A265C32773 for ; Wed, 17 Aug 2022 05:44:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238734AbiHQFoU (ORCPT ); Wed, 17 Aug 2022 01:44:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238639AbiHQFoD (ORCPT ); Wed, 17 Aug 2022 01:44:03 -0400 Received: from smtp-fw-80006.amazon.com (smtp-fw-80006.amazon.com [99.78.197.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A94DF7A518; Tue, 16 Aug 2022 22:43:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715029; x=1692251029; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aakzTg2DzAex8scIdcsOiBD10Miv0IDo0qf7Et9v8nc=; b=J1zM6S9aSUVDyRWE3s+8ITG9BqCLBg/B6TwnlegeSlGeBRU4pjpkEJKr OfFdZfjYNQVQQYdzinu5Ug3jxxLkyHNRQE8tG0TH1fEXzXrnhGOCskd2a a3rNdTXD0MkkqxIV3SFVQtQrV5UjU87d3MRJq5nKyw/GJkQKHRypmRORq A=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="120059420" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1a-c92fe759.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:46 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1a-c92fe759.us-east-1.amazon.com (Postfix) with ESMTPS id 42D46C08F4; Wed, 17 Aug 2022 05:43:43 +0000 (UTC) Received: from EX19D013UWA003.ant.amazon.com (10.13.138.202) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:23 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX19D013UWA003.ant.amazon.com (10.13.138.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 800C44C5B; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 07/16] hwmon: (mr75203) add VM active channels property for Moortec PVT controller Date: Wed, 17 Aug 2022 05:43:12 +0000 Message-ID: <20220817054321.6519-8-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add optional "vm-active-channels" property to define the number of active channels per VM. Signed-off-by: Eliav Farber --- .../devicetree/bindings/hwmon/moortec,mr75203.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index da9c3cdcb6f0..6111b5069b3c 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -49,6 +49,13 @@ properties: reset-control-skip bool property defines if obtaining a reference to a reset controller should be skipped. + vm-active-channels: + description: + vm-active-channels defines the number of channels per VM + that are actually used and are connected to some source. + A value of 0 means that the entire VM sensor is nou used. + $ref: /schemas/types.yaml#definitions/uint8-array + required: - compatible - reg @@ -60,6 +67,7 @@ required: additionalProperties: - intel,vm-map - reset-control-skip + - vm-active-channels examples: - | @@ -73,5 +81,6 @@ examples: intel,vm-map = [03 01 04 ff ff]; clocks = <&osc0>; resets = <&rcu0 0x40 7>; + vm-active-channels = [08 10 02]; #thermal-sensor-cells = <1>; }; From patchwork Wed Aug 17 05:43:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945476 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3D47C25B08 for ; Wed, 17 Aug 2022 05:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238616AbiHQFnt (ORCPT ); Wed, 17 Aug 2022 01:43:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238599AbiHQFnj (ORCPT ); Wed, 17 Aug 2022 01:43:39 -0400 Received: from smtp-fw-9103.amazon.com (smtp-fw-9103.amazon.com [207.171.188.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 452E978239; Tue, 16 Aug 2022 22:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715017; x=1692251017; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BD7xLtT8ZDZM0YeRGZDNFzte0/L/07GbYy8it7xC5Js=; b=gltHg8/CbAseRcXoKTd0KC67YFfrzXp2bxOKNAkf06/Q+LJW8SqH28Qs MP53c9iZub7s5DLI+aXji25ekTdEimtUXNNOmXtLi+VCWFaq5LaSZyGFG He7Al7Y2eXn5nfB6+Lmqsjj79yU6GrKFgCJGRcBZmkDLbVybxx1MUHsLp 8=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="1045102103" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-pdx-2a-11a39b7d.us-west-2.amazon.com) ([10.25.36.214]) by smtp-border-fw-9103.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:26 +0000 Received: from EX13MTAUEB002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2a-11a39b7d.us-west-2.amazon.com (Postfix) with ESMTPS id D5BDA44812; Wed, 17 Aug 2022 05:43:25 +0000 (UTC) Received: from EX13D08UEB002.ant.amazon.com (10.43.60.107) by EX13MTAUEB002.ant.amazon.com (10.43.60.12) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D08UEB002.ant.amazon.com (10.43.60.107) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.61.243) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 838154C62; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 08/16] hwmon: (mr75203) add VM active channel support Date: Wed, 17 Aug 2022 05:43:13 +0000 Message-ID: <20220817054321.6519-9-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add active channel support per VM, which is useful when not all VM channels are used. Number of active channel is read from device-tree. When absent in device-tree, all channels are assumed to be used. Setting number of active channels to 0, means that entire VM sesnor is not used (this can partially replace the "intel,vm-map" functionality). Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 94 +++++++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 22 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 4419e481d47c..2e6139c09efc 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -30,6 +30,8 @@ #define CH_NUM_MSK GENMASK(31, 24) #define CH_NUM_SFT 24 +#define VM_NUM_MAX (VM_NUM_MSK >> VM_NUM_SFT) + /* Macro Common Register */ #define CLK_SYNTH 0x00 #define CLK_SYNTH_LO_SFT 0 @@ -107,6 +109,11 @@ #define PVT_N_CONST 90 #define PVT_R_CONST 245805 +struct voltage_device { + u8 vm_map; + u8 ch_map; +}; + struct pvt_device { struct regmap *c_map; struct regmap *t_map; @@ -114,12 +121,13 @@ struct pvt_device { struct regmap *v_map; struct clk *clk; struct reset_control *rst; + struct voltage_device *vd; u32 t_num; u32 p_num; u32 v_num; - u32 c_num; u32 ip_freq; - u8 *vm_idx; + u8 vm_ch_max; + u8 vm_ch_total; }; static umode_t pvt_is_visible(const void *data, enum hwmon_sensor_types type, @@ -186,11 +194,11 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) u8 ch_idx; int ret; - if (channel >= pvt->v_num * pvt->c_num) + if (channel >= pvt->vm_ch_total) return -EINVAL; - vm_idx = pvt->vm_idx[channel / pvt->c_num]; - ch_idx = channel % pvt->c_num; + vm_idx = pvt->vd[channel].vm_map; + ch_idx = pvt->vd[channel].ch_map; switch (attr) { case hwmon_in_input: @@ -390,7 +398,7 @@ static int pvt_init(struct pvt_device *pvt) if (ret) return ret; - val = GENMASK(pvt->c_num - 1, 0) | VM_CH_INIT | + val = GENMASK(pvt->vm_ch_max - 1, 0) | VM_CH_INIT | IP_POLL << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(v_map, SDIF_W, val); @@ -519,7 +527,7 @@ static int pvt_reset_control_deassert(struct device *dev, struct pvt_device *pvt static int mr75203_probe(struct platform_device *pdev) { const struct hwmon_channel_info **pvt_info; - u32 ts_num, vm_num, pd_num, ch_num, val, index, i; + u32 ts_num, vm_num, pd_num, ch_num, val, index, i, j, k; struct device *dev = &pdev->dev; u32 *temp_config, *in_config; struct device *hwmon_dev; @@ -569,7 +577,6 @@ static int mr75203_probe(struct platform_device *pdev) pvt->t_num = ts_num; pvt->p_num = pd_num; pvt->v_num = vm_num; - pvt->c_num = ch_num; val = 0; if (ts_num) val++; @@ -606,43 +613,86 @@ static int mr75203_probe(struct platform_device *pdev) } if (vm_num) { - u32 total_ch = ch_num * vm_num; + u8 vm_idx[VM_NUM_MAX]; + u8 vm_active_ch[VM_NUM_MAX]; ret = pvt_get_regmap(pdev, "vm", pvt); if (ret) return ret; - pvt->vm_idx = devm_kcalloc(dev, vm_num, sizeof(*pvt->vm_idx), - GFP_KERNEL); - if (!pvt->vm_idx) - return -ENOMEM; - - ret = device_property_read_u8_array(dev, "intel,vm-map", - pvt->vm_idx, vm_num); + ret = device_property_read_u8_array(dev, "intel,vm-map", vm_idx, + vm_num); if (ret) { /* * Incase intel,vm-map property is not defined, we * assume incremental channel numbers. */ for (i = 0; i < vm_num; i++) - pvt->vm_idx[i] = i; + vm_idx[i] = i; } else { for (i = 0; i < vm_num; i++) - if (pvt->vm_idx[i] >= vm_num || - pvt->vm_idx[i] == 0xff) + if (vm_idx[i] >= vm_num || vm_idx[i] == 0xff) break; vm_num = i; pvt->v_num = i; } - in_config = devm_kcalloc(dev, total_ch + 1, + ret = device_property_read_u8_array(dev, "vm-active-channels", + vm_active_ch, vm_num); + if (ret) { + /* + * Incase vm-active-channels property is not defined, + * we assume each VM sensor has all of its channels + * active. + */ + for (i = 0; i < vm_num; i++) + vm_active_ch[i] = ch_num; + + pvt->vm_ch_max = ch_num; + pvt->vm_ch_total = ch_num * vm_num; + } else { + for (i = 0; i < vm_num; i++) { + if (vm_active_ch[i] > ch_num) { + dev_err(dev, + "invalid active channels: %u\n", + vm_active_ch[i]); + return -EINVAL; + } + + pvt->vm_ch_total += vm_active_ch[i]; + + if (vm_active_ch[i] > pvt->vm_ch_max) + pvt->vm_ch_max = vm_active_ch[i]; + } + } + + /* + * Map between the channel-number to VM-index and channel-index. + * Example - 3 VMs, vm_active_ch = [05 02 04]: + * vm_map = [0 0 0 0 0 1 1 2 2 2 2] + * ch_map = [0 1 2 3 4 0 1 0 1 2 3] + */ + pvt->vd = devm_kcalloc(dev, pvt->vm_ch_total, sizeof(*pvt->vd), + GFP_KERNEL); + if (!pvt->vd) + return -ENOMEM; + + k = 0; + for (i = 0; i < vm_num; i++) + for (j = 0; j < vm_active_ch[i]; j++) { + pvt->vd[k].vm_map = vm_idx[i]; + pvt->vd[k].ch_map = j; + k++; + } + + in_config = devm_kcalloc(dev, pvt->vm_ch_total + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) return -ENOMEM; - memset32(in_config, HWMON_I_INPUT, total_ch); - in_config[total_ch] = 0; + memset32(in_config, HWMON_I_INPUT, pvt->vm_ch_total); + in_config[pvt->vm_ch_total] = 0; pvt_in.config = in_config; pvt_info[index++] = &pvt_in; From patchwork Wed Aug 17 05:43:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945478 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B08B4C25B08 for ; Wed, 17 Aug 2022 05:44:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238673AbiHQFoD (ORCPT ); Wed, 17 Aug 2022 01:44:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238640AbiHQFnx (ORCPT ); Wed, 17 Aug 2022 01:43:53 -0400 Received: from smtp-fw-33001.amazon.com (smtp-fw-33001.amazon.com [207.171.190.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 659047C193; Tue, 16 Aug 2022 22:43:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715023; x=1692251023; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hL47Mt4NCN4uw7YbFIII+nlUX4qr86MJ2L/tI0qq6tE=; b=TP3TzdOkzw1CGhrp92nvqv74WwNtrlgxKW+AXMGfazZFjZKb4FhMxfOy abF7gNexm2gbbdB9zufu+dqEQAxSDp0xr0ECzS5mkL8AZRUw+XiAu/Sme ERic/RE5+x/zDUxak/3uUBhX/q0lMjo0wIUAAha8yAzSlFr+qWBJCQVrb M=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="218561708" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-41c1ef8b.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-33001.sea14.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:26 +0000 Received: from EX13MTAUEE001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1e-41c1ef8b.us-east-1.amazon.com (Postfix) with ESMTPS id 418A4162673; Wed, 17 Aug 2022 05:43:22 +0000 (UTC) Received: from EX13D08UEE004.ant.amazon.com (10.43.62.182) by EX13MTAUEE001.ant.amazon.com (10.43.62.226) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D08UEE004.ant.amazon.com (10.43.62.182) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.61.243) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 86CA54C67; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 09/16] hwmon: (mr75203) add VM pre-scalar property for Moortec PVT controller Date: Wed, 17 Aug 2022 05:43:14 +0000 Message-ID: <20220817054321.6519-10-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org vm-pre-scalar-ch# is a per channel optional parameter that can be used to normalzie the voltage output results. Signed-off-by: Eliav Farber --- .../devicetree/bindings/hwmon/moortec,mr75203.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index 6111b5069b3c..e2a55001eefc 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -56,6 +56,12 @@ properties: A value of 0 means that the entire VM sensor is nou used. $ref: /schemas/types.yaml#definitions/uint8-array + vm-pre-scalar-ch#: + description: + vm-active-channels defines the pre-scalar per channel value + used to normalzie the voltage output results. + $ref: /schemas/types.yaml#definitions/uint32 + required: - compatible - reg @@ -68,6 +74,7 @@ additionalProperties: - intel,vm-map - reset-control-skip - vm-active-channels + - vm-pre-scalar-ch# examples: - | @@ -82,5 +89,6 @@ examples: clocks = <&osc0>; resets = <&rcu0 0x40 7>; vm-active-channels = [08 10 02]; + vm-pre-scalar-ch5 = <2>; #thermal-sensor-cells = <1>; }; From patchwork Wed Aug 17 05:43:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945485 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76E0EC25B08 for ; Wed, 17 Aug 2022 05:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238706AbiHQFot (ORCPT ); Wed, 17 Aug 2022 01:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238707AbiHQFoP (ORCPT ); Wed, 17 Aug 2022 01:44:15 -0400 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 088E07CB50; Tue, 16 Aug 2022 22:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715038; x=1692251038; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zDa/OToZ/vYiAzKBvDIfF4630+PtGKDsU6JSOj2YYVc=; b=qDRlQpZ088xOdvaptCHrNGt0E/QR5idS1h9HDwWwFMhFolvoPiIHREbV 5QKnJ56qm91Hcq7bBO5/d2Eec7rnYO4xE1wcWm5ShbJnIeYFMbMAA4/i1 EdVgUrPBYxOTXJ5Gjxt8xWTX1CoJO5fLyKuGXs+56d78nNPGpU1aN7SmH o=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="233936718" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1a-c92fe759.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:46 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1a-c92fe759.us-east-1.amazon.com (Postfix) with ESMTPS id 45499C08A4; Wed, 17 Aug 2022 05:43:44 +0000 (UTC) Received: from EX19D013UWA002.ant.amazon.com (10.13.138.210) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:23 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX19D013UWA002.ant.amazon.com (10.13.138.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 8A3C24C6A; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 10/16] hwmon: (mr75203) add VM pre-scalar support Date: Wed, 17 Aug 2022 05:43:15 +0000 Message-ID: <20220817054321.6519-11-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add pre-scalar support to normalzie the voltage output results for channels the use pre-scalar units to get the measurement to be within the range that the sensor supports. The pre-scalar value is used if it exists in device-tree, otherwise default value of 1 is used. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 2e6139c09efc..24a00339cfd8 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -112,8 +112,12 @@ struct voltage_device { u8 vm_map; u8 ch_map; + u32 pre_scaler; }; +#define PRE_SCALR_PROPERTY_NAME 32 +#define PRE_SCALR_DEFAULT_VAL 1 + struct pvt_device { struct regmap *c_map; struct regmap *t_map; @@ -215,7 +219,9 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) n &= SAMPLE_DATA_MSK; /* Convert the N bitstream count into voltage */ - *val = (PVT_N_CONST * n - PVT_R_CONST) >> PVT_CONV_BITS; + *val = pvt->vd[channel].pre_scaler; + *val *= (PVT_N_CONST * n - PVT_R_CONST); + *val >>= PVT_CONV_BITS; return 0; default: @@ -527,6 +533,7 @@ static int pvt_reset_control_deassert(struct device *dev, struct pvt_device *pvt static int mr75203_probe(struct platform_device *pdev) { const struct hwmon_channel_info **pvt_info; + const struct device_node *np = pdev->dev.of_node; u32 ts_num, vm_num, pd_num, ch_num, val, index, i, j, k; struct device *dev = &pdev->dev; u32 *temp_config, *in_config; @@ -552,7 +559,7 @@ static int mr75203_probe(struct platform_device *pdev) return ret; } - if (of_property_read_bool(dev->of_node, "reset-control-skip")) { + if (of_property_read_bool(np, "reset-control-skip")) { dev_info(dev, "skipping reset-control\n"); } else { pvt->rst = devm_reset_control_get_exclusive(dev, NULL); @@ -615,6 +622,8 @@ static int mr75203_probe(struct platform_device *pdev) if (vm_num) { u8 vm_idx[VM_NUM_MAX]; u8 vm_active_ch[VM_NUM_MAX]; + char prop_name[PRE_SCALR_PROPERTY_NAME] = {0}; + u32 pre_scaler; ret = pvt_get_regmap(pdev, "vm", pvt); if (ret) @@ -686,6 +695,21 @@ static int mr75203_probe(struct platform_device *pdev) k++; } + /* + * Incase vm-pre-scalar-ch# property is not defined, we assume + * default pre-scaler of 1. + */ + for (i = 0; i < pvt->vm_ch_total; i++) { + snprintf(prop_name, sizeof(prop_name), + "vm-pre-scalar-ch%u", i); + + ret = of_property_read_u32(np, prop_name, &pre_scaler); + if (ret) + pvt->vd[i].pre_scaler = PRE_SCALR_DEFAULT_VAL; + else + pvt->vd[i].pre_scaler = pre_scaler; + } + in_config = devm_kcalloc(dev, pvt->vm_ch_total + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) From patchwork Wed Aug 17 05:43:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945488 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDD3AC25B08 for ; Wed, 17 Aug 2022 05:45:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238796AbiHQFo5 (ORCPT ); Wed, 17 Aug 2022 01:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238715AbiHQFoR (ORCPT ); Wed, 17 Aug 2022 01:44:17 -0400 Received: from smtp-fw-80007.amazon.com (smtp-fw-80007.amazon.com [99.78.197.218]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A6D67CB7D; Tue, 16 Aug 2022 22:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715041; x=1692251041; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fs/9146WgnjF/BhtH8jRN4vQYRrSPrHOqbPejU/yHNA=; b=prZs6LcXJs0gtkSmrGHoe/OaWZ8zVFVszsKhyP4cHI6eFGtIzrZVuefs Xb3xG5xIgNmSxs+J0F+OWBWXwQM6fT5Yh5iHZeVqVqodZcStOQPnPY9/V oSYaqkCmG8n6f5lSiA7IgOWPBga/z0U1+LkVhLDdoWbEjrtPHxWVSE7lM Y=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="120136357" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-41c1ef8b.us-east-1.amazon.com) ([10.25.36.214]) by smtp-border-fw-80007.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:47 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1e-41c1ef8b.us-east-1.amazon.com (Postfix) with ESMTPS id 303CA1600D3; Wed, 17 Aug 2022 05:43:43 +0000 (UTC) Received: from EX19D013UWA001.ant.amazon.com (10.13.138.253) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:23 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX19D013UWA001.ant.amazon.com (10.13.138.253) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 8D9FF4C75; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 11/16] hwmon: (mr75203) add protection for negative voltage value Date: Wed, 17 Aug 2022 05:43:16 +0000 Message-ID: <20220817054321.6519-12-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This change makes sure the returned voltage vlaue is 0 or positive. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 24a00339cfd8..e3191f590167 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -218,6 +218,13 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) return ret; n &= SAMPLE_DATA_MSK; + + /* Voltage can't be negative */ + if (PVT_N_CONST * n < PVT_R_CONST) { + *val = 0; + return 0; + } + /* Convert the N bitstream count into voltage */ *val = pvt->vd[channel].pre_scaler; *val *= (PVT_N_CONST * n - PVT_R_CONST); From patchwork Wed Aug 17 05:43:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945481 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 050AFC25B08 for ; Wed, 17 Aug 2022 05:44:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238637AbiHQFoU (ORCPT ); Wed, 17 Aug 2022 01:44:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238638AbiHQFoD (ORCPT ); Wed, 17 Aug 2022 01:44:03 -0400 Received: from smtp-fw-80006.amazon.com (smtp-fw-80006.amazon.com [99.78.197.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0F5F7C51D; Tue, 16 Aug 2022 22:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715031; x=1692251031; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jff7zFZy9d0ZfKOoOEHMeXHCib3VjD8wsOPjEMr1j1Q=; b=hDAkPyHyknrzzFPPmlaklAkdcXBvhMTPzUEhkEPS6NuAdukIvM7DwX6u c+pCAqGtv2vSHlvaWQP1IoTj+XbAZzo7opyBu4ExCKwE55SCbJrQsB+so fUnBIVBVbglw+lc/UjpTzqQBLPjjW4irk3fG3BU1XHBZpZpyZKKwhOVLO 0=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="120059432" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1d-7a21ed79.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:49 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1d-7a21ed79.us-east-1.amazon.com (Postfix) with ESMTPS id 3B934220502; Wed, 17 Aug 2022 05:43:45 +0000 (UTC) Received: from EX19D013UWA004.ant.amazon.com (10.13.138.207) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:23 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX19D013UWA004.ant.amazon.com (10.13.138.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 911AA4C7D; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 12/16] hwmon: (mr75203) modify the temperature equation Date: Wed, 17 Aug 2022 05:43:17 +0000 Message-ID: <20220817054321.6519-13-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Modify the equation and coefficients to convert the digital output to temperature according to series 5 of the Moortec Embedded Temperature Sensor (METS) datasheet: T = G + H * (n / cal5 - 0.5) + J * F The G, H and J coefficients are multiplied by 1000 to get the temperature in milli-Celsius. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index e3191f590167..e500897585e4 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -102,9 +102,10 @@ #define PVT_POLL_DELAY_US 20 #define PVT_POLL_TIMEOUT_US 20000 -#define PVT_H_CONST 100000 -#define PVT_CAL5_CONST 2047 -#define PVT_G_CONST 40000 +#define PVT_H_CONST 60000 +#define PVT_G_CONST 200000 +#define PVT_J_CONST -100 +#define PVT_CAL5_CONST 4094 #define PVT_CONV_BITS 10 #define PVT_N_CONST 90 #define PVT_R_CONST 245805 @@ -158,7 +159,6 @@ static int pvt_read_temp(struct device *dev, u32 attr, int channel, long *val) struct regmap *t_map = pvt->t_map; u32 stat, nbs; int ret; - u64 tmp; switch (attr) { case hwmon_temp_input: @@ -176,12 +176,13 @@ static int pvt_read_temp(struct device *dev, u32 attr, int channel, long *val) nbs &= SAMPLE_DATA_MSK; /* - * Convert the register value to - * degrees centigrade temperature + * Convert the register value to degrees centigrade temperature: + * T = G + H * (n / cal5 - 0.5) + J * F */ - tmp = nbs * PVT_H_CONST; - do_div(tmp, PVT_CAL5_CONST); - *val = tmp - PVT_G_CONST - pvt->ip_freq; + *val = PVT_G_CONST; + *val += PVT_H_CONST * nbs / PVT_CAL5_CONST; + *val -= PVT_H_CONST / 2; + *val += PVT_J_CONST * pvt->ip_freq / HZ_PER_MHZ; return 0; default: @@ -313,7 +314,7 @@ static int pvt_init(struct pvt_device *pvt) (key >> 1) << CLK_SYNTH_HI_SFT | (key >> 1) << CLK_SYNTH_HOLD_SFT | CLK_SYNTH_EN; - pvt->ip_freq = sys_freq * 100 / (key + 2); + pvt->ip_freq = clk_get_rate(pvt->clk) / (key + 2); if (t_num) { ret = regmap_write(t_map, SDIF_SMPL_CTRL, 0x0); From patchwork Wed Aug 17 05:43:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945487 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A1B8C25B08 for ; Wed, 17 Aug 2022 05:44:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238792AbiHQFo5 (ORCPT ); Wed, 17 Aug 2022 01:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238635AbiHQFoR (ORCPT ); Wed, 17 Aug 2022 01:44:17 -0400 Received: from smtp-fw-80007.amazon.com (smtp-fw-80007.amazon.com [99.78.197.218]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C18D7CB6E; Tue, 16 Aug 2022 22:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715041; x=1692251041; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FNHPX12Pit1WxIpHyPTouV10hppwOlS2zHdFi1vLKSQ=; b=VmJoJFgdIwLTO0zuOSjjU/SchKcGjg5HpTrReGeAvLxcdsg8xF3Voxbu u9cIxem2AwCpr71rj62GIfNliIXV+htc0ASZFYlJVDQwRFba7rAZe97qY PKMb5Sk+KAol/T0/F2qV3vBUgsbjMsHAAErprWsTFgzyvSUT6TRsk1phR s=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="120136327" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-pdx-2a-5feb294a.us-west-2.amazon.com) ([10.25.36.214]) by smtp-border-fw-80007.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:39 +0000 Received: from EX13MTAUEE002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2a-5feb294a.us-west-2.amazon.com (Postfix) with ESMTPS id 73EAE835D8; Wed, 17 Aug 2022 05:43:38 +0000 (UTC) Received: from EX13D08UEE002.ant.amazon.com (10.43.62.92) by EX13MTAUEE002.ant.amazon.com (10.43.62.24) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from EX13MTAUEE002.ant.amazon.com (10.43.62.24) by EX13D08UEE002.ant.amazon.com (10.43.62.92) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.62.224) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 948004C90; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 13/16] hwmon: (mr75203) add thermal coefficient properties for Moortec PVT controller Date: Wed, 17 Aug 2022 05:43:18 +0000 Message-ID: <20220817054321.6519-14-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add optional "ts-coeff-g", "ts-coeff-h", "ts-coeff-cal5" and "ts-coeff-j" properties to be used instead of defaults for the thermal equasion. Signed-off-by: Eliav Farber --- .../bindings/hwmon/moortec,mr75203.yaml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index e2a55001eefc..867664bd937f 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -62,6 +62,30 @@ properties: used to normalzie the voltage output results. $ref: /schemas/types.yaml#definitions/uint32 + ts-coeff-g: + description: + G coefficient for thermal equation. + maxItems: 1 + $ref: /schemas/types.yaml#definitions/uint32 + + ts-coeff-h: + description: + H coefficient for thermal equation. + maxItems: 1 + $ref: /schemas/types.yaml#definitions/uint32 + + ts-coeff-cal5: + description: + cal5 coefficient for thermal equation (can't be 0). + maxItems: 1 + $ref: /schemas/types.yaml#definitions/uint32 + + ts-coeff-j: + description: + J coefficient for thermal equation. + maxItems: 1 + $ref: /schemas/types.yaml#definitions/int32 + required: - compatible - reg @@ -75,6 +99,10 @@ additionalProperties: - reset-control-skip - vm-active-channels - vm-pre-scalar-ch# + - ts-coeff-g + - ts-coeff-h + - ts-coeff-cal5 + - ts-coeff-j examples: - | @@ -90,5 +118,10 @@ examples: resets = <&rcu0 0x40 7>; vm-active-channels = [08 10 02]; vm-pre-scalar-ch5 = <2>; + ts-coeff-g = <57400>; + ts-coeff-h = <249400>; + ts-coeff-cal5 = <4096>; + ts-coeff-j = <0>; + #thermal-sensor-cells = <1>; }; From patchwork Wed Aug 17 05:43:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945484 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E37EC25B08 for ; Wed, 17 Aug 2022 05:44:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238763AbiHQFom (ORCPT ); Wed, 17 Aug 2022 01:44:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238699AbiHQFoH (ORCPT ); Wed, 17 Aug 2022 01:44:07 -0400 Received: from smtp-fw-6001.amazon.com (smtp-fw-6001.amazon.com [52.95.48.154]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4747726BB; Tue, 16 Aug 2022 22:43:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715032; x=1692251032; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NUVwpERCm95Kj0g+5lmwIVfkVMiD6QAcR9x2CsyUtlc=; b=uH+YR2csXv8akWiaJnFO2+QqMmLFvO9KflE0S0GFLc2CmKSeyjdpG3r0 9XmHGKqZyjaw+jOPCijTMKZEfI2T0U6SmcUFnjnqQulEVBKctCpMzQby0 p+b1kKfe49rEwXErSpHiar2A9VjmxmiO0Nr8Wd+AMmcoKK2PvutgwjDpu o=; Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-pdx-2c-90419278.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-6001.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:39 +0000 Received: from EX13MTAUEE002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2c-90419278.us-west-2.amazon.com (Postfix) with ESMTPS id 6D5A544E5D; Wed, 17 Aug 2022 05:43:38 +0000 (UTC) Received: from EX13D08UEE003.ant.amazon.com (10.43.62.118) by EX13MTAUEE002.ant.amazon.com (10.43.62.24) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D08UEE003.ant.amazon.com (10.43.62.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.61.243) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 97D864CA6; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 14/16] hwmon: (mr75203) parse thermal coefficients from device-tree Date: Wed, 17 Aug 2022 05:43:19 +0000 Message-ID: <20220817054321.6519-15-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Use thermal coefficients from the device tree if they exist. Otherwise, use default values. The equation used in the driver is: T = G + H * (n / cal5 - 0.5) + J * F With this change we can support also Mode 1 Conversion, which uses A instead of G, and B instead of H. We can also support the series 6 equation that has different coefficients and has a slightly different format: T = G + H * (n / cal5 - 0.5) by setting J to 0. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 44 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index e500897585e4..e54a4d1803e4 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -131,6 +131,10 @@ struct pvt_device { u32 p_num; u32 v_num; u32 ip_freq; + u32 ts_coeff_h; + u32 ts_coeff_g; + s32 ts_coeff_j; + u32 ts_coeff_cal5; u8 vm_ch_max; u8 vm_ch_total; }; @@ -179,10 +183,10 @@ static int pvt_read_temp(struct device *dev, u32 attr, int channel, long *val) * Convert the register value to degrees centigrade temperature: * T = G + H * (n / cal5 - 0.5) + J * F */ - *val = PVT_G_CONST; - *val += PVT_H_CONST * nbs / PVT_CAL5_CONST; - *val -= PVT_H_CONST / 2; - *val += PVT_J_CONST * pvt->ip_freq / HZ_PER_MHZ; + *val = pvt->ts_coeff_g; + *val += pvt->ts_coeff_h * nbs / pvt->ts_coeff_cal5; + *val -= pvt->ts_coeff_h / 2; + *val += pvt->ts_coeff_j * pvt->ip_freq / HZ_PER_MHZ; return 0; default: @@ -619,6 +623,38 @@ static int mr75203_probe(struct platform_device *pdev) memset32(temp_config, HWMON_T_INPUT, ts_num); pvt_temp.config = temp_config; pvt_info[index++] = &pvt_temp; + + /* + * Incase ts-coeff-h/g/j/cal5 property is not defined, use + * default value. + */ + ret = of_property_read_u32(np, "ts-coeff-h", &pvt->ts_coeff_h); + if (ret) + pvt->ts_coeff_h = PVT_H_CONST; + + ret = of_property_read_u32(np, "ts-coeff-g", &pvt->ts_coeff_g); + if (ret) + pvt->ts_coeff_g = PVT_G_CONST; + + ret = of_property_read_s32(np, "ts-coeff-j", &pvt->ts_coeff_j); + if (ret) + pvt->ts_coeff_j = PVT_J_CONST; + + ret = of_property_read_u32(np, "ts-coeff-cal5", + &pvt->ts_coeff_cal5); + if (ret) { + pvt->ts_coeff_cal5 = PVT_CAL5_CONST; + } else { + if (pvt->ts_coeff_cal5 == 0) { + dev_err(dev, "invalid ts-coeff-cal5 (%u)\n", + pvt->ts_coeff_cal5); + return -EINVAL; + } + } + + dev_dbg(dev, "ts-coeff: h = %u, g = %u, j = %d, cal5 = %u\n", + pvt->ts_coeff_h, pvt->ts_coeff_g, pvt->ts_coeff_j, + pvt->ts_coeff_cal5); } if (pd_num) { From patchwork Wed Aug 17 05:43:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945479 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48EE8C32771 for ; Wed, 17 Aug 2022 05:44:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238678AbiHQFoE (ORCPT ); Wed, 17 Aug 2022 01:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238599AbiHQFnx (ORCPT ); Wed, 17 Aug 2022 01:43:53 -0400 Received: from smtp-fw-80006.amazon.com (smtp-fw-80006.amazon.com [99.78.197.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C3427968D; Tue, 16 Aug 2022 22:43:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715024; x=1692251024; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hBhc/EYjMes9Bbjmd/5giazoEua+gxSqcbH/4UOdMxs=; b=uiiuDA2h/I/QMSQ1hGccan0kup/Ojlkb5XFk4qo2ArxMpiATRziqh7yM cN4qVnBBkgPJNiZolm9+z4e6wyZ8GKaweynzeXJVfvJyOpjptbz6T/Szp 77HyFkybs0llj1M/lpxvTkepo26je7HjeJ6omwRmqVwYurNzam4pR0zsY M=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="120059347" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1e-41c1ef8b.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:27 +0000 Received: from EX13MTAUEE001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1e-41c1ef8b.us-east-1.amazon.com (Postfix) with ESMTPS id 71914162679; Wed, 17 Aug 2022 05:43:25 +0000 (UTC) Received: from EX13D08UEB001.ant.amazon.com (10.43.60.245) by EX13MTAUEE001.ant.amazon.com (10.43.62.226) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:23 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D08UEB001.ant.amazon.com (10.43.60.245) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:22 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.61.243) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 9B3DC4CA7; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 15/16] hwmon: (mr75203) fix coding style space errors Date: Wed, 17 Aug 2022 05:43:20 +0000 Message-ID: <20220817054321.6519-16-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Fix: "ERROR: space required before the open parenthesis '('" Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index e54a4d1803e4..2898565afaab 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -174,7 +174,7 @@ static int pvt_read_temp(struct device *dev, u32 attr, int channel, long *val) return ret; ret = regmap_read(t_map, SDIF_DATA(channel), &nbs); - if(ret < 0) + if (ret < 0) return ret; nbs &= SAMPLE_DATA_MSK; @@ -219,7 +219,7 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) return ret; ret = regmap_read(v_map, VM_SDIF_DATA(vm_idx, ch_idx), &n); - if(ret < 0) + if (ret < 0) return ret; n &= SAMPLE_DATA_MSK; @@ -322,19 +322,19 @@ static int pvt_init(struct pvt_device *pvt) if (t_num) { ret = regmap_write(t_map, SDIF_SMPL_CTRL, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(t_map, SDIF_HALT, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(t_map, CLK_SYNTH, clk_synth); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(t_map, SDIF_DISABLE, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_read_poll_timeout(t_map, SDIF_STAT, @@ -347,7 +347,7 @@ static int pvt_init(struct pvt_device *pvt) val = CFG0_MODE_2 | CFG0_PARALLEL_OUT | CFG0_12_BIT | IP_CFG << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(t_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_read_poll_timeout(t_map, SDIF_STAT, @@ -360,7 +360,7 @@ static int pvt_init(struct pvt_device *pvt) val = POWER_DELAY_CYCLE_256 | IP_TMR << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(t_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_read_poll_timeout(t_map, SDIF_STAT, @@ -374,39 +374,39 @@ static int pvt_init(struct pvt_device *pvt) IP_CTRL << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(t_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; } if (p_num) { ret = regmap_write(p_map, SDIF_HALT, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(p_map, SDIF_DISABLE, BIT(p_num) - 1); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(p_map, CLK_SYNTH, clk_synth); - if(ret < 0) + if (ret < 0) return ret; } if (v_num) { ret = regmap_write(v_map, SDIF_SMPL_CTRL, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(v_map, SDIF_HALT, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(v_map, CLK_SYNTH, clk_synth); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(v_map, SDIF_DISABLE, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_read_poll_timeout(v_map, SDIF_STAT, @@ -434,7 +434,7 @@ static int pvt_init(struct pvt_device *pvt) CFG1_14_BIT | IP_CFG << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(v_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_read_poll_timeout(v_map, SDIF_STAT, @@ -447,7 +447,7 @@ static int pvt_init(struct pvt_device *pvt) val = POWER_DELAY_CYCLE_64 | IP_TMR << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(v_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_read_poll_timeout(v_map, SDIF_STAT, @@ -461,7 +461,7 @@ static int pvt_init(struct pvt_device *pvt) IP_CTRL << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(v_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; } @@ -586,7 +586,7 @@ static int mr75203_probe(struct platform_device *pdev) } ret = regmap_read(pvt->c_map, PVT_IP_CONFIG, &val); - if(ret < 0) + if (ret < 0) return ret; ts_num = (val & TS_NUM_MSK) >> TS_NUM_SFT; From patchwork Wed Aug 17 05:43:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12945474 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE62CC25B08 for ; Wed, 17 Aug 2022 05:43:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238571AbiHQFnh (ORCPT ); Wed, 17 Aug 2022 01:43:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233486AbiHQFng (ORCPT ); Wed, 17 Aug 2022 01:43:36 -0400 Received: from smtp-fw-9103.amazon.com (smtp-fw-9103.amazon.com [207.171.188.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E7DD78239; Tue, 16 Aug 2022 22:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660715015; x=1692251015; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yKQWTXqsUyX4LcBeXNBnNfziaCies5UNS/o5L6A+j78=; b=u0DleJAOdusBA0p2iSE3hazDm1b0h2N9uRVKaCeeKFhAudxv3x3V3bF4 7QZao+uZyNjS/cMdvgth3wvcW9E6vLNnffICx+dC/0kA6dWIR9kHO+6pI hTB97lZAMOgLSYa2crdP6iLiGxsjPxWm0GJcgI/VRQr3nzjpLkZyhiqKM 8=; X-IronPort-AV: E=Sophos;i="5.93,242,1654560000"; d="scan'208";a="1045102089" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-pdx-2c-388992e0.us-west-2.amazon.com) ([10.25.36.214]) by smtp-border-fw-9103.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 05:43:23 +0000 Received: from EX13MTAUWB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2c-388992e0.us-west-2.amazon.com (Postfix) with ESMTPS id BF1F6E07AA; Wed, 17 Aug 2022 05:43:23 +0000 (UTC) Received: from EX19D013UWB002.ant.amazon.com (10.13.138.21) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 17 Aug 2022 05:43:23 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX19D013UWB002.ant.amazon.com (10.13.138.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Wed, 17 Aug 2022 05:43:23 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Wed, 17 Aug 2022 05:43:22 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 9EC4E4CC3; Wed, 17 Aug 2022 05:43:21 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 16/16] hwmon: (mr75203) add debugfs to read and write temperature coefficients Date: Wed, 17 Aug 2022 05:43:21 +0000 Message-ID: <20220817054321.6519-17-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220817054321.6519-1-farbere@amazon.com> References: <20220817054321.6519-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This change adds debugfs to read and write TS coefficients - g, h, j and cal5. The coefficients can vary between product and product, so to calibrate them it can be very useful to to be able to modify them on the fly. e.g. cat /sys/kernel/debug/940f23d0000.pvt/ts_coeff_cal5 4096 echo 83000 > sys/kernel/debug/940f23d0000.pvt/ts_coeff_g Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 196 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 2898565afaab..ce34a44237e8 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -9,6 +9,7 @@ */ #include #include +#include #include #include #include @@ -127,6 +128,7 @@ struct pvt_device { struct clk *clk; struct reset_control *rst; struct voltage_device *vd; + struct dentry *dbgfs_dir; u32 t_num; u32 p_num; u32 v_num; @@ -139,6 +141,198 @@ struct pvt_device { u8 vm_ch_total; }; +static ssize_t pvt_ts_coeff_h_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + char buf[16]; + unsigned int len; + + len = sprintf(buf, "%u\n", pvt->ts_coeff_h); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t pvt_ts_coeff_h_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + int ret; + u32 coeff; + + ret = kstrtou32_from_user(user_buf, count, 0, &coeff); + if (ret) + return ret; + + pvt->ts_coeff_h = coeff; + + return count; +} + +static const struct file_operations pvt_ts_coeff_h_fops = { + .read = pvt_ts_coeff_h_read, + .write = pvt_ts_coeff_h_write, + .open = simple_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + +static ssize_t pvt_ts_coeff_g_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + char buf[16]; + unsigned int len; + + len = sprintf(buf, "%u\n", pvt->ts_coeff_g); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t pvt_ts_coeff_g_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + int ret; + u32 coeff; + + ret = kstrtou32_from_user(user_buf, count, 0, &coeff); + if (ret) + return ret; + + pvt->ts_coeff_g = coeff; + + return count; +} + +static const struct file_operations pvt_ts_coeff_g_fops = { + .read = pvt_ts_coeff_g_read, + .write = pvt_ts_coeff_g_write, + .open = simple_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + +static ssize_t pvt_ts_coeff_j_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + char buf[16]; + unsigned int len; + + len = sprintf(buf, "%d\n", pvt->ts_coeff_j); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t pvt_ts_coeff_j_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + int ret; + s32 coeff; + + ret = kstrtos32_from_user(user_buf, count, 0, &coeff); + if (ret) + return ret; + + pvt->ts_coeff_j = coeff; + + return count; +} + +static const struct file_operations pvt_ts_coeff_j_fops = { + .read = pvt_ts_coeff_j_read, + .write = pvt_ts_coeff_j_write, + .open = simple_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + +static ssize_t pvt_ts_coeff_cal5_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + char buf[16]; + unsigned int len; + + len = sprintf(buf, "%u\n", pvt->ts_coeff_cal5); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t pvt_ts_coeff_cal5_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + int ret; + u32 coeff; + + ret = kstrtou32_from_user(user_buf, count, 0, &coeff); + if (ret) + return ret; + + if (coeff == 0) + return -EINVAL; + + pvt->ts_coeff_cal5 = coeff; + + return count; +} + +static const struct file_operations pvt_ts_coeff_cal5_fops = { + .read = pvt_ts_coeff_cal5_read, + .write = pvt_ts_coeff_cal5_write, + .open = simple_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + +static void devm_pvt_ts_dbgfs_remove(void *data) +{ + struct pvt_device *pvt = (struct pvt_device *)data; + + debugfs_remove_recursive(pvt->dbgfs_dir); + pvt->dbgfs_dir = NULL; +} + +static int pvt_ts_dbgfs_create(struct pvt_device *pvt, struct device *dev) +{ + int ret; + + pvt->dbgfs_dir = debugfs_create_dir(dev_name(dev), NULL); + if (!pvt->dbgfs_dir) { + dev_err(dev, "Failed to create dbgfs_dir\n"); + return -EINVAL; + } + + debugfs_create_file("ts_coeff_h", 0644, pvt->dbgfs_dir, pvt, + &pvt_ts_coeff_h_fops); + debugfs_create_file("ts_coeff_g", 0644, pvt->dbgfs_dir, pvt, + &pvt_ts_coeff_g_fops); + debugfs_create_file("ts_coeff_j", 0644, pvt->dbgfs_dir, pvt, + &pvt_ts_coeff_j_fops); + debugfs_create_file("ts_coeff_cal5", 0644, pvt->dbgfs_dir, pvt, + &pvt_ts_coeff_cal5_fops); + + ret = devm_add_action_or_reset(dev, devm_pvt_ts_dbgfs_remove, pvt); + if (ret) { + dev_err(dev, "failed to add action to remove pvt dbgfs (%d)\n", + ret); + return ret; + } + + return 0; +} + static umode_t pvt_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr, int channel) { @@ -655,6 +849,8 @@ static int mr75203_probe(struct platform_device *pdev) dev_dbg(dev, "ts-coeff: h = %u, g = %u, j = %d, cal5 = %u\n", pvt->ts_coeff_h, pvt->ts_coeff_g, pvt->ts_coeff_j, pvt->ts_coeff_cal5); + + pvt_ts_dbgfs_create(pvt, dev); } if (pd_num) {