ARM: rockchip: rk3228: implement function rk3228_restart
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rockchip / rk3126b.c
1 /*
2  * Copyright (C) 2014 ROCKCHIP, Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14
15 #include <linux/delay.h>
16 #include <linux/init.h>
17 #include <linux/kernel.h>
18 #include <linux/rockchip/common.h>
19 #include <linux/rockchip/cpu.h>
20 #include <linux/rockchip/cru.h>
21 #include <linux/rockchip/grf.h>
22 #include <linux/rockchip/iomap.h>
23 #include <linux/rockchip/pmu.h>
24 #include "rk3126b.h"
25 #define CPU 3126b
26 #include "sram.h"
27 #include "pm.h"
28 #include "pm-rk312x.c"
29
30 char PIE_DATA(sram_stack)[1024];
31 EXPORT_PIE_SYMBOL(DATA(sram_stack));
32
33 static int __init rk3126b_pie_init(void)
34 {
35         int err;
36
37         if (!soc_is_rk3126b())
38                 return 0;
39
40         err = rockchip_pie_init();
41         if (err)
42                 return err;
43
44         rockchip_pie_chunk = pie_load_sections(rockchip_sram_pool, rk3126b);
45         if (IS_ERR(rockchip_pie_chunk)) {
46                 err = PTR_ERR(rockchip_pie_chunk);
47                 pr_err("%s: failed to load section %d\n", __func__, err);
48                 rockchip_pie_chunk = NULL;
49                 return err;
50         }
51
52         rockchip_sram_virt = kern_to_pie(rockchip_pie_chunk, &__pie_common_start[0]);
53         rockchip_sram_stack = kern_to_pie(rockchip_pie_chunk, (char *)DATA(sram_stack) + sizeof(DATA(sram_stack)));
54
55         return 0;
56 }
57 arch_initcall(rk3126b_pie_init);
58
59 #ifdef CONFIG_PM
60 void __init rk3126b_init_suspend(void)
61 {
62         pr_info("%s\n", __func__);
63         rkpm_pie_init();
64         rk312x_suspend_init();
65 }
66 #endif
67
68 #include "ddr_rk3126b.c"
69 static int __init rk3126b_ddr_init(void)
70 {
71         if (!soc_is_rk3126b())
72                 return 0;
73
74         ddr_change_freq = _ddr_change_freq;
75         ddr_round_rate = _ddr_round_rate;
76         ddr_set_auto_self_refresh = _ddr_set_auto_self_refresh;
77         ddr_bandwidth_get = _ddr_bandwidth_get;
78         ddr_init(DDR3_DEFAULT, 0);
79
80         return 0;
81 }
82 arch_initcall_sync(rk3126b_ddr_init);