9a5486f5519c8ade2032a3c4c6024fbb8d7476c6
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-davinci / common.c
1 /*
2  * Code commons to all DaVinci SoCs.
3  *
4  * Author: Mark A. Greer <mgreer@mvista.com>
5  *
6  * 2009 (c) MontaVista Software, Inc. This file is licensed under
7  * the terms of the GNU General Public License version 2. This program
8  * is licensed "as is" without any warranty of any kind, whether express
9  * or implied.
10  */
11 #include <linux/module.h>
12 #include <linux/io.h>
13
14 #include <asm/tlb.h>
15 #include <asm/mach/map.h>
16
17 #include <mach/common.h>
18
19 struct davinci_soc_info davinci_soc_info;
20 EXPORT_SYMBOL(davinci_soc_info);
21
22 void __init davinci_common_init(struct davinci_soc_info *soc_info)
23 {
24         int ret;
25
26         if (!soc_info) {
27                 ret = -EINVAL;
28                 goto err;
29         }
30
31         memcpy(&davinci_soc_info, soc_info, sizeof(struct davinci_soc_info));
32
33         if (davinci_soc_info.io_desc && (davinci_soc_info.io_desc_num > 0))
34                 iotable_init(davinci_soc_info.io_desc,
35                                 davinci_soc_info.io_desc_num);
36
37         /*
38          * Normally devicemaps_init() would flush caches and tlb after
39          * mdesc->map_io(), but we must also do it here because of the CPU
40          * revision check below.
41          */
42         local_flush_tlb_all();
43         flush_cache_all();
44
45         /*
46          * We want to check CPU revision early for cpu_is_xxxx() macros.
47          * IO space mapping must be initialized before we can do that.
48          */
49         davinci_check_revision();
50
51         return;
52
53 err:
54         pr_err("davinci_common_init: SoC Initialization failed\n");
55 }