From: Kartik <kkartik@nvidia.com>
To: <thierry.reding@gmail.com>, <jonathanh@nvidia.com>,
<keescook@chromium.org>, <andy@kernel.org>,
<akpm@linux-foundation.org>, <arnd@arndb.de>,
<ulf.hansson@linaro.org>, <linus.walleij@linaro.org>,
<kkartik@nvidia.com>, <pshete@nvidia.com>, <petlozup@nvidia.com>,
<frank.li@vivo.com>, <robh@kernel.org>, <stefank@nvidia.com>,
<pdeschrijver@nvidia.com>, <linux-tegra@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-hardening@vger.kernel.org>,
<linux-mm@kvack.org>
Subject: [PATCH v5 7/8] soc/tegra: fuse: Add ACPI support for Tegra194 and Tegra234
Date: Mon, 16 Oct 2023 11:04:10 +0530 [thread overview]
Message-ID: <20231016053411.3380-8-kkartik@nvidia.com> (raw)
In-Reply-To: <20231016053411.3380-1-kkartik@nvidia.com>
Add ACPI support for Tegra194 & Tegra243 SoC's. This requires
following modifications to the probe when ACPI boot is used:
- Initialize soc data.
- Add nvmem lookups.
- Register soc device.
- use devm_clk_get_optional() instead of devm_clk_get() to get
fuse->clk, as fuse clocks are not required when using ACPI boot.
Also, drop '__init' keyword for tegra_soc_device_register() as this is also
used by tegra_fuse_probe() and use dev_err_probe() wherever applicable.
Signed-off-by: Kartik <kkartik@nvidia.com>
---
v4 -> v5:
* Fix build warnings seen with tegra_fuse_acpi_match when
CONFIG_ACPI is disabled.
v3 -> v4:
* Use dev_fwnode() to dereference the fwnode.
* Add MODULE_DEVICE_TABLE for tegra_fuse_acpi_match.
* Moved tegra_fuse_acpi_match above tegra_fuse_driver i.e.,
close to the user of tegra_fuse_acpi_match.
* Moved the improvements made to fuse clk/rst get error handling
to separate patch.
* Moved ACPI related initialization after fuse->base is
initialized in tegra_fuse_probe(), as this triggers a warning
in tegra_fuse_read_early() which is called from
fuse->soc->init().
v2 -> v3:
* Updated commit message to specify changes related to inclusion
of dev_err_probe().
v1 -> v2:
* Updated ACPI ID table 'tegra_fuse_acpi_match'.
* Removed ',' after "{ /* sentinel */ }" in
'tegra_fuse_acpi_match'.
* Using same probe for ACPI and device-tree boot.
* Added code for required initialization when ACPI boot is used.
* Make clocks optional for ACPI.
* Use dev_err_probe() wherever applicable.
* Check if clock has been initialized only when device-tree
boot is used.
---
drivers/soc/tegra/fuse/fuse-tegra.c | 50 +++++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)
diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
index 9bab758a60f2..daf39f0e6d93 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
@@ -3,11 +3,13 @@
* 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>
#include <linux/init.h>
#include <linux/io.h>
+#include <linux/mod_devicetable.h>
#include <linux/nvmem-consumer.h>
#include <linux/nvmem-provider.h>
#include <linux/of.h>
@@ -152,6 +154,37 @@ static int tegra_fuse_probe(struct platform_device *pdev)
return PTR_ERR(fuse->base);
fuse->phys = res->start;
+ /* Initialize the soc data and lookups if using ACPI boot. */
+ if (is_acpi_node(dev_fwnode(&pdev->dev)) && !fuse->soc) {
+ u8 chip;
+
+ 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:
+ return dev_err_probe(&pdev->dev, -EINVAL, "Unsupported SoC: %02x\n", chip);
+ }
+
+ fuse->soc->init(fuse);
+ tegra_fuse_print_sku_info(&tegra_sku_info);
+ tegra_soc_device_register();
+
+ err = tegra_fuse_add_lookups(fuse);
+ if (err)
+ return dev_err_probe(&pdev->dev, err, "failed to add FUSE lookups\n");
+ }
+
fuse->clk = devm_clk_get(&pdev->dev, "fuse");
if (IS_ERR(fuse->clk))
return dev_err_probe(&pdev->dev, PTR_ERR(fuse->clk), "failed to get FUSE clock\n");
@@ -275,10 +308,17 @@ static const struct dev_pm_ops tegra_fuse_pm = {
SET_SYSTEM_SLEEP_PM_OPS(tegra_fuse_suspend, tegra_fuse_resume)
};
+static const struct acpi_device_id __maybe_unused tegra_fuse_acpi_match[] = {
+ { "NVDA200F" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(acpi, tegra_fuse_acpi_match);
+
static struct platform_driver tegra_fuse_driver = {
.driver = {
.name = "tegra-fuse",
.of_match_table = tegra_fuse_match,
+ .acpi_match_table = ACPI_PTR(tegra_fuse_acpi_match),
.pm = &tegra_fuse_pm,
.suppress_bind_attrs = true,
},
@@ -300,7 +340,13 @@ u32 __init tegra_fuse_read_early(unsigned int offset)
int tegra_fuse_readl(unsigned long offset, u32 *value)
{
- if (!fuse->read || !fuse->clk)
+ /*
+ * Wait for fuse->clk to be initialized if device-tree boot is used.
+ */
+ if (is_of_node(dev_fwnode(fuse->dev)) && !fuse->clk)
+ return -EPROBE_DEFER;
+
+ if (!fuse->read)
return -EPROBE_DEFER;
if (IS_ERR(fuse->clk))
@@ -383,7 +429,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-10-16 5:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 5:34 [PATCH v5 0/8] soc/tegra: fuse: Add ACPI support Kartik
2023-10-16 5:34 ` [PATCH v5 1/8] mm/util: Introduce kmemdup_array() Kartik
2023-10-16 19:49 ` Kees Cook
2023-10-16 5:34 ` [PATCH v5 2/8] soc/tegra: fuse: Use dev_err_probe for probe failures Kartik
2023-10-16 5:34 ` [PATCH v5 3/8] soc/tegra: fuse: Refactor resource mapping Kartik
2023-10-16 5:34 ` [PATCH v5 4/8] soc/tegra: fuse: Add tegra_acpi_init_apbmisc() Kartik
2023-10-16 5:41 ` Christophe JAILLET
2023-10-16 10:15 ` Kartik
2023-10-16 5:34 ` [PATCH v5 5/8] soc/tegra: fuse: Add function to add lookups Kartik
2023-10-16 5:34 ` [PATCH v5 6/8] soc/tegra: fuse: Add function to print SKU info Kartik
2023-10-16 5:34 ` Kartik [this message]
2023-10-16 5:34 ` [PATCH v5 8/8] soc/tegra: fuse: Add support for Tegra241 Kartik
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=20231016053411.3380-8-kkartik@nvidia.com \
--to=kkartik@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=andy@kernel.org \
--cc=arnd@arndb.de \
--cc=frank.li@vivo.com \
--cc=jonathanh@nvidia.com \
--cc=keescook@chromium.org \
--cc=linus.walleij@linaro.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-tegra@vger.kernel.org \
--cc=pdeschrijver@nvidia.com \
--cc=petlozup@nvidia.com \
--cc=pshete@nvidia.com \
--cc=robh@kernel.org \
--cc=stefank@nvidia.com \
--cc=thierry.reding@gmail.com \
--cc=ulf.hansson@linaro.org \
/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