From patchwork Mon Oct 16 10:14:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kartik X-Patchwork-Id: 13422917 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EB3FCDB483 for ; Mon, 16 Oct 2023 10:15:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6E318D0058; Mon, 16 Oct 2023 06:15:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF9628D0001; Mon, 16 Oct 2023 06:15:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C72038D0058; Mon, 16 Oct 2023 06:15:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id ACE8C8D0001 for ; Mon, 16 Oct 2023 06:15:30 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7C7A2160BA4 for ; Mon, 16 Oct 2023 10:15:30 +0000 (UTC) X-FDA: 81350917620.07.15A9C73 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2069.outbound.protection.outlook.com [40.107.223.69]) by imf11.hostedemail.com (Postfix) with ESMTP id 9DA9940012 for ; Mon, 16 Oct 2023 10:15:27 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=SoJ7vhug; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf11.hostedemail.com: domain of kkartik@nvidia.com designates 40.107.223.69 as permitted sender) smtp.mailfrom=kkartik@nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1697451327; a=rsa-sha256; cv=pass; b=BKl8gWr7OdiIQKuTxXzztmaDrB/qCHq5t6XWKN9NOj5foRNaN4ikIumCCdJ6pOZHGGcdaV G9+08O/rldJeWh/u1lh0uoUxAthOIOsBG8MbCkuQmwwPYWJ67z+sSFbQu/G6qfV1XrjoHn g4LkmIWEW6AJvTx7G9I1JIumBgcCv1A= ARC-Authentication-Results: i=2; imf11.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=SoJ7vhug; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf11.hostedemail.com: domain of kkartik@nvidia.com designates 40.107.223.69 as permitted sender) smtp.mailfrom=kkartik@nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697451327; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Huwxg3aaNBgwNNxWl7rYicXbXEr+ZCJVJJKyE4DsCNU=; b=EaHVErbBKrRGn6/+j8vcQ46PDqNpEHyiA71hBpsEg+a7dOqFrXJZjLHLni8vo6DQw+lPie +Q6bN2bpBR5a+g4BrK0zFJrCTkQV9bNFWeV3AyvEssBcY3A8dBFsKckrdZs4f5vCaX73gI 7/ek6Ktl84QyJdnCrqcsME5pPAvnCII= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GQYu2kY1U5G5H+F8oY4M+GmA2enH6EUnbNNp64joTtV926fZdvrTLc/bf3GihX3PQmndXNtccqZ+lcGNUxmscZX67gX2ZnvQsuM3hfRNyMYZg5KhrHe804/QHOLxsaa3CdCVRZARMgKo+w8bRQ+1iUORcL/PzIfZ7wwDrixu1n1QVtpo7PnsRV6v6WHRwqiGnMJ1egWZBl6FF1ajuXNyML68brME5x6uHDZ0h47FLRNJGQmm214uk/Z5it/OwU4NsiaKmCf3+5xnnn1mobP6h8bUPKDac9DbG0fIe2S0A4h/gkpcOtlqXuUZveAwrDU8OOdwy4p9BJW7kexsfhl8Xw== 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=Huwxg3aaNBgwNNxWl7rYicXbXEr+ZCJVJJKyE4DsCNU=; b=khI81Aeem5EyyAMCMHBGrMsCpN6TsSN8ZCnDhi7L3Nw7WGSTa4h4uotHV5v++FqP04rkKIK0OYWJP4VGFrLqj96GIAocsEeyKYW5GovR7LC7Hh9wnRYceObpu29gs2dLvOeZdSnFuHYxE8E07ldVS/eP6v2r880ysxq1YruVnEVjHsBdZbZpQc7GvDSrG1VmIkjrjUIXMNjdApLT231/nwLXgsBb2sm6AdZUh+qk54D5UTa1Pz1j26Lvu0a7L3ZoFAzI2pUPCbNYLHN5/lja4ByyH38l1E99KR0Z6sDnyiGQJ/DDYC2CV7Tiv9nmjFk8ApQ91B0z4649H6CSe2U8sQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=gmail.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=Huwxg3aaNBgwNNxWl7rYicXbXEr+ZCJVJJKyE4DsCNU=; b=SoJ7vhugt4aft1ur0hmCyj63dKhf0J1DWWPKT2LT2rjl/Isxa4B7nZZ23FDDA9nul8xTVrjV+KUTRLVAntOvmjX4GekLOOqiZY6mcHw/uR5j1W4rMQfDoVvh6DZHAJ4EEzsyxQ7Sgj9mhC+1ODqrzeWZBZE+wrwUJ4GXgYkktDKcELoOgze9bAMjoK848zn6dVkCWhWrJdIetwjPgavLZxbQknYpuu6pH5JuQigSR1+Tf87fOoMklKUnO0inXlYVdm8e3MLJPWiSdXrbZybz302vC6y88AoAaT0bREAjd+IbSr0BRZ9ZrMhOTcv2FX6L/29fPldFZZY0x6TXfrDIjQ== Received: from PH8PR20CA0002.namprd20.prod.outlook.com (2603:10b6:510:23c::6) by CH2PR12MB4876.namprd12.prod.outlook.com (2603:10b6:610:67::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.35; Mon, 16 Oct 2023 10:15:25 +0000 Received: from SA2PEPF000015C9.namprd03.prod.outlook.com (2603:10b6:510:23c:cafe::fc) by PH8PR20CA0002.outlook.office365.com (2603:10b6:510:23c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.30 via Frontend Transport; Mon, 16 Oct 2023 10:15:25 +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 SA2PEPF000015C9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.22 via Frontend Transport; Mon, 16 Oct 2023 10:15:25 +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; Mon, 16 Oct 2023 03:15:12 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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; Mon, 16 Oct 2023 03:15:11 -0700 Received: from localhost.localdomain (10.127.8.10) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Mon, 16 Oct 2023 03:15:06 -0700 From: Kartik To: , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 4/8] soc/tegra: fuse: Add tegra_acpi_init_apbmisc() Date: Mon, 16 Oct 2023 15:44:32 +0530 Message-ID: <20231016101436.7146-5-kkartik@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231016101436.7146-1-kkartik@nvidia.com> References: <20231016101436.7146-1-kkartik@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C9:EE_|CH2PR12MB4876:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fa599d8-4bcf-4453-fbe5-08dbce30d057 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HnXXmtuxgWYd/mOFSVEgjRhlE9vZwtFDy2fyzT5Z1VSzLs/6QCVp8eXcUQxDFpMF/J+dTS2tc1L63dnR97wTfdvpMPdKWvdq3ryevT+FWz2C+Ah8vpJzjfOZxpOI4oTtzV6yzEsJNNfkqdXy21pjTeyQ0oOvDykWoBgH3UAeGxdOlB1LoQvR/6QurwXsEvec6q1/G8IIM1GwuF+j88ctmWQbFU8K40svdbnF38MxojeGToOc6ojTk1Uk0Dz7doJPIuh6ACPIEZvVWm6T83AwoMKYaWe3ovWi8L2EZrJfC7ktrlDWCXQOfjF62g85D5EY4HwJ0PdwtP/FZFxag/MRM1cfzwESQCMEjZSwSu3rYmqrgKSIDhKNrtMknwwK00STNLqEbE6wt10qRxJg59nYe1qVr73x4HopE6Ax7isCMVToYetaDlsy8H8u7zmXqueqHEThe0/5DD2ccqk0bYRI+PXph7DBZwMaqnxn+zXIwUtDCAs6/e/hwVD6pllPireiG45yhVcePlms4CZ+gsXOoGJJPIL4rKONd44zKD1vepHwcFLqU0OB3mA/JXW9tHvtzeMAlUJYDNdhCkUxTFT+Rd74LQtlADbhWaehosvLZ7RqrFYsX4qhurdKx02AKbkc9aLKN9YXLI68UWR5x4tvnooJXV5bptMVB0CDWw4zzwpBllNa1zPE1Dw0f+PZLwPwRemjZ8u6bqulSDyRE9IBi7IaVJtxrdvfUN1UpeIe3ekW6qkQ1+5KB67Fsq8k51lkAcXDIMzL+D5G1CarG56X2UOSbuelZchOUrfdMyExy1oaLVjIyhB97EmoRMVgVpST 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)(376002)(39860400002)(346002)(136003)(396003)(230922051799003)(451199024)(82310400011)(64100799003)(186009)(1800799009)(36840700001)(40470700004)(46966006)(40460700003)(40480700001)(82740400003)(36756003)(7636003)(921005)(356005)(36860700001)(47076005)(83380400001)(6666004)(26005)(70586007)(70206006)(316002)(478600001)(2616005)(1076003)(426003)(336012)(110136005)(41300700001)(2906002)(7416002)(86362001)(5660300002)(8936002)(8676002)(2101003)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2023 10:15:25.0517 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fa599d8-4bcf-4453-fbe5-08dbce30d057 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: SA2PEPF000015C9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4876 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9DA9940012 X-Stat-Signature: 4b855gbijyweddoj3jcn3oakfp1biidp X-HE-Tag: 1697451327-928050 X-HE-Meta: U2FsdGVkX1+38+vM6bHM0niT8aT+4MVkVT2+ql2mTXZhVTFsKBUYe3G+XPQSQw/6At3z7VBTBj27G/LvOU90vtP8St01Qqd27zv4P59FjMmp1uDYHq9LZuNO/g8bMGSvZ5NHJM7ADi3QSSttQlLxCzOOK/F2fYKzs++yQVLyWiSUjiJ0g9FYuSvrAybNNKyJ8OzDpV1HalTuc7aX8s2vOa+jZiU7Fb25j4e0KkDIZO3SHlRkayPVMwCvK1MPhI1pduX/qWeViPaZhvi0Uz5lX7rKDBdi3TlcG+BoZkkhvx6RM6oS/XZ7OXz4an9yfA7pch5D91mNZ3sTjMM4wTmMlOjUHktL9WTDmhFtwbqLOvhhw7Lveul5Y6AS5kUXwMz5cJZiXe2WUOUeCcrYY32R05f9i0Gu5b0HQKLHStcJ/hMj1lJ/RlBFTxWu4BiWqdvGhWQqT6vPg9BWiGRiiLfD0wxIMz45M68awBM+xip7aPt57eC4KjQHu2G4fXtg/ZslDdDyorNy3reEAdFowcX52/MYFGphMzgdao/L2WGJ7BcY2cZdxx4BySOSi/B/lkbMcqEC7rt1vlNRKt5Ogy6fWyZkPA8X3/BH0OJEUFUtkJhFmRTyAIDolva6yOyCFA0GAE82RYaXjWR/8Q0chKzPyuqLhA1w2UtKenNyIYmQ0AQEuEl3/1r5/UlBub/gghz7CTSNWrpD2irS85/BZNJUeV+xpiJNT+qKgKVLnPg4hvY9Y6RfYDwgp90sZIvw8le8RoemRCWmwTqqTguEgZym2PZkVRAtT+Knp3x/2s71BOidVdKFMopJArjpuR5Gdlil+sLCb58FeVNSn5qe4nAl+SnkzntDGxtC9l1gLa6IVOeHyQQes8i08tXIaU3YL7TTgvuUr37yfRB/nbNefHl+cdf5Iwx58yGeM062OWEgeq1zx7NNxen54i018UPMwjtet+50QoCgLFWcAuU7xiV WXCWZy+9 uV+gs9xLcJnV2ZFiSKCEQNqQAHogxfy35fe7x8T09nH0/OsA2XOezGST4T8tsUFTRNglodh9BIeeXOimwZPPL6hFBrDmCUuZyM8HDPBwsR0gYEF8HLixqL3wld1RcOc7CIDpUmv5LuTb+yebTLPOtAv26AaRl6MHxlCIylRECfHhE4ijsphWGHLImSWk/MpMq8EIigdTtHnm74lde4P4FT8BQlaApg9uLl/sSYOVA408PE8XAXecFI80Vzp1yjSeSsdQmZ2B5B4/LMPjbuTTWqHRCA8VBY5qCE6NrFDDLG9yLV6bcLWzL+qQFTh2t9qAPh3SVa5HYX1WFLrBxLfV96tru7h4Q2tOoNPCNn6av6zEwiCJMo1pDVQpXDFV2tW0nQ9EaejHTqcVxWEMWhZlP6Ed42wW2heSOA3OT X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In preparation to ACPI support in Tegra fuse driver add function tegra_acpi_init_apbmisc() to initialize tegra-apbmisc driver. Also, document the reason of calling tegra_init_apbmisc() at early init. Note that function tegra_acpi_init_apbmisc() is not placed in the __init section, because it will be called during probe. Signed-off-by: Kartik --- v3 -> v6: * Use resource_list_for_each_entry() instead of resource_list_for_each_entry_safe(). v2 -> v3: * Fix build warnings seen when CONFIG_ACPI is disabled by moving tegra_init_apbmisc table inside #ifdef CONFIG_ACPI block. v1 -> v2: * Update ACPI ID table 'tegra_init_apbmisc'. * Add comment to document the reason to call tegra_init_apbmisc at early init. * Fix an issue where acpi_dev_free_resource_list() and * acpi_dev_put() were not called if acpi_dev_get_memory_resources() returned 1. * Update logic to fetch memory resources in tegra_acpi_init_apbmisc(). * Fix build errors seen when CONFIG_ACPI is disabled. --- drivers/soc/tegra/fuse/fuse.h | 1 + drivers/soc/tegra/fuse/tegra-apbmisc.c | 72 ++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/drivers/soc/tegra/fuse/fuse.h b/drivers/soc/tegra/fuse/fuse.h index 90f23be73894..a41e9f85281a 100644 --- a/drivers/soc/tegra/fuse/fuse.h +++ b/drivers/soc/tegra/fuse/fuse.h @@ -69,6 +69,7 @@ struct tegra_fuse { void tegra_init_revision(void); void tegra_init_apbmisc(void); +void tegra_acpi_init_apbmisc(void); u32 __init tegra_fuse_read_spare(unsigned int spare); u32 __init tegra_fuse_read_early(unsigned int offset); diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c index 06c1b3a2c7ec..6457f80821bb 100644 --- a/drivers/soc/tegra/fuse/tegra-apbmisc.c +++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c @@ -3,9 +3,11 @@ * Copyright (c) 2014-2023, NVIDIA CORPORATION. All rights reserved. */ +#include #include #include #include +#include #include #include @@ -180,6 +182,12 @@ static void tegra_init_apbmisc_resources(struct resource *apbmisc, } } +/** + * tegra_init_apbmisc - Initializes Tegra APBMISC and Strapping registers. + * + * This is called during early init as some of the old 32-bit ARM code needs + * information from the APBMISC registers very early during boot. + */ void __init tegra_init_apbmisc(void) { struct resource apbmisc, straps; @@ -244,3 +252,67 @@ void __init tegra_init_apbmisc(void) put: of_node_put(np); } + +#ifdef CONFIG_ACPI +static const struct acpi_device_id apbmisc_acpi_match[] = { + { "NVDA2010" }, + { /* sentinel */ } +}; + +void tegra_acpi_init_apbmisc(void) +{ + struct resource *resources[2] = { NULL }; + struct resource_entry *rentry; + struct acpi_device *adev = NULL; + struct list_head resource_list; + int rcount = 0; + int ret; + + adev = acpi_dev_get_first_match_dev(apbmisc_acpi_match[0].id, NULL, -1); + if (!adev) + return; + + INIT_LIST_HEAD(&resource_list); + + ret = acpi_dev_get_memory_resources(adev, &resource_list); + if (ret < 0) { + pr_err("failed to get APBMISC memory resources"); + goto out_put_acpi_dev; + } + + /* + * Get required memory resources. + * + * resources[0]: apbmisc. + * resources[1]: straps. + */ + resource_list_for_each_entry(rentry, &resource_list) { + if (rcount >= ARRAY_SIZE(resources)) + break; + + resources[rcount++] = rentry->res; + } + + if (!resources[0]) { + pr_err("failed to get APBMISC registers\n"); + goto out_free_resource_list; + } + + if (!resources[1]) { + pr_err("failed to get strapping options registers\n"); + goto out_free_resource_list; + } + + tegra_init_apbmisc_resources(resources[0], resources[1]); + +out_free_resource_list: + acpi_dev_free_resource_list(&resource_list); + +out_put_acpi_dev: + acpi_dev_put(adev); +} +#else +void tegra_acpi_init_apbmisc(void) +{ +} +#endif