memory: tegra: Make per-SoC setup more generic
authorThierry Reding <treding@nvidia.com>
Wed, 2 Jun 2021 16:32:55 +0000 (18:32 +0200)
committerKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Thu, 3 Jun 2021 19:49:41 +0000 (21:49 +0200)
The current per-SoC setup code runs at a fairly arbitrary point during
probe, thereby making it less flexible for other SoC generations. Move
the call around slightly (after only the very basic, common setup that
applies to all SoC generations has been performed), which will allow
it to be used for other implementations.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20210602163302.120041-6-thierry.reding@gmail.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
drivers/memory/tegra/mc.c
drivers/memory/tegra/tegra20.c
include/soc/tegra/mc.h

index a3b7ba33b7f90c8a719decd6ee536154335dc1f4..ea2142ba720a09666e2a8d21781a09ba726bc8b6 100644 (file)
@@ -784,6 +784,14 @@ static int tegra_mc_probe(struct platform_device *pdev)
                return PTR_ERR(mc->clk);
        }
 
+       mc->debugfs.root = debugfs_create_dir("mc", NULL);
+
+       if (mc->soc->ops && mc->soc->ops->probe) {
+               err = mc->soc->ops->probe(mc);
+               if (err < 0)
+                       return err;
+       }
+
 #ifdef CONFIG_ARCH_TEGRA_2x_SOC
        if (mc->soc == &tegra20_mc_soc) {
                isr = tegra20_mc_irq;
@@ -827,15 +835,6 @@ static int tegra_mc_probe(struct platform_device *pdev)
                return err;
        }
 
-       mc->debugfs.root = debugfs_create_dir("mc", NULL);
-
-       if (mc->soc->ops && mc->soc->ops->init) {
-               err = mc->soc->ops->init(mc);
-               if (err < 0)
-                       dev_err(&pdev->dev, "failed to initialize SoC driver: %d\n",
-                               err);
-       }
-
        err = tegra_mc_reset_setup(mc);
        if (err < 0)
                dev_err(&pdev->dev, "failed to register reset controller: %d\n",
index a3335ad20f4dce81d9dacfbb66943d2f88f96f92..2c86c0d70d59f0faee500ed635af4fdccc2228a6 100644 (file)
@@ -679,7 +679,7 @@ static int tegra20_mc_stats_show(struct seq_file *s, void *unused)
        return 0;
 }
 
-static int tegra20_mc_init(struct tegra_mc *mc)
+static int tegra20_mc_probe(struct tegra_mc *mc)
 {
        debugfs_create_devm_seqfile(mc->dev, "stats", mc->debugfs.root,
                                    tegra20_mc_stats_show);
@@ -714,7 +714,7 @@ static int tegra20_mc_resume(struct tegra_mc *mc)
 }
 
 static const struct tegra_mc_ops tegra20_mc_ops = {
-       .init = tegra20_mc_init,
+       .probe = tegra20_mc_probe,
        .suspend = tegra20_mc_suspend,
        .resume = tegra20_mc_resume,
 };
index 7c49f75087c3e562f2cbc64ef6c1175a49572745..00d16c356db8425d36cc00fac2852613101a3116 100644 (file)
@@ -170,7 +170,11 @@ struct tegra_mc_icc_ops {
 };
 
 struct tegra_mc_ops {
-       int (*init)(struct tegra_mc *mc);
+       /*
+        * @probe: Callback to set up SoC-specific bits of the memory controller. This is called
+        * after basic, common set up that is done by the SoC-agnostic bits.
+        */
+       int (*probe)(struct tegra_mc *mc);
        int (*suspend)(struct tegra_mc *mc);
        int (*resume)(struct tegra_mc *mc);
 };