Mark A. Greer | 79c3c0b | 2009-04-15 12:38:58 -0700 | [diff] [blame] | 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> |
| 13 | |
| 14 | #include <asm/tlb.h> |
| 15 | #include <asm/mach/map.h> |
| 16 | |
| 17 | #include <mach/common.h> |
Mark A. Greer | b9ab127 | 2009-04-15 12:39:09 -0700 | [diff] [blame] | 18 | #include <mach/cputype.h> |
Mark A. Greer | 79c3c0b | 2009-04-15 12:38:58 -0700 | [diff] [blame] | 19 | |
Mark A. Greer | 66e0c39 | 2009-04-15 12:39:23 -0700 | [diff] [blame] | 20 | #include "clock.h" |
| 21 | |
Mark A. Greer | 79c3c0b | 2009-04-15 12:38:58 -0700 | [diff] [blame] | 22 | struct davinci_soc_info davinci_soc_info; |
| 23 | EXPORT_SYMBOL(davinci_soc_info); |
| 24 | |
Mark A. Greer | 673dd36 | 2009-04-15 12:40:00 -0700 | [diff] [blame^] | 25 | void __iomem *davinci_intc_base; |
| 26 | |
Mark A. Greer | b9ab127 | 2009-04-15 12:39:09 -0700 | [diff] [blame] | 27 | static struct davinci_id * __init davinci_get_id(u32 jtag_id) |
| 28 | { |
| 29 | int i; |
| 30 | struct davinci_id *dip; |
| 31 | u8 variant = (jtag_id & 0xf0000000) >> 28; |
| 32 | u16 part_no = (jtag_id & 0x0ffff000) >> 12; |
| 33 | |
| 34 | for (i = 0, dip = davinci_soc_info.ids; i < davinci_soc_info.ids_num; |
| 35 | i++, dip++) |
| 36 | /* Don't care about the manufacturer right now */ |
| 37 | if ((dip->part_no == part_no) && (dip->variant == variant)) |
| 38 | return dip; |
| 39 | |
| 40 | return NULL; |
| 41 | } |
| 42 | |
Mark A. Greer | 79c3c0b | 2009-04-15 12:38:58 -0700 | [diff] [blame] | 43 | void __init davinci_common_init(struct davinci_soc_info *soc_info) |
| 44 | { |
| 45 | int ret; |
Mark A. Greer | b9ab127 | 2009-04-15 12:39:09 -0700 | [diff] [blame] | 46 | struct davinci_id *dip; |
Mark A. Greer | 79c3c0b | 2009-04-15 12:38:58 -0700 | [diff] [blame] | 47 | |
| 48 | if (!soc_info) { |
| 49 | ret = -EINVAL; |
| 50 | goto err; |
| 51 | } |
| 52 | |
| 53 | memcpy(&davinci_soc_info, soc_info, sizeof(struct davinci_soc_info)); |
| 54 | |
| 55 | if (davinci_soc_info.io_desc && (davinci_soc_info.io_desc_num > 0)) |
| 56 | iotable_init(davinci_soc_info.io_desc, |
| 57 | davinci_soc_info.io_desc_num); |
| 58 | |
| 59 | /* |
| 60 | * Normally devicemaps_init() would flush caches and tlb after |
| 61 | * mdesc->map_io(), but we must also do it here because of the CPU |
| 62 | * revision check below. |
| 63 | */ |
| 64 | local_flush_tlb_all(); |
| 65 | flush_cache_all(); |
| 66 | |
| 67 | /* |
| 68 | * We want to check CPU revision early for cpu_is_xxxx() macros. |
| 69 | * IO space mapping must be initialized before we can do that. |
| 70 | */ |
Mark A. Greer | b9ab127 | 2009-04-15 12:39:09 -0700 | [diff] [blame] | 71 | davinci_soc_info.jtag_id = __raw_readl(davinci_soc_info.jtag_id_base); |
| 72 | |
| 73 | dip = davinci_get_id(davinci_soc_info.jtag_id); |
| 74 | if (!dip) { |
| 75 | ret = -EINVAL; |
| 76 | goto err; |
| 77 | } |
| 78 | |
| 79 | davinci_soc_info.cpu_id = dip->cpu_id; |
| 80 | pr_info("DaVinci %s variant 0x%x\n", dip->name, dip->variant); |
Mark A. Greer | 79c3c0b | 2009-04-15 12:38:58 -0700 | [diff] [blame] | 81 | |
Mark A. Greer | 66e0c39 | 2009-04-15 12:39:23 -0700 | [diff] [blame] | 82 | if (davinci_soc_info.cpu_clks) { |
| 83 | ret = davinci_clk_init(davinci_soc_info.cpu_clks); |
| 84 | |
| 85 | if (ret != 0) |
| 86 | goto err; |
| 87 | } |
| 88 | |
Mark A. Greer | 673dd36 | 2009-04-15 12:40:00 -0700 | [diff] [blame^] | 89 | davinci_intc_base = davinci_soc_info.intc_base; |
Mark A. Greer | 79c3c0b | 2009-04-15 12:38:58 -0700 | [diff] [blame] | 90 | return; |
| 91 | |
| 92 | err: |
| 93 | pr_err("davinci_common_init: SoC Initialization failed\n"); |
| 94 | } |