728792c2a84d03cc23734e14f2fef8f99c7500b1
[openwrt/staging/chunkeey.git] / target / linux / mediatek / patches / 0041-arm-mediatek-enable-gpt6-on-boot-up-to-make-arch-tim.patch
1 From eec99287ace37015ed313b4fc27ba205a158b66c Mon Sep 17 00:00:00 2001
2 From: Matthias Brugger <matthias.bgg@gmail.com>
3 Date: Fri, 1 May 2015 15:43:26 +0800
4 Subject: [PATCH 41/76] arm: mediatek: enable gpt6 on boot up to make arch
5 timer working
6
7 We enable GTP6 which ungates the arch timer clock.
8 In the future this should be done in the bootloader.
9
10 Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
11 Signed-off-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
12 ---
13 arch/arm/mach-mediatek/mediatek.c | 29 +++++++++++++++++++++++++++++
14 1 file changed, 29 insertions(+)
15
16 diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
17 index a954900..6b38d67 100644
18 --- a/arch/arm/mach-mediatek/mediatek.c
19 +++ b/arch/arm/mach-mediatek/mediatek.c
20 @@ -16,6 +16,34 @@
21 */
22 #include <linux/init.h>
23 #include <asm/mach/arch.h>
24 +#include <linux/of.h>
25 +#include <linux/clk-provider.h>
26 +#include <linux/clocksource.h>
27 +
28 +
29 +#define GPT6_CON_MT65xx 0x10008060
30 +#define GPT_ENABLE 0x31
31 +
32 +static void __init mediatek_timer_init(void)
33 +{
34 + void __iomem *gpt_base = 0;
35 +
36 + if (of_machine_is_compatible("mediatek,mt6589") ||
37 + of_machine_is_compatible("mediatek,mt8135") ||
38 + of_machine_is_compatible("mediatek,mt8127")) {
39 + /* turn on GPT6 which ungates arch timer clocks */
40 + gpt_base = ioremap(GPT6_CON_MT65xx, 0x04);
41 + }
42 +
43 + /* enabel clock and set to free-run */
44 + if (gpt_base) {
45 + writel(GPT_ENABLE, gpt_base);
46 + iounmap(gpt_base);
47 + }
48 +
49 + of_clk_init(NULL);
50 + clocksource_of_init();
51 +};
52
53 static const char * const mediatek_board_dt_compat[] = {
54 "mediatek,mt6589",
55 @@ -27,4 +55,5 @@ static const char * const mediatek_board_dt_compat[] = {
56
57 DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
58 .dt_compat = mediatek_board_dt_compat,
59 + .init_time = mediatek_timer_init,
60 MACHINE_END
61 --
62 1.7.10.4
63