xref: /linux/arch/arm/mach-mediatek/mediatek.c (revision 22c55fb9eb92395d999b8404d73e58540d11bdd8)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Device Tree support for Mediatek SoCs
4  *
5  * Copyright (c) 2014 MundoReader S.L.
6  * Author: Matthias Brugger <matthias.bgg@gmail.com>
7  */
8 #include <linux/init.h>
9 #include <linux/io.h>
10 #include <asm/mach/arch.h>
11 #include <linux/of.h>
12 #include <linux/of_clk.h>
13 #include <linux/clocksource.h>
14 
15 
16 #define GPT6_CON_MT65xx 0x10008060
17 #define GPT_ENABLE      0x31
18 
19 static void __init mediatek_timer_init(void)
20 {
21 	void __iomem *gpt_base;
22 
23 	if (of_machine_is_compatible("mediatek,mt6589") ||
24 	    of_machine_is_compatible("mediatek,mt7623") ||
25 	    of_machine_is_compatible("mediatek,mt8135") ||
26 	    of_machine_is_compatible("mediatek,mt8127")) {
27 		/* turn on GPT6 which ungates arch timer clocks */
28 		gpt_base = ioremap(GPT6_CON_MT65xx, 0x04);
29 
30 		/* enable clock and set to free-run */
31 		writel(GPT_ENABLE, gpt_base);
32 		iounmap(gpt_base);
33 	}
34 
35 	of_clk_init(NULL);
36 	timer_probe();
37 };
38 
39 static const char * const mediatek_board_dt_compat[] = {
40 	"mediatek,mt2701",
41 	"mediatek,mt6572",
42 	"mediatek,mt6589",
43 	"mediatek,mt6592",
44 	"mediatek,mt7623",
45 	"mediatek,mt7629",
46 	"mediatek,mt8127",
47 	"mediatek,mt8135",
48 	NULL,
49 };
50 
51 DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
52 	.dt_compat	= mediatek_board_dt_compat,
53 	.init_time	= mediatek_timer_init,
54 MACHINE_END
55