Skip to contentSkip to conversation

soc/tegra: fuse: Add ACPI support

PATCH Superseded Kartik 2 participants 12 messages Sep 7, 2023 – Oct 11, 2023 Tegra architecture support

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Kartik

author
#0 lore raw

v3 cover soc/tegra: fuse: Add ACPI support

This series of patches add ACPI support for Tegra194 and Tegra234 in Tegra fuse and apbmisc drivers. It also adds support for Tegra241 which uses ACPI boot.

Kartik (6):
soc/tegra: fuse: Refactor resource mapping soc/tegra: fuse: Add tegra_acpi_init_apbmisc() soc/tegra: fuse: Add function to add lookups soc/tegra: fuse: Add function to print SKU info soc/tegra: fuse: Add ACPI support for Tegra194 and Tegra234 soc/tegra: fuse: Add support for Tegra241

 drivers/soc/tegra/Kconfig              |   5 ++
 drivers/soc/tegra/fuse/fuse-tegra.c    | 119 +++++++++++++++++++------
 drivers/soc/tegra/fuse/fuse-tegra30.c  |  21 +++++
 drivers/soc/tegra/fuse/fuse.h          |   5 ++
 drivers/soc/tegra/fuse/tegra-apbmisc.c | 110 +++++++++++++++++++----
 include/soc/tegra/fuse.h               |   1 +
 6 files changed, 217 insertions(+), 44 deletions(-)

---
v2 -> v3:
* Minor changes in following patches:
soc/tegra: fuse: Add tegra_acpi_init_apbmisc() soc/tegra: fuse: Add ACPI support for Tegra194 and Tegra234

v1 -> v2:
* Used '--patience' while formatting patches.
* Added "soc/tegra: fuse: Refactor resource mapping" to share the common code between tegra_init_apbmisc() and tegra_acpi_init_apbmisc() functions.
* Dropped "soc/tegra: fuse: Add function to register nvmem" as ACPI and device-tree boot are sharing the same probe. So, no need to refactor the code here.
---

Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v3 1/6 soc/tegra: fuse: Refactor resource mapping

To prepare for adding ACPI support to the tegra-apbmisc driver, relocate the code responsible for mapping memory resources from the function ‘tegra_init_apbmisc’ to the function ‘tegra_init_apbmisc_resources.’ This adjustment will allow the code to be shared between ‘tegra_init_apbmisc’ and the upcoming ‘tegra_acpi_init_apbmisc’ function.

---
 drivers/soc/tegra/fuse/tegra-apbmisc.c | 37 +++++++++++++++-----------
 1 file changed, 21 insertions(+), 16 deletions(-)
drivers/soc/tegra/fuse/tegra-apbmisc.c +21 -16
index da970f3dbf35..06c1b3a2c7ec 100644
@@ -160,9 +160,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_resources(struct resource *apbmisc,
+					 struct resource *straps)
 {
 	void __iomem *strapping_base;
+
+	apbmisc_base = ioremap(apbmisc->start, resource_size(apbmisc));
+	if (apbmisc_base)
+		chipid = readl_relaxed(apbmisc_base + 4);
+	else
+		pr_err("failed to map APBMISC registers\n");
+
+	strapping_base = ioremap(straps->start, resource_size(straps));
+	if (strapping_base) {
+		strapping = readl_relaxed(strapping_base);
+		iounmap(strapping_base);
+	} else {
+		pr_err("failed to map strapping options registers\n");
+	}
+}
+
+void __init tegra_init_apbmisc(void)
+{
 	struct resource apbmisc, straps;
 	struct device_node *np;
 
@@ -219,21 +238,7 @@ 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_resources(&apbmisc, &straps);
 	long_ram_code = of_property_read_bool(np, "nvidia,long-ram-code");
 
 put:
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v3 1/6] soc/tegra: fuse: Refactor resource mapping

Quoted 6 lines · Kartik

To prepare for adding ACPI support to the tegra-apbmisc driver, relocate the code responsible for mapping memory resources from the function ‘tegra_init_apbmisc’ to the function ‘tegra_init_apbmisc_resources.’ This adjustment will allow the code to be shared between ‘tegra_init_apbmisc’ and the upcoming ‘tegra_acpi_init_apbmisc’ function.

...

drivers/soc/tegra/fuse/tegra-apbmisc.c void __init tegra_init_revision(void)

Quoted 8 lines
drivers/soc/tegra/fuse/tegra-apbmisc.c +5 -1
-void __init tegra_init_apbmisc(void)
+static void tegra_init_apbmisc_resources(struct resource *apbmisc,
+					 struct resource *straps)
 {
 
+}
+
+void __init tegra_init_apbmisc(void)

Looks like the patches can be improved by using --patience when you format patches before sending.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#3 lore raw

PATCH v3 2/6 soc/tegra: fuse: Add tegra_acpi_init_apbmisc()

In reply to Kartik

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.

---
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(+)
drivers/soc/tegra/fuse/fuse.h +1 -0
index 90f23be73894..a41e9f85281a 100644
@@ -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);
drivers/soc/tegra/fuse/tegra-apbmisc.c +72 -0

90 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#4 lore raw

PATCH v3 3/6 soc/tegra: fuse: Add function to add lookups

In reply to Kartik

Add helper function tegra_fuse_add_lookups() to register Tegra fuse nvmem lookups. So, this can be shared between tegra_fuse_init() and ACPI probe, which is to be introduced later.

---
v1 -> v2:
* Use size_mul to calculate lookups array size.

---
 drivers/soc/tegra/fuse/fuse-tegra.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)
drivers/soc/tegra/fuse/fuse-tegra.c +23 -6
index a2c28f493a75..821bb485ec45 100644
@@ -113,6 +113,24 @@ static void tegra_fuse_restore(void *base)
 	fuse->clk = NULL;
 }
 
+static int tegra_fuse_add_lookups(struct tegra_fuse *fuse)
+{
+	size_t size;
+
+	if (!fuse->soc->lookups)
+		return 0;
+
+	size = size_mul(sizeof(*fuse->lookups), fuse->soc->num_lookups);
+
+	fuse->lookups = kmemdup(fuse->soc->lookups, size, GFP_KERNEL);
+	if (!fuse->lookups)
+		return -ENOMEM;
+
+	nvmem_add_cell_lookups(fuse->lookups, fuse->soc->num_lookups);
+
+	return 0;
+}
+
 static int tegra_fuse_probe(struct platform_device *pdev)
 {
 	void __iomem *base = fuse->base;
@@ -407,6 +425,7 @@ static int __init tegra_init_fuse(void)
 	const struct of_device_id *match;
 	struct device_node *np;
 	struct resource regs;
+	int err;
 
 	tegra_init_apbmisc();
 
@@ -504,12 +523,10 @@ static int __init tegra_init_fuse(void)
 	pr_debug("Tegra CPU Speedo ID %d, SoC Speedo ID %d\n",
 		 tegra_sku_info.cpu_speedo_id, tegra_sku_info.soc_speedo_id);
 
-	if (fuse->soc->lookups) {
-		size_t size = sizeof(*fuse->lookups) * fuse->soc->num_lookups;
-
-		fuse->lookups = kmemdup(fuse->soc->lookups, size, GFP_KERNEL);
-		if (fuse->lookups)
-			nvmem_add_cell_lookups(fuse->lookups, fuse->soc->num_lookups);
+	err = tegra_fuse_add_lookups(fuse);
+	if (err) {
+		pr_err("failed to add FUSE lookups\n");
+		return err;
 	}
 
 	return 0;
Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH v3 3/6] soc/tegra: fuse: Add function to add lookups

Quoted 3 lines · Kartik

Add helper function tegra_fuse_add_lookups() to register Tegra fuse nvmem lookups. So, this can be shared between tegra_fuse_init() and ACPI probe, which is to be introduced later.

...

drivers/soc/tegra/fuse/fuse-tegra.c static void tegra_fuse_restore(void *base) · line 127

Quoted 12 lines
drivers/soc/tegra/fuse/fuse-tegra.c +11 -0
+static int tegra_fuse_add_lookups(struct tegra_fuse *fuse)
+{
+	size_t size;
+
+	if (!fuse->soc->lookups)
+		return 0;
 
+	size = size_mul(sizeof(*fuse->lookups), fuse->soc->num_lookups);
+
+	fuse->lookups = kmemdup(fuse->soc->lookups, size, GFP_KERNEL);
+	if (!fuse->lookups)
+		return -ENOMEM;

Why not introducing kmemdup_array()?

Quoted 4 lines
drivers/soc/tegra/fuse/fuse-tegra.c +4 -0
+	nvmem_add_cell_lookups(fuse->lookups, fuse->soc->num_lookups);
+
+	return 0;
+}

...

drivers/soc/tegra/fuse/fuse-tegra.c static int __init tegra_init_fuse(void) · line 528

Quoted 3 lines
drivers/soc/tegra/fuse/fuse-tegra.c +3 -0
+	err = tegra_fuse_add_lookups(fuse);
+	if (err) {
+		pr_err("failed to add FUSE lookups\n");

Why pr_err() and not dev_err()?

drivers/soc/tegra/fuse/fuse-tegra.c static int __init tegra_init_fuse(void) · line 532

Quoted 4 lines
drivers/soc/tegra/fuse/fuse-tegra.c +1 -0
+		return err;
 	}
 
 	return 0;

These four lines can be just shortened to

	return err;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#6 lore raw

Re: [PATCH v3 3/6] soc/tegra: fuse: Add function to add lookups

Quoted 14 lines · Andy Shevchenko
Quoted 3 lines · Kartik

Add helper function tegra_fuse_add_lookups() to register Tegra fuse nvmem lookups. So, this can be shared between tegra_fuse_init() and ACPI probe, which is to be introduced later.

...

Quoted 6 lines
drivers/soc/tegra/fuse/fuse-tegra.c +6 -0
+static int tegra_fuse_add_lookups(struct tegra_fuse *fuse)
+{
+	size_t size;
+
+	if (!fuse->soc->lookups)
+		return 0;
Quoted 7 lines

drivers/soc/tegra/fuse/fuse-tegra.c static void tegra_fuse_restore(void *base) · line 127

Quoted 5 lines
drivers/soc/tegra/fuse/fuse-tegra.c +5 -0
+	size = size_mul(sizeof(*fuse->lookups), fuse->soc->num_lookups);
+
+	fuse->lookups = kmemdup(fuse->soc->lookups, size, GFP_KERNEL);
+	if (!fuse->lookups)
+		return -ENOMEM;

Why not introducing kmemdup_array()?

Introduced this in v4.

Quoted 8 lines
Quoted 5 lines
drivers/soc/tegra/fuse/fuse-tegra.c +4 -0
+	nvmem_add_cell_lookups(fuse->lookups, fuse->soc->num_lookups);
+
+	return 0;
+}

...

Quoted 5 lines

drivers/soc/tegra/fuse/fuse-tegra.c static int __init tegra_init_fuse(void) · line 528

Quoted 3 lines
drivers/soc/tegra/fuse/fuse-tegra.c +3 -0
+	err = tegra_fuse_add_lookups(fuse);
+	if (err) {
+		pr_err("failed to add FUSE lookups\n");

Why pr_err() and not dev_err()?

This is called before tegra_fuse_probe in device-tree boot hence the reason behing using pr_err instead of dev_err.

Quoted 10 lines

drivers/soc/tegra/fuse/fuse-tegra.c static int __init tegra_init_fuse(void) · line 532

Quoted 5 lines
drivers/soc/tegra/fuse/fuse-tegra.c +1 -0
+		return err;
 	}
 
 	return 0;

These four lines can be just shortened to

	return err;

Updated this in v4.

Quoted 3 lines
Signature · 2 lines
With Best Regards,
Andy Shevchenko

Regards,
Kartik

author
#7 lore raw

PATCH v3 4/6 soc/tegra: fuse: Add function to print SKU info

In reply to Kartik

Add helper function tegra_fuse_print_sku_info() to print Tegra SKU information. So, it can be shared between tegra_fuse_init() and ACPI probe which is to be introduced later.

---
v1 -> v2:
* Renamed tegra_fuse_pr_sku_info() as
tegra_fuse_print_sku_info().

---
 drivers/soc/tegra/fuse/fuse-tegra.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/soc/tegra/fuse/fuse-tegra.c +11 -6
index 821bb485ec45..64f7001823ce 100644
@@ -113,6 +113,16 @@ static void tegra_fuse_restore(void *base)
 	fuse->clk = NULL;
 }
 
+static void tegra_fuse_print_sku_info(struct tegra_sku_info *tegra_sku_info)
+{
+	pr_info("Tegra Revision: %s SKU: %d CPU Process: %d SoC Process: %d\n",
+		tegra_revision_name[tegra_sku_info->revision],
+		tegra_sku_info->sku_id, tegra_sku_info->cpu_process_id,
+		tegra_sku_info->soc_process_id);
+	pr_debug("Tegra CPU Speedo ID %d, SoC Speedo ID %d\n",
+		tegra_sku_info->cpu_speedo_id, tegra_sku_info->soc_speedo_id);
+}
+
 static int tegra_fuse_add_lookups(struct tegra_fuse *fuse)
 {
 	size_t size;
@@ -516,12 +526,7 @@ static int __init tegra_init_fuse(void)
 
 	fuse->soc->init(fuse);
 
-	pr_info("Tegra Revision: %s SKU: %d CPU Process: %d SoC Process: %d\n",
-		tegra_revision_name[tegra_sku_info.revision],
-		tegra_sku_info.sku_id, tegra_sku_info.cpu_process_id,
-		tegra_sku_info.soc_process_id);
-	pr_debug("Tegra CPU Speedo ID %d, SoC Speedo ID %d\n",
-		 tegra_sku_info.cpu_speedo_id, tegra_sku_info.soc_speedo_id);
+	tegra_fuse_print_sku_info(&tegra_sku_info);
 
 	err = tegra_fuse_add_lookups(fuse);
 	if (err) {
Signature · 1 line
2.34.1
author
#8 lore raw

PATCH v3 5/6 soc/tegra: fuse: Add ACPI support for Tegra194 and Tegra234

In reply to Kartik

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.

---
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 | 68 ++++++++++++++++++++++-------
 1 file changed, 52 insertions(+), 16 deletions(-)
drivers/soc/tegra/fuse/fuse-tegra.c +52 -16
index 64f7001823ce..f35f9651a653 100644
@@ -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>
@@ -94,6 +96,11 @@ static const struct of_device_id tegra_fuse_match[] = {
 	{ /* sentinel */ }
 };
 
+static const struct acpi_device_id tegra_fuse_acpi_match[] = {
+	{ "NVDA200F" },
+	{ /* sentinel */ }
+};
+
 static int tegra_fuse_read(void *priv, unsigned int offset, void *value,
 			   size_t bytes)
 {
@@ -148,6 +155,37 @@ static int tegra_fuse_probe(struct platform_device *pdev)
 	struct resource *res;
 	int err;
 
+	/* Initialize the soc data and lookups if using ACPI boot. */
+	if (is_acpi_node(pdev->dev.fwnode) && !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");
+	}
+
 	err = devm_add_action(&pdev->dev, tegra_fuse_restore, (void __force *)base);
 	if (err)
 		return err;
@@ -158,14 +196,9 @@ static int tegra_fuse_probe(struct platform_device *pdev)
 		return PTR_ERR(fuse->base);
 	fuse->phys = res->start;
 
-	fuse->clk = devm_clk_get(&pdev->dev, "fuse");
-	if (IS_ERR(fuse->clk)) {
-		if (PTR_ERR(fuse->clk) != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "failed to get FUSE clock: %ld",
-				PTR_ERR(fuse->clk));
-
-		return PTR_ERR(fuse->clk);
-	}
+	fuse->clk = devm_clk_get_optional(&pdev->dev, "fuse");
+	if (IS_ERR(fuse->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(fuse->clk), "failed to get FUSE clock\n");
 
 	platform_set_drvdata(pdev, fuse);
 	fuse->dev = &pdev->dev;
@@ -207,12 +240,8 @@ static int tegra_fuse_probe(struct platform_device *pdev)
 	}
 
 	fuse->rst = devm_reset_control_get_optional(&pdev->dev, "fuse");
-	if (IS_ERR(fuse->rst)) {
-		err = PTR_ERR(fuse->rst);
-		dev_err(&pdev->dev, "failed to get FUSE reset: %pe\n",
-			fuse->rst);
-		return err;
-	}
+	if (IS_ERR(fuse->rst))
+		return dev_err_probe(&pdev->dev, PTR_ERR(fuse->rst), "failed to get FUSE reset");
 
 	/*
 	 * FUSE clock is enabled at a boot time, hence this resume/suspend
@@ -294,6 +323,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,
 	},
@@ -315,7 +345,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(fuse->dev->fwnode) && !fuse->clk)
+		return -EPROBE_DEFER;
+
+	if (!fuse->read)
 		return -EPROBE_DEFER;
 
 	if (IS_ERR(fuse->clk))
@@ -398,7 +434,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;
Signature · 1 line
2.34.1
#9 lore raw

Re: [PATCH v3 5/6] soc/tegra: fuse: Add ACPI support for Tegra194 and Tegra234

Quoted 10 lines · Kartik

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.

...

drivers/soc/tegra/fuse/fuse-tegra.c static const struct of_device_id tegra_fuse_match[] = { · line 102

Quoted 4 lines
drivers/soc/tegra/fuse/fuse-tegra.c +4 -0
+static const struct acpi_device_id tegra_fuse_acpi_match[] = {
+	{ "NVDA200F" },
+	{ /* sentinel */ }
+};

Where is NODULE_DEVICE_TABLE() for it? And why it's located here and not at the its first user's location?

...

drivers/soc/tegra/fuse/fuse-tegra.c static int tegra_fuse_probe(struct platform_device *pdev) · line 159

Quoted 1 line
drivers/soc/tegra/fuse/fuse-tegra.c +1 -0
+	if (is_acpi_node(pdev->dev.fwnode) && !fuse->soc) {

We do not dereference fwnode in struct device, use dev_fwnode() for that.

...

drivers/soc/tegra/fuse/fuse-tegra.c static int tegra_fuse_probe(struct platform_device *pdev)

Quoted 3 lines
drivers/soc/tegra/fuse/fuse-tegra.c +2 -0
+		return dev_err_probe(&pdev->dev, PTR_ERR(fuse->clk), "failed to get FUSE clock\n");
 
+		return dev_err_probe(&pdev->dev, PTR_ERR(fuse->rst), "failed to get FUSE reset");

This requires a separate patch.

...

drivers/soc/tegra/fuse/fuse-tegra.c u32 __init tegra_fuse_read_early(unsigned int offset)

Quoted 5 lines
drivers/soc/tegra/fuse/fuse-tegra.c +4 -0
+	/*
+	 * Wait for fuse->clk to be initialized if device-tree boot is used.
+	 */
 
+	if (is_of_node(fuse->dev->fwnode) && !fuse->clk)

dev_fwnode()

The second check is questionable. If you get it NULL, it won't ever appear. Did I miss anything?

Quoted 1 line
drivers/soc/tegra/fuse/fuse-tegra.c +1 -0
+		return -EPROBE_DEFER;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#10 lore raw

Re: [PATCH v3 5/6] soc/tegra: fuse: Add ACPI support for Tegra194 and Tegra234

Quoted 14 lines · Andy Shevchenko
Quoted 10 lines · Kartik

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.

...

Quoted 7 lines

drivers/soc/tegra/fuse/fuse-tegra.c static const struct of_device_id tegra_fuse_match[] = { · line 102

Quoted 4 lines
drivers/soc/tegra/fuse/fuse-tegra.c +4 -0
+static const struct acpi_device_id tegra_fuse_acpi_match[] = {
+	{ "NVDA200F" },
+	{ /* sentinel */ }
+};

Where is NODULE_DEVICE_TABLE() for it? And why it's located here and not at the its first user's location?

Fixed this in v4.

Quoted 9 lines

...

drivers/soc/tegra/fuse/fuse-tegra.c static int tegra_fuse_probe(struct platform_device *pdev) · line 159

Quoted 1 line
drivers/soc/tegra/fuse/fuse-tegra.c +1 -0
+	if (is_acpi_node(pdev->dev.fwnode) && !fuse->soc) {

We do not dereference fwnode in struct device, use dev_fwnode() for that.

...

Fixed this in v4.

Quoted 6 lines

drivers/soc/tegra/fuse/fuse-tegra.c static int tegra_fuse_probe(struct platform_device *pdev)

Quoted 3 lines
drivers/soc/tegra/fuse/fuse-tegra.c +2 -0
+		return dev_err_probe(&pdev->dev, PTR_ERR(fuse->clk), "failed to get FUSE clock\n");
 
+		return dev_err_probe(&pdev->dev, PTR_ERR(fuse->rst), "failed to get FUSE reset");

This requires a separate patch.

Pushed a separate patch in v4 of this series.

Quoted 6 lines

...

Quoted 3 lines
drivers/soc/tegra/fuse/fuse-tegra.c +3 -0
+	/*
+	 * Wait for fuse->clk to be initialized if device-tree boot is used.
+	 */
Quoted 7 lines

drivers/soc/tegra/fuse/fuse-tegra.c u32 __init tegra_fuse_read_early(unsigned int offset) · line 351

Quoted 1 line
drivers/soc/tegra/fuse/fuse-tegra.c +1 -0
+	if (is_of_node(fuse->dev->fwnode) && !fuse->clk)

dev_fwnode()

The second check is questionable. If you get it NULL, it won't ever appear. Did I miss anything?

If tegra_fuse_readl is called before Tegra fuse driver is probed, then fuse->clk will NULL. Hence, this is required here.

Quoted 5 lines
Quoted 1 line
drivers/soc/tegra/fuse/fuse-tegra.c +1 -0
+		return -EPROBE_DEFER;
Signature · 2 lines
With Best Regards,
Andy Shevchenko

Regards,
Kartik

author
#11 lore raw

PATCH v3 6/6 soc/tegra: fuse: Add support for Tegra241

In reply to Kartik

Add support for Tegra241 which use ACPI boot.

---
v1 -> v2:
* Removed few entries from tegra241_fuse_soc which were initilized as NULL or 0.

---
 drivers/soc/tegra/Kconfig              |  5 +++++
 drivers/soc/tegra/fuse/fuse-tegra.c    |  5 +++++
 drivers/soc/tegra/fuse/fuse-tegra30.c  | 21 +++++++++++++++++++++
 drivers/soc/tegra/fuse/fuse.h          |  4 ++++
 drivers/soc/tegra/fuse/tegra-apbmisc.c |  1 +
 include/soc/tegra/fuse.h               |  1 +
 6 files changed, 37 insertions(+)
drivers/soc/tegra/Kconfig +5 -0
index 6f3098822969..5f5d9d663fef 100644
@@ -133,6 +133,11 @@ config ARCH_TEGRA_234_SOC
 	help
 	  Enable support for the NVIDIA Tegra234 SoC.
 
+config ARCH_TEGRA_241_SOC
+	bool "NVIDIA Tegra241 SoC"
+	help
+	  Enable support for the NVIDIA Tegra241 SoC.
+
 endif
 endif
 
drivers/soc/tegra/fuse/fuse-tegra.c +5 -0
index f35f9651a653..eb11465e8092 100644
@@ -172,6 +172,11 @@ static int tegra_fuse_probe(struct platform_device *pdev)
 		case TEGRA234:
 			fuse->soc = &tegra234_fuse_soc;
 			break;
+#endif
+#if defined(CONFIG_ARCH_TEGRA_241_SOC)
+		case TEGRA241:
+			fuse->soc = &tegra241_fuse_soc;
+			break;
 #endif
 		default:
 			return dev_err_probe(&pdev->dev, -EINVAL, "Unsupported SoC: %02x\n", chip);
drivers/soc/tegra/fuse/fuse-tegra30.c +20 -0
index e94d46372a63..34fcc23a6449 100644
@@ -678,3 +678,23 @@ const struct tegra_fuse_soc tegra234_fuse_soc = {
 	.clk_suspend_on = false,
 };
 #endif
+
+#if defined(CONFIG_ARCH_TEGRA_241_SOC)
+static const struct tegra_fuse_info tegra241_fuse_info = {
+	.read = tegra30_fuse_read,
+	.size = 0x16008,
+	.spare = 0xcf0,
+};
+
+static const struct nvmem_keepout tegra241_fuse_keepouts[] = {
+	{ .start = 0xc, .end = 0x1600c }
+};
+
+const struct tegra_fuse_soc tegra241_fuse_soc = {
+	.init = tegra30_fuse_init,
+	.info = &tegra241_fuse_info,
+	.keepouts = tegra241_fuse_keepouts,
+	.num_keepouts = ARRAY_SIZE(tegra241_fuse_keepouts),
+	.soc_attr_group = &tegra194_soc_attr_group,
+};
+#endif
drivers/soc/tegra/fuse/fuse.h +4 -0
index a41e9f85281a..f3b705327c20 100644
@@ -136,4 +136,8 @@ extern const struct tegra_fuse_soc tegra194_fuse_soc;
 extern const struct tegra_fuse_soc tegra234_fuse_soc;
 #endif
 
+#ifdef CONFIG_ARCH_TEGRA_241_SOC
+extern const struct tegra_fuse_soc tegra241_fuse_soc;
+#endif
+
 #endif
drivers/soc/tegra/fuse/tegra-apbmisc.c +1 -0
index e2ca93de6c1f..c72bdb3e4e2c 100644
@@ -64,6 +64,7 @@ bool tegra_is_silicon(void)
 	switch (tegra_get_chip_id()) {
 	case TEGRA194:
 	case TEGRA234:
+	case TEGRA241:
 	case TEGRA264:
 		if (tegra_get_platform() == 0)
 			return true;
include/soc/tegra/fuse.h +1 -0
index 3a513be50243..8f421b9f7585 100644
@@ -17,6 +17,7 @@
 #define TEGRA186	0x18
 #define TEGRA194	0x19
 #define TEGRA234	0x23
+#define TEGRA241	0x24
 #define TEGRA264	0x26
 
 #define TEGRA_FUSE_SKU_CALIB_0	0xf0
Signature · 1 line
2.34.1