blob: 2e5b888e6ca66b652dc0624e2265ae1c360a7428 [file] [log] [blame]
Mark A. Greer79c3c0b2009-04-15 12:38:58 -07001/*
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>
Mark A. Greerb9ab1272009-04-15 12:39:09 -070018#include <mach/cputype.h>
Mark A. Greer79c3c0b2009-04-15 12:38:58 -070019
Mark A. Greer66e0c392009-04-15 12:39:23 -070020#include "clock.h"
21
Mark A. Greer79c3c0b2009-04-15 12:38:58 -070022struct davinci_soc_info davinci_soc_info;
23EXPORT_SYMBOL(davinci_soc_info);
24
Mark A. Greerb9ab1272009-04-15 12:39:09 -070025static struct davinci_id * __init davinci_get_id(u32 jtag_id)
26{
27 int i;
28 struct davinci_id *dip;
29 u8 variant = (jtag_id & 0xf0000000) >> 28;
30 u16 part_no = (jtag_id & 0x0ffff000) >> 12;
31
32 for (i = 0, dip = davinci_soc_info.ids; i < davinci_soc_info.ids_num;
33 i++, dip++)
34 /* Don't care about the manufacturer right now */
35 if ((dip->part_no == part_no) && (dip->variant == variant))
36 return dip;
37
38 return NULL;
39}
40
Mark A. Greer79c3c0b2009-04-15 12:38:58 -070041void __init davinci_common_init(struct davinci_soc_info *soc_info)
42{
43 int ret;
Mark A. Greerb9ab1272009-04-15 12:39:09 -070044 struct davinci_id *dip;
Mark A. Greer79c3c0b2009-04-15 12:38:58 -070045
46 if (!soc_info) {
47 ret = -EINVAL;
48 goto err;
49 }
50
51 memcpy(&davinci_soc_info, soc_info, sizeof(struct davinci_soc_info));
52
53 if (davinci_soc_info.io_desc && (davinci_soc_info.io_desc_num > 0))
54 iotable_init(davinci_soc_info.io_desc,
55 davinci_soc_info.io_desc_num);
56
57 /*
58 * Normally devicemaps_init() would flush caches and tlb after
59 * mdesc->map_io(), but we must also do it here because of the CPU
60 * revision check below.
61 */
62 local_flush_tlb_all();
63 flush_cache_all();
64
65 /*
66 * We want to check CPU revision early for cpu_is_xxxx() macros.
67 * IO space mapping must be initialized before we can do that.
68 */
Mark A. Greerb9ab1272009-04-15 12:39:09 -070069 davinci_soc_info.jtag_id = __raw_readl(davinci_soc_info.jtag_id_base);
70
71 dip = davinci_get_id(davinci_soc_info.jtag_id);
72 if (!dip) {
73 ret = -EINVAL;
74 goto err;
75 }
76
77 davinci_soc_info.cpu_id = dip->cpu_id;
78 pr_info("DaVinci %s variant 0x%x\n", dip->name, dip->variant);
Mark A. Greer79c3c0b2009-04-15 12:38:58 -070079
Mark A. Greer66e0c392009-04-15 12:39:23 -070080 if (davinci_soc_info.cpu_clks) {
81 ret = davinci_clk_init(davinci_soc_info.cpu_clks);
82
83 if (ret != 0)
84 goto err;
85 }
86
Mark A. Greer79c3c0b2009-04-15 12:38:58 -070087 return;
88
89err:
90 pr_err("davinci_common_init: SoC Initialization failed\n");
91}