From patchwork Thu Sep 21 13:08:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 13394054 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 35C71E7109A for ; Thu, 21 Sep 2023 17:01:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbjIURCC (ORCPT ); Thu, 21 Sep 2023 13:02:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbjIURB6 (ORCPT ); Thu, 21 Sep 2023 13:01:58 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2089.outbound.protection.outlook.com [40.107.223.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAF9F170E; Thu, 21 Sep 2023 10:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aTfGRLD4LVW9e1aKdw52gSS3GpD3u81HOKpqAz7PcseDVY9zEbILFKTZZ1mXP1V4MjonX5cEO6KrZ/GGvhLrdaJ3tMEi3JOmX6pv+j/K/fcLiSjwLjakGNRsN8RqxDYskFzEBMrwA5e0+OIMIe9ucWEsVQiCgW9E22fPpSYg/7yCBLd9UYBk6ZWEiqX+aSe0tj5HTr2ns+7oI9sabhrPi9H+js8LfLRsFPHGsvD0zcup3My+huL0EIK3WSDoQlXNB5tvCYeIVo5af0XBW/XOh3g6Z7Be2zZHqJ6pW/IkczoMl53RzTvWzNV4jApyOGyKRHxNy2pAB1+8/QkWjw1/+g== 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=elHLBbtv1zcjEj9anL0X35M1mh+/aEBf2anjlL6RkzI=; b=BXMRkTnifKVeBLQ7w8kMHk8bpbajtHqQqrTTLocIM/Dx9stsIVd0Gr4VP/Yf3x4gJXmfsi2O62JNtV9qD2bMPUOufZr3ZbJ+76RWVIGOGVqH+4tbKPh90sk2JCGpvQlPvh92dcKYuZOFnyO1QvcFilt17TN1tq3rVKWnz+nwyLA9gl6WgX14kl2ptWc1rdrhhIs+PdaRTtYystAeGJUiZwCpLiZDbWY5xYIAjzcjuviNeGysaqvX+GZUJxD4j0p2DikXiO82Q5IlCNqbV/cu2uZqKntaD2amX7NId0Q3yQB5GdXfndqt7BHxmFpxyEevxtmO2jknqWEBGxFcld8ZbA== 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=elHLBbtv1zcjEj9anL0X35M1mh+/aEBf2anjlL6RkzI=; b=cXG9g91mDLr1V152gA/Ed79RoxcLsZ5fUUoDupIIomkzd43VTR2uwLnHGEcO4cStyQU669o/K9HapvWSVokXm5efSyVcVjPYWNw83z1HU3VDRnCtJzenvZMiauQandGio0h8bfXdKCGP5U2q4T4q8V+uZMR/E3umh8pqEY1iMWY4ZozkT20SfgxbbBE2Q7gsB1gT268Pg7JxgQFJUcTrSz/ZcmWdo4o2pKLsYN7Mzr4UkgscXuZMLK8ajX0paGJFY49nbJVISc6qaJ8Uu7jMHhMsuoXV7mDRxhcUqGcmrKgVfu7DN37GYsvmDJtxlf3RVRHHSu8GgLggmj2tV63Y3g== Received: from PR3P251CA0016.EURP251.PROD.OUTLOOK.COM (2603:10a6:102:b5::8) by DM6PR12MB4433.namprd12.prod.outlook.com (2603:10b6:5:2a1::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Thu, 21 Sep 2023 13:12:10 +0000 Received: from SN1PEPF000252A4.namprd05.prod.outlook.com (2603:10a6:102:b5:cafe::25) by PR3P251CA0016.outlook.office365.com (2603:10a6:102:b5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.29 via Frontend Transport; Thu, 21 Sep 2023 13:12: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 SN1PEPF000252A4.mail.protection.outlook.com (10.167.242.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Thu, 21 Sep 2023 13:12:08 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Thu, 21 Sep 2023 06:11:35 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 21 Sep 2023 06:11:35 -0700 Received: from moonraker.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 21 Sep 2023 06:11:33 -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 V3 1/4] dt-bindings: hwmon: ina3221: Convert to json-schema Date: Thu, 21 Sep 2023 14:08:15 +0100 Message-ID: <20230921130818.21247-2-jonathanh@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230921130818.21247-1-jonathanh@nvidia.com> References: <20230921130818.21247-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: SN1PEPF000252A4:EE_|DM6PR12MB4433:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d43cc93-c9f3-4185-755e-08dbbaa45c32 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Dfi+OEHSU4YQQXA90xoRyR0eiHegVaLkjtKiaGeMqhx8cXThc25+Q0MyFqPneXjLVKwVpxcV37RVUjZpqx9X6nk37Sig0sJzreIxLINVZJwU+5IewZNxCyAOUi0xSdMkLqNv1xfc6d+/BcfwardOfPzYXyKuPFaATsegH2NfibRTi/6yvSZwcnLU7mNn7aRez3T1B2ldfIaW3cNNWvf/fGIAZUr8qt0c3m5bs/DC10u5wJk2CU0LhxcrSEEFg0rG/MR+wMhjkOJtRrrQ40GXJQZyVZO+83tBJ0Zp68WBIEcZ28+4nCFXxSydXKAVC8vx48zrp53uuekjZ7KJ6G5vsk31jcpd1FhwG0rxPx8Og1AAUNS5tJ21ExESWV9CkUhHxTdzYmh7oSFtcf2cWXkOp+zrSwpoJ/N6q8ED1326+Yn7cCTISsR1Dd9wWuYV3ih+Iic2o6Xd0npd74ixW8s5mYh24NuWnlnQamCohT3kyX6+h6GyMusglB40NagoLwwi2pR7i3bOF6FBxB5VullrhBfyq9xd6bfJiVXVC/kb7xXKhxtCL75AMmlckZgISY1J/6rcbbpe5H/YC5xu01+QAQ1dZubkKPOe2p/g2gGZZPErgwWLVAVkx8dUU/HCGoNtQPUIZHTFLnYzwUbfdLQmrtxpc2Ai8/mHJgpmwvnr7o9hCA4KTI9FqpQUTohsX8U7gn1yh1UwITPCd8RpQHNI1JX7uqNra2xdlMPPHrzhIKkcbrfqKS7Ibr8Clcw3LG9BuEz9Ly573oKhurIuGCqlhg== 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)(39860400002)(376002)(396003)(346002)(451199024)(1800799009)(82310400011)(186009)(40470700004)(46966006)(36840700001)(83380400001)(7696005)(82740400003)(5660300002)(4326008)(2906002)(36756003)(41300700001)(8936002)(8676002)(54906003)(316002)(6666004)(336012)(478600001)(966005)(47076005)(426003)(36860700001)(70206006)(2616005)(7636003)(356005)(70586007)(40480700001)(110136005)(86362001)(26005)(107886003)(40460700003)(1076003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2023 13:12:08.5864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d43cc93-c9f3-4185-755e-08dbbaa45c32 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: SN1PEPF000252A4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4433 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 --- .../devicetree/bindings/hwmon/ina3221.txt | 54 ---------- .../devicetree/bindings/hwmon/ti,ina3221.yaml | 98 +++++++++++++++++++ 2 files changed, 98 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..d0e64a72af5b --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/ti,ina3221.yaml @@ -0,0 +1,98 @@ +# 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>; + 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 Thu Sep 21 13:08:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 13394053 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 D1C8BE71096 for ; Thu, 21 Sep 2023 17:01:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbjIURBK (ORCPT ); Thu, 21 Sep 2023 13:01:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229817AbjIURAv (ORCPT ); Thu, 21 Sep 2023 13:00:51 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2082.outbound.protection.outlook.com [40.107.94.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6A3B137; Thu, 21 Sep 2023 09:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eRzsp5G34i0fevyqdEFjimNydJJVos/GQga87DPjMFRb+rwfJHoBWelQd51ZCP7RZq4pJDagusdfCHm0ids1EAY1iOcKaII6FzkJEYj3vv25otubXNt1bTchrHZzMbBsb8WWO92CR/r05aXEn4pwNFi/wUXTJ8h0GQu042VZkmmi6uX7U//eDWNqs/0vh8cXD/XLsau/O66WmPixnrjLozr50ujyFKsM048msrZCPmFc+QxREOta9QZFPXRxvsTWRjamAZkyhR/y9OmwO/ir3Izz30zd38nzW20vHXCDMhptMc+8a4FhtzTV8lkr2IU/mN3cmjT7RyIYsVbPkNUU+w== 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=qR4d4vbEHOKN9d8aHifXMTDoVTXtTq3Ui6AtIADyNL0=; b=eBs7uuJhgODfKvDlXJ3S9ZJuVdznyB+a1GzACa2MgH+o+9fEqR/GkdMwae8zCq/XzK/FT/C9bRiHXcKoFwODKZMqzs3VMZTqnTmpwU+JQJ1FEQ7BJr/aTD1KKqoRZw90zlUUb0FhuX605WJxBPPxH/PXssO8JDI68puuYsuSblFLJag/H6rfvcneB5Z1dzp9fnudKqLSpVlOsADOITLpc7EXdqGcvQN5gism3DtlPCT4RVfSJtBgiqFZAicLk9mbqkIBrI4J9ZlScoXeBYg4KawvgJ3jQU6YXT2g+lsn/DSCxMLiOVVFDxjdwGqLB/odLEKoBS+UINfsIve43Xq0YA== 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=qR4d4vbEHOKN9d8aHifXMTDoVTXtTq3Ui6AtIADyNL0=; b=OMTCeeLUQpTr+52+HaDTUjetdX4+cdUnP+UeBIhi0t+hEILBYSqBDVyoVHeu207umFXKRAGmn9CQ+U4u/RJS2w3r0Ar+Mban77YC8x27iYOec/kAXhwGCI3Q7qxvVo+Q/X/bgai3rpJl0Ytj/0kfTM8z98Pci9QyitfQLLRG1wFdQ4MsCua9PfjTrTPgtzFFfzY7RamyeZgonmjfiJ34yKws/zksWD1foEfbZEjhrLS4PqSYwtzB+EvErD5lS8jbPX3StdHCJb6rOvQAc7xTf3gQK28UkTyEX6L81gzFsXESTOxf1o8Q5Cw2JNuzxbZLgaNxT26JqmNcAOExIrbwUQ== Received: from DM5PR07CA0092.namprd07.prod.outlook.com (2603:10b6:4:ae::21) by SJ0PR12MB6734.namprd12.prod.outlook.com (2603:10b6:a03:478::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Thu, 21 Sep 2023 13:11:51 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:4:ae:cafe::b3) by DM5PR07CA0092.outlook.office365.com (2603:10b6:4:ae::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.31 via Frontend Transport; Thu, 21 Sep 2023 13:11:51 +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 DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Thu, 21 Sep 2023 13:11:51 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Thu, 21 Sep 2023 06:11:38 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 21 Sep 2023 06:11:37 -0700 Received: from moonraker.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 21 Sep 2023 06:11:36 -0700 From: Jon Hunter To: Jean Delvare , Guenter Roeck , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley , Thierry Reding CC: , , , Jon Hunter , "Ninad Malwade" Subject: [PATCH V3 2/4] dt-bindings: hwmon: ina3221: Add ti,summation-disable Date: Thu, 21 Sep 2023 14:08:16 +0100 Message-ID: <20230921130818.21247-3-jonathanh@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230921130818.21247-1-jonathanh@nvidia.com> References: <20230921130818.21247-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: DS2PEPF0000343A:EE_|SJ0PR12MB6734:EE_ X-MS-Office365-Filtering-Correlation-Id: 18a8852f-8c81-4d6b-f7f9-08dbbaa451ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0P3ZEGPg4meDDGr4nH4+93l0zSpICzV10NMBH+aai8ihbHpWzdRJVoJ0soDmU3o2cqqrGBg0rHai3V51gv/jJkQQ6WJ1GvUz8BaUS6LoZSzFp0JNxUNnOrQfthIkAyrub02JJwXIsAHTYTrBWbT+AEJPe5DcZsNlhLnHCRl6l0/y5EW/RdcJc1nmc31Al9TXR7bprJe3vUPugiQx7Zy/+MOhla/VAr8jDyxedrDTcmLyQd3WoJQYoLagEkOgKKn9HVZ0u+Wi4QOCx3dloSJffrgS7ozam9hFAdxhaqJIhq4ewq++EIf4eXFAi0QadINt3Yxdq649z/oiZDGJA64Z6eqmJPr0uoEdx7MJTurkR4R0Vf3WU0PHoSVp/LlpBp6q1XkAbAOi83yeYFWfkojZ+B2dhgT/kJF/wlMaGmwo8YYW2eWYlusCjfhpUpBEkZStytqX+EZL1ZUYfSlySTLn+bMTRctr/4OAReFYH8QJ7tPAyswmz5ajghdbpiUboV59rh9KxCjPhyG82fsofwTHEa0RqbIEU9ww6gk7xYvAN4YcJOBxUrp0M4OmxV120ftD0tSSN0IvobKF/0VwEucJiji0AzDRTPMUt/IqO7Imy6AqRa/Ch6JLXxx9USRoXNSq701b2ym0G2CVBh58ZOoRy5iSM9SHMYE36gb8aR0FRJaMNrThAsbMlHYLjVwPfnDKzZSjrdqfbY4F70UG0Qtx1+8V7Xgfe7LE3IsuBX1MQSswyDMosvulNz8+BKJHfNOc 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)(136003)(346002)(396003)(376002)(1800799009)(82310400011)(186009)(451199024)(40470700004)(36840700001)(46966006)(1076003)(47076005)(336012)(40460700003)(40480700001)(316002)(86362001)(7636003)(356005)(82740400003)(2616005)(8676002)(4326008)(70586007)(70206006)(54906003)(8936002)(41300700001)(107886003)(110136005)(2906002)(83380400001)(5660300002)(26005)(426003)(7696005)(36860700001)(6666004)(36756003)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2023 13:11:51.3578 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18a8852f-8c81-4d6b-f7f9-08dbbaa451ef 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: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6734 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. Signed-off-by: Jon Hunter Signed-off-by: Ninad Malwade --- .../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 d0e64a72af5b..8afbe729076f 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 Thu Sep 21 13:08:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 13394055 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 BC918E7109A for ; Thu, 21 Sep 2023 17:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbjIURCQ (ORCPT ); Thu, 21 Sep 2023 13:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbjIURCE (ORCPT ); Thu, 21 Sep 2023 13:02:04 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5EED19BE; Thu, 21 Sep 2023 09:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UZAYgm82ntBfO+UUHZtnsZxysUtEZZmRWjx8Aqx0aZO84j/vNre7luLw/gexksNf4JCBvYMMrryfrIZMTEw1ZoDdZeZvZJZ5xEtkz5thUn3zdF9Ved98EzPptY7e42aCbSXXY6foQwWzBOyv/C/mSHPTGpZFKtyFxyHkN47XlaneopXWgY2KaRHccgrgYhoz6Ec6pltWt5/BeJJ4UbaBdymWfDyoQGjbUI2wtOwr77mZM9rSrQ+FrH9yyZdfpxAyfoN8BSQIZpRF333XEoveq6EWEpj/g3lI8JI6jRIqenZtJm8LiKJhpq3OFepKVBZOm+ahXeo4HSylpAnOqyCsBQ== 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=4UkB9s5xBccRKqPVNLpA4gXzkA9jD0OZbiBOWe052aI=; b=CY55o5U9SGiMea63HfADC/V2w1Xc0WiefU+7HSRkOPtoKPr9Kby0x7H2fuWUqYH/Uu/kO5k+im2/VQE6Bmu/peo0wsQhbjl6pn6TeJO9KHHU+UPhb1xAVtN/eyOfneNEZ8X5ASWajep7pRdVjZNiM+7yWnZc5hGeoNSAaw8DBVZVZY9QRxLJTilgAJuu/EsmFLXUoazDzLzJ261EwNibRqpF9sF4sV1qSL1OkAUiz31hVxUHZ8l775mGhB2DVfStxexo8ukJk/EMpr9F8vryo7HFwj+3Duh2oOv5usuP/bVY/aOi8X0duY3UkC5TWG+yoa/nA1WhJ8so4PlVvS1brA== 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=4UkB9s5xBccRKqPVNLpA4gXzkA9jD0OZbiBOWe052aI=; b=e2vq3VYUhBSmqR8y9WrNnV8Ex0pxVBMWyq2FD5HdW1xDHPAnS70sTkfNT8trkdfHMLQ11EGG599ju1vCkaewl1eoXfPGzy8crkugE5FrW0ujA/8tUY5MsLg4rbA4H84h4hN9wrTSJGjr0zGGJiHYCsYz6KezugvyvGFOK0OsobFyvLwrOXebwj5JX0H8z/jrqGkuI+6WiXWSEO+zcgvs3hacE4tc4lyyPaDj2jdMwSCqwnv3+xVdU9B34v0qhhVPF81In3DFG0uOh3MLiucRxYoC+hgG+pF2GADtxnU00EM4sy0pPGAMTzWPB5NAiI5pKeP/9Vsb5D3i6XpJpdFI+Q== Received: from BY5PR04CA0022.namprd04.prod.outlook.com (2603:10b6:a03:1d0::32) by IA1PR12MB8538.namprd12.prod.outlook.com (2603:10b6:208:455::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Thu, 21 Sep 2023 13:11:56 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:a03:1d0:cafe::86) by BY5PR04CA0022.outlook.office365.com (2603:10b6:a03:1d0::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.31 via Frontend Transport; Thu, 21 Sep 2023 13:11:55 +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 DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Thu, 21 Sep 2023 13:11:54 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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; Thu, 21 Sep 2023 06:11:41 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 21 Sep 2023 06:11:40 -0700 Received: from moonraker.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 21 Sep 2023 06:11:38 -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 V3 3/4] hwmon: ina3221: Add support for channel summation disable Date: Thu, 21 Sep 2023 14:08:17 +0100 Message-ID: <20230921130818.21247-4-jonathanh@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230921130818.21247-1-jonathanh@nvidia.com> References: <20230921130818.21247-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: DS2PEPF0000343E:EE_|IA1PR12MB8538:EE_ X-MS-Office365-Filtering-Correlation-Id: 9fb73dff-8491-4347-391c-08dbbaa453fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JeMoSaBE7k4MnBjgx1X6QmBOihfrvIeEoZvObuOsUyzEk7CMVVAWR0rl0eRCGaSQM85irE9YZP6K9LKSfXRh6U0grlss1x0K4nCiNMj8UUc9GE2yfUmU18rhybVycU8ndCC2nQvmrccArxYNwVoFYIOTWCnyYNBwDjlQ1jzWqVHczHSEl59DXsev9DqJ174v1+z6PuuRzxv3mt73SrM6WslrC8RlnSaPxvbW2MEvvdBPLpAQqiJ08f4EHerTnfbUOTvhcZQRlMSQCrmA9DbZotPrzqz+EixKH4fScggrxGqa/xfs9kwilpn4Hl4Ym1W53Lmyf9UFJs3GNSx7+lFa3mPneQXEIaBWf+OWDNne5Ix9eLohD3Bx9+o7PUBLNDHjCe5xXw2JZn1YbVdp5jperL28viBfdEKHJ9S7xyoitGrcMFo5KPVYfy3/KGXItlsw1Y+DZeTh74PFNpYK5YsbQnamue6PQlVh+mGpkt5ba1xlgd2OYnE32zYU8ppHYlAFzTgKsPTU6URMeD+dhSBn1oKDzCbyb7pmn6box69Y9Q1wg5jYGJ0FOPWkSZNCVmS2zh4N/C/jJaoX+sLdYCh0OVOJeVI83Xwu/bruY+E+XInpD/xWANfZOXw+x3nOtZKFaUfD+icZOQ/mKLa5G7v/U1tlbP984N5BPPhUYGYBuB8ko81DWTv2Dl+KWARef+oDPLUKNreqJfTP4w3+ShYRTAlNW2lNscNZBYC3NOTnm0u4nWZ+4CkuL2reZsrpO/vN 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)(396003)(376002)(39860400002)(136003)(346002)(82310400011)(1800799009)(186009)(451199024)(46966006)(40470700004)(36840700001)(7696005)(478600001)(6666004)(8936002)(8676002)(83380400001)(70206006)(70586007)(54906003)(110136005)(316002)(40460700003)(5660300002)(107886003)(2616005)(36860700001)(36756003)(4326008)(86362001)(82740400003)(40480700001)(26005)(47076005)(336012)(2906002)(426003)(1076003)(41300700001)(356005)(7636003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2023 13:11:54.8223 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9fb73dff-8491-4347-391c-08dbbaa453fe 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: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8538 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 | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index 5ab944056ec0..359b758e9f03 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c @@ -6,6 +6,7 @@ * Andrew F. Davis */ +#include #include #include #include @@ -104,6 +105,7 @@ struct ina3221_input { const char *label; int shunt_resistor; bool disconnected; + bool summation_disable; }; /** @@ -123,8 +125,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 +158,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 +791,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 +835,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 +882,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 +913,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 +940,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 +1002,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 Thu Sep 21 13:08:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 13394818 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 05C2FE7D0B2 for ; Thu, 21 Sep 2023 22:27:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231847AbjIUW1P (ORCPT ); Thu, 21 Sep 2023 18:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233030AbjIUW1B (ORCPT ); Thu, 21 Sep 2023 18:27:01 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2084.outbound.protection.outlook.com [40.107.93.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D249E1BEC; Thu, 21 Sep 2023 10:01:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lgj/yq2BkTv8b8fzCRtk2yY7ijbLoRndSaGEpymxecUOA1+M6Mq55NdpczIT3g7ysFJzNyaAptWpeDxbKr9HCD5Ubr0tdDZ3/Y/duU8xLn/jMWsWqEpK12D0H2u3eyjEKGtsnkmALd2lolPRxw1Rmt4AzIJqmg8t/xqZRuEixyo4hPW1i9C9HDN0fDNen754QErCBtppCzncM6d4fndl3PQMqYDK8v+hCMqif6OOlFcsxhpwcPPPQruasvGDeX2pQHK9MmQ4cTASljK10hL58KisnH5wQaG0+UuEW3X5wUCr1+f4MK2JnNZtMauN+Rwwq7Ealy+cxiSAZQIIbHzV2g== 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=iXSvBADS4EnH4Ujj/OSerpOCufuhtC19CvGfbMINvg9kpj8xbWdXPG90tRy2I5iaQOing3cpbLOEQgGDdPPYJHFkjRFpAhnZPH0dwh0H4NZ0D83RG+B7fRxSNjH3XmNX3RpMWydQg3lQNWH5PRn2yVHqvq4HWVmV0Q7n3Lah7HmRDiWaIDs9MlJWlv61UOfRNp68OFwHL4CHdXPOf//D3wLg6j9JRY2rO5d57u8kuPP7/5LrVfg9Yj2O52AF05x/6FmUME9DU8wLja6Nn2s/ZyIcsYXURnoX78ACXfUiVq7LtHzrItQPIbSR9cT1ZeMhOwADOoZdlP6/LRRBXKp/BA== 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=2XaPyv2lE5WRYoUdgD23hSpvILDhTeXIhU2mGxCNQbE=; b=e/EIzvq3rZNZAjg0ZcdovOquM1SSoXG/Q/oC2FlQVptd5wgZI3TTmHO6+6o76ouPqgDCgR/cgV+FFo/NA5JJzqOV+yLSkeVgKMGXmRpcYipCa8dtqCwVsFI509LxzBqXrFCEOTtjLGJmLgmd9TBikPDd2nOQsbhfoMM5Lq4FBH4GiqdKBT7IkM9aejnL914heodR3uSNqWHUfq6eOMn9d/KNvthhYaglAba69ElmaG3w9vbDUsiyfhtbgotPWlRtp+DgDe0RqWKPPYgif9lWpWSQ7dVciEuaba166ujdiKvF3EUh2fnk13royb2pGX8EI4kxR6OiXAp/iRvJzXgW0Q== Received: from CH5P221CA0016.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::12) by MW4PR12MB7285.namprd12.prod.outlook.com (2603:10b6:303:22e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.24; Thu, 21 Sep 2023 13:12:02 +0000 Received: from DS2PEPF0000343F.namprd02.prod.outlook.com (2603:10b6:610:1f2:cafe::6f) by CH5P221CA0016.outlook.office365.com (2603:10b6:610:1f2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.31 via Frontend Transport; Thu, 21 Sep 2023 13:12:02 +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 DS2PEPF0000343F.mail.protection.outlook.com (10.167.18.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Thu, 21 Sep 2023 13:12:02 +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; Thu, 21 Sep 2023 06:11:43 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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; Thu, 21 Sep 2023 06:11:42 -0700 Received: from moonraker.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 21 Sep 2023 06:11:41 -0700 From: Jon Hunter To: Jean Delvare , Guenter Roeck , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley , Thierry Reding CC: , , , Jon Hunter Subject: [PATCH V3 4/4] arm64: tegra: Add power-sensors for Tegra234 boards Date: Thu, 21 Sep 2023 14:08:18 +0100 Message-ID: <20230921130818.21247-5-jonathanh@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230921130818.21247-1-jonathanh@nvidia.com> References: <20230921130818.21247-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: DS2PEPF0000343F:EE_|MW4PR12MB7285:EE_ X-MS-Office365-Filtering-Correlation-Id: d008099b-94d9-4653-3597-08dbbaa45887 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DZ+Aib8XkJ3dOzlMtuWqXVKlcRn942bY2dpd+gOY6bmxY9xTKfWegt3+FKGBQvtp+bxjC7VQFDaFq+5OmHzzT1G8sUM8EZJo6qgxwQJiUbRUcYfHOFKDmAaBBfYlgLiT//WKSsoLvz8qorTQo2Iq8kq5TTpTG6QErVvyp9RlhMjS3kXmWexs9VGcdjWy9FrNvJZ6IV3W/Ao+Qz8XwsOun/u/jCSHZ4uOGkp5x9EKG5EEOE/iP1RSzAVyuW80tlmnVPh2nwUCQvgAfDXLDQwoa1Nfw6UcWjpOIcl6Z5bl/+4rM5SVCHlc82pQN1kbWwqxebiLBfBzTr+P5jvvPzy9NUwQn8u2bT0d+l5dPSAQ/cEMSJ8Abo3wdTUVzQtOMHEqccqqhfBMpPXiOeHWgBlBUQESDf3HisgrojMtwFlkGOhbv3uhpLp64taBtjEauVtlJiKZai8q4AKe+KQ3wRNoMCLSgnYlbJx+nsSoTNgJYqyO7rUwUQ/UxhRl2N9g1iS2czX3daMPMvuQSPBSdCZo+ij6N7gpKDv3iu3+dSQ5cKi8MCZUd3jBlhaCIW4z5XEMkJXr+8vcTVu0YCJ9HAwMGKG2wa3M8YMZtskN4+qRU3nmS/+xaj+lhvCGVi7Mi+1zAbkvUPCFu3zQAp6q6o2GEZvvHYfye1kmTjAc25e2eqwbm4oBPZpW/klonp2w5+ZbCipRmbk66he0aT/y3bamvTCyk8H13WBdROhZi/xjOiU= 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)(396003)(39860400002)(136003)(376002)(186009)(82310400011)(451199024)(1800799009)(36840700001)(46966006)(40470700004)(83380400001)(26005)(70586007)(316002)(70206006)(107886003)(110136005)(2616005)(426003)(336012)(6666004)(36756003)(7696005)(47076005)(1076003)(82740400003)(36860700001)(86362001)(40480700001)(356005)(7636003)(40460700003)(54906003)(478600001)(2906002)(5660300002)(41300700001)(8936002)(8676002)(4326008);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2023 13:12:02.4152 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d008099b-94d9-4653-3597-08dbbaa45887 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: DS2PEPF0000343F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7285 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"; };