From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: kkartik@nvidia.com
Cc: akpm@linux-foundation.org, andy@kernel.org, arnd@arndb.de,
frank.li@vivo.com, jonathanh@nvidia.com, keescook@chromium.org,
linus.walleij@linaro.org, linux-hardening@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-tegra@vger.kernel.org, pdeschrijver@nvidia.com,
petlozup@nvidia.com, pshete@nvidia.com, robh@kernel.org,
stefank@nvidia.com, thierry.reding@gmail.com,
ulf.hansson@linaro.org
Subject: Re: [PATCH v5 4/8] soc/tegra: fuse: Add tegra_acpi_init_apbmisc()
Date: Mon, 16 Oct 2023 07:41:14 +0200 [thread overview]
Message-ID: <998767cb-1c70-45c2-91cc-858315be1a52@wanadoo.fr> (raw)
In-Reply-To: <20231016053411.3380-5-kkartik@nvidia.com>
Le 16/10/2023 à 07:34, Kartik a écrit :
> 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 <kkartik-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
> 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 <linux/acpi.h>
> #include <linux/export.h>
> #include <linux/io.h>
> #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
> #include <linux/of.h>
> #include <linux/of_address.h>
>
> @@ -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) {
Nit: Is the 'safe' version really needed here?
CJ
> + 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
next prev parent reply other threads:[~2023-10-16 5:41 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 [this message]
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 ` [PATCH v5 7/8] soc/tegra: fuse: Add ACPI support for Tegra194 and Tegra234 Kartik
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=998767cb-1c70-45c2-91cc-858315be1a52@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--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=kkartik@nvidia.com \
--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