[Arm64-baikalm] [PATCH] clk-bm1000: initialize early enough

Alexey Sheplyakov asheplyakov на basealt.ru
Вт Июл 19 16:24:19 MSK 2022


Most of BE-M1000 devices (PCI-E, VDU, etc) need clocks, hence
register clock (non-ACPI) driver as early as possible, so other
devices (PCI-E, VDU) can be probed without extra delays.
Note that ACPI version of the driver already gets registered
early enough (via device initcall).
Amongst other things this patch reduces the boot time from
~ 80 seconds to ~ 30 seconds (when rootfs is on the NVME drive).

---
 src/kernel/drivers/clk/baikal/clk-bm1000.c | 46 ++++++----------------
 1 file changed, 12 insertions(+), 34 deletions(-)

diff --git a/src/kernel/drivers/clk/baikal/clk-bm1000.c b/src/kernel/drivers/clk/baikal/clk-bm1000.c
index 4cff5fc4a..c5f894768 100644
--- a/src/kernel/drivers/clk/baikal/clk-bm1000.c
+++ b/src/kernel/drivers/clk/baikal/clk-bm1000.c
@@ -226,13 +226,12 @@ static const struct clk_ops baikal_clk_ops = {
 	.round_rate  = baikal_clk_round_rate
 };
 
-static int baikal_clk_probe(struct platform_device *pdev)
+static int baikal_clk_probe(struct device_node *node)
 {
 	struct clk_init_data init;
 	struct clk_init_data *init_ch;
 	struct baikal_clk_cmu *cmu;
 	struct baikal_clk_cmu **cmu_ch;
-	struct device_node *node = pdev->dev.of_node;
 
 	struct clk *clk;
 	struct clk_onecell_data *clk_ch;
@@ -349,16 +348,10 @@ static int baikal_clk_probe(struct platform_device *pdev)
 			i++;
 		}
 
-		return of_clk_add_provider(pdev->dev.of_node, of_clk_src_onecell_get, clk_ch);
+		return of_clk_add_provider(node, of_clk_src_onecell_get, clk_ch);
 	}
 
-	return of_clk_add_provider(pdev->dev.of_node, of_clk_src_simple_get, clk);
-}
-
-static int baikal_clk_remove(struct platform_device *pdev)
-{
-	of_clk_del_provider(pdev->dev.of_node);
-	return 0;
+	return of_clk_add_provider(node, of_clk_src_simple_get, clk);
 }
 
 #ifdef CONFIG_ACPI
@@ -695,28 +688,13 @@ static int __init baikal_acpi_clk_driver_init(void)
 device_initcall(baikal_acpi_clk_driver_init);
 #endif
 
-static const struct of_device_id baikal_clk_of_match[] = {
-	{ .compatible = "baikal,bm1000-cmu" },
-
-	/*
-	 * TODO: "baikal,cmu" is legacy.
-	 *        Use "baikal,bm1000-cmu" for future development.
-	 */
-	{ .compatible = "baikal,cmu" },
-	{ /* sentinel */ }
-};
-
-static struct platform_driver bm1000_cmu_driver = {
-	.probe	= baikal_clk_probe,
-	.remove	= baikal_clk_remove,
-	.driver	= {
-		.name = "bm1000-cmu",
-		.of_match_table = baikal_clk_of_match
+static void __init baikal_clk_init(struct device_node *np) {
+	int err;
+	err = baikal_clk_probe(np);
+	if (err) {
+		panic("%s: failed to probe clock %pOF: %d\n", __func__, np, err);
+	} else {
+		pr_info("%s: successfully probed %pOF\n", __func__, np);
 	}
-};
-module_platform_driver(bm1000_cmu_driver);
-
-MODULE_DESCRIPTION("Baikal BE-M1000 clock driver");
-MODULE_AUTHOR("Ekaterina Skachko <ekaterina.skachko at baikalelectronics.ru>");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:bm1000-cmu");
+}
+CLK_OF_DECLARE_DRIVER(bm1000_cmu_driver, "baikal,bm1000-cmu", baikal_clk_init);
-- 
2.32.0



Подробная информация о списке рассылки Arm64-baikalm