Skip to contentSkip to conversation

ARM: bcm2835: probe clock and sdram driver early

PATCH New kernel at martin.sperl.org 1 participant 3 messages May 20, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover ARM: bcm2835: probe clock and sdram driver early

From: Martin Sperl <[email protected]>

Probe the clock and sdram driver early during the boot process. This is done to minimize the risk that the PLLD_CORE0 or PLLD clocks get disabled by another driver.

Such a situation results in the SDRAM stopping to work, which we can trigger easily with current kernels when there are only a few clocks enabled.

Right now both drivers are registered with core_initcall. I am unsure if there is any link-ordering that could impact us - if such is the case we will need to move the priorities of one of the drivers slightly. Recommendations?

Note that this patchset requires the sdram memory driver patch to be applied first.

Martin Sperl (2):
clk: bcm2835: register clocks early
memory: bcm2835: enable driver early in the boot process

 drivers/clk/bcm/clk-bcm2835.c  | 18 +++++++++++++++---
 drivers/memory/bcm2835-sdram.c | 10 +++++++++-
 2 files changed, 24 insertions(+), 4 deletions(-)

--
2.1.4

#1 lore raw

PATCH 1/2 clk: bcm2835: register clocks early

From: Martin Sperl <[email protected]>

Register the clocks early during the boot process, so that special/critical clocks can get enabled early on in the boot process avoiding the risk of disabling a clock, pll_divider or pll when a claiming driver fails to install propperly - maybe it needs to defer.

---
 drivers/clk/bcm/clk-bcm2835.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/clk/bcm/clk-bcm2835.c +15 -3
index 085e521..6aaeab4 100644
@@ -1825,6 +1825,7 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
 	const struct bcm2835_clk_desc *desc;
 	const size_t asize = ARRAY_SIZE(clk_desc_array);
 	size_t i;
+	int err;
 
 	cprman = devm_kzalloc(dev,
 			      sizeof(*cprman) + asize * sizeof(*clks),
@@ -1855,8 +1856,15 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
 			clks[i] = desc->clk_register(cprman, desc->data);
 	}
 
-	return of_clk_add_provider(dev->of_node, of_clk_src_onecell_get,
-				   &cprman->onecell);
+	err = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get,
+				  &cprman->onecell);
+	if (err)
+		return err;
+
+	/* note that we have registered all the clocks */
+	dev_dbg(dev, "registered %d clocks\n", asize);
+
+	return 0;
 }
 
 static const struct of_device_id bcm2835_clk_of_match[] = {
@@ -1873,7 +1881,11 @@ static struct platform_driver bcm2835_clk_driver = {
 	.probe          = bcm2835_clk_probe,
 };
 
-builtin_platform_driver(bcm2835_clk_driver);
+static int __init __bcm2835_clk_driver_init(void)
+{
+	return platform_driver_register(&bcm2835_clk_driver);
+}
+core_initcall(__bcm2835_clk_driver_init);
 
 MODULE_AUTHOR("Eric Anholt <[email protected]>");
 MODULE_DESCRIPTION("BCM2835 clock driver");
Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/2 memory: bcm2835: enable driver early in the boot process

In reply to kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Enable the critical sdram-clocks early during the boot process, so that these clocks (and their PLLs) can not get disabled when a different driver disables its clocks again because it failed to probe propperly (maybe deferred).

---
 drivers/memory/bcm2835-sdram.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/memory/bcm2835-sdram.c +9 -1
index 9d8cce2..7b6406d 100644
@@ -431,6 +431,9 @@ static int bcm2835_sdram_probe(struct platform_device *pdev)
 	/* setup debugfs */
 	bcm2835_sdram_debugfs(pdev);
 
+	/* note that we have registered sdram */
+	dev_dbg(&pdev->dev, "registered sdram\n");
+
 	return 0;
 }
 
@@ -457,7 +460,12 @@ static struct platform_driver bcm2835_sdram_driver = {
 		.of_match_table = bcm2835_sdram_of_match_table,
 	},
 };
-module_platform_driver(bcm2835_sdram_driver);
+
+static int __init __bcm2835_sdram_driver_init(void)
+{
+	return platform_driver_register(&bcm2835_sdram_driver);
+}
+core_initcall_sync(__bcm2835_sdram_driver_init);
 
 MODULE_AUTHOR("Martin Sperl");
 MODULE_DESCRIPTION("sdram driver for bcm2835 chip");
Signature · 1 line
2.1.4