ARM: rockchip: rk3036: add initial support
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rockchip / rk3036.c
1 /*
2  * Device Tree support for Rockchip RK3036
3  *
4  * Copyright (C) 2014 ROCKCHIP, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  */
16
17 #include <linux/clk-provider.h>
18 #include <linux/clocksource.h>
19 #include <linux/cpuidle.h>
20 #include <linux/delay.h>
21 #include <linux/init.h>
22 #include <linux/irqchip.h>
23 #include <linux/kernel.h>
24 #include <linux/of_address.h>
25 #include <linux/of_platform.h>
26 #include <linux/rockchip/common.h>
27 #include <linux/rockchip/cpu.h>
28 #include <linux/rockchip/cru.h>
29 #include <linux/rockchip/dvfs.h>
30 #include <linux/rockchip/grf.h>
31 #include <linux/rockchip/iomap.h>
32 #include <linux/rockchip/pmu.h>
33 #include <asm/cpuidle.h>
34 #include <asm/cputype.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37 #include "cpu_axi.h"
38 #include "loader.h"
39 #define CPU 3036
40 #include "sram.h"
41 #include "pm.h"
42
43 #define RK3036_DEVICE(name) \
44         { \
45                 .virtual        = (unsigned long) RK_##name##_VIRT, \
46                 .pfn            = __phys_to_pfn(RK3036_##name##_PHYS), \
47                 .length         = RK3036_##name##_SIZE, \
48                 .type           = MT_DEVICE, \
49         }
50
51
52 #define RK3036_TIMER5_VIRT (RK_TIMER_VIRT + 0xa0)
53
54 static const char * const rk3036_dt_compat[] __initconst = {
55         "rockchip,rk3036",
56         NULL,
57 };
58
59 static struct map_desc rk3036_io_desc[] __initdata = {
60         RK3036_DEVICE(TIMER),
61 };
62
63 static void __init rk3036_dt_map_io(void)
64 {
65         rockchip_soc_id = ROCKCHIP_SOC_RK3036;
66
67         iotable_init(rk3036_io_desc, ARRAY_SIZE(rk3036_io_desc));
68
69         /* enable timer5 for core */
70         writel_relaxed(0, RK3036_TIMER5_VIRT + 0x10);
71         dsb();
72         writel_relaxed(0xFFFFFFFF, RK3036_TIMER5_VIRT + 0x00);
73         writel_relaxed(0xFFFFFFFF, RK3036_TIMER5_VIRT + 0x04);
74         dsb();
75         writel_relaxed(1, RK3036_TIMER5_VIRT + 0x10);
76         dsb();
77 }
78
79 static void __init rk3036_dt_init_timer(void)
80 {
81         clocksource_of_init();
82 }
83
84 static void __init rk3036_reserve(void)
85 {
86 }
87
88 static void __init rk3036_init_late(void)
89 {
90 }
91
92 static void rk3036_restart(char mode, const char *cmd)
93 {
94 }
95
96 DT_MACHINE_START(RK3036_DT, "Rockchip RK3036")
97         .dt_compat      = rk3036_dt_compat,
98         .smp            = smp_ops(rockchip_smp_ops),
99         .reserve        = rk3036_reserve,
100         .map_io         = rk3036_dt_map_io,
101         .init_time      = rk3036_dt_init_timer,
102         .init_late      = rk3036_init_late,
103         .restart        = rk3036_restart,
104 MACHINE_END