[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230818093028.7807-2-kkartik@nvidia.com>
Date: Fri, 18 Aug 2023 15:00:23 +0530
From: Kartik <kkartik@...dia.com>
To: <thierry.reding@...il.com>, <jonathanh@...dia.com>,
<sumitg@...dia.com>, <arnd@...db.de>, <pshete@...dia.co>,
<andriy.shevchenko@...ux.intel.com>, <kkartik@...dia.com>,
<digetx@...il.com>, <petlozup@...dia.com>, <windhl@....com>,
<frank.li@...o.com>, <robh@...nel.org>, <stefank@...dia.com>,
<pdeschrijver@...dia.com>, <linux-tegra@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH 1/6] soc/tegra: fuse: Add tegra_acpi_init_apbmisc()
In preparation to ACPI support in Tegra fuse driver add function
tegra_acpi_init_apbmisc() and move common code used for both ACPI and
device-tree into a new helper function tegra_init_apbmisc_base().
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 <kkartik@...dia.com>
---
drivers/soc/tegra/fuse/fuse.h | 1 +
drivers/soc/tegra/fuse/tegra-apbmisc.c | 73 ++++++++++++++++++++------
2 files changed, 58 insertions(+), 16 deletions(-)
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 da970f3dbf35..79db12076d56 100644
--- a/drivers/soc/tegra/fuse/tegra-apbmisc.c
+++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c
@@ -3,6 +3,7 @@
* Copyright (c) 2014-2023, NVIDIA CORPORATION. All rights reserved.
*/
+#include <linux/acpi.h>
#include <linux/export.h>
#include <linux/io.h>
#include <linux/kernel.h>
@@ -120,6 +121,11 @@ int tegra194_miscreg_mask_serror(void)
}
EXPORT_SYMBOL(tegra194_miscreg_mask_serror);
+static const struct acpi_device_id apbmisc_acpi_match[] = {
+ { .id = "NVDA2010", 0 },
+ { /* sentinel */ }
+};
+
static const struct of_device_id apbmisc_match[] __initconst = {
{ .compatible = "nvidia,tegra20-apbmisc", },
{ .compatible = "nvidia,tegra186-misc", },
@@ -160,9 +166,28 @@ void __init tegra_init_revision(void)
tegra_sku_info.platform = tegra_get_platform();
}
-void __init tegra_init_apbmisc(void)
+static void tegra_init_apbmisc_base(struct resource *apbmisc,
+ struct resource *straps)
{
void __iomem *strapping_base;
+
+ apbmisc_base = ioremap(apbmisc->start, resource_size(apbmisc));
+ if (!apbmisc_base)
+ pr_err("failed to map APBMISC registers\n");
+ else
+ chipid = readl_relaxed(apbmisc_base + 4);
+
+ strapping_base = ioremap(straps->start, resource_size(straps));
+ if (!strapping_base) {
+ pr_err("failed to map strapping options registers\n");
+ } else {
+ strapping = readl_relaxed(strapping_base);
+ iounmap(strapping_base);
+ }
+}
+
+void __init tegra_init_apbmisc(void)
+{
struct resource apbmisc, straps;
struct device_node *np;
@@ -219,23 +244,39 @@ void __init tegra_init_apbmisc(void)
}
}
- apbmisc_base = ioremap(apbmisc.start, resource_size(&apbmisc));
- if (!apbmisc_base) {
- pr_err("failed to map APBMISC registers\n");
- } else {
- chipid = readl_relaxed(apbmisc_base + 4);
- }
-
- strapping_base = ioremap(straps.start, resource_size(&straps));
- if (!strapping_base) {
- pr_err("failed to map strapping options registers\n");
- } else {
- strapping = readl_relaxed(strapping_base);
- iounmap(strapping_base);
- }
-
+ tegra_init_apbmisc_base(&apbmisc, &straps);
long_ram_code = of_property_read_bool(np, "nvidia,long-ram-code");
put:
of_node_put(np);
}
+
+void tegra_acpi_init_apbmisc(void)
+{
+ struct acpi_device *adev = NULL;
+ struct resource *apbmisc, *straps;
+ struct list_head resource_list;
+ struct resource_entry *rentry;
+ int rcount;
+
+ adev = acpi_dev_get_first_match_dev(apbmisc_acpi_match[0].id, NULL, -1);
+ if (!adev)
+ return;
+
+ INIT_LIST_HEAD(&resource_list);
+
+ rcount = acpi_dev_get_memory_resources(adev, &resource_list);
+ if (rcount != 2) {
+ pr_err("failed to get APBMISC memory resources");
+ return;
+ }
+
+ rentry = list_first_entry(&resource_list, struct resource_entry, node);
+ apbmisc = rentry->res;
+ rentry = list_next_entry(rentry, node);
+ straps = rentry->res;
+
+ tegra_init_apbmisc_base(apbmisc, straps);
+ acpi_dev_free_resource_list(&resource_list);
+ acpi_dev_put(adev);
+}
--
2.34.1
Powered by blists - more mailing lists