powerpc/64s/exception: clean up system call entry
[linux-2.6-block.git] / arch / arm / mach-davinci / common.c
CommitLineData
79c3c0b7
MG
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>
b14dc0f9 13#include <linux/etherdevice.h>
8ee2bf9a 14#include <linux/davinci_emac.h>
fd24f903 15#include <linux/dma-mapping.h>
79c3c0b7
MG
16
17#include <asm/tlb.h>
18#include <asm/mach/map.h>
19
20#include <mach/common.h>
b9ab1279 21#include <mach/cputype.h>
79c3c0b7
MG
22
23struct davinci_soc_info davinci_soc_info;
24EXPORT_SYMBOL(davinci_soc_info);
25
3347db83 26static int __init davinci_init_id(struct davinci_soc_info *soc_info)
b9ab1279 27{
3347db83
CC
28 int i;
29 struct davinci_id *dip;
30 u8 variant;
31 u16 part_no;
32 void __iomem *base;
33
34 base = ioremap(soc_info->jtag_id_reg, SZ_4K);
35 if (!base) {
36 pr_err("Unable to map JTAG ID register\n");
37 return -ENOMEM;
38 }
39
40 soc_info->jtag_id = __raw_readl(base);
41 iounmap(base);
b9ab1279 42
3347db83
CC
43 variant = (soc_info->jtag_id & 0xf0000000) >> 28;
44 part_no = (soc_info->jtag_id & 0x0ffff000) >> 12;
45
46 for (i = 0, dip = soc_info->ids; i < soc_info->ids_num;
b9ab1279
MG
47 i++, dip++)
48 /* Don't care about the manufacturer right now */
3347db83
CC
49 if ((dip->part_no == part_no) && (dip->variant == variant)) {
50 soc_info->cpu_id = dip->cpu_id;
51 pr_info("DaVinci %s variant 0x%x\n", dip->name,
52 dip->variant);
53 return 0;
54 }
55
56 pr_err("Unknown DaVinci JTAG ID 0x%x\n", soc_info->jtag_id);
57 return -EINVAL;
b9ab1279
MG
58}
59
1a6d490b 60void __init davinci_common_init(const struct davinci_soc_info *soc_info)
79c3c0b7
MG
61{
62 int ret;
63
64 if (!soc_info) {
65 ret = -EINVAL;
66 goto err;
67 }
68
69 memcpy(&davinci_soc_info, soc_info, sizeof(struct davinci_soc_info));
70
71 if (davinci_soc_info.io_desc && (davinci_soc_info.io_desc_num > 0))
72 iotable_init(davinci_soc_info.io_desc,
73 davinci_soc_info.io_desc_num);
74
75 /*
76 * Normally devicemaps_init() would flush caches and tlb after
77 * mdesc->map_io(), but we must also do it here because of the CPU
78 * revision check below.
79 */
80 local_flush_tlb_all();
81 flush_cache_all();
82
83 /*
84 * We want to check CPU revision early for cpu_is_xxxx() macros.
85 * IO space mapping must be initialized before we can do that.
86 */
3347db83
CC
87 ret = davinci_init_id(&davinci_soc_info);
88 if (ret < 0)
b9ab1279 89 goto err;
79c3c0b7 90
66e0c399 91
79c3c0b7
MG
92 return;
93
94err:
69872e93 95 panic("davinci_common_init: SoC Initialization failed\n");
79c3c0b7 96}
3aa3e840
SG
97
98void __init davinci_init_late(void)
99{
100 davinci_cpufreq_init();
3aa3e840 101}