]> git.dujemihanovic.xyz Git - linux.git/commitdiff
DONOTMERGE: Enable AArch64 system timer properly
authorDuje Mihanović <duje.mihanovic@skole.hr>
Sun, 4 Sep 2022 15:20:43 +0000 (17:20 +0200)
committerDuje Mihanović <duje.mihanovic@skole.hr>
Tue, 1 Oct 2024 16:18:21 +0000 (18:18 +0200)
With this, an initramfs can be reached.

Long-term, this will be moved someplace such as U-Boot.

drivers/clk/mmp/clk-pxa1908-apbc.c

index a418b9f895c11eb1aed7b3a23ce9baf465f89162..6f71c46c272578be3764513eb9c9ca4e1adb0988 100644 (file)
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
+#include <asm/io.h>
 #include <linux/clk-provider.h>
 #include <linux/device.h>
 #include <linux/module.h>
@@ -30,6 +31,8 @@
 
 #define APBC_NR_CLKS           19
 
+#define APBC_COUNTER_CLK_SEL   0x64
+
 struct pxa1908_clk_unit {
        struct mmp_clk_unit unit;
        void __iomem *base;
@@ -108,6 +111,21 @@ static int pxa1908_apbc_probe(struct platform_device *pdev)
 
        pxa1908_apb_periph_clk_init(pxa_unit);
 
+       /* Assign a 26MHz clock to the ARM architected timer. */
+       int tmp = readl(pxa_unit->base + APBC_COUNTER_CLK_SEL);
+       if ((tmp >> 16) == 0x319) {
+               writel(tmp | 1, pxa_unit->base + APBC_COUNTER_CLK_SEL);
+       }
+
+       /* Enable the ARM architected timer. */
+       void __iomem *cnt_base = ioremap(0xd4101000, 0x1000);
+       if (!cnt_base)
+               pr_err("failed to map cnt register\n");
+       else {
+               writel(BIT(0) | BIT(1), cnt_base);
+               iounmap(cnt_base);
+       }
+
        return 0;
 }
 
@@ -124,7 +142,18 @@ static struct platform_driver pxa1908_apbc_driver = {
                .of_match_table = pxa1908_apbc_match_table
        }
 };
-module_platform_driver(pxa1908_apbc_driver);
+
+static int __init pxa1908_apbc_init(void)
+{
+       return platform_driver_register(&pxa1908_apbc_driver);
+}
+core_initcall(pxa1908_apbc_init);
+
+static void __exit pxa1908_apbc_exit(void)
+{
+       platform_driver_unregister(&pxa1908_apbc_driver);
+}
+module_exit(pxa1908_apbc_exit);
 
 MODULE_AUTHOR("Duje Mihanović <duje.mihanovic@skole.hr>");
 MODULE_DESCRIPTION("Marvell PXA1908 APBC Clock Driver");