From: Kartik <kkartik@nvidia.com>
To: <thierry.reding@gmail.com>, <jonathanh@nvidia.com>,
<sumitg@nvidia.com>, <arnd@arndb.de>, <pshete@nvidia.co>,
<andriy.shevchenko@linux.intel.com>, <kkartik@nvidia.com>,
<digetx@gmail.com>, <petlozup@nvidia.com>, <windhl@126.com>,
<frank.li@vivo.com>, <robh@kernel.org>, <stefank@nvidia.com>,
<pdeschrijver@nvidia.com>, <linux-tegra@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH 5/6] soc/tegra: fuse: Add ACPI support for Tegra194 and Tegra234
Date: Fri, 18 Aug 2023 15:00:27 +0530 [thread overview]
Message-ID: <20230818093028.7807-6-kkartik@nvidia.com> (raw)
In-Reply-To: <20230818093028.7807-1-kkartik@nvidia.com>
Add tegra_fuse_acpi_probe() to initialize Tegra fuse while using ACPI.
Also, drop '__init' keyword for tegra_soc_device_register() as this is also
used by tegra_fuse_acpi_probe().
Note that as ACPI subsystem initialize at subsys init, function
tegra_fuse_acpi_probe() also contains the necessary initialization
that we are currently doing for device-tree boot as a part of
early init.
Signed-off-by: Kartik <kkartik@nvidia.com>
---
drivers/soc/tegra/fuse/fuse-tegra.c | 67 ++++++++++++++++++++++++++++-
1 file changed, 65 insertions(+), 2 deletions(-)
diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
index 70e8eeddcbd9..9c5596d968a2 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
@@ -3,6 +3,7 @@
* Copyright (c) 2013-2023, NVIDIA CORPORATION. All rights reserved.
*/
+#include <linux/acpi.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/kobject.h>
@@ -94,6 +95,13 @@ static const struct of_device_id tegra_fuse_match[] = {
{ /* sentinel */ }
};
+static const struct acpi_device_id tegra_fuse_acpi_match[] = {
+ {
+ .id = "NVDA200F",
+ },
+ { /* sentinel */ },
+};
+
static int tegra_fuse_read(void *priv, unsigned int offset, void *value,
size_t bytes)
{
@@ -176,12 +184,65 @@ static void tegra_fuse_pr_sku_info(struct tegra_sku_info *tegra_sku_info)
tegra_sku_info->cpu_speedo_id, tegra_sku_info->soc_speedo_id);
}
+static int tegra_fuse_acpi_probe(struct platform_device *pdev)
+{
+ struct resource *res;
+ u8 chip;
+ int err;
+
+ tegra_acpi_init_apbmisc();
+
+ chip = tegra_get_chip_id();
+ switch (chip) {
+#if defined(CONFIG_ARCH_TEGRA_194_SOC)
+ case TEGRA194:
+ fuse->soc = &tegra194_fuse_soc;
+ break;
+#endif
+#if defined(CONFIG_ARCH_TEGRA_234_SOC)
+ case TEGRA234:
+ fuse->soc = &tegra234_fuse_soc;
+ break;
+#endif
+ default:
+ dev_err(&pdev->dev, "Unsupported SoC: %02x\n", chip);
+ return -EINVAL;
+ }
+
+ fuse->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+ if (IS_ERR(fuse->base))
+ return PTR_ERR(fuse->base);
+ fuse->phys = res->start;
+
+ platform_set_drvdata(pdev, fuse);
+ fuse->dev = &pdev->dev;
+
+ err = tegra_fuse_nvmem_register(fuse, &pdev->dev);
+ if (err)
+ return err;
+
+ fuse->soc->init(fuse);
+ tegra_soc_device_register();
+ tegra_fuse_pr_sku_info(&tegra_sku_info);
+
+ err = tegra_fuse_add_lookups(fuse);
+ if (err) {
+ dev_err(&pdev->dev, "failed to add FUSE lookups\n");
+ return err;
+ }
+
+ return 0;
+}
+
static int tegra_fuse_probe(struct platform_device *pdev)
{
void __iomem *base = fuse->base;
struct resource *res;
int err;
+ if (has_acpi_companion(&pdev->dev))
+ return tegra_fuse_acpi_probe(pdev);
+
err = devm_add_action(&pdev->dev, tegra_fuse_restore, (void __force *)base);
if (err)
return err;
@@ -306,6 +367,7 @@ static struct platform_driver tegra_fuse_driver = {
.driver = {
.name = "tegra-fuse",
.of_match_table = tegra_fuse_match,
+ .acpi_match_table = tegra_fuse_acpi_match,
.pm = &tegra_fuse_pm,
.suppress_bind_attrs = true,
},
@@ -327,7 +389,8 @@ u32 __init tegra_fuse_read_early(unsigned int offset)
int tegra_fuse_readl(unsigned long offset, u32 *value)
{
- if (!fuse->read || !fuse->clk)
+ /* fuse->clk is not required when ACPI is used. */
+ if (!fuse->read || (!fuse->clk && !has_acpi_companion(fuse->dev)))
return -EPROBE_DEFER;
if (IS_ERR(fuse->clk))
@@ -410,7 +473,7 @@ const struct attribute_group tegra194_soc_attr_group = {
};
#endif
-struct device * __init tegra_soc_device_register(void)
+struct device *tegra_soc_device_register(void)
{
struct soc_device_attribute *attr;
struct soc_device *dev;
--
2.34.1
next prev parent reply other threads:[~2023-08-18 9:32 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-18 9:30 [PATCH 0/6] soc/tegra: fuse: Add ACPI support Kartik
2023-08-18 9:30 ` [PATCH 1/6] soc/tegra: fuse: Add tegra_acpi_init_apbmisc() Kartik
2023-08-18 13:21 ` Andy Shevchenko
2023-08-21 11:32 ` Kartik
2023-08-21 12:32 ` Andy Shevchenko
2023-08-22 7:52 ` Thierry Reding
2023-08-22 3:12 ` kernel test robot
2023-08-22 4:01 ` kernel test robot
2023-08-18 9:30 ` [PATCH 2/6] soc/tegra: fuse: Add function to register nvmem Kartik
2023-08-18 13:50 ` Andy Shevchenko
2023-08-21 11:34 ` Kartik
2023-08-18 9:30 ` [PATCH 3/6] soc/tegra: fuse: Add function to add lookups Kartik
2023-08-18 14:06 ` Andy Shevchenko
2023-08-21 11:36 ` Kartik
2023-08-18 9:30 ` [PATCH 4/6] soc/tegra: fuse: Add function to print SKU info Kartik
2023-08-22 7:55 ` Thierry Reding
2023-08-18 9:30 ` Kartik [this message]
2023-08-18 15:07 ` [PATCH 5/6] soc/tegra: fuse: Add ACPI support for Tegra194 and Tegra234 Andy Shevchenko
2023-08-21 11:38 ` Kartik
2023-08-21 12:45 ` Andy Shevchenko
2023-08-18 9:30 ` [PATCH 6/6] soc/tegra: fuse: Add support for Tegra241 Kartik
2023-08-18 15:10 ` Andy Shevchenko
2023-08-21 11:40 ` Kartik
2023-08-21 12:47 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230818093028.7807-6-kkartik@nvidia.com \
--to=kkartik@nvidia.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=digetx@gmail.com \
--cc=frank.li@vivo.com \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=pdeschrijver@nvidia.com \
--cc=petlozup@nvidia.com \
--cc=pshete@nvidia.co \
--cc=robh@kernel.org \
--cc=stefank@nvidia.com \
--cc=sumitg@nvidia.com \
--cc=thierry.reding@gmail.com \
--cc=windhl@126.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome