2 * Code commons to all DaVinci SoCs.
4 * Author: Mark A. Greer <mgreer@mvista.com>
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
11 #include <linux/module.h>
13 #include <linux/etherdevice.h>
14 #include <linux/davinci_emac.h>
15 #include <linux/dma-mapping.h>
18 #include <asm/mach/map.h>
20 #include <mach/common.h>
21 #include <mach/cputype.h>
25 struct davinci_soc_info davinci_soc_info
;
26 EXPORT_SYMBOL(davinci_soc_info
);
28 void __iomem
*davinci_intc_base
;
29 int davinci_intc_type
;
31 void davinci_get_mac_addr(struct nvmem_device
*nvmem
, void *context
)
33 char *mac_addr
= davinci_soc_info
.emac_pdata
->mac_addr
;
34 off_t offset
= (off_t
)context
;
36 if (!IS_BUILTIN(CONFIG_NVMEM
)) {
37 pr_warn("Cannot read MAC addr from EEPROM without CONFIG_NVMEM\n");
41 /* Read MAC addr from EEPROM */
42 if (nvmem_device_read(nvmem
, offset
, ETH_ALEN
, mac_addr
) == ETH_ALEN
)
43 pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr
);
46 static int __init
davinci_init_id(struct davinci_soc_info
*soc_info
)
49 struct davinci_id
*dip
;
54 base
= ioremap(soc_info
->jtag_id_reg
, SZ_4K
);
56 pr_err("Unable to map JTAG ID register\n");
60 soc_info
->jtag_id
= __raw_readl(base
);
63 variant
= (soc_info
->jtag_id
& 0xf0000000) >> 28;
64 part_no
= (soc_info
->jtag_id
& 0x0ffff000) >> 12;
66 for (i
= 0, dip
= soc_info
->ids
; i
< soc_info
->ids_num
;
68 /* Don't care about the manufacturer right now */
69 if ((dip
->part_no
== part_no
) && (dip
->variant
== variant
)) {
70 soc_info
->cpu_id
= dip
->cpu_id
;
71 pr_info("DaVinci %s variant 0x%x\n", dip
->name
,
76 pr_err("Unknown DaVinci JTAG ID 0x%x\n", soc_info
->jtag_id
);
80 void __init
davinci_common_init(struct davinci_soc_info
*soc_info
)
89 memcpy(&davinci_soc_info
, soc_info
, sizeof(struct davinci_soc_info
));
91 if (davinci_soc_info
.io_desc
&& (davinci_soc_info
.io_desc_num
> 0))
92 iotable_init(davinci_soc_info
.io_desc
,
93 davinci_soc_info
.io_desc_num
);
96 * Normally devicemaps_init() would flush caches and tlb after
97 * mdesc->map_io(), but we must also do it here because of the CPU
98 * revision check below.
100 local_flush_tlb_all();
104 * We want to check CPU revision early for cpu_is_xxxx() macros.
105 * IO space mapping must be initialized before we can do that.
107 ret
= davinci_init_id(&davinci_soc_info
);
115 panic("davinci_common_init: SoC Initialization failed\n");
118 void __init
davinci_init_late(void)
120 davinci_cpufreq_init();
121 davinci_clk_disable_unused();