From patchwork Fri Sep 29 10:36:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 13404052 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 41DDDE80ABE for ; Fri, 29 Sep 2023 10:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232977AbjI2Kha (ORCPT ); Fri, 29 Sep 2023 06:37:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233052AbjI2KhP (ORCPT ); Fri, 29 Sep 2023 06:37:15 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2070.outbound.protection.outlook.com [40.107.95.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 904CD1B2; Fri, 29 Sep 2023 03:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IUT1EfsW2uU9yzFBn9bizSY1HZcxHfHrHpBxdn95poRAv8PYLOUMO7SV1zwTxlPtFW2w3slP8kzGvLwuxfZHtccK1JPtfqHAEXNEhDAo9pHD6X6SinSCoRDdxgbpPZLGeqP6gBPF1PlUoZIFcivmUzujC0rtGLJv8eBnvFrsd2xHNkO82pqOtIgf24gulJJC53nl06dlPHN9Q4bG4Etb5ys4S0IjNOCaAsLgO6P5n0pLKkco8wGRv3qUocBEJsyrQthgK4QF7iGNRO17KzBmdbzdNNNLtm0PlkhWufu60/MKBxKuvjYjGYZ5vzn7FUw3NwhGqOHFKkzQnvI5G5JuMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zMfHSHVXBV/Gn3LdqZnwcM663CH4zjrI17d8liEWcIg=; b=mtB0A9SzuVHRpigKxq3Qo8sASzwx1PowNB2KxlfHq82iJoaLscLdGPBynMO/ovXB4HCl54k62CGYpBpPQPBZgXfEwZM0avqLF5G3yvLoJnLspEBKI9/6+YwDeDiEeAjZ2wi9iJ1z4Va+RIg6oClshXyz4cRjr1JAP+/NNMZi8etkQOGfttNYnrdbxiU2TD+lGDWNvoLK3fRZ5ui4SFTT/CkRE6alWbKuHcE31in+e4N/qg02aaMAoSImsSrWtwccamWIzCAZS9SB/ypqNyKv5e52HdRwsfHS7fwVLwlw6JmWy2ouVlVEQlwlrRPZAKSqi7Z1BRUr4olGxYDBekOP8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=suse.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zMfHSHVXBV/Gn3LdqZnwcM663CH4zjrI17d8liEWcIg=; b=Uypk9Sp3v/smNu33rFoIRGQuWM/gUaP/eXJ+eGImXH/z71YKwQ21e8V2PW7MElpI5PXh/2vYRZTZJMzwX5UUhPJ/ezBfep5RllHSBBfH8fxF5c8RMzO1MIj7uNbSWV+fbs130hnO8LFfeSzCTRBwrNTREJ1KPVY/X7ie6/yXpKDy3P+P1L+7zOB0sYnr0hJ0QkfE+MWOpU5IKKM7Gu2kIWZATP7wh8sTWN06fvx1FIZ/HrfBScaooU0jqRylmir0hi+4nGWBnxkvfsTSV681GuuKigBdcczuP5l6z+2rgYi8OhGJSwvpHKwtr9yFgBDGKiy6rNq0znvevk8lqZtjjw== Received: from MW4PR04CA0147.namprd04.prod.outlook.com (2603:10b6:303:84::32) by CY5PR12MB6454.namprd12.prod.outlook.com (2603:10b6:930:36::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.27; Fri, 29 Sep 2023 10:37:07 +0000 Received: from CO1PEPF000042A8.namprd03.prod.outlook.com (2603:10b6:303:84:cafe::74) by MW4PR04CA0147.outlook.office365.com (2603:10b6:303:84::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.26 via Frontend Transport; Fri, 29 Sep 2023 10:37:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000042A8.mail.protection.outlook.com (10.167.243.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Fri, 29 Sep 2023 10:37:07 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 29 Sep 2023 03:36:57 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 29 Sep 2023 03:36:57 -0700 Received: from moonraker.home (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Fri, 29 Sep 2023 03:36:55 -0700 From: Jon Hunter To: Jean Delvare , Guenter Roeck , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley , Thierry Reding CC: , , , Ninad Malwade , "Thierry Reding" , Jon Hunter Subject: [PATCH V5 1/4] dt-bindings: hwmon: ina3221: Convert to json-schema Date: Fri, 29 Sep 2023 11:36:47 +0100 Message-ID: <20230929103650.86074-2-jonathanh@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929103650.86074-1-jonathanh@nvidia.com> References: <20230929103650.86074-1-jonathanh@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042A8:EE_|CY5PR12MB6454:EE_ X-MS-Office365-Filtering-Correlation-Id: 9fc96328-9558-42e7-58cf-08dbc0d80780 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RHIzetiJsaF6owY4sLKSi0qpDGaFiWUFtSAtQhwQeGEgF+6zDk8ZI3p9q34DUCzp1Os2UQUE/9PYrVH+aI5MWb7xirbgZtDmTpVItm5EHAwS+bnd+A3f1wcTaJRuttluX0QeBbWMGlXVTsUqDJGjgWtt0Ku/bSNQLSLY23l/6KaK+rmtV4FW4UTFxxeI/QPXm/gDdJ0dl1MRo82Vu2HWTmgZtwTgtNb+xdD/s7xwslpCHmHSXExncFo3cY0AkM5zsHlY/An+mSOP40vFY3DdoHeDLCW6fTjnrvnFmYjikWwSYNp4v4+2v1G97yXDVfbrvCcLzzLhoTjVw5C2gdp77RcaeQvCEv8a/lDISmphcyuumesb2ppnztyFrrZh6GgwIp9XCYOGzwcyGcJXCG8hBroBKyCR0NYcyspOv9aRAdCtef3Pf2dS4HtjZigzTfkIVUaGWCY69LORg1FtqplAWmQmmEAY1OBWDEymvhMQwCmi3OCACsPmB3eZu7Im5QFnS1IZobCGBaVz2kJsm+pgMzy+pzaJeY7HCHxZ+vHFcJAXJHItkAwbq7xbpFjIAKCPaju2AI4rTVvkbmwT5tDX8Zvd1ZIRKj1UdRKDsPTNLp0Bxb3IukVolQ0hRkz8h6OsNkPG8EQsI9e58mNVRXV2Wg6LDFpO+5sIs8Uuv0re0YqNeGTU0LKIZFWlU1WDpVrNCTFWPoU5gLD5CadIoSqrLHYAJttLeh5cUMvARC33BW3l9MWj5qbhw6pv+9PxvvqnMvWgnx4ncY2JeRGh1o9FxQ== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(376002)(346002)(396003)(136003)(230922051799003)(186009)(64100799003)(82310400011)(1800799009)(451199024)(40470700004)(36840700001)(46966006)(2906002)(5660300002)(8936002)(4326008)(8676002)(26005)(36756003)(1076003)(2616005)(40480700001)(107886003)(41300700001)(70206006)(316002)(54906003)(70586007)(40460700003)(110136005)(6666004)(356005)(83380400001)(478600001)(966005)(336012)(426003)(47076005)(36860700001)(82740400003)(7636003)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2023 10:37:07.2815 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9fc96328-9558-42e7-58cf-08dbc0d80780 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042A8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6454 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Ninad Malwade Convert the TI INA3221 bindings from the free-form text format to json-schema. Note that the INA3221 input channels default to enabled in the chip. Unless channels are explicitly disabled in device-tree, input channels will be enabled. Signed-off-by: Thierry Reding Signed-off-by: Ninad Malwade Signed-off-by: Jon Hunter Reviewed-by: Rob Herring --- .../devicetree/bindings/hwmon/ina3221.txt | 54 ---------- .../devicetree/bindings/hwmon/ti,ina3221.yaml | 102 ++++++++++++++++++ 2 files changed, 102 insertions(+), 54 deletions(-) delete mode 100644 Documentation/devicetree/bindings/hwmon/ina3221.txt create mode 100644 Documentation/devicetree/bindings/hwmon/ti,ina3221.yaml diff --git a/Documentation/devicetree/bindings/hwmon/ina3221.txt b/Documentation/devicetree/bindings/hwmon/ina3221.txt deleted file mode 100644 index fa63b6171407..000000000000 --- a/Documentation/devicetree/bindings/hwmon/ina3221.txt +++ /dev/null @@ -1,54 +0,0 @@ -Texas Instruments INA3221 Device Tree Bindings - -1) ina3221 node - Required properties: - - compatible: Must be "ti,ina3221" - - reg: I2C address - - Optional properties: - - ti,single-shot: This chip has two power modes: single-shot (chip takes one - measurement and then shuts itself down) and continuous ( - chip takes continuous measurements). The continuous mode is - more reliable and suitable for hardware monitor type device, - but the single-shot mode is more power-friendly and useful - for battery-powered device which cares power consumptions - while still needs some measurements occasionally. - If this property is present, the single-shot mode will be - used, instead of the default continuous one for monitoring. - - = The node contains optional child nodes for three channels = - = Each child node describes the information of input source = - - - #address-cells: Required only if a child node is present. Must be 1. - - #size-cells: Required only if a child node is present. Must be 0. - -2) child nodes - Required properties: - - reg: Must be 0, 1 or 2, corresponding to IN1, IN2 or IN3 port of INA3221 - - Optional properties: - - label: Name of the input source - - shunt-resistor-micro-ohms: Shunt resistor value in micro-Ohm - -Example: - -ina3221@40 { - compatible = "ti,ina3221"; - reg = <0x40>; - #address-cells = <1>; - #size-cells = <0>; - - input@0 { - reg = <0x0>; - status = "disabled"; - }; - input@1 { - reg = <0x1>; - shunt-resistor-micro-ohms = <5000>; - }; - input@2 { - reg = <0x2>; - label = "VDD_5V"; - shunt-resistor-micro-ohms = <5000>; - }; -}; diff --git a/Documentation/devicetree/bindings/hwmon/ti,ina3221.yaml b/Documentation/devicetree/bindings/hwmon/ti,ina3221.yaml new file mode 100644 index 000000000000..0fd8ae5f6a22 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/ti,ina3221.yaml @@ -0,0 +1,102 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/ti,ina3221.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments INA3221 Current and Voltage Monitor + +maintainers: + - Jean Delvare + - Guenter Roeck + +properties: + compatible: + const: ti,ina3221 + + reg: + maxItems: 1 + + ti,single-shot: + description: | + This chip has two power modes: single-shot (chip takes one measurement + and then shuts itself down) and continuous (chip takes continuous + measurements). The continuous mode is more reliable and suitable for + hardware monitor type device, but the single-shot mode is more power- + friendly and useful for battery-powered device which cares power + consumptions while still needs some measurements occasionally. + + If this property is present, the single-shot mode will be used, instead + of the default continuous one for monitoring. + $ref: /schemas/types.yaml#/definitions/flag + + "#address-cells": + description: Required only if a child node is present. + const: 1 + + "#size-cells": + description: Required only if a child node is present. + const: 0 + +patternProperties: + "^input@[0-2]$": + description: The node contains optional child nodes for three channels. + Each child node describes the information of input source. Input channels + default to enabled in the chip. Unless channels are explicitly disabled + in device-tree, input channels will be enabled. + type: object + additionalProperties: false + properties: + reg: + description: Must be 0, 1 and 2, corresponding to the IN1, IN2 or IN3 + ports of the INA3221, respectively. + enum: [ 0, 1, 2 ] + + label: + description: name of the input source + + shunt-resistor-micro-ohms: + description: shunt resistor value in micro-Ohm + + required: + - reg + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + power-sensor@40 { + compatible = "ti,ina3221"; + reg = <0x40>; + #address-cells = <1>; + #size-cells = <0>; + + input@0 { + reg = <0x0>; + /* + * Input channels are enabled by default in the device and so + * to disable, must be explicitly disabled in device-tree. + */ + status = "disabled"; + }; + + input@1 { + reg = <0x1>; + shunt-resistor-micro-ohms = <5000>; + }; + + input@2 { + reg = <0x2>; + label = "VDD_5V"; + shunt-resistor-micro-ohms = <5000>; + }; + }; + }; From patchwork Fri Sep 29 10:36:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 13404051 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 4EFF1E7F156 for ; Fri, 29 Sep 2023 10:37:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233061AbjI2Kh3 (ORCPT ); Fri, 29 Sep 2023 06:37:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233046AbjI2KhO (ORCPT ); Fri, 29 Sep 2023 06:37:14 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2089.outbound.protection.outlook.com [40.107.244.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 887EB1B1; Fri, 29 Sep 2023 03:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n9m2AC9CtpGwOLnTVaCeoUQcGPJQTe0qwEjyjppQtp3qWqeIoOkJV9VG8ewRNWF8DexR5LkSzIWzdeclo0uibkmKAqUF7gquzqjv0LzoKNStaMlfmUC/zWaINM4JKoNlQloUiu1Y3ZBHxD+M4ytZLuzX+eXDzNK4+G9e0jz3H5YnDt2WY6pI4jjTBAeLdp7CzAowLRJwnSGzzAuwsbRctWhWXBkZxMmm05OiK6qjjRH+Z+6kKb9Dgp7ynN+Bo5o3jI1v6K1LOp9eGRQUVo1I/GL/lvw45seyvKpm8Thlj/5wuYlU4/V6MKmzgGeEE3/M3+DhMIRU9yrHOEEZ9Wx6lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zkR3+BXDwUV1HYy5UVfZDM1SuhNeuEsRGgQfCgwsU7w=; b=KhsEKBMWRJXpXnMytYq9juzYUQbWnVft/dE4fiwbr0+P7PEuQ8VqqaQt0ZQAjX0ScV76q6hy9KPhK6hTwAO60SaVR5lQ9kNLxADnxR+mCM+5RN5HFRcMhY17Qgt4PMnkJNE70lugwgtp3vy0WKfVxo/D2EdiQWTbLSHV8Rke8VkPcORw1/loKXbUot5ejVuQ0ZC/tNAVlb5fBNKrxtrcZg1k50LhEJ/zaaEaPdE0IREOJSOd4OVS7jxO5qZ+uR4KlkqLyJXK6tAEhpQ+F8Oeejr3x79Q/rWfh0KD5x83Snuf3aWkDUBp6XVvytj/v30yUM7FdE4cxvWM3V/GDJUtHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=suse.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zkR3+BXDwUV1HYy5UVfZDM1SuhNeuEsRGgQfCgwsU7w=; b=tMyjJu4CxYD21KQdorPg8UREA7PEv0eIsKkrOzaZj1WjUtFtD/Q04w8OldGlUrnnfuOVEOmp3ycIUIv33AhYFzJsjFDEj5CNDUACp7iBxqgrS67Snkd+oc1yB5TnCWlu+M65M8HL+QFLo85DcyX1/H6Cd72iTRGPl8TvnqorjdKiVeSLpJzle9X/R7Q0xeoN5Sg8L1M5nepCBTHtqyZbeYQlwdJ3yNgB8NOPCAeO6ho4XW0bhwLTTu4OS4QpyjoEGy01mYDTTyr+caUqcPLdQ+wNX9OYgH0jD0kFdFM/uHfSTg7NLT/zG4UfbTlODExevOS37hypN3Wg2h9sj1blXg== Received: from DM5PR08CA0034.namprd08.prod.outlook.com (2603:10b6:4:60::23) by PH0PR12MB5482.namprd12.prod.outlook.com (2603:10b6:510:ea::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.27; Fri, 29 Sep 2023 10:37:09 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:4:60:cafe::3d) by DM5PR08CA0034.outlook.office365.com (2603:10b6:4:60::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.26 via Frontend Transport; Fri, 29 Sep 2023 10:37:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.19 via Frontend Transport; Fri, 29 Sep 2023 10:37:08 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 29 Sep 2023 03:37:00 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 29 Sep 2023 03:37:00 -0700 Received: from moonraker.home (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Fri, 29 Sep 2023 03:36:58 -0700 From: Jon Hunter To: Jean Delvare , Guenter Roeck , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley , Thierry Reding CC: , , , Jon Hunter , "Ninad Malwade" Subject: [PATCH V5 2/4] dt-bindings: hwmon: ina3221: Add ti,summation-disable Date: Fri, 29 Sep 2023 11:36:48 +0100 Message-ID: <20230929103650.86074-3-jonathanh@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929103650.86074-1-jonathanh@nvidia.com> References: <20230929103650.86074-1-jonathanh@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|PH0PR12MB5482:EE_ X-MS-Office365-Filtering-Correlation-Id: a9b1f9fa-b9e5-403a-cfab-08dbc0d8083b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xZJge4+iJG062HQbXFQkT1bNbfjwoYQvwt3xtCNzpUBX8ZtJkNO/YBWsWT0XUP/HBgadfTd9Bu5van21okyvni9CHSQvTJnVGxmgOfkohUkdiQ5O0MtfkPBh4lh4VgFUGHlpoB1Zd3mc/QeM4wyd2F/+6dy80SlMrB0e0g0roqlr76a+H/HgGlk8E+qa0x6EFd1y02ZQKDGckjmygskw4H7YgOE80D//CbO4UcGAyHS61DdAPp3SgSPYuB86G6U3ksVsESirOxkl1kveyPaF2T/Jnm4Wut3NdOirYpj1pvlXG77M5QtdeXlJc4+bzDGY5+jI9PJVC1SNFOGfOuEhRNJwqofXOMW/syoMLy6B1qJgNmMbGWW89n6kuq85TkXrFU1oWaU0xdDxybPDpGolF9oV6xqOcZ3LzxtO6TfQq1bSmgnRVVIuZ70vTXMsRlABPfjqd2kQkrgUOUnvB0Pi2ZXRUurVgL8EQplMBns34By+hpg4qoE1Kc2JPNprIOlSnvcyXq9jPaGVTc6G0OOCRj33wYEaekK9ixRaL/8gPnzqgWBe3BiKodAhDwcXx/I5gTcAqHL/8qlINgZuuhjissRwIVcIfMMSGldZSZYn9YZl/ZabK7BhCh/PwX9a7rzmIJfw9BFdPwy6xz7CDLAXZVb/QQkFxGTgY7qgWeouN5ScjvQl289b4TKx2oC6YGBme0r0zWi5xe/qFxQg9zn4zPDlY7TFUdaqul5EV6fbbxe3+0Uap07QHUda6LvMmz0e X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(396003)(136003)(346002)(39860400002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(82310400011)(46966006)(36840700001)(40470700004)(54906003)(70586007)(110136005)(26005)(70206006)(1076003)(41300700001)(316002)(6666004)(2906002)(478600001)(5660300002)(2616005)(107886003)(336012)(426003)(83380400001)(36860700001)(4326008)(8676002)(8936002)(47076005)(82740400003)(356005)(7636003)(86362001)(40460700003)(36756003)(40480700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2023 10:37:08.5569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9b1f9fa-b9e5-403a-cfab-08dbc0d8083b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5482 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org The INA3221 has a critical alert pin that can be controlled by the summation control function. This function adds the single shunt-voltage conversions for the desired channels in order to compare the combined sum to the programmed limit. The Shunt-Voltage Sum Limit register contains the programmed value that is compared to the value in the Shunt-Voltage Sum register in order to determine if the total summed limit is exceeded. If the shunt-voltage sum limit value is exceeded, the critical alert pin pulls low. For the summation limit to have a meaningful value, it is necessary to use the same shunt-resistor value on all included channels. Add a new vendor specific property, 'ti,summation-disable', to allow specific channels to be excluded from the summation control function if the shunt resistor is different to other channels or the channel should not be considered for triggering the critical alert pin. Note that the ina3221 has always supported summing the various input channels and summation is enabled by default if the shunt-resistor values are the same. This change simply provides a way to exclude inputs from the summation. If this property is not populated, then the functionality of the driver does not change. Signed-off-by: Jon Hunter Signed-off-by: Ninad Malwade Reviewed-by: Rob Herring --- .../devicetree/bindings/hwmon/ti,ina3221.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/ti,ina3221.yaml b/Documentation/devicetree/bindings/hwmon/ti,ina3221.yaml index 0fd8ae5f6a22..5f10f1207d69 100644 --- a/Documentation/devicetree/bindings/hwmon/ti,ina3221.yaml +++ b/Documentation/devicetree/bindings/hwmon/ti,ina3221.yaml @@ -58,6 +58,25 @@ patternProperties: shunt-resistor-micro-ohms: description: shunt resistor value in micro-Ohm + ti,summation-disable: + description: | + The INA3221 has a critical alert pin that can be controlled by the + summation control function. This function adds the single + shunt-voltage conversions for the desired channels in order to + compare the combined sum to the programmed limit. The Shunt-Voltage + Sum Limit register contains the programmed value that is compared + to the value in the Shunt-Voltage Sum register in order to + determine if the total summed limit is exceeded. If the + shunt-voltage sum limit value is exceeded, the critical alert pin + is asserted. + + For the summation limit to have a meaningful value, it is necessary + to use the same shunt-resistor value on all enabled channels. If + this is not the case or if a channel should not be used for + triggering the critical alert pin, then this property can be used + exclude specific channels from the summation control function. + type: boolean + required: - reg From patchwork Fri Sep 29 10:36:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 13404054 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 6829FE7F156 for ; Fri, 29 Sep 2023 10:37:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233003AbjI2Khe (ORCPT ); Fri, 29 Sep 2023 06:37:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233088AbjI2KhU (ORCPT ); Fri, 29 Sep 2023 06:37:20 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2040.outbound.protection.outlook.com [40.107.220.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5806A1BD; Fri, 29 Sep 2023 03:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I6CsoAKTghstwDc5ID8zd8Lu2GNvwgX6yDZs/OZF90mKKoR733k9AccgPtfy5ILKpnQKvlpyWOSmaZrJQDanVOne+JITYlQgZqLzoOroU0xoiuPggRS1aRzUFswpRept4JAQot4F/r38rayTA37v5C10P5BvaTuvOGvzkcTefZ1eUnQ89YT01vrHC3lX+W+d+zTsCe6CCDIAlTWM1APRUh6j76jRgg3AZarjF+SOgHSLrMLfzSJj8twyB6NiVPvtWhZoJjVPvX1SygEwxeeXSYWNphJXukM/+tnxRpFYVTmlBeiAasDkMXjNxKwRXVc3i4ihbOgezQGpkmVFiJQ4Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=74/nJgm1DUzuN0eOOY/xluCtvtQDd27o3MR3/EqiIHA=; b=YXn1ySa6F20ptu41sJL3w+RM6M4GhQC2QAqEKTlZtmQD8CKX3bbIwvZh05jc6mkvMi+NNZuq0yNHCwwzeKpo4P4u2xk4AXJK7KnaXdNAlL96X1obsZlpYmfQNR+4el6Q5bLdXSMIp1KssAtkGjVGDxSjWciFP1n5NouA3ZfueDRgeooCTlPN8FNzWDjn03Ikv7EOa0xb9sjzwmuqPZOfGlwpnN5MMO5y9x9EGTiBegy1ksAxWC8Wo0uvVTcgj4Evl6IquAvIiG6jM+t4RMvkd9rkZh5VI2PaHcmKWsea+N0uTTfuA+3BcpgArqANxWVB858KJMH3WwXZdNnJ+u9fNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=suse.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=74/nJgm1DUzuN0eOOY/xluCtvtQDd27o3MR3/EqiIHA=; b=iprxxo41Ak+Mtmomm3h+GAELLeG119R7mOKFN4YM3C+FKzwy/cL6giemyGh4Ka50awwVnxy0HnnbVhCfdDWepQOdzC5GLQokahm2zlxQqmL9YqhMh5D6UPOwFN6acOH9rK1RQXU7a0irMQ02woTZvYouS6z1BYpbx99U51w+eKuxhwhaze7y/gllci15SyBziEdSvzgltH7c8+19YaItTXMQWKXO7hcnd5guiYtTDoDAUgATzfRuBPy8ErxqRzLxPvS73sgxRgmqXTKh3NyAhe1xzwr/tRrvqbEis6gTeZFEnCuULMW0ceDDh4aG6cUxshFPjIIz1qhiHlc2yx0z4A== Received: from MW4PR04CA0133.namprd04.prod.outlook.com (2603:10b6:303:84::18) by SA3PR12MB9225.namprd12.prod.outlook.com (2603:10b6:806:39e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.26; Fri, 29 Sep 2023 10:37:15 +0000 Received: from CO1PEPF000042A8.namprd03.prod.outlook.com (2603:10b6:303:84:cafe::f9) by MW4PR04CA0133.outlook.office365.com (2603:10b6:303:84::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.26 via Frontend Transport; Fri, 29 Sep 2023 10:37:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000042A8.mail.protection.outlook.com (10.167.243.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Fri, 29 Sep 2023 10:37:15 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 29 Sep 2023 03:37:04 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 29 Sep 2023 03:37:03 -0700 Received: from moonraker.home (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Fri, 29 Sep 2023 03:37:00 -0700 From: Jon Hunter To: Jean Delvare , Guenter Roeck , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley , Thierry Reding CC: , , , Ninad Malwade , "Rajkumar Kasirajan" , Jon Hunter Subject: [PATCH V5 3/4] hwmon: ina3221: Add support for channel summation disable Date: Fri, 29 Sep 2023 11:36:49 +0100 Message-ID: <20230929103650.86074-4-jonathanh@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929103650.86074-1-jonathanh@nvidia.com> References: <20230929103650.86074-1-jonathanh@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042A8:EE_|SA3PR12MB9225:EE_ X-MS-Office365-Filtering-Correlation-Id: a20c6846-3292-4550-faab-08dbc0d80c50 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VOhcztgOiPkJxQ0zNoTY8I7GxwRtI25jCuZuw3UCXGnpwoUBdz/VJROU++hdSBFEy6DfoMOf4RbNIQRtwz1wE1truDWdkELGqPH8nbT6tvd49E34q18DjkweHvSb5E2O/dDebKTIhxMW867BHAabcd3xYR6/EriMrLGISPbLPztrYcmnt7YhotHK4Pu0lqOdcxj1+wjWo/Z+2nhvs04Y5XDa/nfbVTEJVf2gBGiRlU6OCdA8gJqP/58IMDJf/kf7L54VNEnnXZDtYb/O9dJ4Q7cUm9PsvMqy45iV9OrHjAGPLETYybb1YYEZcSN2HQRPgNMzwCqjk9IIZgdCbsMKAX9ltE/rN2Iw/i4t5UM0cQAIC5vGqgwvgvBQyNDAxeORDDJ5cXLz+2tSSreW2Q4LAwWgX1fo4RTr/Ei8hFdUjRuVYKm2RpYNPc8/3b7jHXn8MAG3P4+IbwqOOW2e5OjJUfwlG0yQdsfFEZYcE5ZDWuGV1UaRwdNntu3dykmIGycsr3HbhvbOtmkWbpmPzXjkcxPfbhbnWPBM4x5czbdwZ9RF3jmTysOQ8OZputfh35+jBIVF1ebasV54ZPSUhuITrJx3ja8y0fZKdSyVzJ6Z+wDHcmrGxgNcFso+MqsHbSuI6ZsCTuf8JtVFI4hChPuC57+dcJVCsTGNaxOfG0o+gUfMUh4eb9/Dz/27FBD1GtTyxb2z+1mhjIK8djTOHONq5WMGpNE24JELW5bon5V8myzRGSEz89iEBZ3OIrQfcr2n X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(346002)(136003)(376002)(39860400002)(396003)(230922051799003)(64100799003)(1800799009)(451199024)(82310400011)(186009)(36840700001)(46966006)(40470700004)(316002)(54906003)(8676002)(4326008)(8936002)(41300700001)(107886003)(26005)(40480700001)(36756003)(2616005)(1076003)(83380400001)(426003)(336012)(70586007)(478600001)(6666004)(356005)(82740400003)(86362001)(7636003)(47076005)(36860700001)(70206006)(40460700003)(110136005)(2906002)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2023 10:37:15.3597 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a20c6846-3292-4550-faab-08dbc0d80c50 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042A8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9225 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Ninad Malwade The INA3221 allows the Critical alert pin to be controlled by the summation control function. This function adds the single shunt-voltage conversions for the desired channels in order to compare the combined sum to the programmed limit. The Shunt-Voltage Sum Limit register contains the programmed value that is compared to the value in the Shunt-Voltage Sum register in order to determine if the total summed limit is exceeded. If the shunt-voltage sum limit value is exceeded, the Critical alert pin pulls low. For the summation limit to have a meaningful value, we have to use the same shunt-resistor value on all included channels. Unless equal shunt-resistor values are used for each channel, the summation control function cannot be used and it is not enabled by the driver. To address this, add support to disable the summation of specific channels via device tree property "ti,summation-disable". The channel which has this property would be excluded from the calculation of summation control function. For example, summation control function calculates Shunt-Voltage Sum as: - input_shunt_voltage_summation = input_shunt_voltage_channel1 + input_shunt_voltage_channel2 + input_shunt_voltage_channel3 If we want the summation to only use channel1 and channel3, we can add 'ti,summation-disable' property in device tree node for channel2. Then the calculation will skip channel2. - input_shunt_voltage_summation = input_shunt_voltage_channel1 + input_shunt_voltage_channel3 Note that we only want the channel to be skipped for summation control function rather than completely disabled. Therefore, even if we add the property 'ti,summation-disable', the channel is still enabled and functional. Finally, create debugfs entries that display if summation is disabled for each of the channels. Signed-off-by: Rajkumar Kasirajan Signed-off-by: Ninad Malwade Co-developed-by: Jon Hunter Signed-off-by: Jon Hunter --- drivers/hwmon/ina3221.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index 5ab944056ec0..5ffdc94db436 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c @@ -6,6 +6,7 @@ * Andrew F. Davis */ +#include #include #include #include @@ -99,11 +100,13 @@ enum ina3221_channels { * @label: label of channel input source * @shunt_resistor: shunt resistor value of channel input source * @disconnected: connection status of channel input source + * @summation_disable: channel summation status of input source */ struct ina3221_input { const char *label; int shunt_resistor; bool disconnected; + bool summation_disable; }; /** @@ -113,8 +116,10 @@ struct ina3221_input { * @fields: Register fields of the device * @inputs: Array of channel input source specific structures * @lock: mutex lock to serialize sysfs attribute accesses + * @debugfs: Pointer to debugfs entry for device * @reg_config: Register value of INA3221_CONFIG * @summation_shunt_resistor: equivalent shunt resistor value for summation + * @summation_channel_control: Value written to SCC field in INA3221_MASK_ENABLE * @single_shot: running in single-shot operating mode */ struct ina3221_data { @@ -123,8 +128,10 @@ struct ina3221_data { struct regmap_field *fields[F_MAX_FIELDS]; struct ina3221_input inputs[INA3221_NUM_CHANNELS]; struct mutex lock; + struct dentry *debugfs; u32 reg_config; int summation_shunt_resistor; + u32 summation_channel_control; bool single_shot; }; @@ -154,7 +161,8 @@ static inline int ina3221_summation_shunt_resistor(struct ina3221_data *ina) int i, shunt_resistor = 0; for (i = 0; i < INA3221_NUM_CHANNELS; i++) { - if (input[i].disconnected || !input[i].shunt_resistor) + if (input[i].disconnected || !input[i].shunt_resistor || + input[i].summation_disable) continue; if (!shunt_resistor) { /* Found the reference shunt resistor value */ @@ -786,6 +794,9 @@ static int ina3221_probe_child_from_dt(struct device *dev, /* Save the connected input label if available */ of_property_read_string(child, "label", &input->label); + /* summation channel control */ + input->summation_disable = of_property_read_bool(child, "ti,summation-disable"); + /* Overwrite default shunt resistor value optionally */ if (!of_property_read_u32(child, "shunt-resistor-micro-ohms", &val)) { if (val < 1 || val > INT_MAX) { @@ -827,6 +838,7 @@ static int ina3221_probe(struct i2c_client *client) struct device *dev = &client->dev; struct ina3221_data *ina; struct device *hwmon_dev; + char name[32]; int i, ret; ina = devm_kzalloc(dev, sizeof(*ina), GFP_KERNEL); @@ -873,6 +885,10 @@ static int ina3221_probe(struct i2c_client *client) /* Initialize summation_shunt_resistor for summation channel control */ ina->summation_shunt_resistor = ina3221_summation_shunt_resistor(ina); + for (i = 0; i < INA3221_NUM_CHANNELS; i++) { + if (!ina->inputs[i].summation_disable) + ina->summation_channel_control |= BIT(14 - i); + } ina->pm_dev = dev; mutex_init(&ina->lock); @@ -900,6 +916,15 @@ static int ina3221_probe(struct i2c_client *client) goto fail; } + scnprintf(name, sizeof(name), "%s-%s", INA3221_DRIVER_NAME, dev_name(dev)); + ina->debugfs = debugfs_create_dir(name, NULL); + + for (i = 0; i < INA3221_NUM_CHANNELS; i++) { + scnprintf(name, sizeof(name), "in%d_summation_disable", i); + debugfs_create_bool(name, 0400, ina->debugfs, + &ina->inputs[i].summation_disable); + } + return 0; fail: @@ -918,6 +943,8 @@ static void ina3221_remove(struct i2c_client *client) struct ina3221_data *ina = dev_get_drvdata(&client->dev); int i; + debugfs_remove_recursive(ina->debugfs); + pm_runtime_disable(ina->pm_dev); pm_runtime_set_suspended(ina->pm_dev); @@ -978,13 +1005,13 @@ static int ina3221_resume(struct device *dev) /* Initialize summation channel control */ if (ina->summation_shunt_resistor) { /* - * Take all three channels into summation by default + * Sum only channels that are not disabled for summation. * Shunt measurements of disconnected channels should * be 0, so it does not matter for summation. */ ret = regmap_update_bits(ina->regmap, INA3221_MASK_ENABLE, INA3221_MASK_ENABLE_SCC_MASK, - INA3221_MASK_ENABLE_SCC_MASK); + ina->summation_channel_control); if (ret) { dev_err(dev, "Unable to control summation channel\n"); return ret; From patchwork Fri Sep 29 10:36:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 13404053 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 0CFD6E7F153 for ; Fri, 29 Sep 2023 10:37:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233083AbjI2Khc (ORCPT ); Fri, 29 Sep 2023 06:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233090AbjI2KhV (ORCPT ); Fri, 29 Sep 2023 06:37:21 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2056.outbound.protection.outlook.com [40.107.243.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2C121BE; Fri, 29 Sep 2023 03:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VuKjCSJUJTsEHvvc/DUM+Mr5XaiA6sjFIO7sqmiIUttVdbUCQ1cbZtDrqb3Xl38EhLKUKmUN6ZoGb/CQ+aZhdEaUiAuf2Uc7TEUsVZIWc9lu+7tA5lDg/c+GLF6ggRSNShVu/8U16rfKZWpG2hb+9pc+R65bTJiQ1prCuRmwwwxJm5/0Hg2vlwovPbimtG3Jt8mjyIQWxJ4AtIUpXapOCmatFJbOOv/fA5aioOFCjfcmTQOkeHjhCe9mUuSQixB2LixSkYy7nJltRSqSiXuT+GTLyfD+/tindY5Ypr9NDQYjmB0h1/ejnDyxOcpNBgPaRehYfXGxB25gETAKduUXSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2XaPyv2lE5WRYoUdgD23hSpvILDhTeXIhU2mGxCNQbE=; b=JOEX7g18wEbd4sEmt+2cfU9k4rkXIjKNnG6SRF0+Z0Y425/p+0rcOgD+8hDvzwxcNT4vS02DAQDfdYe+kBC06HXHiocw7IbZ9DDUiKO41Mmi4B9Cv2mFMMsM+MgclH0qM1BCCBnI350pnHRVLhMwonWN56sz+IUAUVK8usxZXGb125Pm3HE6ic+bDm7THkL1eCHpaggqqhH/uZw1VVSbXoI50n8LN6VGysaGuJC5soHxgnr4dXBKSb6sgVo16mTyZ88ZpF8f3hFi0sSRN9ifpHwi35v5+rpG+fYRNRYIyR12xl/zzrUWA1B9eW/aWZrlH9knwi6rfsCpV6iM6Oy7xQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=suse.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2XaPyv2lE5WRYoUdgD23hSpvILDhTeXIhU2mGxCNQbE=; b=Y9M8LHWQlkyLfzgPiYZLbFkZDcwyuflOjbOEw1pj6VgadckV4C4ed6gHtxX4UjJNpIsRb11oj2uMyYZ00T5RLPENCQUzPiaT3nbEGRI73UdXDYVcpaSTpMNkyjeF8VwzdHRzRe5BxqvkcAyzGcjy9tG+SCZmaNxXqMto0yxa/bUAobAAwRIyECG2Zk8aI/0nG6CoSr4xregfhuWfQN1zU7u+DeSqj5klSxZ9f/fZU1V9JD2EHqpQaIzpIRaRk1jSZQCk2BV8ODBCzMvlItHIRDgawuZ0so/pn4PCOO46XdFWZIPpSCArBZQWunkdQDh30Juu7uoBY2PzyTaWjp4O/g== Received: from CH0PR13CA0060.namprd13.prod.outlook.com (2603:10b6:610:b2::35) by CY5PR12MB6549.namprd12.prod.outlook.com (2603:10b6:930:43::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Fri, 29 Sep 2023 10:37:16 +0000 Received: from CY4PEPF0000E9D5.namprd05.prod.outlook.com (2603:10b6:610:b2:cafe::8f) by CH0PR13CA0060.outlook.office365.com (2603:10b6:610:b2::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.14 via Frontend Transport; Fri, 29 Sep 2023 10:37:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000E9D5.mail.protection.outlook.com (10.167.241.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Fri, 29 Sep 2023 10:37:16 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 29 Sep 2023 03:37:06 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 29 Sep 2023 03:37:06 -0700 Received: from moonraker.home (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Fri, 29 Sep 2023 03:37:04 -0700 From: Jon Hunter To: Jean Delvare , Guenter Roeck , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley , Thierry Reding CC: , , , Jon Hunter Subject: [PATCH V5 4/4] arm64: tegra: Add power-sensors for Tegra234 boards Date: Fri, 29 Sep 2023 11:36:50 +0100 Message-ID: <20230929103650.86074-5-jonathanh@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929103650.86074-1-jonathanh@nvidia.com> References: <20230929103650.86074-1-jonathanh@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D5:EE_|CY5PR12MB6549:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d905c2e-7a79-4ae2-8d10-08dbc0d80ce6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hr5WUhgZCW/rOeZDO3/URzYItRjl62Q8U61Z5hRuI1IT0FiIuWMAjmEMGCo6uWbxGAXr1Oq9i1fGkAFPuDRF/euwZ2+joELUZOZcNWC2pzmsAdUo+oVn+s0gYsuvaB7IOjTEMBwQ7fiCAJA3dnZTCifTGfGqjztXP1XHLsEutamoYKmnSOL0OiQYjeCi/w4ZoINvokeziFjxt7vG2MnWh48zxk4oFM6hyIeAhDq5b61DGt5Ro/vclDgrenBvaGxNbNhUS+veLhIKCHAULxJaWV8hDBEsfLA2FwP82YqAw2pqhDVZedbxr+UfvSQpcPMlaCbB2XTH2zZTUANqHRaMhtTe63LTJSRjjQLs3oEA+rATiDZGWo+eDE1AZJrnioJvNytLxxYA4RaXoGhI8pXk+QTnQQUo0/YYF36TCzqOeBIZPsWFHoHEajvJAjOR8JdZM00rIxG+w5+bxkPlEinrgSlwZKFxhoA6X3wY5PHsjW/loQ613NAB7BRzf402idT7NYXfs1RQQT5Dx1Z8G0LsAEgnO0V7CXAk+0S+33AR63Z93YZmd6IQwCkVV1MQf+Pnh+gnF0PGvLN9V9XrGWBJr9+iSPRv+QcmyG8R6ESo8naU10iGzPbuuVzaK+NoxsvGL8x4c8yhXr/mggfd6SmlPPI4kB0mVScaGC6CqXPpic4sNRMWPKmZ0nLt35ITHcVbN1TjUCGGEN8oEFhj7g8/gYmZtkBnKEfAccg859HNH6A= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(396003)(39860400002)(346002)(230922051799003)(186009)(64100799003)(451199024)(82310400011)(1800799009)(36840700001)(46966006)(40470700004)(2906002)(5660300002)(40480700001)(70586007)(41300700001)(26005)(54906003)(110136005)(478600001)(316002)(70206006)(4326008)(1076003)(8676002)(8936002)(2616005)(6666004)(336012)(40460700003)(426003)(7636003)(47076005)(36860700001)(107886003)(36756003)(86362001)(356005)(82740400003)(83380400001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2023 10:37:16.3868 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d905c2e-7a79-4ae2-8d10-08dbc0d80ce6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6549 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Populate the ina219 and ina3221 power-sensors for the various Tegra234 boards. These sensors are located on the Tegra234 module boards and the configuration of some sensors is common across the different Tegra234 modules. Therefore, add any common sensor configurations to appropriate device tree source file so it can be re-used across modules. Signed-off-by: Jon Hunter --- .../boot/dts/nvidia/tegra234-p3701-0008.dtsi | 33 ++++++++++++ .../arm64/boot/dts/nvidia/tegra234-p3701.dtsi | 53 +++++++++++++++++++ .../arm64/boot/dts/nvidia/tegra234-p3767.dtsi | 29 ++++++++++ 3 files changed, 115 insertions(+) diff --git a/arch/arm64/boot/dts/nvidia/tegra234-p3701-0008.dtsi b/arch/arm64/boot/dts/nvidia/tegra234-p3701-0008.dtsi index 62c4fdad0b60..553fa4ba1cd4 100644 --- a/arch/arm64/boot/dts/nvidia/tegra234-p3701-0008.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra234-p3701-0008.dtsi @@ -44,6 +44,39 @@ i2c@c240000 { status = "okay"; }; + i2c@c250000 { + power-sensor@41 { + compatible = "ti,ina3221"; + reg = <0x41>; + #address-cells = <1>; + #size-cells = <0>; + + input@0 { + reg = <0x0>; + label = "CVB_ATX_12V"; + shunt-resistor-micro-ohms = <2000>; + }; + + input@1 { + reg = <0x1>; + label = "CVB_ATX_3V3"; + shunt-resistor-micro-ohms = <2000>; + }; + + input@2 { + reg = <0x2>; + label = "CVB_ATX_5V"; + shunt-resistor-micro-ohms = <2000>; + }; + }; + + power-sensor@44 { + compatible = "ti,ina219"; + reg = <0x44>; + shunt-resistor = <2000>; + }; + }; + rtc@c2a0000 { status = "okay"; }; diff --git a/arch/arm64/boot/dts/nvidia/tegra234-p3701.dtsi b/arch/arm64/boot/dts/nvidia/tegra234-p3701.dtsi index 5e7797df50c2..db6ef711674a 100644 --- a/arch/arm64/boot/dts/nvidia/tegra234-p3701.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra234-p3701.dtsi @@ -1987,5 +1987,58 @@ interrupt-controller@2a40000 { status = "okay"; }; }; + + i2c@c240000 { + status = "okay"; + + power-sensor@40 { + compatible = "ti,ina3221"; + reg = <0x40>; + #address-cells = <1>; + #size-cells = <0>; + + input@0 { + reg = <0x0>; + label = "VDD_GPU_SOC"; + shunt-resistor-micro-ohms = <2000>; + }; + + input@1 { + reg = <0x1>; + label = "VDD_CPU_CV"; + shunt-resistor-micro-ohms = <2000>; + }; + + input@2 { + reg = <0x2>; + label = "VIN_SYS_5V0"; + shunt-resistor-micro-ohms = <2000>; + ti,summation-disable; + }; + }; + + power-sensor@41 { + compatible = "ti,ina3221"; + reg = <0x41>; + #address-cells = <1>; + #size-cells = <0>; + + input@0 { + reg = <0x0>; + status = "disabled"; + }; + + input@1 { + reg = <0x1>; + label = "VDDQ_VDD2_1V8AO"; + shunt-resistor-micro-ohms = <2000>; + }; + + input@2 { + reg = <0x2>; + status = "disabled"; + }; + }; + }; }; }; diff --git a/arch/arm64/boot/dts/nvidia/tegra234-p3767.dtsi b/arch/arm64/boot/dts/nvidia/tegra234-p3767.dtsi index fe08e131b7b9..59c14ded5e9f 100644 --- a/arch/arm64/boot/dts/nvidia/tegra234-p3767.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra234-p3767.dtsi @@ -55,6 +55,35 @@ padctl@3520000 { avdd-usb-supply = <&vdd_3v3_ao>; }; + i2c@c240000 { + status = "okay"; + + power-sensor@40 { + compatible = "ti,ina3221"; + reg = <0x40>; + #address-cells = <1>; + #size-cells = <0>; + + input@0 { + reg = <0x0>; + label = "VDD_IN"; + shunt-resistor-micro-ohms = <5000>; + }; + + input@1 { + reg = <0x1>; + label = "VDD_CPU_GPU_CV"; + shunt-resistor-micro-ohms = <5000>; + }; + + input@2 { + reg = <0x2>; + label = "VDD_SOC"; + shunt-resistor-micro-ohms = <5000>; + }; + }; + }; + rtc@c2a0000 { status = "okay"; };