xref: /linux/arch/arm/mach-mediatek/mediatek.c (revision a43379dddf1ba14b6a9d50d95175117bbdf52ed2)
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>
199821e545SMatthias Brugger #include <linux/of.h>
209821e545SMatthias Brugger #include <linux/clk-provider.h>
219821e545SMatthias Brugger #include <linux/clocksource.h>
229821e545SMatthias Brugger 
239821e545SMatthias Brugger 
249821e545SMatthias Brugger #define GPT6_CON_MT65xx 0x10008060
259821e545SMatthias Brugger #define GPT_ENABLE      0x31
269821e545SMatthias Brugger 
279821e545SMatthias Brugger static void __init mediatek_timer_init(void)
289821e545SMatthias Brugger {
299821e545SMatthias Brugger 	void __iomem *gpt_base;
309821e545SMatthias Brugger 
319821e545SMatthias Brugger 	if (of_machine_is_compatible("mediatek,mt6589") ||
32601bac76SJohn Crispin 	    of_machine_is_compatible("mediatek,mt7623") ||
339821e545SMatthias Brugger 	    of_machine_is_compatible("mediatek,mt8135") ||
349821e545SMatthias Brugger 	    of_machine_is_compatible("mediatek,mt8127")) {
359821e545SMatthias Brugger 		/* turn on GPT6 which ungates arch timer clocks */
369821e545SMatthias Brugger 		gpt_base = ioremap(GPT6_CON_MT65xx, 0x04);
379821e545SMatthias Brugger 
389821e545SMatthias Brugger 		/* enable clock and set to free-run */
399821e545SMatthias Brugger 		writel(GPT_ENABLE, gpt_base);
409821e545SMatthias Brugger 		iounmap(gpt_base);
419821e545SMatthias Brugger 	}
429821e545SMatthias Brugger 
439821e545SMatthias Brugger 	of_clk_init(NULL);
44ba5d08c0SDaniel Lezcano 	timer_probe();
459821e545SMatthias Brugger };
46f682a218SMatthias Brugger 
47f682a218SMatthias Brugger static const char * const mediatek_board_dt_compat[] = {
4874d25721SErin Lo 	"mediatek,mt2701",
49f682a218SMatthias Brugger 	"mediatek,mt6589",
504542172eSHoward Chen 	"mediatek,mt6592",
5131ac0d69SJohn Crispin 	"mediatek,mt7623",
52*a43379ddSRyder Lee 	"mediatek,mt7629",
531ccd653cSJoe.C 	"mediatek,mt8127",
540c3fb203SJoe.C 	"mediatek,mt8135",
55f682a218SMatthias Brugger 	NULL,
56f682a218SMatthias Brugger };
57f682a218SMatthias Brugger 
58f682a218SMatthias Brugger DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
59f682a218SMatthias Brugger 	.dt_compat	= mediatek_board_dt_compat,
609821e545SMatthias Brugger 	.init_time	= mediatek_timer_init,
61f682a218SMatthias Brugger MACHINE_END
62