From patchwork Tue Aug 16 08:27:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944583 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 20BCEC2BB41 for ; Tue, 16 Aug 2022 10:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234112AbiHPKRS (ORCPT ); Tue, 16 Aug 2022 06:17:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234397AbiHPKQg (ORCPT ); Tue, 16 Aug 2022 06:16:36 -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 F3548DF0B3; Tue, 16 Aug 2022 01:28: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=1660638501; x=1692174501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ULkqAHITNyNY+nb/F2KUcwZfWxaEdjYhDYRpVxQWyfI=; b=vZF3rZuQuo4YNJXjDkVRkT9o0m6qo8vDPkO3XxIGS/qT3SAelrx6VY8k 1gVd89lxvtmr2KxQ+r+Ll8HtSPn7jvSngY/rJOHNkEzp4jegBvZzBZR3S +e5v+XBZXhAvPB0Xkk0Mcs+l/WE6HiXbUhtEfUWnLcp9W7NJy4TTvg4TK Q=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="233486642" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1a-2d7489a4.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; 16 Aug 2022 08:28:20 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1a-2d7489a4.us-east-1.amazon.com (Postfix) with ESMTPS id 9A42C8705F; Tue, 16 Aug 2022 08:28:20 +0000 (UTC) Received: from EX19D013UWA004.ant.amazon.com (10.13.138.207) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:28:00 +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, 16 Aug 2022 08:27: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, 16 Aug 2022 08:27:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 61ACF4C09; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 01/16] hwmon: (mr75203) fix VM sensor allocation when "intel,vm-map" not defined Date: Tue, 16 Aug 2022 08:27:42 +0000 Message-ID: <20220816082757.11990-2-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Fix a bug that in case "intel,vm-map" is missing 'num' is set to 0, and no voltage channel infos are allocated. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 046523d47c29..0e29877a1a9c 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -580,8 +580,6 @@ static int mr75203_probe(struct platform_device *pdev) } if (vm_num) { - u32 num = vm_num; - ret = pvt_get_regmap(pdev, "vm", pvt); if (ret) return ret; @@ -594,30 +592,28 @@ static int mr75203_probe(struct platform_device *pdev) ret = device_property_read_u8_array(dev, "intel,vm-map", pvt->vm_idx, vm_num); if (ret) { - num = 0; + /* + * Incase intel,vm-map property is not defined, we + * assume incremental channel numbers. + */ + for (i = 0; i < vm_num; i++) + pvt->vm_idx[i] = i; } else { for (i = 0; i < vm_num; i++) if (pvt->vm_idx[i] >= vm_num || - pvt->vm_idx[i] == 0xff) { - num = i; + pvt->vm_idx[i] == 0xff) break; - } - } - /* - * Incase intel,vm-map property is not defined, we assume - * incremental channel numbers. - */ - for (i = num; i < vm_num; i++) - pvt->vm_idx[i] = i; + vm_num = i; + } - in_config = devm_kcalloc(dev, num + 1, + in_config = devm_kcalloc(dev, vm_num + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) return -ENOMEM; - memset32(in_config, HWMON_I_INPUT, num); - in_config[num] = 0; + memset32(in_config, HWMON_I_INPUT, vm_num); + in_config[vm_num] = 0; pvt_in.config = in_config; pvt_info[index++] = &pvt_in; From patchwork Tue Aug 16 08:27:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944522 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 146CEC2BB41 for ; Tue, 16 Aug 2022 09:41:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233483AbiHPJlO (ORCPT ); Tue, 16 Aug 2022 05:41:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233595AbiHPJj7 (ORCPT ); Tue, 16 Aug 2022 05:39:59 -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 5C5551367D7; Tue, 16 Aug 2022 01:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660638494; x=1692174494; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9K9d4IjBMmcloaT+QG5eIvNYUR3xOoTYrU9248uTcL8=; b=RL1BBWbhtBKQW143Cw1JhTGrLvoKQipy+ui9/EbVUs3CNtXKlTPd0E5v amz9Yp646NL4g0tO9thkRTTRu6yj+Y5cOoeDH0VQAsCDk7TUobJwJXQ5W 9vXsKGe/ynp8s55DIybFpjF8MOyOdxTQCXTTSMDvYMlQmq9R0MLbT6Yl1 8=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="233486519" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2b-31df91b1.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 08:28:00 +0000 Received: from EX13MTAUEE002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2b-31df91b1.us-west-2.amazon.com (Postfix) with ESMTPS id 14069450A1; Tue, 16 Aug 2022 08:28:00 +0000 (UTC) Received: from EX13D08UEE001.ant.amazon.com (10.43.62.126) by EX13MTAUEE002.ant.amazon.com (10.43.62.24) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27:59 +0000 Received: from EX13MTAUEE002.ant.amazon.com (10.43.62.24) by EX13D08UEE001.ant.amazon.com (10.43.62.126) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27: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.62.224) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 16 Aug 2022 08:27:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 5F4D64C55; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 02/16] hwmon: (mr75203) update pvt->v_num to the actual number of used sensors Date: Tue, 16 Aug 2022 08:27:43 +0000 Message-ID: <20220816082757.11990-3-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This issue is relevant when intel,vm-map is set, and defines a lower number of VMs than actually supported. This change is needed for all places that use pvt->v_num later on in the code. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 0e29877a1a9c..f89f7bb5d698 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -605,6 +605,7 @@ static int mr75203_probe(struct platform_device *pdev) break; vm_num = i; + pvt->v_num = i; } in_config = devm_kcalloc(dev, vm_num + 1, From patchwork Tue Aug 16 08:27:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944570 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 ACBA4C32773 for ; Tue, 16 Aug 2022 10:08:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234221AbiHPKIS (ORCPT ); Tue, 16 Aug 2022 06:08:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234312AbiHPKH5 (ORCPT ); Tue, 16 Aug 2022 06:07:57 -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 45DAE138D16; Tue, 16 Aug 2022 01:28:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660638498; x=1692174498; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+l0S1eFzfrFNNB93/ZUmAdO4vUxtc2g6DrjY5R7747U=; b=pjklAByTM1AxTC5YNyUGPnQ0q7ESyADln23XEyEyBciiY4+LJxOluG0Z ghyhuwUMRoF5vrBSWBCGhgVjYGr16pJK5766hDjphEvbqVZ+nGbnvXxCc 0ofuaY44G7QUArEIM84r8x0km7B6X/W6fvSNwg7W3hndzQ1tftaI1Va9n o=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="233486617" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2b-718d0906.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 08:28:17 +0000 Received: from EX13MTAUEE001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2b-718d0906.us-west-2.amazon.com (Postfix) with ESMTPS id 939EA3E009B; Tue, 16 Aug 2022 08:28:16 +0000 (UTC) Received: from EX13D08UEB001.ant.amazon.com (10.43.60.245) by EX13MTAUEE001.ant.amazon.com (10.43.62.200) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27:59 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D08UEB001.ant.amazon.com (10.43.60.245) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27: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, 16 Aug 2022 08:27:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 60DBB4C6A; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 03/16] hwmon: (mr75203) update Moortec PVT controller intel,vm-map property Date: Tue, 16 Aug 2022 08:27:44 +0000 Message-ID: <20220816082757.11990-4-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org The "intel,vm-map property" is optional and not required. Signed-off-by: Eliav Farber --- Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index 6f3e3c01f717..f9e849cc73e0 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -48,12 +48,12 @@ required: - compatible - reg - reg-names - - intel,vm-map - clocks - resets - "#thermal-sensor-cells" -additionalProperties: false +additionalProperties: + - intel,vm-map examples: - | From patchwork Tue Aug 16 08:27:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944600 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 3F89CC32772 for ; Tue, 16 Aug 2022 10:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234782AbiHPKef (ORCPT ); Tue, 16 Aug 2022 06:34:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234772AbiHPKdx (ORCPT ); Tue, 16 Aug 2022 06:33:53 -0400 Received: from smtp-fw-80006.amazon.com (smtp-fw-80006.amazon.com [99.78.197.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 656771394FC; Tue, 16 Aug 2022 01:28: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=1660638501; x=1692174501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y+K+ejUZbidNdp7fNJrcGWpO2dwpzC63OfGNy7Tg6HU=; b=tFp9P8UBnrsEy8IR1Nt7lPX29/pIfPkXVhvTmB1Qdz/VbtPXanOBwNgU bLFHEKRQoBupD5zPcdXS8f7/eIccdJXrgU8rx2lMoFYMrIxcvbfqNe7Ck TE/nk4THH7XfKl3AzNg0O7i/8ZGsHHoO8A6dnq8E54ULxcICTiz792Tc1 8=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="119633964" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1a-b09d0114.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 08:28:04 +0000 Received: from EX13MTAUEB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1a-b09d0114.us-east-1.amazon.com (Postfix) with ESMTPS id 0D5CF8130A; Tue, 16 Aug 2022 08:28:00 +0000 (UTC) Received: from EX13D08UEB003.ant.amazon.com (10.43.60.11) by EX13MTAUEB001.ant.amazon.com (10.43.60.96) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27:59 +0000 Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D08UEB003.ant.amazon.com (10.43.60.11) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27: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.60.234) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 16 Aug 2022 08:27:58 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 5BF784C4B; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 04/16] hwmon: (mr75203) add Moortec PVT controller reset-control-skip property Date: Tue, 16 Aug 2022 08:27:45 +0000 Message-ID: <20220816082757.11990-5-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Adding a "reset-control-skip" bool property to the mr75203 node will avoid looking up and obtaining a reference to a reset controller. Signed-off-by: Eliav Farber --- .../devicetree/bindings/hwmon/moortec,mr75203.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index f9e849cc73e0..da9c3cdcb6f0 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -44,6 +44,11 @@ properties: "#thermal-sensor-cells": const: 1 + reset-control-skip: + description: + reset-control-skip bool property defines if obtaining a + reference to a reset controller should be skipped. + required: - compatible - reg @@ -54,6 +59,7 @@ required: additionalProperties: - intel,vm-map + - reset-control-skip examples: - | From patchwork Tue Aug 16 08:27:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944597 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 3B08AC32772 for ; Tue, 16 Aug 2022 10:31:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234586AbiHPKbk (ORCPT ); Tue, 16 Aug 2022 06:31:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234596AbiHPKbF (ORCPT ); Tue, 16 Aug 2022 06:31:05 -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 90DF52E9D0; Tue, 16 Aug 2022 01:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660638502; x=1692174502; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0AQXnw93t2lwDKh5bic/I1TgdsGF0kswV/Nq4data+4=; b=J11MyqkC+rkT56LkT7HEylRkcXlqU8RsXzUskwj5XD+0hr4yN88V3pHB Y9bPYJaPw4iiT+9iEDoAA20TS5B6PV3eDYHJfuDuzcVXwxqcTvDLO1cOG i1C4DFYaCCSx7AGodE0JzForrPO3dtMJRyketjnCDHY7qud8RYbRQz28w g=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="119634076" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1a-2d7489a4.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; 16 Aug 2022 08:28:21 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1a-2d7489a4.us-east-1.amazon.com (Postfix) with ESMTPS id 26C9A82BCF; Tue, 16 Aug 2022 08:28:17 +0000 (UTC) Received: from EX19D013UWA002.ant.amazon.com (10.13.138.210) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27: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, 16 Aug 2022 08:27: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.160.118) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 16 Aug 2022 08:27:58 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 5876C4C67; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 05/16] hwmon: (mr75203) add option to skip reset controller Date: Tue, 16 Aug 2022 08:27:46 +0000 Message-ID: <20220816082757.11990-6-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Adding a "reset-control-skip" bool property to the mr75203 node will avoid looking up and obtaining a reference to a reset controller. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index f89f7bb5d698..bec63b611eb4 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -525,14 +526,19 @@ static int mr75203_probe(struct platform_device *pdev) return ret; } - pvt->rst = devm_reset_control_get_exclusive(dev, NULL); - if (IS_ERR(pvt->rst)) - return dev_err_probe(dev, PTR_ERR(pvt->rst), - "failed to get reset control\n"); + if (of_property_read_bool(dev->of_node, "reset-control-skip")) { + dev_info(dev, "skipping reset-control\n"); + } else { + pvt->rst = devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(pvt->rst)) + return dev_err_probe(dev, PTR_ERR(pvt->rst), + "failed to get reset control\n"); - ret = pvt_reset_control_deassert(dev, pvt); - if (ret) - return dev_err_probe(dev, ret, "cannot deassert reset control\n"); + ret = pvt_reset_control_deassert(dev, pvt); + if (ret) + return dev_err_probe(dev, ret, + "cannot deassert reset control\n"); + } ret = regmap_read(pvt->c_map, PVT_IP_CONFIG, &val); if(ret < 0) From patchwork Tue Aug 16 08:27:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944544 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 66267C32772 for ; Tue, 16 Aug 2022 09:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233882AbiHPJvi (ORCPT ); Tue, 16 Aug 2022 05:51:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233888AbiHPJvQ (ORCPT ); Tue, 16 Aug 2022 05:51:16 -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 28837105F38; Tue, 16 Aug 2022 01:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660638502; x=1692174502; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I4ndVs36DtLZuD0EkdTFDFSmoQQ7OUW1UMKQNUkt/6g=; b=pPPyDPQfVnzUB4au4FG8OyKMpiCHil9Os6Fh2JcisG+OhtSbxSJmJ7aY w1aUdqK6zO52nVqWKF9hmWlTlsUaOoz4HMjfgM0i4mEzrvJ9rzUN2+pvL QR9Hu0I6RjdXFMFNFUl2UkuILHPRmimAXLcQRA25OC3nI6i74C68e29tD Y=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="233486648" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-26daedd8.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; 16 Aug 2022 08:28:22 +0000 Received: from EX13MTAUEB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1e-26daedd8.us-east-1.amazon.com (Postfix) with ESMTPS id 59E319052D; Tue, 16 Aug 2022 08:28:20 +0000 (UTC) Received: from EX13D08UEB002.ant.amazon.com (10.43.60.107) by EX13MTAUEB001.ant.amazon.com (10.43.60.129) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:28:03 +0000 Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D08UEB002.ant.amazon.com (10.43.60.107) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:28:02 +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, 16 Aug 2022 08:28:01 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 5DB1A4C47; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 06/16] hwmon: (mr75203) fix multi-channel voltage reading Date: Tue, 16 Aug 2022 08:27:47 +0000 Message-ID: <20220816082757.11990-7-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org - Fix voltage reading to support number of channels in VM IP (CH_NUM). - Configure the ip-polling register to enable polling for all channels. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index bec63b611eb4..4419e481d47c 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -69,8 +69,9 @@ /* VM Individual Macro Register */ #define VM_COM_REG_SIZE 0x200 -#define VM_SDIF_DONE(n) (VM_COM_REG_SIZE + 0x34 + 0x200 * (n)) -#define VM_SDIF_DATA(n) (VM_COM_REG_SIZE + 0x40 + 0x200 * (n)) +#define VM_SDIF_DONE(vm) (VM_COM_REG_SIZE + 0x34 + 0x200 * (vm)) +#define VM_SDIF_DATA(vm, ch) \ + (VM_COM_REG_SIZE + 0x40 + 0x200 * (vm) + 0x4 * (ch)) /* SDA Slave Register */ #define IP_CTRL 0x00 @@ -116,6 +117,7 @@ struct pvt_device { u32 t_num; u32 p_num; u32 v_num; + u32 c_num; u32 ip_freq; u8 *vm_idx; }; @@ -181,12 +183,14 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) struct regmap *v_map = pvt->v_map; u32 n, stat; u8 vm_idx; + u8 ch_idx; int ret; - if (channel >= pvt->v_num) + if (channel >= pvt->v_num * pvt->c_num) return -EINVAL; - vm_idx = pvt->vm_idx[channel]; + vm_idx = pvt->vm_idx[channel / pvt->c_num]; + ch_idx = channel % pvt->c_num; switch (attr) { case hwmon_in_input: @@ -197,7 +201,7 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) if (ret) return ret; - ret = regmap_read(v_map, VM_SDIF_DATA(vm_idx), &n); + ret = regmap_read(v_map, VM_SDIF_DATA(vm_idx, ch_idx), &n); if(ret < 0) return ret; @@ -386,6 +390,20 @@ static int pvt_init(struct pvt_device *pvt) if (ret) return ret; + val = GENMASK(pvt->c_num - 1, 0) | VM_CH_INIT | + IP_POLL << SDIF_ADDR_SFT | + SDIF_WRN_W | SDIF_PROG; + ret = regmap_write(v_map, SDIF_W, val); + if (ret < 0) + return ret; + + ret = regmap_read_poll_timeout(v_map, SDIF_STAT, + val, !(val & SDIF_BUSY), + PVT_POLL_DELAY_US, + PVT_POLL_TIMEOUT_US); + if (ret) + return ret; + val = CFG1_VOL_MEAS_MODE | CFG1_PARALLEL_OUT | CFG1_14_BIT | IP_CFG << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; @@ -501,7 +519,7 @@ static int pvt_reset_control_deassert(struct device *dev, struct pvt_device *pvt static int mr75203_probe(struct platform_device *pdev) { const struct hwmon_channel_info **pvt_info; - u32 ts_num, vm_num, pd_num, val, index, i; + u32 ts_num, vm_num, pd_num, ch_num, val, index, i; struct device *dev = &pdev->dev; u32 *temp_config, *in_config; struct device *hwmon_dev; @@ -547,9 +565,11 @@ static int mr75203_probe(struct platform_device *pdev) ts_num = (val & TS_NUM_MSK) >> TS_NUM_SFT; pd_num = (val & PD_NUM_MSK) >> PD_NUM_SFT; vm_num = (val & VM_NUM_MSK) >> VM_NUM_SFT; + ch_num = (val & CH_NUM_MSK) >> CH_NUM_SFT; pvt->t_num = ts_num; pvt->p_num = pd_num; pvt->v_num = vm_num; + pvt->c_num = ch_num; val = 0; if (ts_num) val++; @@ -586,6 +606,8 @@ static int mr75203_probe(struct platform_device *pdev) } if (vm_num) { + u32 total_ch = ch_num * vm_num; + ret = pvt_get_regmap(pdev, "vm", pvt); if (ret) return ret; @@ -614,13 +636,13 @@ static int mr75203_probe(struct platform_device *pdev) pvt->v_num = i; } - in_config = devm_kcalloc(dev, vm_num + 1, + in_config = devm_kcalloc(dev, total_ch + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) return -ENOMEM; - memset32(in_config, HWMON_I_INPUT, vm_num); - in_config[vm_num] = 0; + memset32(in_config, HWMON_I_INPUT, total_ch); + in_config[total_ch] = 0; pvt_in.config = in_config; pvt_info[index++] = &pvt_in; From patchwork Tue Aug 16 08:27:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944598 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 44201C2BB41 for ; Tue, 16 Aug 2022 10:32:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234689AbiHPKcA (ORCPT ); Tue, 16 Aug 2022 06:32:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234431AbiHPKbg (ORCPT ); Tue, 16 Aug 2022 06:31:36 -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 059C0139DA2; Tue, 16 Aug 2022 01:28: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=1660638502; x=1692174502; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aakzTg2DzAex8scIdcsOiBD10Miv0IDo0qf7Et9v8nc=; b=viAO5iBpZAFgObz4gaF8wSgR+BsQXQXgSXb/a2xttR1De2R0uOUhNdc3 RWx8dG049mcOE1aa+LsFT+Mlkqakui1xjcZjTU3m1Hjzr7RIl9bqQybfN ktfl4KdsW0/sJuw7PKg4Rl165H4cZvT740hawCQmfM7TYxo5Ne1emMCNF M=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="249302483" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1a-b27d4a00.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; 16 Aug 2022 08:28:01 +0000 Received: from EX13MTAUEB002.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1a-b27d4a00.us-east-1.amazon.com (Postfix) with ESMTPS id 2036C80EED; Tue, 16 Aug 2022 08:28:00 +0000 (UTC) Received: from EX13D08UEB002.ant.amazon.com (10.43.60.107) by EX13MTAUEB002.ant.amazon.com (10.43.60.12) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27:59 +0000 Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D08UEB002.ant.amazon.com (10.43.60.107) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27: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, 16 Aug 2022 08:27:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 634134C62; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 07/16] hwmon: (mr75203) add VM active channels property for Moortec PVT controller Date: Tue, 16 Aug 2022 08:27:48 +0000 Message-ID: <20220816082757.11990-8-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add optional "vm-active-channels" property to define the number of active channels per VM. Signed-off-by: Eliav Farber --- .../devicetree/bindings/hwmon/moortec,mr75203.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index da9c3cdcb6f0..6111b5069b3c 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -49,6 +49,13 @@ properties: reset-control-skip bool property defines if obtaining a reference to a reset controller should be skipped. + vm-active-channels: + description: + vm-active-channels defines the number of channels per VM + that are actually used and are connected to some source. + A value of 0 means that the entire VM sensor is nou used. + $ref: /schemas/types.yaml#definitions/uint8-array + required: - compatible - reg @@ -60,6 +67,7 @@ required: additionalProperties: - intel,vm-map - reset-control-skip + - vm-active-channels examples: - | @@ -73,5 +81,6 @@ examples: intel,vm-map = [03 01 04 ff ff]; clocks = <&osc0>; resets = <&rcu0 0x40 7>; + vm-active-channels = [08 10 02]; #thermal-sensor-cells = <1>; }; From patchwork Tue Aug 16 08:27:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944586 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 12765C32772 for ; Tue, 16 Aug 2022 10:22:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234402AbiHPKWf (ORCPT ); Tue, 16 Aug 2022 06:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234476AbiHPKWO (ORCPT ); Tue, 16 Aug 2022 06:22:14 -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 5BCAE11DD45; Tue, 16 Aug 2022 01:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660638502; x=1692174502; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LT+uQKQYay0NpQ9akz1XWeAUd+sCergcYHUcmH9Mcb4=; b=NU3F5EARCxaO+empSVoMZXjc/FDnf8g4zVyS2iFQeVWCwsdU+qOBxTVO 1TuhD5wWx7KQOhJUaEs4irsFsJ6Nr6UVvOVDfsgzKaDe6QjrU0jhBDs+1 uDdmlWwjqi8CueGFOlGlMyK4yOYUaI8BgKlYncSNow90qN5yC9fOfyrpB o=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="1044708734" 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; 16 Aug 2022 08:28:21 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1e-7dac3c4d.us-east-1.amazon.com (Postfix) with ESMTPS id BDFF4853FB; Tue, 16 Aug 2022 08:28:18 +0000 (UTC) Received: from EX19D013UWA003.ant.amazon.com (10.13.138.202) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27:59 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX19D013UWA003.ant.amazon.com (10.13.138.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Tue, 16 Aug 2022 08:27: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, 16 Aug 2022 08:27:58 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 5954C4C10; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 08/16] hwmon: (mr75203) add VM active channel support Date: Tue, 16 Aug 2022 08:27:49 +0000 Message-ID: <20220816082757.11990-9-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add active channel support per VM, which is useful when not all VM channels are used. Number of active channel is read from device-tree. When absent in device-tree, all channels are assumed to be used. Setting number of active channels to 0, means that entire VM sesnor is not used (this can partially replace the "intel,vm-map" functionality). Signed-off-by: Eliav Farber Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/hwmon/mr75203.c | 92 +++++++++++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 22 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 4419e481d47c..9b45fd089fcf 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -107,6 +107,11 @@ #define PVT_N_CONST 90 #define PVT_R_CONST 245805 +struct voltage_device { + u8 vm_map; + u8 ch_map; +}; + struct pvt_device { struct regmap *c_map; struct regmap *t_map; @@ -114,12 +119,13 @@ struct pvt_device { struct regmap *v_map; struct clk *clk; struct reset_control *rst; + struct voltage_device *vd; u32 t_num; u32 p_num; u32 v_num; - u32 c_num; u32 ip_freq; - u8 *vm_idx; + u8 vm_ch_max; + u8 vm_ch_total; }; static umode_t pvt_is_visible(const void *data, enum hwmon_sensor_types type, @@ -186,11 +192,11 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) u8 ch_idx; int ret; - if (channel >= pvt->v_num * pvt->c_num) + if (channel >= pvt->vm_ch_total) return -EINVAL; - vm_idx = pvt->vm_idx[channel / pvt->c_num]; - ch_idx = channel % pvt->c_num; + vm_idx = pvt->vd[channel].vm_map; + ch_idx = pvt->vd[channel].ch_map; switch (attr) { case hwmon_in_input: @@ -390,7 +396,7 @@ static int pvt_init(struct pvt_device *pvt) if (ret) return ret; - val = GENMASK(pvt->c_num - 1, 0) | VM_CH_INIT | + val = GENMASK(pvt->vm_ch_max - 1, 0) | VM_CH_INIT | IP_POLL << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(v_map, SDIF_W, val); @@ -519,7 +525,7 @@ static int pvt_reset_control_deassert(struct device *dev, struct pvt_device *pvt static int mr75203_probe(struct platform_device *pdev) { const struct hwmon_channel_info **pvt_info; - u32 ts_num, vm_num, pd_num, ch_num, val, index, i; + u32 ts_num, vm_num, pd_num, ch_num, val, index, i, j, k; struct device *dev = &pdev->dev; u32 *temp_config, *in_config; struct device *hwmon_dev; @@ -569,7 +575,6 @@ static int mr75203_probe(struct platform_device *pdev) pvt->t_num = ts_num; pvt->p_num = pd_num; pvt->v_num = vm_num; - pvt->c_num = ch_num; val = 0; if (ts_num) val++; @@ -606,43 +611,86 @@ static int mr75203_probe(struct platform_device *pdev) } if (vm_num) { - u32 total_ch = ch_num * vm_num; + u8 vm_idx[vm_num]; + u8 vm_active_ch[vm_num]; ret = pvt_get_regmap(pdev, "vm", pvt); if (ret) return ret; - pvt->vm_idx = devm_kcalloc(dev, vm_num, sizeof(*pvt->vm_idx), - GFP_KERNEL); - if (!pvt->vm_idx) - return -ENOMEM; - - ret = device_property_read_u8_array(dev, "intel,vm-map", - pvt->vm_idx, vm_num); + ret = device_property_read_u8_array(dev, "intel,vm-map", vm_idx, + vm_num); if (ret) { /* * Incase intel,vm-map property is not defined, we * assume incremental channel numbers. */ for (i = 0; i < vm_num; i++) - pvt->vm_idx[i] = i; + vm_idx[i] = i; } else { for (i = 0; i < vm_num; i++) - if (pvt->vm_idx[i] >= vm_num || - pvt->vm_idx[i] == 0xff) + if (vm_idx[i] >= vm_num || vm_idx[i] == 0xff) break; vm_num = i; pvt->v_num = i; } - in_config = devm_kcalloc(dev, total_ch + 1, + ret = device_property_read_u8_array(dev, "vm-active-channels", + vm_active_ch, vm_num); + if (ret) { + /* + * Incase vm-active-channels property is not defined, + * we assume each VM sensor has all of its channels + * active. + */ + for (i = 0; i < vm_num; i++) + vm_active_ch[i] = ch_num; + + pvt->vm_ch_max = ch_num; + pvt->vm_ch_total = ch_num * vm_num; + } else { + for (i = 0; i < vm_num; i++) { + if (vm_active_ch[i] > ch_num) { + dev_err(dev, + "invalid active channels: %u\n", + vm_active_ch[i]); + return -EINVAL; + } + + pvt->vm_ch_total += vm_active_ch[i]; + + if (vm_active_ch[i] > pvt->vm_ch_max) + pvt->vm_ch_max = vm_active_ch[i]; + } + } + + /* + * Map between the channel-number to VM-index and channel-index. + * Example - 3 VMs, vm_active_ch = [05 02 04]: + * vm_map = [0 0 0 0 0 1 1 2 2 2 2] + * ch_map = [0 1 2 3 4 0 1 0 1 2 3] + */ + pvt->vd = devm_kcalloc(dev, pvt->vm_ch_total, sizeof(*pvt->vd), + GFP_KERNEL); + if (!pvt->vd) + return -ENOMEM; + + k = 0; + for (i = 0; i < vm_num; i++) + for (j = 0; j < vm_active_ch[i]; j++) { + pvt->vd[k].vm_map = vm_idx[i]; + pvt->vd[k].ch_map = j; + k++; + } + + in_config = devm_kcalloc(dev, pvt->vm_ch_total + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) return -ENOMEM; - memset32(in_config, HWMON_I_INPUT, total_ch); - in_config[total_ch] = 0; + memset32(in_config, HWMON_I_INPUT, pvt->vm_ch_total); + in_config[pvt->vm_ch_total] = 0; pvt_in.config = in_config; pvt_info[index++] = &pvt_in; From patchwork Tue Aug 16 08:27:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944523 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 214B1C32771 for ; Tue, 16 Aug 2022 09:41:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233576AbiHPJlO (ORCPT ); Tue, 16 Aug 2022 05:41:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233847AbiHPJkQ (ORCPT ); Tue, 16 Aug 2022 05:40:16 -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 CEA90139DA1; Tue, 16 Aug 2022 01:28: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=1660638501; x=1692174501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hL47Mt4NCN4uw7YbFIII+nlUX4qr86MJ2L/tI0qq6tE=; b=QbPbuqX5rCOTab6VhQhxVmcm+RrtwAbgYEIYhAHOxlWEQ4jIAma0WTOD DaKmclEnrv+Sp8XBOTj3KvBdiVVSgqUfeW0PwbZwAk6ik+pmjH2rdqxWa qISYyhZRVz3PIG67FBxxile2ReJmIZlywKvASNVYWOpAA4SJNFGmtp1q4 s=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="119633990" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-pdx-2b-02ee77e7.us-west-2.amazon.com) ([10.25.36.210]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 08:28:08 +0000 Received: from EX13MTAUWB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2b-02ee77e7.us-west-2.amazon.com (Postfix) with ESMTPS id BE337449BA; Tue, 16 Aug 2022 08:28:07 +0000 (UTC) Received: from EX19D013UWB001.ant.amazon.com (10.13.138.52) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:28:00 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX19D013UWB001.ant.amazon.com (10.13.138.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Tue, 16 Aug 2022 08:28: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.161.249) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 16 Aug 2022 08:27:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 642174C21; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 09/16] hwmon: (mr75203) add VM pre-scalar property for Moortec PVT controller Date: Tue, 16 Aug 2022 08:27:50 +0000 Message-ID: <20220816082757.11990-10-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org vm-pre-scalar-ch# is a per channel optional parameter that can be used to normalzie the voltage output results. Signed-off-by: Eliav Farber --- .../devicetree/bindings/hwmon/moortec,mr75203.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index 6111b5069b3c..e2a55001eefc 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -56,6 +56,12 @@ properties: A value of 0 means that the entire VM sensor is nou used. $ref: /schemas/types.yaml#definitions/uint8-array + vm-pre-scalar-ch#: + description: + vm-active-channels defines the pre-scalar per channel value + used to normalzie the voltage output results. + $ref: /schemas/types.yaml#definitions/uint32 + required: - compatible - reg @@ -68,6 +74,7 @@ additionalProperties: - intel,vm-map - reset-control-skip - vm-active-channels + - vm-pre-scalar-ch# examples: - | @@ -82,5 +89,6 @@ examples: clocks = <&osc0>; resets = <&rcu0 0x40 7>; vm-active-channels = [08 10 02]; + vm-pre-scalar-ch5 = <2>; #thermal-sensor-cells = <1>; }; From patchwork Tue Aug 16 08:27:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944599 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 2228CC32772 for ; Tue, 16 Aug 2022 10:32:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbiHPKcm (ORCPT ); Tue, 16 Aug 2022 06:32:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234685AbiHPKcV (ORCPT ); Tue, 16 Aug 2022 06:32:21 -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 6F650B9406; Tue, 16 Aug 2022 01:28: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=1660638499; x=1692174499; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c8/SDcTJ30dbsZp2QPCvuIMC9D3VXp4QdqzbVFqmdMU=; b=gzng2BZWA2tgDnctUO+lpBuDgCvhWSipfgHkhidylqiBrt/EcnQ2O1TH 1IdI6PU34Garc6Z6qgLHTltan+ttWhNYaayVtD4tmbXlMO7T2q+MseXOW l7wsFL4Qn2RfmZqF0zQdDO+F+8io0C1vug4DiaLfEStFjCSSAUM9esy3m I=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="233486620" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2b-718d0906.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 08:28:17 +0000 Received: from EX13MTAUEE002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2b-718d0906.us-west-2.amazon.com (Postfix) with ESMTPS id EBFE43E0053; Tue, 16 Aug 2022 08:28:16 +0000 (UTC) Received: from EX13D08UEE003.ant.amazon.com (10.43.62.118) by EX13MTAUEE002.ant.amazon.com (10.43.62.24) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27:59 +0000 Received: from EX13MTAUEE002.ant.amazon.com (10.43.62.24) by EX13D08UEE003.ant.amazon.com (10.43.62.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27: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.62.224) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 16 Aug 2022 08:27:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 5CD724C0C; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 10/16] hwmon: (mr75203) add VM pre-scalar support Date: Tue, 16 Aug 2022 08:27:51 +0000 Message-ID: <20220816082757.11990-11-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add pre-scalar support to normalzie the voltage output results for channels the use pre-scalar units to get the measurement to be within the range that the sensor supports. The pre-scalar value is used if it exists in device-tree, otherwise default value of 1 is used. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 9b45fd089fcf..417b135c1b3f 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -110,8 +110,12 @@ struct voltage_device { u8 vm_map; u8 ch_map; + u32 pre_scaler; }; +#define PRE_SCALR_PROPERTY_NAME 32 +#define PRE_SCALR_DEFAULT_VAL 1 + struct pvt_device { struct regmap *c_map; struct regmap *t_map; @@ -213,7 +217,9 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) n &= SAMPLE_DATA_MSK; /* Convert the N bitstream count into voltage */ - *val = (PVT_N_CONST * n - PVT_R_CONST) >> PVT_CONV_BITS; + *val = pvt->vd[channel].pre_scaler; + *val *= (PVT_N_CONST * n - PVT_R_CONST); + *val >>= PVT_CONV_BITS; return 0; default: @@ -525,6 +531,7 @@ static int pvt_reset_control_deassert(struct device *dev, struct pvt_device *pvt static int mr75203_probe(struct platform_device *pdev) { const struct hwmon_channel_info **pvt_info; + const struct device_node *np = pdev->dev.of_node; u32 ts_num, vm_num, pd_num, ch_num, val, index, i, j, k; struct device *dev = &pdev->dev; u32 *temp_config, *in_config; @@ -550,7 +557,7 @@ static int mr75203_probe(struct platform_device *pdev) return ret; } - if (of_property_read_bool(dev->of_node, "reset-control-skip")) { + if (of_property_read_bool(np, "reset-control-skip")) { dev_info(dev, "skipping reset-control\n"); } else { pvt->rst = devm_reset_control_get_exclusive(dev, NULL); @@ -613,6 +620,8 @@ static int mr75203_probe(struct platform_device *pdev) if (vm_num) { u8 vm_idx[vm_num]; u8 vm_active_ch[vm_num]; + char prop_name[PRE_SCALR_PROPERTY_NAME] = {0}; + u32 pre_scaler; ret = pvt_get_regmap(pdev, "vm", pvt); if (ret) @@ -684,6 +693,21 @@ static int mr75203_probe(struct platform_device *pdev) k++; } + /* + * Incase vm-pre-scalar-ch# property is not defined, we assume + * default pre-scaler of 1. + */ + for (i = 0; i < pvt->vm_ch_total; i++) { + snprintf(prop_name, sizeof(prop_name), + "vm-pre-scalar-ch%u", i); + + ret = of_property_read_u32(np, prop_name, &pre_scaler); + if (ret) + pvt->vd[i].pre_scaler = PRE_SCALR_DEFAULT_VAL; + else + pvt->vd[i].pre_scaler = pre_scaler; + } + in_config = devm_kcalloc(dev, pvt->vm_ch_total + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) From patchwork Tue Aug 16 08:27:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944524 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 2BEA1C32772 for ; Tue, 16 Aug 2022 09:41:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233743AbiHPJlT (ORCPT ); Tue, 16 Aug 2022 05:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233955AbiHPJks (ORCPT ); Tue, 16 Aug 2022 05:40:48 -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 21C8C13927A; Tue, 16 Aug 2022 01:28: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=1660638499; x=1692174499; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EJd1o/p/S0Q3ZMPg/GLSYaA+EOKY6YoA3u+3TbLbo0w=; b=kTLFhALgIu/fDOUrMe3pM4b6qCS+8lduH9t3WEvPc0iGzYwYXyqhTU4M Q2My38g+MPfPtfs1gp+SgEWqvBRFx/4KoSBiTkUJa4SpMKZP0ZxJqO2t5 B4SMwQK/LoxPSS5dbkPzDLkcKQjpBPAr5L8ROGXqs3FF1wVD+2E9FTpgZ c=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="1044708628" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-pdx-2a-2dbf0206.us-west-2.amazon.com) ([10.25.36.214]) by smtp-border-fw-9103.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 08:28:00 +0000 Received: from EX13MTAUWB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2a-2dbf0206.us-west-2.amazon.com (Postfix) with ESMTPS id B4BDCA27C8; Tue, 16 Aug 2022 08:28:00 +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, 16 Aug 2022 08:27: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, 16 Aug 2022 08:27: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, 16 Aug 2022 08:27:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 5B13F4C51; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 11/16] hwmon: (mr75203) add protection for negative voltage value Date: Tue, 16 Aug 2022 08:27:52 +0000 Message-ID: <20220816082757.11990-12-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This change makes sure the returned voltage vlaue is 0 or positive. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 417b135c1b3f..8d8883301ff5 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -216,6 +216,13 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) return ret; n &= SAMPLE_DATA_MSK; + + /* Voltage can't be negative */ + if (PVT_N_CONST * n < PVT_R_CONST) { + *val = 0; + return 0; + } + /* Convert the N bitstream count into voltage */ *val = pvt->vd[channel].pre_scaler; *val *= (PVT_N_CONST * n - PVT_R_CONST); From patchwork Tue Aug 16 08:27:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944532 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 4FCE6C2BB41 for ; Tue, 16 Aug 2022 09:43:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233854AbiHPJnd (ORCPT ); Tue, 16 Aug 2022 05:43:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233851AbiHPJm4 (ORCPT ); Tue, 16 Aug 2022 05:42:56 -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 B9E13135AF3; Tue, 16 Aug 2022 01:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660638492; x=1692174492; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5uH3xAWY1NPlAqbvwT+BOwsnVqZsYpICWoOmCTyNqN4=; b=Z5bmZwYk8L9u+JvWeFcpHaV7Fd819UXSjxOAvW9o7G6Dvv5IHXuwNRcZ D5NrnwOxHp5ZMPcPPMN3Q2BMCGxjjs0UCiEI3tnDOY0RzclvzMVeUJ1Q1 a1Pi26Xznb3lQe9kyUCjA3QsxhcwnW2E+qr6xLKbb08+v5c7kvxpQYKRK I=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="230105244" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-8be8ed69.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; 16 Aug 2022 08:28:00 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1e-8be8ed69.us-east-1.amazon.com (Postfix) with ESMTPS id 90397C0865; Tue, 16 Aug 2022 08:27:59 +0000 (UTC) Received: from EX19D013UWA001.ant.amazon.com (10.13.138.253) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27:59 +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, 16 Aug 2022 08:27: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.160.118) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 16 Aug 2022 08:27:58 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 5A2094C22; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 12/16] hwmon: (mr75203) modify the temperature equation Date: Tue, 16 Aug 2022 08:27:53 +0000 Message-ID: <20220816082757.11990-13-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Modify the equation and coefficients to convert the digital output to temperature according to series 5 of the Moortec Embedded Temperature Sensor (METS) datasheet: T = G + H * (n / cal5 - 0.5) + J * F The G, H and J coefficients are multiplied by 1000 to get the temperature in milli-Celsius. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 8d8883301ff5..59e2dc8fa333 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -100,9 +100,10 @@ #define PVT_POLL_DELAY_US 20 #define PVT_POLL_TIMEOUT_US 20000 -#define PVT_H_CONST 100000 -#define PVT_CAL5_CONST 2047 -#define PVT_G_CONST 40000 +#define PVT_H_CONST 60000 +#define PVT_G_CONST 200000 +#define PVT_J_CONST -100 +#define PVT_CAL5_CONST 4094 #define PVT_CONV_BITS 10 #define PVT_N_CONST 90 #define PVT_R_CONST 245805 @@ -156,7 +157,6 @@ static int pvt_read_temp(struct device *dev, u32 attr, int channel, long *val) struct regmap *t_map = pvt->t_map; u32 stat, nbs; int ret; - u64 tmp; switch (attr) { case hwmon_temp_input: @@ -174,12 +174,13 @@ static int pvt_read_temp(struct device *dev, u32 attr, int channel, long *val) nbs &= SAMPLE_DATA_MSK; /* - * Convert the register value to - * degrees centigrade temperature + * Convert the register value to degrees centigrade temperature: + * T = G + H * (n / cal5 - 0.5) + J * F */ - tmp = nbs * PVT_H_CONST; - do_div(tmp, PVT_CAL5_CONST); - *val = tmp - PVT_G_CONST - pvt->ip_freq; + *val = PVT_G_CONST; + *val += PVT_H_CONST * nbs / PVT_CAL5_CONST; + *val -= PVT_H_CONST / 2; + *val += PVT_J_CONST * pvt->ip_freq / HZ_PER_MHZ; return 0; default: @@ -311,7 +312,7 @@ static int pvt_init(struct pvt_device *pvt) (key >> 1) << CLK_SYNTH_HI_SFT | (key >> 1) << CLK_SYNTH_HOLD_SFT | CLK_SYNTH_EN; - pvt->ip_freq = sys_freq * 100 / (key + 2); + pvt->ip_freq = clk_get_rate(pvt->clk) / (key + 2); if (t_num) { ret = regmap_write(t_map, SDIF_SMPL_CTRL, 0x0); From patchwork Tue Aug 16 08:27:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944571 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 3E741C32772 for ; Tue, 16 Aug 2022 10:10:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231991AbiHPKKn (ORCPT ); Tue, 16 Aug 2022 06:10:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234344AbiHPKJk (ORCPT ); Tue, 16 Aug 2022 06:09:40 -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 0FDA112309F; Tue, 16 Aug 2022 01:28:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660638504; x=1692174504; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FNHPX12Pit1WxIpHyPTouV10hppwOlS2zHdFi1vLKSQ=; b=anChMr3piLQwLFYGojdKtN7uUC+VQMcms+54NFx+LPI6TNxoxw+lYnsc rz+4LkSI+f46QlnTyIerS/UjDAbOS9d7NaHNDUh1rnjVUGDK+oQD+aDzD LnVv2IWrk75Ka09y8ETlYQc2HyfYQ6zlFmX/koDV+f1cqLp3XCC+OhOkL g=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="1044708753" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-10222bbc.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; 16 Aug 2022 08:28:22 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1d-10222bbc.us-east-1.amazon.com (Postfix) with ESMTPS id 792FD1A17C2; Tue, 16 Aug 2022 08:28:20 +0000 (UTC) Received: from EX19D013UWA002.ant.amazon.com (10.13.138.210) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:28: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, 16 Aug 2022 08:27: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, 16 Aug 2022 08:27:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 5E7E84C1C; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 13/16] hwmon: (mr75203) add thermal coefficient properties for Moortec PVT controller Date: Tue, 16 Aug 2022 08:27:54 +0000 Message-ID: <20220816082757.11990-14-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add optional "ts-coeff-g", "ts-coeff-h", "ts-coeff-cal5" and "ts-coeff-j" properties to be used instead of defaults for the thermal equasion. Signed-off-by: Eliav Farber --- .../bindings/hwmon/moortec,mr75203.yaml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml index e2a55001eefc..867664bd937f 100644 --- a/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml +++ b/Documentation/devicetree/bindings/hwmon/moortec,mr75203.yaml @@ -62,6 +62,30 @@ properties: used to normalzie the voltage output results. $ref: /schemas/types.yaml#definitions/uint32 + ts-coeff-g: + description: + G coefficient for thermal equation. + maxItems: 1 + $ref: /schemas/types.yaml#definitions/uint32 + + ts-coeff-h: + description: + H coefficient for thermal equation. + maxItems: 1 + $ref: /schemas/types.yaml#definitions/uint32 + + ts-coeff-cal5: + description: + cal5 coefficient for thermal equation (can't be 0). + maxItems: 1 + $ref: /schemas/types.yaml#definitions/uint32 + + ts-coeff-j: + description: + J coefficient for thermal equation. + maxItems: 1 + $ref: /schemas/types.yaml#definitions/int32 + required: - compatible - reg @@ -75,6 +99,10 @@ additionalProperties: - reset-control-skip - vm-active-channels - vm-pre-scalar-ch# + - ts-coeff-g + - ts-coeff-h + - ts-coeff-cal5 + - ts-coeff-j examples: - | @@ -90,5 +118,10 @@ examples: resets = <&rcu0 0x40 7>; vm-active-channels = [08 10 02]; vm-pre-scalar-ch5 = <2>; + ts-coeff-g = <57400>; + ts-coeff-h = <249400>; + ts-coeff-cal5 = <4096>; + ts-coeff-j = <0>; + #thermal-sensor-cells = <1>; }; From patchwork Tue Aug 16 08:27:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944543 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 6B7FDC2BB41 for ; Tue, 16 Aug 2022 09:50:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233926AbiHPJut (ORCPT ); Tue, 16 Aug 2022 05:50:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234094AbiHPJu0 (ORCPT ); Tue, 16 Aug 2022 05:50:26 -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 BD2BF139D93; Tue, 16 Aug 2022 01:28: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=1660638501; x=1692174501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4O85Ywpsk0CWX8vVdYh3wJcHjYPaTGC/6XL8TPAGJOE=; b=oY6AdOURKu2wtaB8asLWGrTpXSq5hWNp7FQx+nWXbbMFCajnthtdnbbC rSHKiBHAW5Bu4YEzmk6SSAK+43mxqLH/QbITRF5Jtws6Lp+dWSVKlcthO mMXP2Ghi8t97y2uUwwqDt2zkmG0vQdfVJEJ/AQL1mV6ergZkfAdVBRj2v Y=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="230105355" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2c-b09ea7fa.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 08:28:20 +0000 Received: from EX13MTAUEE002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2c-b09ea7fa.us-west-2.amazon.com (Postfix) with ESMTPS id 46F4744ABC; Tue, 16 Aug 2022 08:28:18 +0000 (UTC) Received: from EX13D08UEE002.ant.amazon.com (10.43.62.92) by EX13MTAUEE002.ant.amazon.com (10.43.62.24) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27:59 +0000 Received: from EX13MTAUEE002.ant.amazon.com (10.43.62.24) by EX13D08UEE002.ant.amazon.com (10.43.62.92) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27: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.62.224) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 16 Aug 2022 08:27:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 626CA4B60; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 14/16] hwmon: (mr75203) parse thermal coefficients from device-tree Date: Tue, 16 Aug 2022 08:27:55 +0000 Message-ID: <20220816082757.11990-15-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Use thermal coefficients from the device tree if they exist. Otherwise, use default values. The equation used in the driver is: T = G + H * (n / cal5 - 0.5) + J * F With this change we can support also Mode 1 Conversion, which uses A instead of G, and B instead of H. We can also support the series 6 equation that has different coefficients and has a slightly different format: T = G + H * (n / cal5 - 0.5) by setting J to 0. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 44 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 59e2dc8fa333..79831a0d5dca 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -129,6 +129,10 @@ struct pvt_device { u32 p_num; u32 v_num; u32 ip_freq; + u32 ts_coeff_h; + u32 ts_coeff_g; + s32 ts_coeff_j; + u32 ts_coeff_cal5; u8 vm_ch_max; u8 vm_ch_total; }; @@ -177,10 +181,10 @@ static int pvt_read_temp(struct device *dev, u32 attr, int channel, long *val) * Convert the register value to degrees centigrade temperature: * T = G + H * (n / cal5 - 0.5) + J * F */ - *val = PVT_G_CONST; - *val += PVT_H_CONST * nbs / PVT_CAL5_CONST; - *val -= PVT_H_CONST / 2; - *val += PVT_J_CONST * pvt->ip_freq / HZ_PER_MHZ; + *val = pvt->ts_coeff_g; + *val += pvt->ts_coeff_h * nbs / pvt->ts_coeff_cal5; + *val -= pvt->ts_coeff_h / 2; + *val += pvt->ts_coeff_j * pvt->ip_freq / HZ_PER_MHZ; return 0; default: @@ -617,6 +621,38 @@ static int mr75203_probe(struct platform_device *pdev) memset32(temp_config, HWMON_T_INPUT, ts_num); pvt_temp.config = temp_config; pvt_info[index++] = &pvt_temp; + + /* + * Incase ts-coeff-h/g/j/cal5 property is not defined, use + * default value. + */ + ret = of_property_read_u32(np, "ts-coeff-h", &pvt->ts_coeff_h); + if (ret) + pvt->ts_coeff_h = PVT_H_CONST; + + ret = of_property_read_u32(np, "ts-coeff-g", &pvt->ts_coeff_g); + if (ret) + pvt->ts_coeff_g = PVT_G_CONST; + + ret = of_property_read_s32(np, "ts-coeff-j", &pvt->ts_coeff_j); + if (ret) + pvt->ts_coeff_j = PVT_J_CONST; + + ret = of_property_read_u32(np, "ts-coeff-cal5", + &pvt->ts_coeff_cal5); + if (ret) { + pvt->ts_coeff_cal5 = PVT_CAL5_CONST; + } else { + if (pvt->ts_coeff_cal5 == 0) { + dev_err(dev, "invalid ts-coeff-cal5 (%u)\n", + pvt->ts_coeff_cal5); + return -EINVAL; + } + } + + dev_dbg(dev, "ts-coeff: h = %u, g = %u, j = %d, cal5 = %u\n", + pvt->ts_coeff_h, pvt->ts_coeff_g, pvt->ts_coeff_j, + pvt->ts_coeff_cal5); } if (pd_num) { From patchwork Tue Aug 16 08:27:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944562 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 32C57C2BB41 for ; Tue, 16 Aug 2022 10:03:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234262AbiHPKDk (ORCPT ); Tue, 16 Aug 2022 06:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234220AbiHPKC7 (ORCPT ); Tue, 16 Aug 2022 06:02:59 -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 3F7A3108F1B; Tue, 16 Aug 2022 01:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660638503; x=1692174503; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fji3MgPbCRHWZISMn5U/UtrDN4wjGdOvke3tjy+CBlE=; b=PwuE044Sazuzsg/LHQ4crVQos+eVopzx8NUH4WF3lUFxUYtsJrIM2Hhs h6+3MHoOp5OS6LmCsFU2Pee+QaoIrKkb5KHy8wQQch8yGYrUBQL2auk5F mnYoPDsS8usoKQO7lobQATsFtiSIwitHsGx+aOCKrRN1+92mp/+QQDn0b g=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="230105363" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-26daedd8.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; 16 Aug 2022 08:28:21 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1e-26daedd8.us-east-1.amazon.com (Postfix) with ESMTPS id 9953D82C1A; Tue, 16 Aug 2022 08:28:18 +0000 (UTC) Received: from EX19D013UWA004.ant.amazon.com (10.13.138.207) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:27: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, 16 Aug 2022 08:27: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.160.118) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 16 Aug 2022 08:27:58 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 57A304ADB; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 15/16] hwmon: (mr75203) fix coding style space errors Date: Tue, 16 Aug 2022 08:27:56 +0000 Message-ID: <20220816082757.11990-16-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Fix: "ERROR: space required before the open parenthesis '('" Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 79831a0d5dca..2777feca1c11 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -172,7 +172,7 @@ static int pvt_read_temp(struct device *dev, u32 attr, int channel, long *val) return ret; ret = regmap_read(t_map, SDIF_DATA(channel), &nbs); - if(ret < 0) + if (ret < 0) return ret; nbs &= SAMPLE_DATA_MSK; @@ -217,7 +217,7 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val) return ret; ret = regmap_read(v_map, VM_SDIF_DATA(vm_idx, ch_idx), &n); - if(ret < 0) + if (ret < 0) return ret; n &= SAMPLE_DATA_MSK; @@ -320,19 +320,19 @@ static int pvt_init(struct pvt_device *pvt) if (t_num) { ret = regmap_write(t_map, SDIF_SMPL_CTRL, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(t_map, SDIF_HALT, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(t_map, CLK_SYNTH, clk_synth); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(t_map, SDIF_DISABLE, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_read_poll_timeout(t_map, SDIF_STAT, @@ -345,7 +345,7 @@ static int pvt_init(struct pvt_device *pvt) val = CFG0_MODE_2 | CFG0_PARALLEL_OUT | CFG0_12_BIT | IP_CFG << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(t_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_read_poll_timeout(t_map, SDIF_STAT, @@ -358,7 +358,7 @@ static int pvt_init(struct pvt_device *pvt) val = POWER_DELAY_CYCLE_256 | IP_TMR << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(t_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_read_poll_timeout(t_map, SDIF_STAT, @@ -372,39 +372,39 @@ static int pvt_init(struct pvt_device *pvt) IP_CTRL << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(t_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; } if (p_num) { ret = regmap_write(p_map, SDIF_HALT, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(p_map, SDIF_DISABLE, BIT(p_num) - 1); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(p_map, CLK_SYNTH, clk_synth); - if(ret < 0) + if (ret < 0) return ret; } if (v_num) { ret = regmap_write(v_map, SDIF_SMPL_CTRL, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(v_map, SDIF_HALT, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(v_map, CLK_SYNTH, clk_synth); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_write(v_map, SDIF_DISABLE, 0x0); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_read_poll_timeout(v_map, SDIF_STAT, @@ -432,7 +432,7 @@ static int pvt_init(struct pvt_device *pvt) CFG1_14_BIT | IP_CFG << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(v_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_read_poll_timeout(v_map, SDIF_STAT, @@ -445,7 +445,7 @@ static int pvt_init(struct pvt_device *pvt) val = POWER_DELAY_CYCLE_64 | IP_TMR << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(v_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; ret = regmap_read_poll_timeout(v_map, SDIF_STAT, @@ -459,7 +459,7 @@ static int pvt_init(struct pvt_device *pvt) IP_CTRL << SDIF_ADDR_SFT | SDIF_WRN_W | SDIF_PROG; ret = regmap_write(v_map, SDIF_W, val); - if(ret < 0) + if (ret < 0) return ret; } @@ -584,7 +584,7 @@ static int mr75203_probe(struct platform_device *pdev) } ret = regmap_read(pvt->c_map, PVT_IP_CONFIG, &val); - if(ret < 0) + if (ret < 0) return ret; ts_num = (val & TS_NUM_MSK) >> TS_NUM_SFT; From patchwork Tue Aug 16 08:27:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 12944563 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 3568CC3F6B0 for ; Tue, 16 Aug 2022 10:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234269AbiHPKDo (ORCPT ); Tue, 16 Aug 2022 06:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231441AbiHPKDD (ORCPT ); Tue, 16 Aug 2022 06:03:03 -0400 Received: from smtp-fw-9103.amazon.com (smtp-fw-9103.amazon.com [207.171.188.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02896D277A; Tue, 16 Aug 2022 01:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660638502; x=1692174502; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zvOwVCJSLyiuRpdF+7TMgXPF/k1shU8+iEjRQRTM8LI=; b=HhWlzLeNRJEpvGCLqdzkV2PweoaeaMe6Q3fSHrBgHBfbKIRoFLnABV6T aGE5eJER049YHb7ZgV9JS03RQ/6YrF05/BEN++1S7JwVJinQupXlZeiRU e9y3DSI2ckeyCzNh0Yz+RVQzx7vnLzI8hX2Ss63W54rufrGQZyQ7USLnv U=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="1044708731" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1a-b09d0114.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; 16 Aug 2022 08:28:20 +0000 Received: from EX13MTAUEB002.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1a-b09d0114.us-east-1.amazon.com (Postfix) with ESMTPS id 56DFA80AF8; Tue, 16 Aug 2022 08:28:18 +0000 (UTC) Received: from EX13D08UEB003.ant.amazon.com (10.43.60.11) by EX13MTAUEB002.ant.amazon.com (10.43.60.12) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:28:02 +0000 Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D08UEB003.ant.amazon.com (10.43.60.11) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 08:28:02 +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, 16 Aug 2022 08:28:01 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 600D34C07; Tue, 16 Aug 2022 08:27:57 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH 16/16] hwmon: (mr75203) add debugfs to read and write temperature coefficients Date: Tue, 16 Aug 2022 08:27:57 +0000 Message-ID: <20220816082757.11990-17-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816082757.11990-1-farbere@amazon.com> References: <20220816082757.11990-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This change adds debugfs to read and write TS coefficients - g, h, j and cal5. The coefficients can vary between product and product, so to calibrate them it can be very useful to to be able to modify them on the fly. e.g. cat /sys/kernel/debug/940f23d0000.pvt/ts_coeff_cal5 4096 echo 83000 > sys/kernel/debug/940f23d0000.pvt/ts_coeff_g Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 196 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 2777feca1c11..04a702830987 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -9,6 +9,7 @@ */ #include #include +#include #include #include #include @@ -125,6 +126,7 @@ struct pvt_device { struct clk *clk; struct reset_control *rst; struct voltage_device *vd; + struct dentry *dbgfs_dir; u32 t_num; u32 p_num; u32 v_num; @@ -137,6 +139,198 @@ struct pvt_device { u8 vm_ch_total; }; +static ssize_t pvt_ts_coeff_h_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + char buf[16]; + unsigned int len; + + len = sprintf(buf, "%u\n", pvt->ts_coeff_h); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t pvt_ts_coeff_h_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + int ret; + u32 coeff; + + ret = kstrtou32_from_user(user_buf, count, 0, &coeff); + if (ret) + return ret; + + pvt->ts_coeff_h = coeff; + + return count; +} + +static const struct file_operations pvt_ts_coeff_h_fops = { + .read = pvt_ts_coeff_h_read, + .write = pvt_ts_coeff_h_write, + .open = simple_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + +static ssize_t pvt_ts_coeff_g_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + char buf[16]; + unsigned int len; + + len = sprintf(buf, "%u\n", pvt->ts_coeff_g); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t pvt_ts_coeff_g_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + int ret; + u32 coeff; + + ret = kstrtou32_from_user(user_buf, count, 0, &coeff); + if (ret) + return ret; + + pvt->ts_coeff_g = coeff; + + return count; +} + +static const struct file_operations pvt_ts_coeff_g_fops = { + .read = pvt_ts_coeff_g_read, + .write = pvt_ts_coeff_g_write, + .open = simple_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + +static ssize_t pvt_ts_coeff_j_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + char buf[16]; + unsigned int len; + + len = sprintf(buf, "%d\n", pvt->ts_coeff_j); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t pvt_ts_coeff_j_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + int ret; + s32 coeff; + + ret = kstrtos32_from_user(user_buf, count, 0, &coeff); + if (ret) + return ret; + + pvt->ts_coeff_j = coeff; + + return count; +} + +static const struct file_operations pvt_ts_coeff_j_fops = { + .read = pvt_ts_coeff_j_read, + .write = pvt_ts_coeff_j_write, + .open = simple_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + +static ssize_t pvt_ts_coeff_cal5_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + char buf[16]; + unsigned int len; + + len = sprintf(buf, "%u\n", pvt->ts_coeff_cal5); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t pvt_ts_coeff_cal5_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct pvt_device *pvt = file->private_data; + int ret; + u32 coeff; + + ret = kstrtou32_from_user(user_buf, count, 0, &coeff); + if (ret) + return ret; + + if (coeff == 0) + return -EINVAL; + + pvt->ts_coeff_cal5 = coeff; + + return count; +} + +static const struct file_operations pvt_ts_coeff_cal5_fops = { + .read = pvt_ts_coeff_cal5_read, + .write = pvt_ts_coeff_cal5_write, + .open = simple_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + +static void devm_pvt_ts_dbgfs_remove(void *data) +{ + struct pvt_device *pvt = (struct pvt_device *)data; + + debugfs_remove_recursive(pvt->dbgfs_dir); + pvt->dbgfs_dir = NULL; +} + +static int pvt_ts_dbgfs_create(struct pvt_device *pvt, struct device *dev) +{ + int ret; + + pvt->dbgfs_dir = debugfs_create_dir(dev_name(dev), NULL); + if (!pvt->dbgfs_dir) { + dev_err(dev, "Failed to create dbgfs_dir\n"); + return -EINVAL; + } + + debugfs_create_file("ts_coeff_h", 0644, pvt->dbgfs_dir, pvt, + &pvt_ts_coeff_h_fops); + debugfs_create_file("ts_coeff_g", 0644, pvt->dbgfs_dir, pvt, + &pvt_ts_coeff_g_fops); + debugfs_create_file("ts_coeff_j", 0644, pvt->dbgfs_dir, pvt, + &pvt_ts_coeff_j_fops); + debugfs_create_file("ts_coeff_cal5", 0644, pvt->dbgfs_dir, pvt, + &pvt_ts_coeff_cal5_fops); + + ret = devm_add_action_or_reset(dev, devm_pvt_ts_dbgfs_remove, pvt); + if (ret) { + dev_err(dev, "failed to add action to remove pvt dbgfs (%d)\n", + ret); + return ret; + } + + return 0; +} + static umode_t pvt_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr, int channel) { @@ -653,6 +847,8 @@ static int mr75203_probe(struct platform_device *pdev) dev_dbg(dev, "ts-coeff: h = %u, g = %u, j = %d, cal5 = %u\n", pvt->ts_coeff_h, pvt->ts_coeff_g, pvt->ts_coeff_j, pvt->ts_coeff_cal5); + + pvt_ts_dbgfs_create(pvt, dev); } if (pd_num) {