kernel: update 4.1 to 4.1.13
[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 --- a/arch/arm/mach-mediatek/mediatek.c
17 +++ b/arch/arm/mach-mediatek/mediatek.c
18 @@ -16,6 +16,34 @@
19 */
20 #include <linux/init.h>
21 #include <asm/mach/arch.h>
22 +#include <linux/of.h>
23 +#include <linux/clk-provider.h>
24 +#include <linux/clocksource.h>
25 +
26 +
27 +#define GPT6_CON_MT65xx 0x10008060
28 +#define GPT_ENABLE 0x31
29 +
30 +static void __init mediatek_timer_init(void)
31 +{
32 + void __iomem *gpt_base = 0;
33 +
34 + if (of_machine_is_compatible("mediatek,mt6589") ||
35 + of_machine_is_compatible("mediatek,mt8135") ||
36 + of_machine_is_compatible("mediatek,mt8127")) {
37 + /* turn on GPT6 which ungates arch timer clocks */
38 + gpt_base = ioremap(GPT6_CON_MT65xx, 0x04);
39 + }
40 +
41 + /* enabel clock and set to free-run */
42 + if (gpt_base) {
43 + writel(GPT_ENABLE, gpt_base);
44 + iounmap(gpt_base);
45 + }
46 +
47 + of_clk_init(NULL);
48 + clocksource_of_init();
49 +};
50
51 static const char * const mediatek_board_dt_compat[] = {
52 "mediatek,mt6589",
53 @@ -27,4 +55,5 @@ static const char * const mediatek_board
54
55 DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
56 .dt_compat = mediatek_board_dt_compat,
57 + .init_time = mediatek_timer_init,
58 MACHINE_END