From nobody Wed Apr 8 10:27:25 2026 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 19272ECAAA1 for ; Tue, 6 Sep 2022 08:40:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239462AbiIFIke (ORCPT ); Tue, 6 Sep 2022 04:40:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239656AbiIFIjT (ORCPT ); Tue, 6 Sep 2022 04:39:19 -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 1CE5777561; Tue, 6 Sep 2022 01:37:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453450; x=1693989450; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7046ePXxVTAnqr0mWyv8v1NYuKAEnOXw9RXG6LdSpxY=; b=nYOwho2gUNeAbz9OLzwbghps0f8MrK+EqiqcTabs2ZcsFvWLXu2kt7Ae TWh/f2PDu5HHy/kI1Ef2f6AD90JvV+dkuqxpYQKXqZGYxJQViLN300H5z O+zLYcfeAKDe77nRN78/oQN2p9fFcQfEEmaezsXKUKg3F52pjil+X+G0B g=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="127050133" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1e-90d70b14.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; 06 Sep 2022 08:34:41 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1e-90d70b14.us-east-1.amazon.com (Postfix) with ESMTPS id 3386BC08D2; Tue, 6 Sep 2022 08:34:37 +0000 (UTC) Received: from EX19D013UWA002.ant.amazon.com (10.13.138.210) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:33:59 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) 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; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id CC5E94D84; Tue, 6 Sep 2022 08:33:56 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 01/21] hwmon: (mr75203) fix coding style space errors Date: Tue, 6 Sep 2022 08:33:36 +0000 Message-ID: <20220906083356.21067-2-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Fix: "ERROR: space required before the open parenthesis '('" Fixes: 9d823351a337 ("hwmon: Add hardware monitoring driver for Moortec MR7= 5203 PVT controller") Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- 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 046523d47c29..8adfbb15453f 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -155,7 +155,7 @@ static int pvt_read_temp(struct device *dev, u32 attr, = int channel, long *val) return ret; =20 ret =3D regmap_read(t_map, SDIF_DATA(channel), &nbs); - if(ret < 0) + if (ret < 0) return ret; =20 nbs &=3D SAMPLE_DATA_MSK; @@ -197,7 +197,7 @@ static int pvt_read_in(struct device *dev, u32 attr, in= t channel, long *val) return ret; =20 ret =3D regmap_read(v_map, VM_SDIF_DATA(vm_idx), &n); - if(ret < 0) + if (ret < 0) return ret; =20 n &=3D SAMPLE_DATA_MSK; @@ -291,19 +291,19 @@ static int pvt_init(struct pvt_device *pvt) =20 if (t_num) { ret =3D regmap_write(t_map, SDIF_SMPL_CTRL, 0x0); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_write(t_map, SDIF_HALT, 0x0); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_write(t_map, CLK_SYNTH, clk_synth); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_write(t_map, SDIF_DISABLE, 0x0); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_read_poll_timeout(t_map, SDIF_STAT, @@ -316,7 +316,7 @@ static int pvt_init(struct pvt_device *pvt) val =3D CFG0_MODE_2 | CFG0_PARALLEL_OUT | CFG0_12_BIT | IP_CFG << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret =3D regmap_write(t_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_read_poll_timeout(t_map, SDIF_STAT, @@ -329,7 +329,7 @@ static int pvt_init(struct pvt_device *pvt) val =3D POWER_DELAY_CYCLE_256 | IP_TMR << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret =3D regmap_write(t_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_read_poll_timeout(t_map, SDIF_STAT, @@ -343,39 +343,39 @@ static int pvt_init(struct pvt_device *pvt) IP_CTRL << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret =3D regmap_write(t_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; } =20 if (p_num) { ret =3D regmap_write(p_map, SDIF_HALT, 0x0); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_write(p_map, SDIF_DISABLE, BIT(p_num) - 1); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_write(p_map, CLK_SYNTH, clk_synth); - if(ret < 0) + if (ret < 0) return ret; } =20 if (v_num) { ret =3D regmap_write(v_map, SDIF_SMPL_CTRL, 0x0); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_write(v_map, SDIF_HALT, 0x0); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_write(v_map, CLK_SYNTH, clk_synth); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_write(v_map, SDIF_DISABLE, 0x0); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_read_poll_timeout(v_map, SDIF_STAT, @@ -389,7 +389,7 @@ static int pvt_init(struct pvt_device *pvt) CFG1_14_BIT | IP_CFG << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret =3D regmap_write(v_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_read_poll_timeout(v_map, SDIF_STAT, @@ -402,7 +402,7 @@ static int pvt_init(struct pvt_device *pvt) val =3D POWER_DELAY_CYCLE_64 | IP_TMR << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret =3D regmap_write(v_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; =20 ret =3D regmap_read_poll_timeout(v_map, SDIF_STAT, @@ -416,7 +416,7 @@ static int pvt_init(struct pvt_device *pvt) IP_CTRL << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret =3D regmap_write(v_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; } =20 @@ -535,7 +535,7 @@ static int mr75203_probe(struct platform_device *pdev) return dev_err_probe(dev, ret, "cannot deassert reset control\n"); =20 ret =3D regmap_read(pvt->c_map, PVT_IP_CONFIG, &val); - if(ret < 0) + if (ret < 0) return ret; =20 ts_num =3D (val & TS_NUM_MSK) >> TS_NUM_SFT; --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 64A76C38145 for ; Tue, 6 Sep 2022 08:40:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239454AbiIFIkX (ORCPT ); Tue, 6 Sep 2022 04:40:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239618AbiIFIjO (ORCPT ); Tue, 6 Sep 2022 04:39:14 -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 1167379A7B; Tue, 6 Sep 2022 01:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453440; x=1693989440; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=V4aH9xyy2/XLqee5tkK0CY6/3gjCyrih6JiYbJmNTYo=; b=LtTcMDKRywkFJbcr3SVT2iWtbb2XkXNCSlg3zLcwNipywhjlemzDZrKf fEE1IEIRhQ66/3afe2mFIUHz9fLQvZs7IhSmod5Fe5T+NzKMmyiZxpNWi E7Yi57LMNhbrX00pUj/8fSL4769BLH7mB8k5nmy4gvCxqLcrEHDYJLc9t E=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="127049967" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1d-8bf71a74.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; 06 Sep 2022 08:34:00 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1d-8bf71a74.us-east-1.amazon.com (Postfix) with ESMTPS id E7374C0A24; Tue, 6 Sep 2022 08:33:58 +0000 (UTC) Received: from EX19D013UWB003.ant.amazon.com (10.13.138.111) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:33:58 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX19D013UWB003.ant.amazon.com (10.13.138.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Tue, 6 Sep 2022 08:33:58 +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; Tue, 6 Sep 2022 08:33:58 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id C694B4D86; Tue, 6 Sep 2022 08:33:56 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 02/21] dt-bindings: hwmon: (mr75203) fix "intel,vm-map" property to be optional Date: Tue, 6 Sep 2022 08:33:37 +0000 Message-ID: <20220906083356.21067-3-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Change "intel,vm-map" property to be optional instead of required. The driver implementation indicates it is not mandatory to have "intel,vm-map" in the device tree: - probe doesn't fail in case it is absent. - explicit comment in code - "Incase intel,vm-map property is not defined, we assume incremental channel numbers". Fixes: 748022ef093f ("hwmon: Add DT bindings schema for PVT controller") Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V3 -> V2: - Change this patch to be first in the series. - Add explanation why "intel,vm-map" is not required. Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b= /Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index b79f069a04c2..8ea97e774364 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -48,7 +48,6 @@ required: - compatible - reg - reg-names - - intel,vm-map - clocks - resets - "#thermal-sensor-cells" --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 39E20ECAAA1 for ; Tue, 6 Sep 2022 08:35:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239070AbiIFIfI (ORCPT ); Tue, 6 Sep 2022 04:35:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234243AbiIFIeu (ORCPT ); Tue, 6 Sep 2022 04:34:50 -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 562A722B10; Tue, 6 Sep 2022 01:34: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=1662453288; x=1693989288; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oYZ9Wq3jM0aGkWOvYWKmVLjFLtLor/Gjf3AcMqCNWmU=; b=VaYfNaSW+iTQZ1muZmtHyTxKPvNyJdUTJkdoiE0PuNgnGtABhRJZq55j pi6g17SZKzxm0p7ye85cz1UraaMjQJs83+NiuZ+J3kp0xeapgniD69OIW OPnndjXW0d+lGiASm2vTU1gXtNI5gwkZ/f4iBXQHC9qLWBK7XgVHbX3Oj o=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="241387515" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-b48bc93b.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; 06 Sep 2022 08:34:40 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1d-b48bc93b.us-east-1.amazon.com (Postfix) with ESMTPS id 88852C022E; Tue, 6 Sep 2022 08:34:38 +0000 (UTC) Received: from EX19D013UWA001.ant.amazon.com (10.13.138.253) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:34:00 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) 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; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id D26DC4D79; Tue, 6 Sep 2022 08:33:56 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 03/21] hwmon: (mr75203) fix VM sensor allocation when "intel,vm-map" not defined Date: Tue, 6 Sep 2022 08:33:38 +0000 Message-ID: <20220906083356.21067-4-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Bug - in case "intel,vm-map" is missing in device-tree ,'num' is set to 0, and no voltage channel infos are allocated. The reason num is set to 0 when "intel,vm-map" is missing is to set the entire pvt->vm_idx[] with incremental channel numbers, but it didn't take into consideration that same num is used later in devm_kcalloc(). If "intel,vm-map" does exist there is no need to set the unspecified channels with incremental numbers, because the unspecified channels can't be accessed in pvt_read_in() which is the only other place besides the probe functions that uses pvt->vm_idx[]. This change fixes the bug by moving the incremental channel numbers setting to be done only if "intel,vm-map" property is defined (starting loop from 0), and removing 'num =3D 0'. Fixes: 9d823351a337 ("hwmon: Add hardware monitoring driver for Moortec MR7= 5203 PVT controller") Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> v3: - Simplify the fix by not removing the local num variable (it is removed as part of a later commit). drivers/hwmon/mr75203.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 8adfbb15453f..0ead576694a1 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -594,7 +594,12 @@ static int mr75203_probe(struct platform_device *pdev) ret =3D device_property_read_u8_array(dev, "intel,vm-map", pvt->vm_idx, vm_num); if (ret) { - num =3D 0; + /* + * Incase intel,vm-map property is not defined, we + * assume incremental channel numbers. + */ + for (i =3D 0; i < vm_num; i++) + pvt->vm_idx[i] =3D i; } else { for (i =3D 0; i < vm_num; i++) if (pvt->vm_idx[i] >=3D vm_num || @@ -604,13 +609,6 @@ static int mr75203_probe(struct platform_device *pdev) } } =20 - /* - * Incase intel,vm-map property is not defined, we assume - * incremental channel numbers. - */ - for (i =3D num; i < vm_num; i++) - pvt->vm_idx[i] =3D i; - in_config =3D devm_kcalloc(dev, num + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 3FFA2ECAAA1 for ; Tue, 6 Sep 2022 08:35:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239240AbiIFIfP (ORCPT ); Tue, 6 Sep 2022 04:35:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234175AbiIFIeu (ORCPT ); Tue, 6 Sep 2022 04:34:50 -0400 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 219D822284; Tue, 6 Sep 2022 01:34: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=1662453289; x=1693989289; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VNUfBH6XqJvzmNg5u+FEs4oR+vTWI22NM2Ghbdb3MNY=; b=QLR6pH+p0qMribficxge2nsWB6YeTMso/V3BfwX7ra32CWXn9Oko0gOd 5iWhv6GE7Lu5Q1YzFinylc3tkSpmP9g0Um8w4ceB2RBKldwhjDZOawHtH 1y2vrGHMHnp/38Zb2VuD+hOCzmk1zAYoAm944lT9MNm2Sx948tg2cwm2A w=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="237979511" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-fc41acad.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 08:34:40 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1e-fc41acad.us-east-1.amazon.com (Postfix) with ESMTPS id DF0A0C08F0; Tue, 6 Sep 2022 08:34:37 +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; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id CE9544D7F; Tue, 6 Sep 2022 08:33:56 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 04/21] hwmon: (mr75203) update pvt->v_num and vm_num to the actual number of used sensors Date: Tue, 6 Sep 2022 08:33:39 +0000 Message-ID: <20220906083356.21067-5-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This issue is relevant when "intel,vm-map" is set in device-tree, and defines a lower number of VMs than actually supported. This change is needed for all places that use pvt->v_num or vm_num later on in the code. Fixes: 9d823351a337 ("hwmon: Add hardware monitoring driver for Moortec MR7= 5203 PVT controller") Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> v3: - Update also vm_num to actual number of VMs. drivers/hwmon/mr75203.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 0ead576694a1..a209f5d95f4b 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -605,6 +605,8 @@ static int mr75203_probe(struct platform_device *pdev) if (pvt->vm_idx[i] >=3D vm_num || pvt->vm_idx[i] =3D=3D 0xff) { num =3D i; + pvt->v_num =3D i; + vm_num =3D i; break; } } --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 B4757C38145 for ; Tue, 6 Sep 2022 08:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239301AbiIFIlv (ORCPT ); Tue, 6 Sep 2022 04:41:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233803AbiIFIky (ORCPT ); Tue, 6 Sep 2022 04:40:54 -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 65D2F7A532; Tue, 6 Sep 2022 01:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453466; x=1693989466; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RTIQugJMBx86KeCOkkBfTbxPV094MtRi64y0zr8uTrg=; b=KKhzi/w/YXLB+mMgfH+dCVyenK/tx7WKLgG1UJIyObpw7l0wQXYdV+cp BVAGHWqVjsTnTp7+1BK3h0X0xgMDtXB3CxNgxaGxtdU1ssUqoce9ArapN mQTOBv90ivhgJE6S3ZMSeCXis2M1vOdl8xzY6QZQCl4AdVMpPJ/68OZoh E=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="127144277" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-1c3c2014.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; 06 Sep 2022 08:34:40 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1d-1c3c2014.us-east-1.amazon.com (Postfix) with ESMTPS id 940D7C0FF0; Tue, 6 Sep 2022 08:34:36 +0000 (UTC) Received: from EX19D013UWB003.ant.amazon.com (10.13.138.111) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:33:59 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX19D013UWB003.ant.amazon.com (10.13.138.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id C9A8E4D77; Tue, 6 Sep 2022 08:33:56 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 05/21] hwmon: (mr75203) fix voltage equation for negative source input Date: Tue, 6 Sep 2022 08:33:40 +0000 Message-ID: <20220906083356.21067-6-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" According to Moortec Embedded Voltage Monitor (MEVM) series 3 data sheet, the minimum input signal is -100mv and maximum input signal is +1000mv. The equation used to convert the digital word to voltage uses mixed types (*val signed and n unsigned), and on 64 bit machines also has different size, since sizeof(u32) =3D 4 and sizeof(long) =3D 8. So when measuring a negative input, n will be small enough, such that PVT_N_CONST * n < PVT_R_CONST, and the result of (PVT_N_CONST * n - PVT_R_CONST) will overflow to a very big positive 32 bit number. Then when storing the result in *val it will be the same value just in 64 bit (instead of it representing a negative number which will what happen when sizeof(long) =3D 4). When -1023 <=3D (PVT_N_CONST * n - PVT_R_CONST) <=3D -1 dividing the number by 1024 should result of in 0, but because ">> 10" is used it results in -1 (0xf...fffff). This change fixes the sign problem and supports negative values by casting n to long and replacing the shift right with div operation. Fixes: 9d823351a337 ("hwmon: Add hardware monitoring driver for Moortec MR7= 5203 PVT controller") Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> V3: - Remove unrelated change (add of empty line). V3 -> V2: - Fix equation to support negative values instead of limiting value to zero. drivers/hwmon/mr75203.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index a209f5d95f4b..78dc471e843c 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -202,7 +202,7 @@ static int pvt_read_in(struct device *dev, u32 attr, in= t channel, long *val) =20 n &=3D SAMPLE_DATA_MSK; /* Convert the N bitstream count into voltage */ - *val =3D (PVT_N_CONST * n - PVT_R_CONST) >> PVT_CONV_BITS; + *val =3D (PVT_N_CONST * (long)n - PVT_R_CONST) / (1 << PVT_CONV_BITS); =20 return 0; default: --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 C5FBFC38145 for ; Tue, 6 Sep 2022 08:35:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238535AbiIFIff (ORCPT ); Tue, 6 Sep 2022 04:35:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234121AbiIFIev (ORCPT ); Tue, 6 Sep 2022 04:34:51 -0400 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC8B52EF01; Tue, 6 Sep 2022 01:34: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=1662453291; x=1693989291; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oyi6EGS0RoM4Eyx6YSslJOyRtutK7naD8OnMXFnZelk=; b=tAILHJisJwlYQukAC8klmFgFKHYGso4KOFPgwkmJKuwMwB0eA1Amkk/g HIRCfqbq0w014tkopHZeA+AJ+UpgmeR7brVkEUdzOGDqbpuUp3uww3pxe 9LhGjmxxGbDgITs/lqC1jPlL/dYmF5Y8Mctgc7Ff/Y6fSexVeg1aQbczC E=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="237979512" 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-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 08:34:41 +0000 Received: from EX13MTAUWB001.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 37B041609B4; Tue, 6 Sep 2022 08:34:37 +0000 (UTC) Received: from EX19D013UWB004.ant.amazon.com (10.13.138.62) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:33:59 +0000 Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX19D013UWB004.ant.amazon.com (10.13.138.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.12; Tue, 6 Sep 2022 08:33:59 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 6 Sep 2022 08:33:58 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id C8C5E4D78; Tue, 6 Sep 2022 08:33:56 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 06/21] hwmon: (mr75203) fix multi-channel voltage reading Date: Tue, 6 Sep 2022 08:33:41 +0000 Message-ID: <20220906083356.21067-7-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Fix voltage allocation and reading to support all channels in all VMs. Prior to this change allocation and reading were done only for the first channel in each VM. This change counts the total number of channels for allocation, and takes into account the channel offset when reading the sample data register. Fixes: 9d823351a337 ("hwmon: Add hardware monitoring driver for Moortec MR7= 5203 PVT controller") Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> V3: - Keep lines sorted according to length. V3 -> V2: - Remove configuration of ip-polling register to a separate commit. - Explain the fix. drivers/hwmon/mr75203.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 78dc471e843c..69f38c05b02d 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -68,8 +68,9 @@ =20 /* 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)) =20 /* SDA Slave Register */ #define IP_CTRL 0x00 @@ -115,6 +116,7 @@ struct pvt_device { u32 t_num; u32 p_num; u32 v_num; + u32 c_num; u32 ip_freq; u8 *vm_idx; }; @@ -178,14 +180,15 @@ static int pvt_read_in(struct device *dev, u32 attr, = int channel, long *val) { struct pvt_device *pvt =3D dev_get_drvdata(dev); struct regmap *v_map =3D pvt->v_map; + u8 vm_idx, ch_idx; u32 n, stat; - u8 vm_idx; int ret; =20 - if (channel >=3D pvt->v_num) + if (channel >=3D pvt->v_num * pvt->c_num) return -EINVAL; =20 - vm_idx =3D pvt->vm_idx[channel]; + vm_idx =3D pvt->vm_idx[channel / pvt->c_num]; + ch_idx =3D channel % pvt->c_num; =20 switch (attr) { case hwmon_in_input: @@ -196,7 +199,7 @@ static int pvt_read_in(struct device *dev, u32 attr, in= t channel, long *val) if (ret) return ret; =20 - ret =3D regmap_read(v_map, VM_SDIF_DATA(vm_idx), &n); + ret =3D regmap_read(v_map, VM_SDIF_DATA(vm_idx, ch_idx), &n); if (ret < 0) return ret; =20 @@ -499,8 +502,8 @@ static int pvt_reset_control_deassert(struct device *de= v, struct pvt_device *pvt =20 static int mr75203_probe(struct platform_device *pdev) { + u32 ts_num, vm_num, pd_num, ch_num, val, index, i; const struct hwmon_channel_info **pvt_info; - u32 ts_num, vm_num, pd_num, val, index, i; struct device *dev =3D &pdev->dev; u32 *temp_config, *in_config; struct device *hwmon_dev; @@ -541,9 +544,11 @@ static int mr75203_probe(struct platform_device *pdev) ts_num =3D (val & TS_NUM_MSK) >> TS_NUM_SFT; pd_num =3D (val & PD_NUM_MSK) >> PD_NUM_SFT; vm_num =3D (val & VM_NUM_MSK) >> VM_NUM_SFT; + ch_num =3D (val & CH_NUM_MSK) >> CH_NUM_SFT; pvt->t_num =3D ts_num; pvt->p_num =3D pd_num; pvt->v_num =3D vm_num; + pvt->c_num =3D ch_num; val =3D 0; if (ts_num) val++; @@ -580,7 +585,7 @@ static int mr75203_probe(struct platform_device *pdev) } =20 if (vm_num) { - u32 num =3D vm_num; + u32 total_ch; =20 ret =3D pvt_get_regmap(pdev, "vm", pvt); if (ret) @@ -604,20 +609,20 @@ static int mr75203_probe(struct platform_device *pdev) for (i =3D 0; i < vm_num; i++) if (pvt->vm_idx[i] >=3D vm_num || pvt->vm_idx[i] =3D=3D 0xff) { - num =3D i; pvt->v_num =3D i; vm_num =3D i; break; } } =20 - in_config =3D devm_kcalloc(dev, num + 1, + total_ch =3D ch_num * vm_num; + in_config =3D devm_kcalloc(dev, total_ch + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) return -ENOMEM; =20 - memset32(in_config, HWMON_I_INPUT, num); - in_config[num] =3D 0; + memset32(in_config, HWMON_I_INPUT, total_ch); + in_config[total_ch] =3D 0; pvt_in.config =3D in_config; =20 pvt_info[index++] =3D &pvt_in; --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 3AC50C38145 for ; Tue, 6 Sep 2022 08:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239280AbiIFIf0 (ORCPT ); Tue, 6 Sep 2022 04:35:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238881AbiIFIeu (ORCPT ); Tue, 6 Sep 2022 04:34:50 -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 E86C9167C7; Tue, 6 Sep 2022 01:34: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=1662453289; x=1693989289; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e6OOJ9Of/ZaB/riGWD/k+rcsqkFt3FkV7A/+oQh8Vrs=; b=Kwjpt5T+WBtBdxQCStWUrzA3mm9ihN1fxMrGR35ssxQ9UQ9dai4Kkf1w PBB/VfOz4xd4fjG7zOQiBFQfnwEjHLKE/iHUE4bff/Ivjrw9So47NpsZu A7jBVUiDTIK44J797ti+IpE43tP5wq5yL7yslOw9IFNfbFzQXqI9kQKPL g=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="241387494" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-0bfdb89e.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; 06 Sep 2022 08:34:37 +0000 Received: from EX13MTAUWB001.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 D4FF6E0E73; Tue, 6 Sep 2022 08:34:34 +0000 (UTC) Received: from EX19D013UWA001.ant.amazon.com (10.13.138.253) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:33:58 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) 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; Tue, 6 Sep 2022 08:33:58 +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; Tue, 6 Sep 2022 08:33:57 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id C81384D83; Tue, 6 Sep 2022 08:33:56 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 07/21] hwmon: (mr75203) enable polling for all VM channels Date: Tue, 6 Sep 2022 08:33:42 +0000 Message-ID: <20220906083356.21067-8-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Configure ip-polling register to enable polling for all voltage monitor channels. This enables reading the voltage values for all inputs other than just input 0. Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V3 -> V2: - Move configuration of ip-polling register from previous patch to a separate commit. V4 -> V3: - Replace GENMASK(pvt->c_num - 1, 0) with (BIT(pvt->c_num) - 1). drivers/hwmon/mr75203.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 69f38c05b02d..5f2b11a2bf5f 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -388,6 +388,19 @@ static int pvt_init(struct pvt_device *pvt) if (ret) return ret; =20 + val =3D (BIT(pvt->c_num) - 1) | VM_CH_INIT | + IP_POLL << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; + ret =3D regmap_write(v_map, SDIF_W, val); + if (ret < 0) + return ret; + + ret =3D 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 =3D CFG1_VOL_MEAS_MODE | CFG1_PARALLEL_OUT | CFG1_14_BIT | IP_CFG << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 0403AC6FA83 for ; Tue, 6 Sep 2022 08:34:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238846AbiIFIez (ORCPT ); Tue, 6 Sep 2022 04:34:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238867AbiIFIer (ORCPT ); Tue, 6 Sep 2022 04:34:47 -0400 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4826EDEFF; Tue, 6 Sep 2022 01:34:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453287; x=1693989287; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j9nLXsVxOy0JGDU7T6OUbxf37zFCWFjVBH7FijS2nao=; b=ZpQTO4HiD0+FS8cO6n1r11d4S0weRutvvZxy7YGLaq8byAcnztfT1k3f 1WibGfkKMqIVGj7y0JYplDC6on3DoCGzc+LRU4zW2AHTW6/8nDGJLsg/P zRVYsicwmtg75KBUZu4XnEXLsjldrLFc/wHXR1V3yOz+bU2i90sabHyY9 c=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="237979510" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-7a21ed79.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 08:34:40 +0000 Received: from EX13MTAUWB001.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 DF490220043; Tue, 6 Sep 2022 08:34:37 +0000 (UTC) Received: from EX19D013UWB003.ant.amazon.com (10.13.138.111) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:33:59 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX19D013UWB003.ant.amazon.com (10.13.138.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id D1BDA4D85; Tue, 6 Sep 2022 08:33:56 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 08/21] dt-bindings: hwmon: (mr75203) add description for Moortec's PVT controller Date: Tue, 6 Sep 2022 08:33:43 +0000 Message-ID: <20220906083356.21067-9-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This changes adds a detailed description for the mr75203 controller and for some of the analog IPs controlled by it. Signed-off-by: Eliav Farber Acked-by: Rob Herring Reviewed-by: Andy Shevchenko --- V4 -> V3: - New patch to add description. .../bindings/hwmon/moortec,mr75203.yaml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b= /Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index 8ea97e774364..5e41aed5891a 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -9,6 +9,32 @@ title: Moortec Semiconductor MR75203 PVT Controller bindin= gs maintainers: - Rahul Tanwar =20 +description: | + A Moortec PVT (Process, Voltage, Temperature) monitoring logic design can + include many different units. + Such a design will usually consists of several Moortec's embedded analog= IPs, + and a single Moortec controller (mr75203) to configure and control the I= Ps. + + Some of the Moortec's analog hard IPs that can be used in a design: + *) Temperature Sensor (TS) - used to monitor core temperature (e.g. mr74= 137). + *) Voltage Monitor (VM) - used to monitor voltage levels (e.g. mr74138). + *) Process Detector (PD) - used to assess silicon speed (e.g. mr74139). + *) Delay Chain - ring oscillator connected to the PD, used to measure IO + based transistors (e.g. mr76008 ring oscillator at 1.1V, mr76007 ring + oscillator at 1.8V). + *) Pre Scaler - provides divide-by-X scaling of input voltage, which can= then + be presented for VM for measurement within its range (e.g. mr76006 - + divide by 2 pre-scaler). + + TS, VM & PD also include a digital interface, which consists of configur= ation + inputs and measurement outputs. + + Some of the units have number of series, each series can have slightly + different characteristics. + + The mr75203 binding describes configuration for the controller unit, but= also + for some of the analog IPs. + properties: compatible: const: moortec,mr75203 --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 6EF48ECAAA1 for ; Tue, 6 Sep 2022 08:35:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239203AbiIFIfV (ORCPT ); Tue, 6 Sep 2022 04:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233147AbiIFIeu (ORCPT ); Tue, 6 Sep 2022 04:34:50 -0400 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A761013FA6; Tue, 6 Sep 2022 01:34: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=1662453290; x=1693989290; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q8Iynp95KpaU7SmgCP1oIvGfO+Da+UEwSVKNj91haTY=; b=PYh0caTL8Ax3xEOGY3QqNghX4dlrLr/g0ork4lcf1PutAOcxzBnvFCvK rhKf0EprRkXOM3vKaEryMCUd9slFwPwEhiJF3dG02fpoN9Wv6/nO35oV7 EETxDMKCqoA6L2+eUuL1ZOVq7N2Pqw7k+6yBqKcWByxGs1KVJqjdiqTDb A=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="237979515" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-35b1f9a2.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 08:34:42 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1d-35b1f9a2.us-east-1.amazon.com (Postfix) with ESMTPS id 06D6E201076; Tue, 6 Sep 2022 08:34:38 +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; Tue, 6 Sep 2022 08:34:00 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) 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; Tue, 6 Sep 2022 08:34:00 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id D31E24D72; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 09/21] dt-bindings: hwmon: (mr75203) change "resets" property to be optional Date: Tue, 6 Sep 2022 08:33:44 +0000 Message-ID: <20220906083356.21067-10-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Change "resets" property to be optional instead of required, for SOCs that don't support a reset controller. Signed-off-by: Eliav Farber Acked-by: Rob Herring Reviewed-by: Andy Shevchenko --- V4 -> V3: - Fix "reset" to "resets". V3 -> v2: - Change "reset" property to be optional instead of adding new "reset-control-skip" property. Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b= /Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index 5e41aed5891a..9454576ebb73 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -75,7 +75,6 @@ required: - reg - reg-names - clocks - - resets - "#thermal-sensor-cells" =20 additionalProperties: false --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 5FD4AC38145 for ; Tue, 6 Sep 2022 08:36:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239256AbiIFIgE (ORCPT ); Tue, 6 Sep 2022 04:36:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239125AbiIFIfA (ORCPT ); Tue, 6 Sep 2022 04:35:00 -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 869CC65813; Tue, 6 Sep 2022 01:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453299; x=1693989299; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LK8bT5LZ+eBgkgbkxsPXj0HVJHSS3mb9XI2/tM9CgPA=; b=W20Uav/NVz0UrYnJxMD2uHcMF1EulVVLGuWYrs5/Xr6jc5nmg/U7qnpq 2Ccy9oeZEDFu95YL3zuUa5SosrxR0yT7gSk+2HIWv4ha1dD0mEwnhCQIh VDWNYyGaebPXSArn0lA1/F29kLBdEK7LeBnUzEJTkTu64sOSAnVJx6/Q/ 8=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="256505589" 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-9102.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 08:34:40 +0000 Received: from EX13MTAUWB001.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 E38C7C02C6; Tue, 6 Sep 2022 08:34:37 +0000 (UTC) Received: from EX19D013UWA004.ant.amazon.com (10.13.138.207) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id CD1954D6F; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 10/21] hwmon: (mr75203) skip reset-control deassert for SOCs that don't support it Date: Tue, 6 Sep 2022 08:33:45 +0000 Message-ID: <20220906083356.21067-11-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Don't fail the probe function and don't deassert the reset controller if a "reset" property doesn't exist in the device tree. Change is done for SOCs that don't support a reset controller. Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V3 -> v2: - Change "reset" property to be optional instead of skipping it. drivers/hwmon/mr75203.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 5f2b11a2bf5f..c94e89c94cb3 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -541,14 +541,17 @@ static int mr75203_probe(struct platform_device *pdev) return ret; } =20 - pvt->rst =3D devm_reset_control_get_exclusive(dev, NULL); + pvt->rst =3D devm_reset_control_get_optional_exclusive(dev, NULL); if (IS_ERR(pvt->rst)) return dev_err_probe(dev, PTR_ERR(pvt->rst), "failed to get reset control\n"); =20 - ret =3D pvt_reset_control_deassert(dev, pvt); - if (ret) - return dev_err_probe(dev, ret, "cannot deassert reset control\n"); + if (pvt->rst) { + ret =3D pvt_reset_control_deassert(dev, pvt); + if (ret) + return dev_err_probe(dev, ret, + "cannot deassert reset control\n"); + } =20 ret =3D regmap_read(pvt->c_map, PVT_IP_CONFIG, &val); if (ret < 0) --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 DA087C54EE9 for ; Tue, 6 Sep 2022 08:37:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239213AbiIFIhE (ORCPT ); Tue, 6 Sep 2022 04:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239342AbiIFIgL (ORCPT ); Tue, 6 Sep 2022 04:36:11 -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 4D09876459; Tue, 6 Sep 2022 01:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453325; x=1693989325; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=17w8R9cWiSJoTxEEKKcqd9TX1Pk/TUW81RJNwHEHIxw=; b=X6vOeRPl30KmQeam6ZP03QA513pBAkvOlh4+A606u6WeFmGL1MwL0mDx vvl6HBP6f4Fh+zH7xlBZVw/Hsa2wr9SykL1YhmFdvYEgEpTHIuVccGFyY uKJDmRes8x9G45gjFeTyN3JcuawdSlGY+pVFXXoX1ptlfdIIRPx8lV1AF A=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="1051603358" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-7dac3c4d.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; 06 Sep 2022 08:34:39 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1e-7dac3c4d.us-east-1.amazon.com (Postfix) with ESMTPS id 6ACA0818CF; Tue, 6 Sep 2022 08:34:38 +0000 (UTC) Received: from EX19D013UWA001.ant.amazon.com (10.13.138.253) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:34:00 +0000 Received: from EX13MTAUEE002.ant.amazon.com (10.43.62.24) 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; Tue, 6 Sep 2022 08:34:00 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id CF5EA4D75; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 11/21] dt-bindings: vendor-prefixes: add vendor prefix for Moortec Date: Tue, 6 Sep 2022 08:33:46 +0000 Message-ID: <20220906083356.21067-12-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add device-tree vendor prefix for Moortec Semiconductor Ltd. Website: https://moortec.com/ Moortec were acquired by Synopsys so link above leads to: https://www.synopsys.com/solutions/silicon-lifecycle-management.html Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> V3: - New patch to add moortec to vendor-prefixes. Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Docum= entation/devicetree/bindings/vendor-prefixes.yaml index 2f0151e9f6be..9bf7c2cd7e89 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -819,6 +819,8 @@ patternProperties: description: MNT Research GmbH "^modtronix,.*": description: Modtronix Engineering + "^moortec,.*": + description: Moortec Semiconductor Ltd. "^mosaixtech,.*": description: Mosaix Technologies, Inc. "^motorola,.*": --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 B1662C38145 for ; Tue, 6 Sep 2022 08:36:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239277AbiIFIgM (ORCPT ); Tue, 6 Sep 2022 04:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239174AbiIFIfB (ORCPT ); Tue, 6 Sep 2022 04:35:01 -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 A647169F7E; Tue, 6 Sep 2022 01:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453299; x=1693989299; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s1EK0oUudRQ1hUnUB5MnNWs/t3MkWH0czu1v7nps9BY=; b=oE3c8mOXvYoo37Sj9iK2J0nHSTe3lzCcKtRo7b9Z98CbLmnUEUr68tYk S6GU7ijyhFTTAt+iezQ15tXeaMulmO7XvuOYm8CmADtP6fc4y08DSZvfD qX+Kk2WA3wiH0ncFgoaIO5B4L2We6V4jDU5iDGv5ffCBuaj4MsVumzT/g w=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="256505583" 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-9102.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 08:34:39 +0000 Received: from EX13MTAUWB001.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 5A8D9E0E6A; Tue, 6 Sep 2022 08:34:38 +0000 (UTC) Received: from EX19D013UWB004.ant.amazon.com (10.13.138.62) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:34:00 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX19D013UWB004.ant.amazon.com (10.13.138.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.12; Tue, 6 Sep 2022 08:34:00 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id CDD054D7B; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 12/21] dt-bindings: hwmon: (mr75203) add "moortec,vm-active-channels" property Date: Tue, 6 Sep 2022 08:33:47 +0000 Message-ID: <20220906083356.21067-13-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add optional "moortec,vm-active-channels" property to define the number of active channels per VM. This shall be useful to avoid exposing sysfs for reading inputs that are not connected to any voltage source. Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> V3: - Fix DT checker errors. V3 -> V2: - Add "moortec" prefix to property name. - Add explanation why this change is needed. .../devicetree/bindings/hwmon/moortec,mr75203.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b= /Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index 9454576ebb73..2aa4c3618596 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -70,6 +70,15 @@ properties: "#thermal-sensor-cells": const: 1 =20 + moortec,vm-active-channels: + description: + Defines the number of channels per VM that are actually used and are + connected to some input source. + Maximum number of items - number of VMs. + Maximum value of each item - number of channels. + Minimum value of each item - 0 (which means entire VM sensor is nou = used). + $ref: /schemas/types.yaml#/definitions/uint8-array + required: - compatible - reg @@ -91,5 +100,6 @@ examples: intel,vm-map =3D [03 01 04 ff ff]; clocks =3D <&osc0>; resets =3D <&rcu0 0x40 7>; + moortec,vm-active-channels =3D /bits/ 8 <0x10 0x05>; #thermal-sensor-cells =3D <1>; }; --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 F1067C38145 for ; Tue, 6 Sep 2022 08:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239136AbiIFIhN (ORCPT ); Tue, 6 Sep 2022 04:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239224AbiIFIgr (ORCPT ); Tue, 6 Sep 2022 04:36:47 -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 407FD76940; Tue, 6 Sep 2022 01:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453330; x=1693989330; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ITh4dnSsT8Tur8fQ0l3TRk5T+2gkpFre/IaJcGH8k0s=; b=pOIJjQN2vR6MsJruY1ydebEyKBGAhcy27rJ5u1CAaejGHSF+jboJFALP gR3bZpWNWkwc/qOX3OQSH5KT0SDFcUEv28cCoTmq6jbecgwGhr/KrNz6z 6dsUu+Ju5eg8AkaAHftQ4Pv3AGy6sjKAqxHhohKzlVERLlPpWoetdcRup I=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="1051603363" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1a-bbd95331.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; 06 Sep 2022 08:34:39 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1a-bbd95331.us-east-1.amazon.com (Postfix) with ESMTPS id 1BBEDC1C27; Tue, 6 Sep 2022 08:34:36 +0000 (UTC) Received: from EX19D013UWA002.ant.amazon.com (10.13.138.210) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id CB0174D8D; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 13/21] hwmon: (mr75203) add VM active channel support Date: Tue, 6 Sep 2022 08:33:48 +0000 Message-ID: <20220906083356.21067-14-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add active channel support per voltage monitor. The number of active channels is read from the device-tree. When absent in device-tree, all channels are assumed to be used. This shall be useful to expose sysfs only for inputs that are connected to a voltage source. Setting number of active channels to 0, means that entire VM sensor is not used. Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> V3: - Convert comments to kernel doc. - Repalce for loop with memset. - Add {} to outer for loop. V3 -> V2: - Refactor the code changes (move code to a new function and group parameters in dedicated structure). V2 -> V1: - Fix compilation error for patch 08/16: "warning: ISO C90 forbids variable length array" drivers/hwmon/mr75203.c | 121 ++++++++++++++++++++++++++++++++-------- 1 file changed, 99 insertions(+), 22 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index c94e89c94cb3..5aa694fd9118 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -29,6 +29,8 @@ #define CH_NUM_MSK GENMASK(31, 24) #define CH_NUM_SFT 24 =20 +#define VM_NUM_MAX (VM_NUM_MSK >> VM_NUM_SFT) + /* Macro Common Register */ #define CLK_SYNTH 0x00 #define CLK_SYNTH_LO_SFT 0 @@ -106,6 +108,31 @@ #define PVT_N_CONST 90 #define PVT_R_CONST 245805 =20 +/** + * struct voltage_device - VM single input parameters. + * @vm_map: Map channel number to VM index. + * @ch_map: Map channel number to channel index. + * + * The structure provides mapping between channel-number (0..N-1) to VM-in= dex + * (0..num_vm-1) and channel-index (0..ch_num-1) where N =3D num_vm * ch_n= um. + */ +struct voltage_device { + u32 vm_map; + u32 ch_map; +}; + +/** + * struct voltage_channels - VM channel count. + * @total: Total number of channels in all VMs. + * @max: Maximum number of channels among all VMs. + * + * The structure provides channel count information across all VMs. + */ +struct voltage_channels { + u32 total; + u8 max; +}; + struct pvt_device { struct regmap *c_map; struct regmap *t_map; @@ -113,12 +140,12 @@ struct pvt_device { struct regmap *v_map; struct clk *clk; struct reset_control *rst; + struct voltage_device *vd; + struct voltage_channels vm_channels; u32 t_num; u32 p_num; u32 v_num; - u32 c_num; u32 ip_freq; - u8 *vm_idx; }; =20 static umode_t pvt_is_visible(const void *data, enum hwmon_sensor_types ty= pe, @@ -184,11 +211,11 @@ static int pvt_read_in(struct device *dev, u32 attr, = int channel, long *val) u32 n, stat; int ret; =20 - if (channel >=3D pvt->v_num * pvt->c_num) + if (channel >=3D pvt->vm_channels.total) return -EINVAL; =20 - vm_idx =3D pvt->vm_idx[channel / pvt->c_num]; - ch_idx =3D channel % pvt->c_num; + vm_idx =3D pvt->vd[channel].vm_map; + ch_idx =3D pvt->vd[channel].ch_map; =20 switch (attr) { case hwmon_in_input: @@ -388,7 +415,7 @@ static int pvt_init(struct pvt_device *pvt) if (ret) return ret; =20 - val =3D (BIT(pvt->c_num) - 1) | VM_CH_INIT | + val =3D (BIT(pvt->vm_channels.max) - 1) | VM_CH_INIT | IP_POLL << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret =3D regmap_write(v_map, SDIF_W, val); if (ret < 0) @@ -513,6 +540,60 @@ static int pvt_reset_control_deassert(struct device *d= ev, struct pvt_device *pvt return devm_add_action_or_reset(dev, pvt_reset_control_assert, pvt); } =20 +static int pvt_get_active_channel(struct device *dev, struct pvt_device *p= vt, + u32 vm_num, u32 ch_num, u8 *vm_idx) +{ + u8 vm_active_ch[VM_NUM_MAX]; + int ret, i, j, k; + + ret =3D device_property_read_u8_array(dev, "moortec,vm-active-channels", + vm_active_ch, vm_num); + if (ret) { + /* + * Incase "moortec,vm-active-channels" property is not defined, + * we assume each VM sensor has all of its channels active. + */ + memset(vm_active_ch, ch_num, vm_num); + pvt->vm_channels.max =3D ch_num; + pvt->vm_channels.total =3D ch_num * vm_num; + } else { + for (i =3D 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_channels.total +=3D vm_active_ch[i]; + + if (vm_active_ch[i] > pvt->vm_channels.max) + pvt->vm_channels.max =3D vm_active_ch[i]; + } + } + + /* + * Map between the channel-number to VM-index and channel-index. + * Example - 3 VMs, "moortec,vm_active_ch" =3D <5 2 4>: + * vm_map =3D [0 0 0 0 0 1 1 2 2 2 2] + * ch_map =3D [0 1 2 3 4 0 1 0 1 2 3] + */ + pvt->vd =3D devm_kcalloc(dev, pvt->vm_channels.total, sizeof(*pvt->vd), + GFP_KERNEL); + if (!pvt->vd) + return -ENOMEM; + + k =3D 0; + for (i =3D 0; i < vm_num; i++) { + for (j =3D 0; j < vm_active_ch[i]; j++) { + pvt->vd[k].vm_map =3D vm_idx[i]; + pvt->vd[k].ch_map =3D j; + k++; + } + } + + return 0; +} + static int mr75203_probe(struct platform_device *pdev) { u32 ts_num, vm_num, pd_num, ch_num, val, index, i; @@ -564,7 +645,6 @@ static int mr75203_probe(struct platform_device *pdev) pvt->t_num =3D ts_num; pvt->p_num =3D pd_num; pvt->v_num =3D vm_num; - pvt->c_num =3D ch_num; val =3D 0; if (ts_num) val++; @@ -601,44 +681,41 @@ static int mr75203_probe(struct platform_device *pdev) } =20 if (vm_num) { - u32 total_ch; + u8 vm_idx[VM_NUM_MAX]; =20 ret =3D pvt_get_regmap(pdev, "vm", pvt); if (ret) return ret; =20 - pvt->vm_idx =3D devm_kcalloc(dev, vm_num, sizeof(*pvt->vm_idx), - GFP_KERNEL); - if (!pvt->vm_idx) - return -ENOMEM; - - ret =3D device_property_read_u8_array(dev, "intel,vm-map", - pvt->vm_idx, vm_num); + ret =3D 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 =3D 0; i < vm_num; i++) - pvt->vm_idx[i] =3D i; + vm_idx[i] =3D i; } else { for (i =3D 0; i < vm_num; i++) - if (pvt->vm_idx[i] >=3D vm_num || - pvt->vm_idx[i] =3D=3D 0xff) { + if (vm_idx[i] >=3D vm_num || vm_idx[i] =3D=3D 0xff) { pvt->v_num =3D i; vm_num =3D i; break; } } =20 - total_ch =3D ch_num * vm_num; - in_config =3D devm_kcalloc(dev, total_ch + 1, + ret =3D pvt_get_active_channel(dev, pvt, vm_num, ch_num, vm_idx); + if (ret) + return ret; + + in_config =3D devm_kcalloc(dev, pvt->vm_channels.total + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) return -ENOMEM; =20 - memset32(in_config, HWMON_I_INPUT, total_ch); - in_config[total_ch] =3D 0; + memset32(in_config, HWMON_I_INPUT, pvt->vm_channels.total); + in_config[pvt->vm_channels.total] =3D 0; pvt_in.config =3D in_config; =20 pvt_info[index++] =3D &pvt_in; --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 C52B1C6FA83 for ; Tue, 6 Sep 2022 08:41:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238882AbiIFIlH (ORCPT ); Tue, 6 Sep 2022 04:41:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239335AbiIFIj2 (ORCPT ); Tue, 6 Sep 2022 04:39:28 -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 9676E79A58; Tue, 6 Sep 2022 01:37: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=1662453457; x=1693989457; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QaZnKD4Usd+c2bBOUsV8NlLFsu3kyiAwP75GhWqBpac=; b=GCK9XOFfigdnu8WM/ZjnBNXX6RSsgq6vunuL7c9fftndVVgNQJ9CwBNl e6hAOMWZwDP2PR46xxi/BEAcJNksvMXCYcwTp7HJgDc8l6SYM5IiuhXux wg+Y19EH5BLO+QOgwK95N+0oYlxEVSAoNpKO8rpwZ1utrl4qcrVIdVGcD k=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="127144293" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1a-828bd003.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; 06 Sep 2022 08:34:43 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1a-828bd003.us-east-1.amazon.com (Postfix) with ESMTPS id 8889E803B1; Tue, 6 Sep 2022 08:34:39 +0000 (UTC) Received: from EX19D013UWA004.ant.amazon.com (10.13.138.207) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:34:00 +0000 Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) 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; Tue, 6 Sep 2022 08:34:00 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id D4AC74D82; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 14/21] dt-bindings: hwmon: (mr75203) add "moortec,vm-pre-scaler-x2" property Date: Tue, 6 Sep 2022 08:33:49 +0000 Message-ID: <20220906083356.21067-15-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add support for mr76006 pre-scaler which provides divide-by-2 scaling of the input voltage, so that it can be presented to the VM for measurement within its range (the VM input range is limited to -0.1V to 1V). The new "moortec,vm-pre-scaler-x2" property lists the channels that use the mr76006 pre-scaler. The driver will use this list to multiply the voltage result by 2, to present to the user with the actual voltage input source. Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> V3: - Rename "moortec,vm-pre-scaler" to "moortec,vm-pre-scaler-x2". - Added mximum number if items in description. V3 -> V2: - Add "moortec" prefix to property name. - Change property format to be a single u8 array. - Fix typo: scalar --> scaler. .../devicetree/bindings/hwmon/moortec,mr75203.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b= /Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index 2aa4c3618596..de92a21d5552 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -79,6 +79,18 @@ properties: Minimum value of each item - 0 (which means entire VM sensor is nou = used). $ref: /schemas/types.yaml#/definitions/uint8-array =20 + moortec,vm-pre-scaler-x2: + description: + Defines the channels that use a mr76006 pre-scaler to divide the inp= ut + source by 2. + The pre-scaler is used for input sources that exceed the VM input ra= nge. + The driver uses this information to present to the user with the act= ual + value of the voltage source. + For channels that are not listed, no pre-scaler is assumed. + Maximum number of items - total number of channels in all VMs. + Each channel should not appear more than once. + $ref: /schemas/types.yaml#/definitions/uint8-array + required: - compatible - reg @@ -101,5 +113,6 @@ examples: clocks =3D <&osc0>; resets =3D <&rcu0 0x40 7>; moortec,vm-active-channels =3D /bits/ 8 <0x10 0x05>; + moortec,vm-pre-scaler-x2 =3D /bits/ 8 <5 6 20>; #thermal-sensor-cells =3D <1>; }; --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 4DC9BC38145 for ; Tue, 6 Sep 2022 08:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239324AbiIFIf5 (ORCPT ); Tue, 6 Sep 2022 04:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239048AbiIFIe7 (ORCPT ); Tue, 6 Sep 2022 04:34:59 -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 6123D51438; Tue, 6 Sep 2022 01:34: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=1662453297; x=1693989297; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=08sYMwrtQYKROSQcOPqY388/Q3O4R9NE1kR8HL/zR+o=; b=r7A/aYHlWzzKCucsJ/XPAeGRYwo4WfIbA9mXCtF1m0/bMfpen0gNAGVR ExGY933CbXgWB+jSFlalqkHPHDMIXkqVWXnBvXyKqIME/IbRW9feMfgtG Ek/1pbktX1kpAseqvYKFRSIrVqeIWobd5ANOu1oKzlggRSJG/Zv/M2jMr k=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="256505599" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1d-10222bbc.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; 06 Sep 2022 08:34:41 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1d-10222bbc.us-east-1.amazon.com (Postfix) with ESMTPS id EFA291A005E; Tue, 6 Sep 2022 08:34:38 +0000 (UTC) Received: from EX19D013UWA001.ant.amazon.com (10.13.138.253) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:34:00 +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; Tue, 6 Sep 2022 08:34:00 +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; Tue, 6 Sep 2022 08:34:00 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id D3EA94D7A; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 15/21] hwmon: (mr75203) add VM pre-scaler x2 support Date: Tue, 6 Sep 2022 08:33:50 +0000 Message-ID: <20220906083356.21067-16-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add support for mr76006 pre-scaler which provides divide-by-2 scaling of the input voltage, so that it can be presented to the VM for measurement within its range (the VM input range is limited from -0.1V to 1V). The driver reads from the device-tree all the channels that use the mr76006 pre-scaler and multiplies the voltage result by a factor of 2, to represent to the user with the actual voltage input source. Channels that are not in the device-tree are multiplied by a factor of 1. Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> V3: - Replace of_property_count_u8_elems() with device_property_count_u8(). - Remove unnecessary blank line. - Remove code that validated the YAML. V3 -> V2: - Modify code according to new property format. drivers/hwmon/mr75203.c | 55 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 5aa694fd9118..66f151082c11 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -17,6 +17,7 @@ #include #include #include +#include =20 /* PVT Common register */ #define PVT_IP_CONFIG 0x04 @@ -108,17 +109,24 @@ #define PVT_N_CONST 90 #define PVT_R_CONST 245805 =20 +#define PRE_SCALER_X1 1 +#define PRE_SCALER_X2 2 + /** * struct voltage_device - VM single input parameters. * @vm_map: Map channel number to VM index. * @ch_map: Map channel number to channel index. + * @pre_scaler: Pre scaler value (1 or 2) used to normalize the voltage ou= tput + * result. * * The structure provides mapping between channel-number (0..N-1) to VM-in= dex * (0..num_vm-1) and channel-index (0..ch_num-1) where N =3D num_vm * ch_n= um. + * It also provides normalization factor for the VM equation. */ struct voltage_device { u32 vm_map; u32 ch_map; + u32 pre_scaler; }; =20 /** @@ -207,8 +215,8 @@ static int pvt_read_in(struct device *dev, u32 attr, in= t channel, long *val) { struct pvt_device *pvt =3D dev_get_drvdata(dev); struct regmap *v_map =3D pvt->v_map; + u32 n, stat, pre_scaler; u8 vm_idx, ch_idx; - u32 n, stat; int ret; =20 if (channel >=3D pvt->vm_channels.total) @@ -232,7 +240,9 @@ static int pvt_read_in(struct device *dev, u32 attr, in= t channel, long *val) =20 n &=3D SAMPLE_DATA_MSK; /* Convert the N bitstream count into voltage */ - *val =3D (PVT_N_CONST * (long)n - PVT_R_CONST) / (1 << PVT_CONV_BITS); + pre_scaler =3D pvt->vd[channel].pre_scaler; + *val =3D pre_scaler * (PVT_N_CONST * (long)n - PVT_R_CONST) / + (1 << PVT_CONV_BITS); =20 return 0; default: @@ -594,6 +604,43 @@ static int pvt_get_active_channel(struct device *dev, = struct pvt_device *pvt, return 0; } =20 +static int pvt_get_pre_scaler(struct device *dev, struct pvt_device *pvt) +{ + u8 *pre_scaler_ch_list; + int i, ret, num_ch; + u32 channel; + + /* Set default pre-scaler value to be 1. */ + for (i =3D 0; i < pvt->vm_channels.total; i++) + pvt->vd[i].pre_scaler =3D PRE_SCALER_X1; + + /* Get number of channels configured in "moortec,vm-pre-scaler-x2". */ + num_ch =3D device_property_count_u8(dev, "moortec,vm-pre-scaler-x2"); + if (num_ch <=3D 0) + return 0; + + pre_scaler_ch_list =3D kcalloc(num_ch, sizeof(*pre_scaler_ch_list), + GFP_KERNEL); + if (!pre_scaler_ch_list) + return -ENOMEM; + + /* Get list of all channels that have pre-scaler of 2. */ + ret =3D device_property_read_u8_array(dev, "moortec,vm-pre-scaler-x2", + pre_scaler_ch_list, num_ch); + if (ret) + goto out; + + for (i =3D 0; i < num_ch; i++) { + channel =3D pre_scaler_ch_list[i]; + pvt->vd[channel].pre_scaler =3D PRE_SCALER_X2; + } + +out: + kfree(pre_scaler_ch_list); + + return ret; +} + static int mr75203_probe(struct platform_device *pdev) { u32 ts_num, vm_num, pd_num, ch_num, val, index, i; @@ -709,6 +756,10 @@ static int mr75203_probe(struct platform_device *pdev) if (ret) return ret; =20 + ret =3D pvt_get_pre_scaler(dev, pvt); + if (ret) + return ret; + in_config =3D devm_kcalloc(dev, pvt->vm_channels.total + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 82EFAECAAA1 for ; Tue, 6 Sep 2022 08:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233058AbiIFIeb (ORCPT ); Tue, 6 Sep 2022 04:34:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234243AbiIFIeV (ORCPT ); Tue, 6 Sep 2022 04:34:21 -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 2DBA117AB5; Tue, 6 Sep 2022 01:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453261; x=1693989261; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x+33rYav/AsPibYhxCbc0w3qFQuDbRm8ElL2qDQwvlI=; b=JRjx7eVhyM3vV7KjqGXDq/cPmPcHQm6H/gnnZPdYcwyl/Gk2fkVmGzs1 +dpCnfBWh/WQbebn6/k3kc79daJaeZoX9qrU+F+IS+uFwEGHy+HKe2Go2 oulUkTzsSUzezJnWyhsZAXYdYwMoNuL/ve5owUzK9jKLqmYOC5nFuea0o U=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="223661265" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-b48bc93b.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; 06 Sep 2022 08:34:03 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1d-b48bc93b.us-east-1.amazon.com (Postfix) with ESMTPS id 304F3C022E; Tue, 6 Sep 2022 08:33:58 +0000 (UTC) Received: from EX19D013UWB004.ant.amazon.com (10.13.138.62) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:33:58 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX19D013UWB004.ant.amazon.com (10.13.138.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.12; Tue, 6 Sep 2022 08:33:58 +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; Tue, 6 Sep 2022 08:33:58 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id C74184D70; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 16/21] hwmon: (mr75203) modify the temperature equation according to series 5 datasheet Date: Tue, 6 Sep 2022 08:33:51 +0000 Message-ID: <20220906083356.21067-17-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Modify the equation and coefficients used to convert the digital output to temperature according to series 5 of the Moortec Embedded Temperature Sensor (METS) datasheet: T =3D G + H * (n / cal5 - 0.5) + J * F Where: *) G =3D 60, H =3D 200, cal5 =3D 4094, J =3D -0.1. *) F =3D frequency clock in MHz. *) n is the digital output. In code, the G, H and J coefficients are multiplied by a factor of 1000 to get the temperature in milli-Celsius. Final result is clamped in case it exceeds min/max thresholds. Change is done since it is unclear where the current equation and coefficients came from. Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> V3: - Change 'not clear' to 'unclear' in commit message. - Add _mC prefix to temperature mix/max defines. - Add SERIES5 to coefficient defines. V3 -> V2: - Protect from overflow. - Add temperature clamping. - Add better documentation. drivers/hwmon/mr75203.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 66f151082c11..f98fb0f3d2fd 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -102,13 +102,19 @@ =20 #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_CONV_BITS 10 #define PVT_N_CONST 90 #define PVT_R_CONST 245805 =20 +#define PVT_TEMP_MIN_mC -40000 +#define PVT_TEMP_MAX_mC 125000 + +/* Temperature coefficients for series 5 */ +#define PVT_SERIES5_H_CONST 200000 +#define PVT_SERIES5_G_CONST 60000 +#define PVT_SERIES5_J_CONST -100 +#define PVT_SERIES5_CAL5_CONST 4094 + #define PRE_SCALER_X1 1 #define PRE_SCALER_X2 2 =20 @@ -174,13 +180,26 @@ static umode_t pvt_is_visible(const void *data, enum = hwmon_sensor_types type, return 0; } =20 +static long pvt_calc_temp(struct pvt_device *pvt, u32 nbs) +{ + /* + * Convert the register value to degrees centigrade temperature: + * T =3D G + H * (n / cal5 - 0.5) + J * F + */ + s64 tmp =3D PVT_SERIES5_G_CONST + + PVT_SERIES5_H_CONST * (s64)nbs / PVT_SERIES5_CAL5_CONST - + PVT_SERIES5_H_CONST / 2 + + PVT_SERIES5_J_CONST * (s64)pvt->ip_freq / HZ_PER_MHZ; + + return clamp_val(tmp, PVT_TEMP_MIN_mC, PVT_TEMP_MAX_mC); +} + static int pvt_read_temp(struct device *dev, u32 attr, int channel, long *= val) { struct pvt_device *pvt =3D dev_get_drvdata(dev); struct regmap *t_map =3D pvt->t_map; u32 stat, nbs; int ret; - u64 tmp; =20 switch (attr) { case hwmon_temp_input: @@ -201,9 +220,7 @@ static int pvt_read_temp(struct device *dev, u32 attr, = int channel, long *val) * Convert the register value to * degrees centigrade temperature */ - tmp =3D nbs * PVT_H_CONST; - do_div(tmp, PVT_CAL5_CONST); - *val =3D tmp - PVT_G_CONST - pvt->ip_freq; + *val =3D pvt_calc_temp(pvt, nbs); =20 return 0; default: @@ -327,7 +344,7 @@ static int pvt_init(struct pvt_device *pvt) (key >> 1) << CLK_SYNTH_HI_SFT | (key >> 1) << CLK_SYNTH_HOLD_SFT | CLK_SYNTH_EN; =20 - pvt->ip_freq =3D sys_freq * 100 / (key + 2); + pvt->ip_freq =3D clk_get_rate(pvt->clk) / (key + 2); =20 if (t_num) { ret =3D regmap_write(t_map, SDIF_SMPL_CTRL, 0x0); --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 E94A8ECAAA1 for ; Tue, 6 Sep 2022 08:40:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232982AbiIFIk1 (ORCPT ); Tue, 6 Sep 2022 04:40:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239655AbiIFIjT (ORCPT ); Tue, 6 Sep 2022 04:39:19 -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 149E279EEB; Tue, 6 Sep 2022 01:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453448; x=1693989448; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WYAxidW5DMSg6wyDs6NW6VjRmOI1Fc+ZAedvRJD+oFc=; b=r2WipW66Td4xumifGRd3SR/1+uDriVwMfSjmog9RxD3La26++tN3+nxs 5eO+N5LSIpEWdrR/oAFIHAmgqBjPk/nCIfgw5vQ5kLfx7CwX5CDvz7A59 EiIwQjir2g6rarM8WRalDQ9lNbcReiq0SIRtmqHjIqfhMQPeubrp0jZis c=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="127144287" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-1c3c2014.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; 06 Sep 2022 08:34:42 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1d-1c3c2014.us-east-1.amazon.com (Postfix) with ESMTPS id AE2893C005D; Tue, 6 Sep 2022 08:34:38 +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; Tue, 6 Sep 2022 08:34:00 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) 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; Tue, 6 Sep 2022 08:34:00 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id CBB7A4D80; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 17/21] dt-bindings: hwmon: (mr75203) add "moortec,ts-series" property Date: Tue, 6 Sep 2022 08:33:52 +0000 Message-ID: <20220906083356.21067-18-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add optional "moortec,ts-series" property to define the temperature equation and coefficients that shall be used to convert the digital output to value in milli-Celsius. Supported series: 5 (default) and 6. Series 5: T =3D G + H * (n / cal5 - 0.5) + J * F Where: G =3D 60, H =3D 200, cal5 =3D 4094, J =3D -0.1, F =3D frequency cloc= k in MHz Series 6: T =3D G + H * (n / cal5 - 0.5) Where: G =3D 57.4, H =3D 249.4, cal5 =3D 4096 Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> V3: - Remove constraints in free-form text descriptions. V3 -> V2: - New patch to introduce "moortec,ts-series" property. .../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 de92a21d5552..28656e9d9059 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -91,6 +91,15 @@ properties: Each channel should not appear more than once. $ref: /schemas/types.yaml#/definitions/uint8-array =20 + moortec,ts-series: + description: + Definition of the temperature equation and coefficients that shall be + used to convert the digital output to value in milli-Celsius. + minimum: 5 + maximum: 6 + default: 5 + $ref: /schemas/types.yaml#/definitions/uint32 + required: - compatible - reg --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 D3602ECAAA1 for ; Tue, 6 Sep 2022 08:35:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238880AbiIFIfk (ORCPT ); Tue, 6 Sep 2022 04:35:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238553AbiIFIev (ORCPT ); Tue, 6 Sep 2022 04:34:51 -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 28192356DC; Tue, 6 Sep 2022 01:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453290; x=1693989290; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ov9+xe+S3g3vEVFOZU63DXVf9WabXZIfj3osYnfDF8M=; b=PGTenc6AuIThj3RebUMk8jtgCs9mADnyT37TPqqetmZUIj/AgwbkS+NI ujHmOfx5n2pNS5Ln+AOQikizVHygyRy0a/CF+E9YQyOu7l4n36EwMvyiZ Q64HcHvBQOIXR3Q3WXLJF5isdeFYFaC+sksLsvn+eR3WS1fs4xT916+GF c=; Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-iad-1a-4ba5c7da.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-6001.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 08:34:38 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1a-4ba5c7da.us-east-1.amazon.com (Postfix) with ESMTPS id 315F5E0145; Tue, 6 Sep 2022 08:34:38 +0000 (UTC) Received: from EX19D013UWA002.ant.amazon.com (10.13.138.210) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:34:00 +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; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id D0F094D8A; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 18/21] hwmon: (mr75203) add support for series 6 temperature equation Date: Tue, 6 Sep 2022 08:33:53 +0000 Message-ID: <20220906083356.21067-19-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current equation used in code is aligned to series 5: T =3D G + H * (n / cal5 - 0.5) + J * F Where: G =3D 60, H =3D 200, cal5 =3D 4094, J =3D -0.1, F =3D frequency clock in MHz Series 6 has a slightly different equation: T =3D G + H * (n / cal5 - 0.5) and a different set of coefficients: G =3D 57.4, H =3D 249.4, cal5 =3D 4096 This change supports equation and coefficients for both series. (for series 6, J is set to 0). The series is determined according to =E2=80=9Cmoortec,ts-series=E2=80=9D p= roperty in the device tree. If absent, series 5 is assumed to be the default. Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> V3: - Replace of_property_read_u32() with device_property_read_u32(). - Use switch-case instead of if-else. V3 -> V2: - New patch to support temperature sensor series 6 instead of having to set all 4 coefficients. drivers/hwmon/mr75203.c | 66 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index f98fb0f3d2fd..ba5abd4065b3 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -115,6 +115,15 @@ #define PVT_SERIES5_J_CONST -100 #define PVT_SERIES5_CAL5_CONST 4094 =20 +/* Temperature coefficients for series 6 */ +#define PVT_SERIES6_H_CONST 249400 +#define PVT_SERIES6_G_CONST 57400 +#define PVT_SERIES6_J_CONST 0 +#define PVT_SERIES6_CAL5_CONST 4096 + +#define TEMPERATURE_SENSOR_SERIES_5 5 +#define TEMPERATURE_SENSOR_SERIES_6 6 + #define PRE_SCALER_X1 1 #define PRE_SCALER_X2 2 =20 @@ -147,6 +156,13 @@ struct voltage_channels { u8 max; }; =20 +struct temp_coeff { + u32 h; + u32 g; + u32 cal5; + s32 j; +}; + struct pvt_device { struct regmap *c_map; struct regmap *t_map; @@ -156,6 +172,7 @@ struct pvt_device { struct reset_control *rst; struct voltage_device *vd; struct voltage_channels vm_channels; + struct temp_coeff ts_coeff; u32 t_num; u32 p_num; u32 v_num; @@ -186,10 +203,12 @@ static long pvt_calc_temp(struct pvt_device *pvt, u32= nbs) * Convert the register value to degrees centigrade temperature: * T =3D G + H * (n / cal5 - 0.5) + J * F */ - s64 tmp =3D PVT_SERIES5_G_CONST + - PVT_SERIES5_H_CONST * (s64)nbs / PVT_SERIES5_CAL5_CONST - - PVT_SERIES5_H_CONST / 2 + - PVT_SERIES5_J_CONST * (s64)pvt->ip_freq / HZ_PER_MHZ; + struct temp_coeff *ts_coeff =3D &pvt->ts_coeff; + + s64 tmp =3D ts_coeff->g + + ts_coeff->h * (s64)nbs / ts_coeff->cal5 - + ts_coeff->h / 2 + + ts_coeff->j * (s64)pvt->ip_freq / HZ_PER_MHZ; =20 return clamp_val(tmp, PVT_TEMP_MIN_mC, PVT_TEMP_MAX_mC); } @@ -658,6 +677,41 @@ static int pvt_get_pre_scaler(struct device *dev, stru= ct pvt_device *pvt) return ret; } =20 +static int pvt_set_temp_coeff(struct device *dev, struct pvt_device *pvt) +{ + struct temp_coeff *ts_coeff =3D &pvt->ts_coeff; + u32 series; + int ret; + + /* Incase ts-series property is not defined, use default 5. */ + ret =3D device_property_read_u32(dev, "moortec,ts-series", &series); + if (ret) + series =3D TEMPERATURE_SENSOR_SERIES_5; + + switch (series) { + case TEMPERATURE_SENSOR_SERIES_5: + ts_coeff->h =3D PVT_SERIES5_H_CONST; + ts_coeff->g =3D PVT_SERIES5_G_CONST; + ts_coeff->j =3D PVT_SERIES5_J_CONST; + ts_coeff->cal5 =3D PVT_SERIES5_CAL5_CONST; + break; + case TEMPERATURE_SENSOR_SERIES_6: + ts_coeff->h =3D PVT_SERIES6_H_CONST; + ts_coeff->g =3D PVT_SERIES6_G_CONST; + ts_coeff->j =3D PVT_SERIES6_J_CONST; + ts_coeff->cal5 =3D PVT_SERIES6_CAL5_CONST; + break; + default: + dev_err(dev, "invalid temperature sensor series (%u)\n", + series); + return -EINVAL; + } + + dev_dbg(dev, "temperature sensor series =3D %u\n", series); + + return 0; +} + static int mr75203_probe(struct platform_device *pdev) { u32 ts_num, vm_num, pd_num, ch_num, val, index, i; @@ -728,6 +782,10 @@ static int mr75203_probe(struct platform_device *pdev) if (ret) return ret; =20 + ret =3D pvt_set_temp_coeff(dev, pvt); + if (ret) + return ret; + temp_config =3D devm_kcalloc(dev, ts_num + 1, sizeof(*temp_config), GFP_KERNEL); if (!temp_config) --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 3E92AECAAA1 for ; Tue, 6 Sep 2022 08:35:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239319AbiIFIfv (ORCPT ); Tue, 6 Sep 2022 04:35:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238506AbiIFIev (ORCPT ); Tue, 6 Sep 2022 04:34:51 -0400 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3782C38449; Tue, 6 Sep 2022 01:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453291; x=1693989291; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dnkseYOVS2+62yTSvl1N8YJytSzjRQ7C8g339XuXXHM=; b=VbDhiNSm5ryJxGp5zwA3CH5wOG6YoStDxQglbcLocfhv6Ys3/5W74ZIn F+RaQKBjTbG52CxeQfZ7o6R13p4JSGfkKeZTxAvSI27D3I0U1/9yDi66v fEiyQlVIpDrIcFhuYFJagbdnyRBHHVUrMoDidqrn4FzA/vNZm6xik8kgG A=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="237979500" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-7dac3c4d.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 08:34:38 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1e-7dac3c4d.us-east-1.amazon.com (Postfix) with ESMTPS id DF4A7818CF; Tue, 6 Sep 2022 08:34:35 +0000 (UTC) Received: from EX19D013UWA003.ant.amazon.com (10.13.138.202) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:33:59 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) 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; Tue, 6 Sep 2022 08:33:58 +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; Tue, 6 Sep 2022 08:33:57 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id C5E144AD5; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 19/21] dt-bindings: hwmon: (mr75203) add coefficient properties for the thermal equation Date: Tue, 6 Sep 2022 08:33:54 +0000 Message-ID: <20220906083356.21067-20-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add optional temperature coefficient properties: *) moortec,ts-coeff-g *) moortec,ts-coeff-h *) moortec,ts-coeff-cal5 *) moortec,ts-coeff-j If defined they shall be used instead of defaults. The coefficients were added to device tree on top of the series property (which can be used to select between series 5 and series 6), because coefficients can vary between product and product, and code defaults might not be accurate enough. Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> V3: - Add 'multipleOf: 1000' instead of plain text. - Add minimum/maximum for some of the new properties. V3 -> V2: - Add "moortec" prefix to property name. .../bindings/hwmon/moortec,mr75203.yaml | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b= /Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index 28656e9d9059..5e3d060290a9 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -100,6 +100,41 @@ properties: default: 5 $ref: /schemas/types.yaml#/definitions/uint32 =20 + moortec,ts-coeff-g: + description: + G coefficient for temperature equation. + Default for series 5 =3D 60000 + Default for series 6 =3D 57400 + multipleOf: 1000 + minimum: 1000 + $ref: /schemas/types.yaml#/definitions/uint32 + + moortec,ts-coeff-h: + description: + H coefficient for temperature equation. + Default for series 5 =3D 200000 + Default for series 6 =3D 249400 + multipleOf: 1000 + minimum: 1000 + $ref: /schemas/types.yaml#/definitions/uint32 + + moortec,ts-coeff-cal5: + description: + cal5 coefficient for temperature equation. + Default for series 5 =3D 4094 + Default for series 6 =3D 4096 + minimum: 1 + $ref: /schemas/types.yaml#/definitions/uint32 + + moortec,ts-coeff-j: + description: + J coefficient for temperature equation. + Default for series 5 =3D -100 + Default for series 6 =3D 0 + multipleOf: 1000 + maximum: 0 + $ref: /schemas/types.yaml#/definitions/int32 + required: - compatible - reg @@ -123,5 +158,7 @@ examples: resets =3D <&rcu0 0x40 7>; moortec,vm-active-channels =3D /bits/ 8 <0x10 0x05>; moortec,vm-pre-scaler-x2 =3D /bits/ 8 <5 6 20>; + moortec,ts-coeff-g =3D <61400>; + moortec,ts-coeff-h =3D <253700>; #thermal-sensor-cells =3D <1>; }; --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 D0BE7ECAAA1 for ; Tue, 6 Sep 2022 08:40:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239310AbiIFIkp (ORCPT ); Tue, 6 Sep 2022 04:40:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239668AbiIFIjV (ORCPT ); Tue, 6 Sep 2022 04:39:21 -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 603A77755B; Tue, 6 Sep 2022 01:37:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453450; x=1693989450; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AiNS3dExIcIQA64HvH7x+bCq1JO8YLTysTnJ3srzlQc=; b=KY84TLKoSJVPgP/8i+ZfgBGrimqWbRv7o8XcQzoKAJ8sp3yZI9mFz+en 04JwHSb0WfhqMubIpPwfaAWaArcPNZPAPBHskc38IqSCXiVfYtHWvhR/X 8wxDsVF9bf82RJ7yWOj+B9STTIvW0y8o7wJn15PGaDBy+3xL1t4Jj1Y/w k=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="127050122" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1a-4ba5c7da.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; 06 Sep 2022 08:34:39 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1a-4ba5c7da.us-east-1.amazon.com (Postfix) with ESMTPS id 9DCFDE05B6; Tue, 6 Sep 2022 08:34:37 +0000 (UTC) Received: from EX19D013UWA003.ant.amazon.com (10.13.138.202) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +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; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id D022E4D7E; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 20/21] hwmon: (mr75203) parse temperature coefficients from device-tree Date: Tue, 6 Sep 2022 08:33:55 +0000 Message-ID: <20220906083356.21067-21-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use thermal coefficients from the device tree if they exist. Otherwise, use default values according to the series (5 or 6). All coefficients can be used or only part of them. The coefficients shall be used for fine tuning the default values since coefficients can vary between product and product. Signed-off-by: Eliav Farber Reviewed-by: Andy Shevchenko --- V4 -> V3: - Replace of_property_read_u32() with device_property_read_u32(). - Fix "Code shouldn't be a YAML validator". - Read directly to ts_coeff-> parameter to avoid conditional if. drivers/hwmon/mr75203.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index ba5abd4065b3..8baa99a9ea83 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -709,6 +709,15 @@ static int pvt_set_temp_coeff(struct device *dev, stru= ct pvt_device *pvt) =20 dev_dbg(dev, "temperature sensor series =3D %u\n", series); =20 + /* Override ts-coeff-h/g/j/cal5 if they are defined. */ + device_property_read_u32(dev, "moortec,ts-coeff-h", &ts_coeff->h); + device_property_read_u32(dev, "moortec,ts-coeff-g", &ts_coeff->g); + device_property_read_u32(dev, "moortec,ts-coeff-j", &ts_coeff->j); + device_property_read_u32(dev, "moortec,ts-coeff-cal5", &ts_coeff->cal5); + + dev_dbg(dev, "ts-coeff: h =3D %u, g =3D %u, j =3D %d, cal5 =3D %u\n", + ts_coeff->h, ts_coeff->g, ts_coeff->j, ts_coeff->cal5); + return 0; } =20 --=20 2.37.1 From nobody Wed Apr 8 10:27:25 2026 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 89877ECAAA1 for ; Tue, 6 Sep 2022 08:40:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239483AbiIFIkv (ORCPT ); Tue, 6 Sep 2022 04:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239671AbiIFIjW (ORCPT ); Tue, 6 Sep 2022 04:39:22 -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 1CC4571710; Tue, 6 Sep 2022 01:37:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453450; x=1693989450; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B83zy8/Sbonf+5Qnjl59QhloJcwP7RKcwdhzViFyxfE=; b=wID3JtrRCKuboMcbNy1Hl47oUUeCvymRJ5Azv+y7Yu+DVH8tBH0Y1xOt 9LldVyvjKmtCmZvphSS+DoMxLQrMJvlzruIy354/mpV8MQQPDU7DC/v5+ qib17L/XA4DYZYaKTBw3vPzM9q+Z/ZPNr/NSHuvzHHSnNP+D4rjrnBEhI o=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="127050136" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1a-4ba5c7da.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; 06 Sep 2022 08:34:41 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1a-4ba5c7da.us-east-1.amazon.com (Postfix) with ESMTPS id 4B824E05AD; Tue, 6 Sep 2022 08:34:38 +0000 (UTC) Received: from EX19D013UWB003.ant.amazon.com (10.13.138.111) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:33:59 +0000 Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX19D013UWB003.ant.amazon.com (10.13.138.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Tue, 6 Sep 2022 08:33:59 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 6 Sep 2022 08:33:58 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id CA5424D76; Tue, 6 Sep 2022 08:33:57 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 21/21] hwmon: (mr75203) add debugfs to read and write temperature coefficients Date: Tue, 6 Sep 2022 08:33:56 +0000 Message-ID: <20220906083356.21067-22-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This change adds debugfs to read and write temperature sensor coefficients - g, h, j and cal5. The coefficients can vary between product and product, so it can be very useful to be able to modify them on the fly during the calibration process. 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 Reviewed-by: Andy Shevchenko --- V4 -> V3: - Remove check of the debugfs_create_dir() return value. - Use debugfs_create_u32() instead of debugfs_create_file(). - Return devm_add_action_or_reset() without checking return value and print= ing an error message on failure. drivers/hwmon/mr75203.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 8baa99a9ea83..e3670075fae4 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -9,6 +9,7 @@ */ #include #include +#include #include #include #include @@ -170,6 +171,7 @@ struct pvt_device { struct regmap *v_map; struct clk *clk; struct reset_control *rst; + struct dentry *dbgfs_dir; struct voltage_device *vd; struct voltage_channels vm_channels; struct temp_coeff ts_coeff; @@ -179,6 +181,30 @@ struct pvt_device { u32 ip_freq; }; =20 +static void devm_pvt_ts_dbgfs_remove(void *data) +{ + struct pvt_device *pvt =3D (struct pvt_device *)data; + + debugfs_remove_recursive(pvt->dbgfs_dir); + pvt->dbgfs_dir =3D NULL; +} + +static int pvt_ts_dbgfs_create(struct pvt_device *pvt, struct device *dev) +{ + pvt->dbgfs_dir =3D debugfs_create_dir(dev_name(dev), NULL); + + debugfs_create_u32("ts_coeff_h", 0644, pvt->dbgfs_dir, + &pvt->ts_coeff.h); + debugfs_create_u32("ts_coeff_g", 0644, pvt->dbgfs_dir, + &pvt->ts_coeff.g); + debugfs_create_u32("ts_coeff_j", 0644, pvt->dbgfs_dir, + &pvt->ts_coeff.j); + debugfs_create_u32("ts_coeff_cal5", 0644, pvt->dbgfs_dir, + &pvt->ts_coeff.cal5); + + return devm_add_action_or_reset(dev, devm_pvt_ts_dbgfs_remove, pvt); +} + static umode_t pvt_is_visible(const void *data, enum hwmon_sensor_types ty= pe, u32 attr, int channel) { @@ -803,6 +829,8 @@ static int mr75203_probe(struct platform_device *pdev) memset32(temp_config, HWMON_T_INPUT, ts_num); pvt_temp.config =3D temp_config; pvt_info[index++] =3D &pvt_temp; + + pvt_ts_dbgfs_create(pvt, dev); } =20 if (pd_num) { --=20 2.37.1