xref: /linux/arch/arm/mach-mediatek/mediatek.c (revision 9821e545c5e02ac28af7c595ce71d037a1f74dc9)
1f682a218SMatthias Brugger /*
2f682a218SMatthias Brugger  * Device Tree support for Mediatek SoCs
3f682a218SMatthias Brugger  *
4f682a218SMatthias Brugger  * Copyright (c) 2014 MundoReader S.L.
5f682a218SMatthias Brugger  * Author: Matthias Brugger <matthias.bgg@gmail.com>
6f682a218SMatthias Brugger  *
7f682a218SMatthias Brugger  * This program is free software; you can redistribute it and/or modify
8f682a218SMatthias Brugger  * it under the terms of the GNU General Public License as published by
9f682a218SMatthias Brugger  * the Free Software Foundation; either version 2 of the License, or
10f682a218SMatthias Brugger  * (at your option) any later version.
11f682a218SMatthias Brugger  *
12f682a218SMatthias Brugger  * This program is distributed in the hope that it will be useful,
13f682a218SMatthias Brugger  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14f682a218SMatthias Brugger  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15f682a218SMatthias Brugger  * GNU General Public License for more details.
16f682a218SMatthias Brugger  */
17f682a218SMatthias Brugger #include <linux/init.h>
18f682a218SMatthias Brugger #include <asm/mach/arch.h>
19*9821e545SMatthias Brugger #include <linux/of.h>
20*9821e545SMatthias Brugger #include <linux/clk-provider.h>
21*9821e545SMatthias Brugger #include <linux/clocksource.h>
22*9821e545SMatthias Brugger 
23*9821e545SMatthias Brugger 
24*9821e545SMatthias Brugger #define GPT6_CON_MT65xx 0x10008060
25*9821e545SMatthias Brugger #define GPT_ENABLE      0x31
26*9821e545SMatthias Brugger 
27*9821e545SMatthias Brugger static void __init mediatek_timer_init(void)
28*9821e545SMatthias Brugger {
29*9821e545SMatthias Brugger 	void __iomem *gpt_base;
30*9821e545SMatthias Brugger 
31*9821e545SMatthias Brugger 	if (of_machine_is_compatible("mediatek,mt6589") ||
32*9821e545SMatthias Brugger 	    of_machine_is_compatible("mediatek,mt8135") ||
33*9821e545SMatthias Brugger 	    of_machine_is_compatible("mediatek,mt8127")) {
34*9821e545SMatthias Brugger 		/* turn on GPT6 which ungates arch timer clocks */
35*9821e545SMatthias Brugger 		gpt_base = ioremap(GPT6_CON_MT65xx, 0x04);
36*9821e545SMatthias Brugger 
37*9821e545SMatthias Brugger 		/* enable clock and set to free-run */
38*9821e545SMatthias Brugger 		writel(GPT_ENABLE, gpt_base);
39*9821e545SMatthias Brugger 		iounmap(gpt_base);
40*9821e545SMatthias Brugger 	}
41*9821e545SMatthias Brugger 
42*9821e545SMatthias Brugger 	of_clk_init(NULL);
43*9821e545SMatthias Brugger 	clocksource_of_init();
44*9821e545SMatthias Brugger };
45f682a218SMatthias Brugger 
46f682a218SMatthias Brugger static const char * const mediatek_board_dt_compat[] = {
47f682a218SMatthias Brugger 	"mediatek,mt6589",
484542172eSHoward Chen 	"mediatek,mt6592",
491ccd653cSJoe.C 	"mediatek,mt8127",
500c3fb203SJoe.C 	"mediatek,mt8135",
51f682a218SMatthias Brugger 	NULL,
52f682a218SMatthias Brugger };
53f682a218SMatthias Brugger 
54f682a218SMatthias Brugger DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
55f682a218SMatthias Brugger 	.dt_compat	= mediatek_board_dt_compat,
56*9821e545SMatthias Brugger 	.init_time	= mediatek_timer_init,
57f682a218SMatthias Brugger MACHINE_END
58