Merge branch 'for-linus' of git://dev.laptop.org/users/cjb/mmc
[deliverable/linux.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>
79c3c0b7
MG
15
16#include <asm/tlb.h>
17#include <asm/mach/map.h>
18
19#include <mach/common.h>
b9ab1279 20#include <mach/cputype.h>
79c3c0b7 21
66e0c399
MG
22#include "clock.h"
23
79c3c0b7
MG
24struct davinci_soc_info davinci_soc_info;
25EXPORT_SYMBOL(davinci_soc_info);
26
673dd36f 27void __iomem *davinci_intc_base;
0b0c4c2a 28int davinci_intc_type;
673dd36f 29
b14dc0f9
MG
30void davinci_get_mac_addr(struct memory_accessor *mem_acc, void *context)
31{
32 char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
33 off_t offset = (off_t)context;
34
35 /* Read MAC addr from EEPROM */
36 if (mem_acc->read(mem_acc, mac_addr, offset, ETH_ALEN) == ETH_ALEN)
37 pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
38}
39
3347db83 40static int __init davinci_init_id(struct davinci_soc_info *soc_info)
b9ab1279 41{
3347db83
CC
42 int i;
43 struct davinci_id *dip;
44 u8 variant;
45 u16 part_no;
46 void __iomem *base;
47
48 base = ioremap(soc_info->jtag_id_reg, SZ_4K);
49 if (!base) {
50 pr_err("Unable to map JTAG ID register\n");
51 return -ENOMEM;
52 }
53
54 soc_info->jtag_id = __raw_readl(base);
55 iounmap(base);
b9ab1279 56
3347db83
CC
57 variant = (soc_info->jtag_id & 0xf0000000) >> 28;
58 part_no = (soc_info->jtag_id & 0x0ffff000) >> 12;
59
60 for (i = 0, dip = soc_info->ids; i < soc_info->ids_num;
b9ab1279
MG
61 i++, dip++)
62 /* Don't care about the manufacturer right now */
3347db83
CC
63 if ((dip->part_no == part_no) && (dip->variant == variant)) {
64 soc_info->cpu_id = dip->cpu_id;
65 pr_info("DaVinci %s variant 0x%x\n", dip->name,
66 dip->variant);
67 return 0;
68 }
69
70 pr_err("Unknown DaVinci JTAG ID 0x%x\n", soc_info->jtag_id);
71 return -EINVAL;
b9ab1279
MG
72}
73
79c3c0b7
MG
74void __init davinci_common_init(struct davinci_soc_info *soc_info)
75{
76 int ret;
77
78 if (!soc_info) {
79 ret = -EINVAL;
80 goto err;
81 }
82
83 memcpy(&davinci_soc_info, soc_info, sizeof(struct davinci_soc_info));
84
85 if (davinci_soc_info.io_desc && (davinci_soc_info.io_desc_num > 0))
86 iotable_init(davinci_soc_info.io_desc,
87 davinci_soc_info.io_desc_num);
88
89 /*
90 * Normally devicemaps_init() would flush caches and tlb after
91 * mdesc->map_io(), but we must also do it here because of the CPU
92 * revision check below.
93 */
94 local_flush_tlb_all();
95 flush_cache_all();
96
c78a5bc2
CC
97 if (!davinci_soc_info.reset)
98 davinci_soc_info.reset = davinci_watchdog_reset;
99
79c3c0b7
MG
100 /*
101 * We want to check CPU revision early for cpu_is_xxxx() macros.
102 * IO space mapping must be initialized before we can do that.
103 */
3347db83
CC
104 ret = davinci_init_id(&davinci_soc_info);
105 if (ret < 0)
b9ab1279 106 goto err;
79c3c0b7 107
66e0c399
MG
108 if (davinci_soc_info.cpu_clks) {
109 ret = davinci_clk_init(davinci_soc_info.cpu_clks);
110
111 if (ret != 0)
112 goto err;
113 }
114
79c3c0b7
MG
115 return;
116
117err:
69872e93 118 panic("davinci_common_init: SoC Initialization failed\n");
79c3c0b7 119}
This page took 0.292962 seconds and 5 git commands to generate.