From patchwork Mon Oct 16 05:34:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kartik X-Patchwork-Id: 13422501 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 76625CDB465 for ; Mon, 16 Oct 2023 05:34:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 11B018D0048; Mon, 16 Oct 2023 01:34:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CB3C8D0001; Mon, 16 Oct 2023 01:34:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E870C8D0048; Mon, 16 Oct 2023 01:34:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D52808D0001 for ; Mon, 16 Oct 2023 01:34:56 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AD434B5C48 for ; Mon, 16 Oct 2023 05:34:56 +0000 (UTC) X-FDA: 81350210592.29.A355B39 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2076.outbound.protection.outlook.com [40.107.94.76]) by imf06.hostedemail.com (Postfix) with ESMTP id 999A4180008 for ; Mon, 16 Oct 2023 05:34:53 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b="EJhiHXw/"; dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf06.hostedemail.com: domain of kkartik@nvidia.com designates 40.107.94.76 as permitted sender) smtp.mailfrom=kkartik@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697434493; 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=H+Fro14rgalH/06qabhLwOLhxQnp+Tg6JsjLLk27Cig=; b=ECs8ajraLitztdzeDHJUKeHdQsMFrETMoVaZcFtnIr2WLvyDtpgpnaEwsJ5worfgyxNF/2 EjXWyxFOMHyn0fGKOqE6LApMg+VX/aBLcp437AaY2nIiFlBZp9yuljM9DgrXclVMIHvdBw 0enTDK9dFRKutDHqeFUlG7lepC2X9Sw= ARC-Authentication-Results: i=2; imf06.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b="EJhiHXw/"; dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf06.hostedemail.com: domain of kkartik@nvidia.com designates 40.107.94.76 as permitted sender) smtp.mailfrom=kkartik@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1697434493; a=rsa-sha256; cv=pass; b=Zdl3m7nCK6vByiudbnfQ56zw1sdcmGnvMZ6gGpQhMVH173mK2QuG9wP1kxAFs4mae0CI4E F8RRB5ob+TLKRZfy3c6i3KWKx8kwLLrg7G6aYvOAw9Gddw5t9F6spIKn8BxrROUNDCK/Tv IYOmjoOxaTxjsltLe7msmpBM7tHOESI= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JEnHW0+I0hcVKdERWb4BJ3ZUJMEG9bMSEwftNQMlKAAcfxgJdQtbcSKr1NGjPldXnMmRP4KBGk43zAS/eByZTP/LygPjMRSqFwtVpKZzNDuoLz2zgFysSzZnGyD0UCjalCeKmeWKccnaoTQYhQr2A/JoO0O29XdFFxRwsJWMcE2e7vMljdonG9PvI9q0xy0izSxJuaG4cPWn5VxvWlmvofEFH4etjuOsNHpYyA1MYhxcYYv1dKujoudim6//Jc/er6TlSV8wjA6RirFAwTkw6GstrDIICn8RLzQg+pHFOff5VpAs+VSfwUD2v+Z+fXq/CqmeOM6Y7mczCdfiuklcBQ== 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=H+Fro14rgalH/06qabhLwOLhxQnp+Tg6JsjLLk27Cig=; b=mdYeQifIyCnTv/msJCmWj7O5FRd+MLXEI/hFFV/d7x0AZ3eF4g5K1jPPSkzolAR/dikaT7B1tuVsItHckZ2hztoFW8YoRE+ECIRJG1/UWCp4rEVsJIsuBiGt+OrIYOcLhKoFRrW9jf2yqXjXGYzrCqeD4EZJt9QNDNR0CaOz8EkgRJR5qABKPTvkGJWvGqhY1M8Aa4cMrR6uJpJ45ES6m+XKoiEcxeWz7CU4Qs9GNuMeqjd4XQ8VJsQKJTWc+MgxT4+CFv4PplFcATJeUGV3R8pRqjCqzX/nSj5YBA1DUbqfHwe8tSn/91/kOJMMNa+cVrHDkdBc6Nj6N5GSZwTc3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=H+Fro14rgalH/06qabhLwOLhxQnp+Tg6JsjLLk27Cig=; b=EJhiHXw/eQ0qSI0b50LirdGXbhE1hJAvKIrw96d8T/yvx+MvvN1ed0eENKkcO/KzodEaTzBng2DMeCkKnh7OLL3Z5BWA0GF2tOlcwne5n+kDVLg96twZ/Rcyyb2qPp4ZXmQ4QcH2glrzOH5MbzsQwzy41j9mhgZ1PeueKm1KTjuSTXStPE/NtlGzXaeqI4D7/EPSeWDv8iXUccGvWBx26/lr2Ix9H0DIGCBD06zN2iCEQ9gEq9Bj9YaQL3bfg+WP6WqF3+Vy/I/t/rPgy7P8hBTIas/30T6pG/70j7aufnDOAiotBFAWky1ADupdJNdaDhUf7rph0hIU9zh0FBKxxQ== Received: from SA0PR11CA0085.namprd11.prod.outlook.com (2603:10b6:806:d2::30) by DM6PR12MB4340.namprd12.prod.outlook.com (2603:10b6:5:2a8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.34; Mon, 16 Oct 2023 05:34:50 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2603:10b6:806:d2:cafe::a9) by SA0PR11CA0085.outlook.office365.com (2603:10b6:806:d2::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.34 via Frontend Transport; Mon, 16 Oct 2023 05:34:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) 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 05:34:50 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Sun, 15 Oct 2023 22:34:44 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Sun, 15 Oct 2023 22:34:43 -0700 Received: from localhost.localdomain (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Sun, 15 Oct 2023 22:34:38 -0700 From: Kartik To: , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 4/8] soc/tegra: fuse: Add tegra_acpi_init_apbmisc() Date: Mon, 16 Oct 2023 11:04:07 +0530 Message-ID: <20231016053411.3380-5-kkartik@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231016053411.3380-1-kkartik@nvidia.com> References: <20231016053411.3380-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: SA2PEPF00001507:EE_|DM6PR12MB4340:EE_ X-MS-Office365-Filtering-Correlation-Id: 02f06d93-628f-468d-7eec-08dbce099e43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qP2r2GZDdysf7gyp370SU2VOGuNHyE5GxwcGlvPGzVC95X9NYVHnMS8VQbquYFgZuS2R/CqzDFkq1WCYxS6Al90XipBg+6zC3hjSWyrhFZpjtQt0AFf+OH2N4MeCvO6VEl+GMuMa+uPHPdw2oCj3M8mVqBDtRS8E2QN0YI8Fb8fUC0RIyA3LA8PhUpQpsLghhvOktMbgVzY6agGaP5rHlNbjivOp2ll7EQ1VL8sNf8ADpeFztE9xvqBiAqhtbxNR7yGkkM1LxqJB4dLe6hL1nARo51wfdVuFn2ct/cmHlT57v7Tsui5qFW/jZYQ2wOPkyc+IW0PLtsZrD6qnkT5XZejRrpRRccWlqWQJMpeYpcaVTTstP2BIKAiGcKjy8juECINaWVIXj9Ja5cV5wx+yStJO93fPgqJHGm8amQnSCDKbrwmq2Xr4/SCO8oBfr+CGwMFVKC9SaRAKK0V873+WQFrBF1dfk71WyiH48u+21GzIacerjZo7ZsxoRERchMoxK/R5B11JKNwm2yCs6jpm1xMEzXbuR+2XKJld42tDBDgOUWfCgO8Tld9uaKEWUfD8nVjcfQS7lLtcnu6x/SRuK7toethCXvjm0xUBuQ5qlv6pJwAuck4hyyziRpH+vQGTebLQ5fJfNB13CZi8HJ3fjgz4qTqQbjHLlp38N7FNsuT4s8EnhXSgidIbrsQcl4SS5jIgSWvsNUM6Rk/lmmxTBLLohjBOJnuHlBZVGvJnskrMzWiIwUES8EH0C51xQDy8aAXjMG34zEORfRP4dUYF4zhiZR0YJzoqDW4D0XrNUArIrBuEXT22JI9c1khz6Jtv X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(39860400002)(396003)(346002)(376002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(478600001)(7416002)(36860700001)(26005)(2616005)(6666004)(5660300002)(8936002)(8676002)(83380400001)(41300700001)(47076005)(1076003)(316002)(2906002)(70586007)(70206006)(82740400003)(110136005)(336012)(426003)(7636003)(356005)(921005)(86362001)(36756003)(40460700003)(40480700001)(2101003)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2023 05:34:50.7058 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02f06d93-628f-468d-7eec-08dbce099e43 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4340 X-Rspamd-Queue-Id: 999A4180008 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: a7w3rkqx3ubfrnmrbpomx98rj1heq6bf X-HE-Tag: 1697434493-380562 X-HE-Meta: U2FsdGVkX1/p3WcLlrheAWs/gXGt6+atdmzlis6vXw46qNb1ItpZ3Yg6QS+6m5OvbB3paFIZLHG+QZU1mOxfW9s/PXPvrlRwM6l2e9w3PdVGBoGKpoftCPk1DF/DBgVNJdwBT7WYFDWg41QDhm5Yg9tG4xAgXvBI1oAg8U/ebE+9izdIg2+yOzGyhEUIP9Rm2Haf7IgxNWYl2z/VcfKisJqJ7mEvV5bND+pSprcIhffyjMhCg9mSlWUv1KLZO/TpL/eHGrzGUtmLxRFXQfK5BodSA5n1iRN1aV++vp6lsaPXpThJtYRmr2LkZPbn/q8/lAX/U+94WtWn6YEemcv6V16MlZ5S/AbW6MOY8xMomhi0CJlQ+Oww+nuKftQ4h0Rlbz2JwYaac145pnXhRU5LTNDYC7BQ5HC4v+eBadxLRqbRdS0t283j9jwLpMWa4SxtQqsIksR3G1J8Or3jnpIF/XVx1qPIZTfP/KmpX9A3kOLATnCeOmpi2CIjoeHaevbHd11FfqLiC5sDLT77XSX2vWqAEzuIgiWMEUNkdo/uo/Tq/3R4s4TsXG+b9+ZetI2Ft5FFw8fdNBZUsuX6rhVBi+zMlOVeNJIfFLdTLpzrqtvfIp2zWT1w2oCSRkIuiNWWz4HAW6Xo+ijqXDZgDN/mFwd72WFD56+M8OG8Ytdjed0jOhDdHgLOu8PN+FH/ain74Vo4AQRMqBY3gTLFvxHLdg00dJ7KOkuTO/tUGmEXEAJT4QAEoR1SgXRLz+r8LrAhiyXGMlf/FXWUFCwYVCgSVQXVuNDMutIfZeaOZlVjat9NVk79ir/7nCAGNf/gwe0g+pEWqKx7/Rv0hLn4oO3US2WHd6wHr5gHwv31IvzWhlyz2306VG6S+SuyeSeyGgXUi0MPySB2PV56ed2tRY6h9lcwqVKz65hOwCr8ffXcIJNyvqhI2ezW/NcbR2WMnRaHUW5iSOPtKbwmmPYdCB+ RJdLjD3I mWn+YCIOd1/p3egLSgRpcpkQ1rDgCIPuo0QiXCsLmcGrhZPnAhSH4q80/dxGTc4MuSuwZN0PB1+DaWutgSbn6vOm5WEqWZEH/Mkdxzt9GN3m8RYdfvmY82EpI2ZiJaF0BkyEAXj3p7hA/rIAfyoCzDqPcuw2U3zIuJCuAIXNZy4erBFZOoEjClPA4D2Qb97HVq5Jhsi0YYFi4go25iKT+TrSGzgkSFrtiAj5ZEDmq9JrAZb4EO4CM1dsXZ4FunYj3z4zVkyMqd4taJHNeJ6tNzu8rvyqk7IdTbimpQdvAYFfpWkXcuvNIQNAaaMmC0e5oek30tQ6cE70huBLGqs39F11A7cjlfZ0Omtzu0wjCLqWN/bfueYT5rJflXzMfkd5+mJAHNvgMqVYFt/dEpGRj7Ya/QQHhQ+58bl9G 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 --- 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..e2ca93de6c1f 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, *tmp; + 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_safe(rentry, tmp, &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