^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Code commons to all DaVinci SoCs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Author: Mark A. Greer <mgreer@mvista.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * 2009 (c) MontaVista Software, Inc. This file is licensed under
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * the terms of the GNU General Public License version 2. This program
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * is licensed "as is" without any warranty of any kind, whether express
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * or implied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/etherdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/davinci_emac.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/dma-mapping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/tlb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/mach/map.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <mach/common.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <mach/cputype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct davinci_soc_info davinci_soc_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) EXPORT_SYMBOL(davinci_soc_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static int __init davinci_init_id(struct davinci_soc_info *soc_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct davinci_id *dip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) u8 variant;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) u16 part_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) void __iomem *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) base = ioremap(soc_info->jtag_id_reg, SZ_4K);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) if (!base) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) pr_err("Unable to map JTAG ID register\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) soc_info->jtag_id = __raw_readl(base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) iounmap(base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) variant = (soc_info->jtag_id & 0xf0000000) >> 28;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) part_no = (soc_info->jtag_id & 0x0ffff000) >> 12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) for (i = 0, dip = soc_info->ids; i < soc_info->ids_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) i++, dip++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* Don't care about the manufacturer right now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) if ((dip->part_no == part_no) && (dip->variant == variant)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) soc_info->cpu_id = dip->cpu_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) pr_info("DaVinci %s variant 0x%x\n", dip->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) dip->variant);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) pr_err("Unknown DaVinci JTAG ID 0x%x\n", soc_info->jtag_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) void __init davinci_common_init(const struct davinci_soc_info *soc_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) if (!soc_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) memcpy(&davinci_soc_info, soc_info, sizeof(struct davinci_soc_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (davinci_soc_info.io_desc && (davinci_soc_info.io_desc_num > 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) iotable_init(davinci_soc_info.io_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) davinci_soc_info.io_desc_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * Normally devicemaps_init() would flush caches and tlb after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * mdesc->map_io(), but we must also do it here because of the CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * revision check below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) local_flush_tlb_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) flush_cache_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * We want to check CPU revision early for cpu_is_xxxx() macros.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * IO space mapping must be initialized before we can do that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) ret = davinci_init_id(&davinci_soc_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) panic("davinci_common_init: SoC Initialization failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) void __init davinci_init_late(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) davinci_cpufreq_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }