Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
Mike Frysinger | 550d553 | 2008-02-02 15:55:37 +0800 | [diff] [blame] | 2 | * arch/blackfin/kernel/setup.c |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 3 | * |
Mike Frysinger | 550d553 | 2008-02-02 15:55:37 +0800 | [diff] [blame] | 4 | * Copyright 2004-2006 Analog Devices Inc. |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 5 | * |
Mike Frysinger | 550d553 | 2008-02-02 15:55:37 +0800 | [diff] [blame] | 6 | * Enter bugs at http://blackfin.uclinux.org/ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 7 | * |
Mike Frysinger | 550d553 | 2008-02-02 15:55:37 +0800 | [diff] [blame] | 8 | * Licensed under the GPL-2 or later. |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <linux/delay.h> |
| 12 | #include <linux/console.h> |
| 13 | #include <linux/bootmem.h> |
| 14 | #include <linux/seq_file.h> |
| 15 | #include <linux/cpu.h> |
Mike Frysinger | 259fea4 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 16 | #include <linux/mm.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 17 | #include <linux/module.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 18 | #include <linux/tty.h> |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 19 | #include <linux/pfn.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 20 | |
| 21 | #include <linux/ext2_fs.h> |
| 22 | #include <linux/cramfs_fs.h> |
| 23 | #include <linux/romfs_fs.h> |
| 24 | |
Robin Getz | 3bebca2 | 2007-10-10 23:55:26 +0800 | [diff] [blame] | 25 | #include <asm/cplb.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 26 | #include <asm/cacheflush.h> |
| 27 | #include <asm/blackfin.h> |
| 28 | #include <asm/cplbinit.h> |
Mike Frysinger | 1754a5d | 2007-11-23 11:28:11 +0800 | [diff] [blame] | 29 | #include <asm/div64.h> |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 30 | #include <asm/cpu.h> |
Bernd Schmidt | 7adfb58 | 2007-06-21 11:34:16 +0800 | [diff] [blame] | 31 | #include <asm/fixed_code.h> |
Robin Getz | ce3afa1 | 2007-10-09 17:28:36 +0800 | [diff] [blame] | 32 | #include <asm/early_printk.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 33 | |
Mike Frysinger | a9c59c2 | 2007-05-21 18:09:32 +0800 | [diff] [blame] | 34 | u16 _bfin_swrst; |
Mike Frysinger | d45118b | 2008-02-25 12:24:44 +0800 | [diff] [blame] | 35 | EXPORT_SYMBOL(_bfin_swrst); |
Mike Frysinger | a9c59c2 | 2007-05-21 18:09:32 +0800 | [diff] [blame] | 36 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 37 | unsigned long memory_start, memory_end, physical_mem_end; |
Mike Frysinger | 3132b58 | 2008-04-24 05:12:09 +0800 | [diff] [blame] | 38 | unsigned long _rambase, _ramstart, _ramend; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 39 | unsigned long reserved_mem_dcache_on; |
| 40 | unsigned long reserved_mem_icache_on; |
| 41 | EXPORT_SYMBOL(memory_start); |
| 42 | EXPORT_SYMBOL(memory_end); |
| 43 | EXPORT_SYMBOL(physical_mem_end); |
| 44 | EXPORT_SYMBOL(_ramend); |
Vitja Makarov | 58c35bd | 2008-10-13 15:23:56 +0800 | [diff] [blame] | 45 | EXPORT_SYMBOL(reserved_mem_dcache_on); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 46 | |
| 47 | #ifdef CONFIG_MTD_UCLINUX |
| 48 | unsigned long memory_mtd_end, memory_mtd_start, mtd_size; |
| 49 | unsigned long _ebss; |
| 50 | EXPORT_SYMBOL(memory_mtd_end); |
| 51 | EXPORT_SYMBOL(memory_mtd_start); |
| 52 | EXPORT_SYMBOL(mtd_size); |
| 53 | #endif |
| 54 | |
Mike Frysinger | 5e10b4a | 2007-06-11 16:44:09 +0800 | [diff] [blame] | 55 | char __initdata command_line[COMMAND_LINE_SIZE]; |
Robin Getz | 0c7a6b2 | 2008-10-08 16:27:12 +0800 | [diff] [blame] | 56 | void __initdata *init_retx, *init_saved_retx, *init_saved_seqstat, |
| 57 | *init_saved_icplb_fault_addr, *init_saved_dcplb_fault_addr; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 58 | |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 59 | /* boot memmap, for parsing "memmap=" */ |
| 60 | #define BFIN_MEMMAP_MAX 128 /* number of entries in bfin_memmap */ |
| 61 | #define BFIN_MEMMAP_RAM 1 |
| 62 | #define BFIN_MEMMAP_RESERVED 2 |
Mike Frysinger | af4c7d4 | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 63 | static struct bfin_memmap { |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 64 | int nr_map; |
| 65 | struct bfin_memmap_entry { |
| 66 | unsigned long long addr; /* start of memory segment */ |
| 67 | unsigned long long size; |
| 68 | unsigned long type; |
| 69 | } map[BFIN_MEMMAP_MAX]; |
| 70 | } bfin_memmap __initdata; |
| 71 | |
| 72 | /* for memmap sanitization */ |
| 73 | struct change_member { |
| 74 | struct bfin_memmap_entry *pentry; /* pointer to original entry */ |
| 75 | unsigned long long addr; /* address for this change point */ |
| 76 | }; |
| 77 | static struct change_member change_point_list[2*BFIN_MEMMAP_MAX] __initdata; |
| 78 | static struct change_member *change_point[2*BFIN_MEMMAP_MAX] __initdata; |
| 79 | static struct bfin_memmap_entry *overlap_list[BFIN_MEMMAP_MAX] __initdata; |
| 80 | static struct bfin_memmap_entry new_map[BFIN_MEMMAP_MAX] __initdata; |
| 81 | |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 82 | DEFINE_PER_CPU(struct blackfin_cpudata, cpu_data); |
| 83 | |
Mike Frysinger | 7f1e2f9 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 84 | static int early_init_clkin_hz(char *buf); |
| 85 | |
Robin Getz | 3bebca2 | 2007-10-10 23:55:26 +0800 | [diff] [blame] | 86 | #if defined(CONFIG_BFIN_DCACHE) || defined(CONFIG_BFIN_ICACHE) |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 87 | void __init generate_cplb_tables(void) |
| 88 | { |
| 89 | unsigned int cpu; |
| 90 | |
Bernd Schmidt | dbdf20d | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 91 | generate_cplb_tables_all(); |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 92 | /* Generate per-CPU I&D CPLB tables */ |
| 93 | for (cpu = 0; cpu < num_possible_cpus(); ++cpu) |
| 94 | generate_cplb_tables_cpu(cpu); |
| 95 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 96 | #endif |
| 97 | |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 98 | void __cpuinit bfin_setup_caches(unsigned int cpu) |
| 99 | { |
Robin Getz | 3bebca2 | 2007-10-10 23:55:26 +0800 | [diff] [blame] | 100 | #ifdef CONFIG_BFIN_ICACHE |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 101 | bfin_icache_init(icplb_tbl[cpu]); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 102 | #endif |
| 103 | |
Robin Getz | 3bebca2 | 2007-10-10 23:55:26 +0800 | [diff] [blame] | 104 | #ifdef CONFIG_BFIN_DCACHE |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 105 | bfin_dcache_init(dcplb_tbl[cpu]); |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 106 | #endif |
| 107 | |
| 108 | /* |
| 109 | * In cache coherence emulation mode, we need to have the |
| 110 | * D-cache enabled before running any atomic operation which |
| 111 | * might invove cache invalidation (i.e. spinlock, rwlock). |
| 112 | * So printk's are deferred until then. |
| 113 | */ |
| 114 | #ifdef CONFIG_BFIN_ICACHE |
| 115 | printk(KERN_INFO "Instruction Cache Enabled for CPU%u\n", cpu); |
| 116 | #endif |
| 117 | #ifdef CONFIG_BFIN_DCACHE |
| 118 | printk(KERN_INFO "Data Cache Enabled for CPU%u" |
Robin Getz | 3bebca2 | 2007-10-10 23:55:26 +0800 | [diff] [blame] | 119 | # if defined CONFIG_BFIN_WB |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 120 | " (write-back)" |
Robin Getz | 3bebca2 | 2007-10-10 23:55:26 +0800 | [diff] [blame] | 121 | # elif defined CONFIG_BFIN_WT |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 122 | " (write-through)" |
| 123 | # endif |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 124 | "\n", cpu); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 125 | #endif |
| 126 | } |
| 127 | |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 128 | void __cpuinit bfin_setup_cpudata(unsigned int cpu) |
| 129 | { |
| 130 | struct blackfin_cpudata *cpudata = &per_cpu(cpu_data, cpu); |
| 131 | |
| 132 | cpudata->idle = current; |
| 133 | cpudata->loops_per_jiffy = loops_per_jiffy; |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 134 | cpudata->imemctl = bfin_read_IMEM_CONTROL(); |
| 135 | cpudata->dmemctl = bfin_read_DMEM_CONTROL(); |
| 136 | } |
| 137 | |
| 138 | void __init bfin_cache_init(void) |
| 139 | { |
| 140 | #if defined(CONFIG_BFIN_DCACHE) || defined(CONFIG_BFIN_ICACHE) |
| 141 | generate_cplb_tables(); |
| 142 | #endif |
| 143 | bfin_setup_caches(0); |
| 144 | } |
| 145 | |
Graf Yang | 5b04f27 | 2008-10-08 17:32:57 +0800 | [diff] [blame] | 146 | void __init bfin_relocate_l1_mem(void) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 147 | { |
| 148 | unsigned long l1_code_length; |
| 149 | unsigned long l1_data_a_length; |
| 150 | unsigned long l1_data_b_length; |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 151 | unsigned long l2_length; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 152 | |
Mike Frysinger | dd3dd38 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 153 | blackfin_dma_early_init(); |
| 154 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 155 | l1_code_length = _etext_l1 - _stext_l1; |
| 156 | if (l1_code_length > L1_CODE_LENGTH) |
Sonic Zhang | b85b82d | 2008-04-24 06:13:37 +0800 | [diff] [blame] | 157 | panic("L1 Instruction SRAM Overflow\n"); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 158 | /* cannot complain as printk is not available as yet. |
| 159 | * But we can continue booting and complain later! |
| 160 | */ |
| 161 | |
| 162 | /* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */ |
| 163 | dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length); |
| 164 | |
Mike Frysinger | 3b1f26a | 2008-10-27 18:21:43 +0800 | [diff] [blame] | 165 | l1_data_a_length = _sbss_l1 - _sdata_l1; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 166 | if (l1_data_a_length > L1_DATA_A_LENGTH) |
Sonic Zhang | b85b82d | 2008-04-24 06:13:37 +0800 | [diff] [blame] | 167 | panic("L1 Data SRAM Bank A Overflow\n"); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 168 | |
Mike Frysinger | 3b1f26a | 2008-10-27 18:21:43 +0800 | [diff] [blame] | 169 | /* Copy _sdata_l1 to _sbss_l1 to L1 data bank A SRAM */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 170 | dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length); |
| 171 | |
Mike Frysinger | 3b1f26a | 2008-10-27 18:21:43 +0800 | [diff] [blame] | 172 | l1_data_b_length = _sbss_b_l1 - _sdata_b_l1; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 173 | if (l1_data_b_length > L1_DATA_B_LENGTH) |
Sonic Zhang | b85b82d | 2008-04-24 06:13:37 +0800 | [diff] [blame] | 174 | panic("L1 Data SRAM Bank B Overflow\n"); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 175 | |
Mike Frysinger | 3b1f26a | 2008-10-27 18:21:43 +0800 | [diff] [blame] | 176 | /* Copy _sdata_b_l1 to _sbss_b_l1 to L1 data bank B SRAM */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 177 | dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length + |
| 178 | l1_data_a_length, l1_data_b_length); |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 179 | |
Mike Frysinger | 07aa7be | 2008-08-13 16:16:11 +0800 | [diff] [blame] | 180 | if (L2_LENGTH != 0) { |
Mike Frysinger | 3b1f26a | 2008-10-27 18:21:43 +0800 | [diff] [blame] | 181 | l2_length = _sbss_l2 - _stext_l2; |
Mike Frysinger | 07aa7be | 2008-08-13 16:16:11 +0800 | [diff] [blame] | 182 | if (l2_length > L2_LENGTH) |
| 183 | panic("L2 SRAM Overflow\n"); |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 184 | |
Mike Frysinger | 07aa7be | 2008-08-13 16:16:11 +0800 | [diff] [blame] | 185 | /* Copy _stext_l2 to _edata_l2 to L2 SRAM */ |
| 186 | dma_memcpy(_stext_l2, _l2_lma_start, l2_length); |
| 187 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 188 | } |
| 189 | |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 190 | /* add_memory_region to memmap */ |
| 191 | static void __init add_memory_region(unsigned long long start, |
| 192 | unsigned long long size, int type) |
| 193 | { |
| 194 | int i; |
| 195 | |
| 196 | i = bfin_memmap.nr_map; |
| 197 | |
| 198 | if (i == BFIN_MEMMAP_MAX) { |
| 199 | printk(KERN_ERR "Ooops! Too many entries in the memory map!\n"); |
| 200 | return; |
| 201 | } |
| 202 | |
| 203 | bfin_memmap.map[i].addr = start; |
| 204 | bfin_memmap.map[i].size = size; |
| 205 | bfin_memmap.map[i].type = type; |
| 206 | bfin_memmap.nr_map++; |
| 207 | } |
| 208 | |
| 209 | /* |
| 210 | * Sanitize the boot memmap, removing overlaps. |
| 211 | */ |
| 212 | static int __init sanitize_memmap(struct bfin_memmap_entry *map, int *pnr_map) |
| 213 | { |
| 214 | struct change_member *change_tmp; |
| 215 | unsigned long current_type, last_type; |
| 216 | unsigned long long last_addr; |
| 217 | int chgidx, still_changing; |
| 218 | int overlap_entries; |
| 219 | int new_entry; |
| 220 | int old_nr, new_nr, chg_nr; |
| 221 | int i; |
| 222 | |
| 223 | /* |
| 224 | Visually we're performing the following (1,2,3,4 = memory types) |
| 225 | |
| 226 | Sample memory map (w/overlaps): |
| 227 | ____22__________________ |
| 228 | ______________________4_ |
| 229 | ____1111________________ |
| 230 | _44_____________________ |
| 231 | 11111111________________ |
| 232 | ____________________33__ |
| 233 | ___________44___________ |
| 234 | __________33333_________ |
| 235 | ______________22________ |
| 236 | ___________________2222_ |
| 237 | _________111111111______ |
| 238 | _____________________11_ |
| 239 | _________________4______ |
| 240 | |
| 241 | Sanitized equivalent (no overlap): |
| 242 | 1_______________________ |
| 243 | _44_____________________ |
| 244 | ___1____________________ |
| 245 | ____22__________________ |
| 246 | ______11________________ |
| 247 | _________1______________ |
| 248 | __________3_____________ |
| 249 | ___________44___________ |
| 250 | _____________33_________ |
| 251 | _______________2________ |
| 252 | ________________1_______ |
| 253 | _________________4______ |
| 254 | ___________________2____ |
| 255 | ____________________33__ |
| 256 | ______________________4_ |
| 257 | */ |
| 258 | /* if there's only one memory region, don't bother */ |
| 259 | if (*pnr_map < 2) |
| 260 | return -1; |
| 261 | |
| 262 | old_nr = *pnr_map; |
| 263 | |
| 264 | /* bail out if we find any unreasonable addresses in memmap */ |
| 265 | for (i = 0; i < old_nr; i++) |
| 266 | if (map[i].addr + map[i].size < map[i].addr) |
| 267 | return -1; |
| 268 | |
| 269 | /* create pointers for initial change-point information (for sorting) */ |
| 270 | for (i = 0; i < 2*old_nr; i++) |
| 271 | change_point[i] = &change_point_list[i]; |
| 272 | |
| 273 | /* record all known change-points (starting and ending addresses), |
| 274 | omitting those that are for empty memory regions */ |
| 275 | chgidx = 0; |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 276 | for (i = 0; i < old_nr; i++) { |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 277 | if (map[i].size != 0) { |
| 278 | change_point[chgidx]->addr = map[i].addr; |
| 279 | change_point[chgidx++]->pentry = &map[i]; |
| 280 | change_point[chgidx]->addr = map[i].addr + map[i].size; |
| 281 | change_point[chgidx++]->pentry = &map[i]; |
| 282 | } |
| 283 | } |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 284 | chg_nr = chgidx; /* true number of change-points */ |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 285 | |
| 286 | /* sort change-point list by memory addresses (low -> high) */ |
| 287 | still_changing = 1; |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 288 | while (still_changing) { |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 289 | still_changing = 0; |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 290 | for (i = 1; i < chg_nr; i++) { |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 291 | /* if <current_addr> > <last_addr>, swap */ |
| 292 | /* or, if current=<start_addr> & last=<end_addr>, swap */ |
| 293 | if ((change_point[i]->addr < change_point[i-1]->addr) || |
| 294 | ((change_point[i]->addr == change_point[i-1]->addr) && |
| 295 | (change_point[i]->addr == change_point[i]->pentry->addr) && |
| 296 | (change_point[i-1]->addr != change_point[i-1]->pentry->addr)) |
| 297 | ) { |
| 298 | change_tmp = change_point[i]; |
| 299 | change_point[i] = change_point[i-1]; |
| 300 | change_point[i-1] = change_tmp; |
| 301 | still_changing = 1; |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | /* create a new memmap, removing overlaps */ |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 307 | overlap_entries = 0; /* number of entries in the overlap table */ |
| 308 | new_entry = 0; /* index for creating new memmap entries */ |
| 309 | last_type = 0; /* start with undefined memory type */ |
| 310 | last_addr = 0; /* start with 0 as last starting address */ |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 311 | /* loop through change-points, determining affect on the new memmap */ |
| 312 | for (chgidx = 0; chgidx < chg_nr; chgidx++) { |
| 313 | /* keep track of all overlapping memmap entries */ |
| 314 | if (change_point[chgidx]->addr == change_point[chgidx]->pentry->addr) { |
| 315 | /* add map entry to overlap list (> 1 entry implies an overlap) */ |
| 316 | overlap_list[overlap_entries++] = change_point[chgidx]->pentry; |
| 317 | } else { |
| 318 | /* remove entry from list (order independent, so swap with last) */ |
| 319 | for (i = 0; i < overlap_entries; i++) { |
| 320 | if (overlap_list[i] == change_point[chgidx]->pentry) |
| 321 | overlap_list[i] = overlap_list[overlap_entries-1]; |
| 322 | } |
| 323 | overlap_entries--; |
| 324 | } |
| 325 | /* if there are overlapping entries, decide which "type" to use */ |
| 326 | /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */ |
| 327 | current_type = 0; |
| 328 | for (i = 0; i < overlap_entries; i++) |
| 329 | if (overlap_list[i]->type > current_type) |
| 330 | current_type = overlap_list[i]->type; |
| 331 | /* continue building up new memmap based on this information */ |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 332 | if (current_type != last_type) { |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 333 | if (last_type != 0) { |
| 334 | new_map[new_entry].size = |
| 335 | change_point[chgidx]->addr - last_addr; |
| 336 | /* move forward only if the new size was non-zero */ |
| 337 | if (new_map[new_entry].size != 0) |
| 338 | if (++new_entry >= BFIN_MEMMAP_MAX) |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 339 | break; /* no more space left for new entries */ |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 340 | } |
| 341 | if (current_type != 0) { |
| 342 | new_map[new_entry].addr = change_point[chgidx]->addr; |
| 343 | new_map[new_entry].type = current_type; |
| 344 | last_addr = change_point[chgidx]->addr; |
| 345 | } |
| 346 | last_type = current_type; |
| 347 | } |
| 348 | } |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 349 | new_nr = new_entry; /* retain count for new entries */ |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 350 | |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 351 | /* copy new mapping into original location */ |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 352 | memcpy(map, new_map, new_nr*sizeof(struct bfin_memmap_entry)); |
| 353 | *pnr_map = new_nr; |
| 354 | |
| 355 | return 0; |
| 356 | } |
| 357 | |
| 358 | static void __init print_memory_map(char *who) |
| 359 | { |
| 360 | int i; |
| 361 | |
| 362 | for (i = 0; i < bfin_memmap.nr_map; i++) { |
| 363 | printk(KERN_DEBUG " %s: %016Lx - %016Lx ", who, |
| 364 | bfin_memmap.map[i].addr, |
| 365 | bfin_memmap.map[i].addr + bfin_memmap.map[i].size); |
| 366 | switch (bfin_memmap.map[i].type) { |
| 367 | case BFIN_MEMMAP_RAM: |
| 368 | printk("(usable)\n"); |
| 369 | break; |
| 370 | case BFIN_MEMMAP_RESERVED: |
| 371 | printk("(reserved)\n"); |
| 372 | break; |
| 373 | default: printk("type %lu\n", bfin_memmap.map[i].type); |
| 374 | break; |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | static __init int parse_memmap(char *arg) |
| 380 | { |
| 381 | unsigned long long start_at, mem_size; |
| 382 | |
| 383 | if (!arg) |
| 384 | return -EINVAL; |
| 385 | |
| 386 | mem_size = memparse(arg, &arg); |
| 387 | if (*arg == '@') { |
| 388 | start_at = memparse(arg+1, &arg); |
| 389 | add_memory_region(start_at, mem_size, BFIN_MEMMAP_RAM); |
| 390 | } else if (*arg == '$') { |
| 391 | start_at = memparse(arg+1, &arg); |
| 392 | add_memory_region(start_at, mem_size, BFIN_MEMMAP_RESERVED); |
| 393 | } |
| 394 | |
| 395 | return 0; |
| 396 | } |
| 397 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 398 | /* |
| 399 | * Initial parsing of the command line. Currently, we support: |
| 400 | * - Controlling the linux memory size: mem=xxx[KMG] |
| 401 | * - Controlling the physical memory size: max_mem=xxx[KMG][$][#] |
| 402 | * $ -> reserved memory is dcacheable |
| 403 | * # -> reserved memory is icacheable |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 404 | * - "memmap=XXX[KkmM][@][$]XXX[KkmM]" defines a memory region |
| 405 | * @ from <start> to <start>+<mem>, type RAM |
| 406 | * $ from <start> to <start>+<mem>, type RESERVED |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 407 | */ |
| 408 | static __init void parse_cmdline_early(char *cmdline_p) |
| 409 | { |
| 410 | char c = ' ', *to = cmdline_p; |
| 411 | unsigned int memsize; |
| 412 | for (;;) { |
| 413 | if (c == ' ') { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 414 | if (!memcmp(to, "mem=", 4)) { |
| 415 | to += 4; |
| 416 | memsize = memparse(to, &to); |
| 417 | if (memsize) |
| 418 | _ramend = memsize; |
| 419 | |
| 420 | } else if (!memcmp(to, "max_mem=", 8)) { |
| 421 | to += 8; |
| 422 | memsize = memparse(to, &to); |
| 423 | if (memsize) { |
| 424 | physical_mem_end = memsize; |
| 425 | if (*to != ' ') { |
| 426 | if (*to == '$' |
| 427 | || *(to + 1) == '$') |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 428 | reserved_mem_dcache_on = 1; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 429 | if (*to == '#' |
| 430 | || *(to + 1) == '#') |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 431 | reserved_mem_icache_on = 1; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 432 | } |
| 433 | } |
Mike Frysinger | 7f1e2f9 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 434 | } else if (!memcmp(to, "clkin_hz=", 9)) { |
| 435 | to += 9; |
| 436 | early_init_clkin_hz(to); |
Robin Getz | ce3afa1 | 2007-10-09 17:28:36 +0800 | [diff] [blame] | 437 | } else if (!memcmp(to, "earlyprintk=", 12)) { |
| 438 | to += 12; |
| 439 | setup_early_printk(to); |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 440 | } else if (!memcmp(to, "memmap=", 7)) { |
| 441 | to += 7; |
| 442 | parse_memmap(to); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 443 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 444 | } |
| 445 | c = *(to++); |
| 446 | if (!c) |
| 447 | break; |
| 448 | } |
| 449 | } |
| 450 | |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 451 | /* |
| 452 | * Setup memory defaults from user config. |
| 453 | * The physical memory layout looks like: |
| 454 | * |
| 455 | * [_rambase, _ramstart]: kernel image |
| 456 | * [memory_start, memory_end]: dynamic memory managed by kernel |
| 457 | * [memory_end, _ramend]: reserved memory |
Bryan Wu | 3094c98 | 2008-10-10 21:22:01 +0800 | [diff] [blame] | 458 | * [memory_mtd_start(memory_end), |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 459 | * memory_mtd_start + mtd_size]: rootfs (if any) |
| 460 | * [_ramend - DMA_UNCACHED_REGION, |
| 461 | * _ramend]: uncached DMA region |
| 462 | * [_ramend, physical_mem_end]: memory not managed by kernel |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 463 | */ |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 464 | static __init void memory_setup(void) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 465 | { |
Mike Frysinger | c0eab3b | 2008-02-02 15:36:11 +0800 | [diff] [blame] | 466 | #ifdef CONFIG_MTD_UCLINUX |
| 467 | unsigned long mtd_phys = 0; |
| 468 | #endif |
| 469 | |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 470 | _rambase = (unsigned long)_stext; |
Mike Frysinger | b7627ac | 2008-02-02 15:53:17 +0800 | [diff] [blame] | 471 | _ramstart = (unsigned long)_end; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 472 | |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 473 | if (DMA_UNCACHED_REGION > (_ramend - _ramstart)) { |
| 474 | console_init(); |
| 475 | panic("DMA region exceeds memory limit: %lu.\n", |
| 476 | _ramend - _ramstart); |
Mike Frysinger | 1aafd90 | 2007-07-25 11:19:14 +0800 | [diff] [blame] | 477 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 478 | memory_end = _ramend - DMA_UNCACHED_REGION; |
| 479 | |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 480 | #ifdef CONFIG_MPU |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 481 | /* Round up to multiple of 4MB */ |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 482 | memory_start = (_ramstart + 0x3fffff) & ~0x3fffff; |
| 483 | #else |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 484 | memory_start = PAGE_ALIGN(_ramstart); |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 485 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 486 | |
| 487 | #if defined(CONFIG_MTD_UCLINUX) |
| 488 | /* generic memory mapped MTD driver */ |
| 489 | memory_mtd_end = memory_end; |
| 490 | |
| 491 | mtd_phys = _ramstart; |
| 492 | mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8))); |
| 493 | |
| 494 | # if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS) |
| 495 | if (*((unsigned short *)(mtd_phys + 0x438)) == EXT2_SUPER_MAGIC) |
| 496 | mtd_size = |
| 497 | PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x404)) << 10); |
| 498 | # endif |
| 499 | |
| 500 | # if defined(CONFIG_CRAMFS) |
| 501 | if (*((unsigned long *)(mtd_phys)) == CRAMFS_MAGIC) |
| 502 | mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x4))); |
| 503 | # endif |
| 504 | |
| 505 | # if defined(CONFIG_ROMFS_FS) |
| 506 | if (((unsigned long *)mtd_phys)[0] == ROMSB_WORD0 |
| 507 | && ((unsigned long *)mtd_phys)[1] == ROMSB_WORD1) |
| 508 | mtd_size = |
| 509 | PAGE_ALIGN(be32_to_cpu(((unsigned long *)mtd_phys)[2])); |
Robin Getz | 3bebca2 | 2007-10-10 23:55:26 +0800 | [diff] [blame] | 510 | # if (defined(CONFIG_BFIN_ICACHE) && ANOMALY_05000263) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 511 | /* Due to a Hardware Anomaly we need to limit the size of usable |
| 512 | * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on |
| 513 | * 05000263 - Hardware loop corrupted when taking an ICPLB exception |
| 514 | */ |
| 515 | # if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO)) |
| 516 | if (memory_end >= 56 * 1024 * 1024) |
| 517 | memory_end = 56 * 1024 * 1024; |
| 518 | # else |
| 519 | if (memory_end >= 60 * 1024 * 1024) |
| 520 | memory_end = 60 * 1024 * 1024; |
| 521 | # endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */ |
| 522 | # endif /* ANOMALY_05000263 */ |
| 523 | # endif /* CONFIG_ROMFS_FS */ |
| 524 | |
| 525 | memory_end -= mtd_size; |
| 526 | |
| 527 | if (mtd_size == 0) { |
| 528 | console_init(); |
| 529 | panic("Don't boot kernel without rootfs attached.\n"); |
| 530 | } |
| 531 | |
| 532 | /* Relocate MTD image to the top of memory after the uncached memory area */ |
Mike Frysinger | b7627ac | 2008-02-02 15:53:17 +0800 | [diff] [blame] | 533 | dma_memcpy((char *)memory_end, _end, mtd_size); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 534 | |
| 535 | memory_mtd_start = memory_end; |
| 536 | _ebss = memory_mtd_start; /* define _ebss for compatible */ |
| 537 | #endif /* CONFIG_MTD_UCLINUX */ |
| 538 | |
Robin Getz | 3bebca2 | 2007-10-10 23:55:26 +0800 | [diff] [blame] | 539 | #if (defined(CONFIG_BFIN_ICACHE) && ANOMALY_05000263) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 540 | /* Due to a Hardware Anomaly we need to limit the size of usable |
| 541 | * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on |
| 542 | * 05000263 - Hardware loop corrupted when taking an ICPLB exception |
| 543 | */ |
| 544 | #if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO)) |
| 545 | if (memory_end >= 56 * 1024 * 1024) |
| 546 | memory_end = 56 * 1024 * 1024; |
| 547 | #else |
| 548 | if (memory_end >= 60 * 1024 * 1024) |
| 549 | memory_end = 60 * 1024 * 1024; |
| 550 | #endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */ |
| 551 | printk(KERN_NOTICE "Warning: limiting memory to %liMB due to hardware anomaly 05000263\n", memory_end >> 20); |
| 552 | #endif /* ANOMALY_05000263 */ |
| 553 | |
Bernd Schmidt | b97b8a9 | 2008-01-27 18:39:16 +0800 | [diff] [blame] | 554 | #ifdef CONFIG_MPU |
| 555 | page_mask_nelts = ((_ramend >> PAGE_SHIFT) + 31) / 32; |
| 556 | page_mask_order = get_order(3 * page_mask_nelts * sizeof(long)); |
| 557 | #endif |
| 558 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 559 | #if !defined(CONFIG_MTD_UCLINUX) |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 560 | /*In case there is no valid CPLB behind memory_end make sure we don't get to close*/ |
| 561 | memory_end -= SIZE_4K; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 562 | #endif |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 563 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 564 | init_mm.start_code = (unsigned long)_stext; |
| 565 | init_mm.end_code = (unsigned long)_etext; |
| 566 | init_mm.end_data = (unsigned long)_edata; |
| 567 | init_mm.brk = (unsigned long)0; |
| 568 | |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 569 | printk(KERN_INFO "Board Memory: %ldMB\n", physical_mem_end >> 20); |
| 570 | printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20); |
| 571 | |
Mike Frysinger | b7627ac | 2008-02-02 15:53:17 +0800 | [diff] [blame] | 572 | printk(KERN_INFO "Memory map:\n" |
Mike Frysinger | 8929ecf8 | 2008-02-22 16:35:20 +0800 | [diff] [blame] | 573 | KERN_INFO " fixedcode = 0x%p-0x%p\n" |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 574 | KERN_INFO " text = 0x%p-0x%p\n" |
| 575 | KERN_INFO " rodata = 0x%p-0x%p\n" |
Mike Frysinger | b7627ac | 2008-02-02 15:53:17 +0800 | [diff] [blame] | 576 | KERN_INFO " bss = 0x%p-0x%p\n" |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 577 | KERN_INFO " data = 0x%p-0x%p\n" |
| 578 | KERN_INFO " stack = 0x%p-0x%p\n" |
| 579 | KERN_INFO " init = 0x%p-0x%p\n" |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 580 | KERN_INFO " available = 0x%p-0x%p\n" |
| 581 | #ifdef CONFIG_MTD_UCLINUX |
| 582 | KERN_INFO " rootfs = 0x%p-0x%p\n" |
| 583 | #endif |
| 584 | #if DMA_UNCACHED_REGION > 0 |
| 585 | KERN_INFO " DMA Zone = 0x%p-0x%p\n" |
| 586 | #endif |
Mike Frysinger | 8929ecf8 | 2008-02-22 16:35:20 +0800 | [diff] [blame] | 587 | , (void *)FIXED_CODE_START, (void *)FIXED_CODE_END, |
| 588 | _stext, _etext, |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 589 | __start_rodata, __end_rodata, |
Mike Frysinger | b7627ac | 2008-02-02 15:53:17 +0800 | [diff] [blame] | 590 | __bss_start, __bss_stop, |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 591 | _sdata, _edata, |
| 592 | (void *)&init_thread_union, |
| 593 | (void *)((int)(&init_thread_union) + 0x2000), |
Mike Frysinger | b7627ac | 2008-02-02 15:53:17 +0800 | [diff] [blame] | 594 | __init_begin, __init_end, |
| 595 | (void *)_ramstart, (void *)memory_end |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 596 | #ifdef CONFIG_MTD_UCLINUX |
| 597 | , (void *)memory_mtd_start, (void *)(memory_mtd_start + mtd_size) |
| 598 | #endif |
| 599 | #if DMA_UNCACHED_REGION > 0 |
| 600 | , (void *)(_ramend - DMA_UNCACHED_REGION), (void *)(_ramend) |
| 601 | #endif |
| 602 | ); |
| 603 | } |
| 604 | |
Yi Li | 2e8d796 | 2008-03-26 07:08:12 +0800 | [diff] [blame] | 605 | /* |
| 606 | * Find the lowest, highest page frame number we have available |
| 607 | */ |
| 608 | void __init find_min_max_pfn(void) |
| 609 | { |
| 610 | int i; |
| 611 | |
| 612 | max_pfn = 0; |
| 613 | min_low_pfn = memory_end; |
| 614 | |
| 615 | for (i = 0; i < bfin_memmap.nr_map; i++) { |
| 616 | unsigned long start, end; |
| 617 | /* RAM? */ |
| 618 | if (bfin_memmap.map[i].type != BFIN_MEMMAP_RAM) |
| 619 | continue; |
| 620 | start = PFN_UP(bfin_memmap.map[i].addr); |
| 621 | end = PFN_DOWN(bfin_memmap.map[i].addr + |
| 622 | bfin_memmap.map[i].size); |
| 623 | if (start >= end) |
| 624 | continue; |
| 625 | if (end > max_pfn) |
| 626 | max_pfn = end; |
| 627 | if (start < min_low_pfn) |
| 628 | min_low_pfn = start; |
| 629 | } |
| 630 | } |
| 631 | |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 632 | static __init void setup_bootmem_allocator(void) |
| 633 | { |
| 634 | int bootmap_size; |
| 635 | int i; |
Yi Li | 2e8d796 | 2008-03-26 07:08:12 +0800 | [diff] [blame] | 636 | unsigned long start_pfn, end_pfn; |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 637 | unsigned long curr_pfn, last_pfn, size; |
| 638 | |
| 639 | /* mark memory between memory_start and memory_end usable */ |
| 640 | add_memory_region(memory_start, |
| 641 | memory_end - memory_start, BFIN_MEMMAP_RAM); |
| 642 | /* sanity check for overlap */ |
| 643 | sanitize_memmap(bfin_memmap.map, &bfin_memmap.nr_map); |
| 644 | print_memory_map("boot memmap"); |
| 645 | |
Yi Li | 2e8d796 | 2008-03-26 07:08:12 +0800 | [diff] [blame] | 646 | /* intialize globals in linux/bootmem.h */ |
| 647 | find_min_max_pfn(); |
| 648 | /* pfn of the last usable page frame */ |
| 649 | if (max_pfn > memory_end >> PAGE_SHIFT) |
| 650 | max_pfn = memory_end >> PAGE_SHIFT; |
| 651 | /* pfn of last page frame directly mapped by kernel */ |
| 652 | max_low_pfn = max_pfn; |
| 653 | /* pfn of the first usable page frame after kernel image*/ |
| 654 | if (min_low_pfn < memory_start >> PAGE_SHIFT) |
| 655 | min_low_pfn = memory_start >> PAGE_SHIFT; |
| 656 | |
| 657 | start_pfn = PAGE_OFFSET >> PAGE_SHIFT; |
| 658 | end_pfn = memory_end >> PAGE_SHIFT; |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 659 | |
| 660 | /* |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 661 | * give all the memory to the bootmap allocator, tell it to put the |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 662 | * boot mem_map at the start of memory. |
| 663 | */ |
| 664 | bootmap_size = init_bootmem_node(NODE_DATA(0), |
| 665 | memory_start >> PAGE_SHIFT, /* map goes here */ |
Yi Li | 2e8d796 | 2008-03-26 07:08:12 +0800 | [diff] [blame] | 666 | start_pfn, end_pfn); |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 667 | |
| 668 | /* register the memmap regions with the bootmem allocator */ |
| 669 | for (i = 0; i < bfin_memmap.nr_map; i++) { |
| 670 | /* |
| 671 | * Reserve usable memory |
| 672 | */ |
| 673 | if (bfin_memmap.map[i].type != BFIN_MEMMAP_RAM) |
| 674 | continue; |
| 675 | /* |
| 676 | * We are rounding up the start address of usable memory: |
| 677 | */ |
| 678 | curr_pfn = PFN_UP(bfin_memmap.map[i].addr); |
Yi Li | 2e8d796 | 2008-03-26 07:08:12 +0800 | [diff] [blame] | 679 | if (curr_pfn >= end_pfn) |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 680 | continue; |
| 681 | /* |
| 682 | * ... and at the end of the usable range downwards: |
| 683 | */ |
| 684 | last_pfn = PFN_DOWN(bfin_memmap.map[i].addr + |
| 685 | bfin_memmap.map[i].size); |
| 686 | |
Yi Li | 2e8d796 | 2008-03-26 07:08:12 +0800 | [diff] [blame] | 687 | if (last_pfn > end_pfn) |
| 688 | last_pfn = end_pfn; |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 689 | |
| 690 | /* |
| 691 | * .. finally, did all the rounding and playing |
| 692 | * around just make the area go away? |
| 693 | */ |
| 694 | if (last_pfn <= curr_pfn) |
| 695 | continue; |
| 696 | |
| 697 | size = last_pfn - curr_pfn; |
| 698 | free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size)); |
| 699 | } |
| 700 | |
| 701 | /* reserve memory before memory_start, including bootmap */ |
| 702 | reserve_bootmem(PAGE_OFFSET, |
| 703 | memory_start + bootmap_size + PAGE_SIZE - 1 - PAGE_OFFSET, |
| 704 | BOOTMEM_DEFAULT); |
| 705 | } |
| 706 | |
Mike Frysinger | a086ee2 | 2008-04-25 02:04:05 +0800 | [diff] [blame] | 707 | #define EBSZ_TO_MEG(ebsz) \ |
| 708 | ({ \ |
| 709 | int meg = 0; \ |
| 710 | switch (ebsz & 0xf) { \ |
| 711 | case 0x1: meg = 16; break; \ |
| 712 | case 0x3: meg = 32; break; \ |
| 713 | case 0x5: meg = 64; break; \ |
| 714 | case 0x7: meg = 128; break; \ |
| 715 | case 0x9: meg = 256; break; \ |
| 716 | case 0xb: meg = 512; break; \ |
| 717 | } \ |
| 718 | meg; \ |
| 719 | }) |
| 720 | static inline int __init get_mem_size(void) |
| 721 | { |
Michael Hennerich | 99d95bb | 2008-07-14 17:04:14 +0800 | [diff] [blame] | 722 | #if defined(EBIU_SDBCTL) |
| 723 | # if defined(BF561_FAMILY) |
Mike Frysinger | a086ee2 | 2008-04-25 02:04:05 +0800 | [diff] [blame] | 724 | int ret = 0; |
| 725 | u32 sdbctl = bfin_read_EBIU_SDBCTL(); |
| 726 | ret += EBSZ_TO_MEG(sdbctl >> 0); |
| 727 | ret += EBSZ_TO_MEG(sdbctl >> 8); |
| 728 | ret += EBSZ_TO_MEG(sdbctl >> 16); |
| 729 | ret += EBSZ_TO_MEG(sdbctl >> 24); |
| 730 | return ret; |
Michael Hennerich | 99d95bb | 2008-07-14 17:04:14 +0800 | [diff] [blame] | 731 | # else |
Mike Frysinger | a086ee2 | 2008-04-25 02:04:05 +0800 | [diff] [blame] | 732 | return EBSZ_TO_MEG(bfin_read_EBIU_SDBCTL()); |
Michael Hennerich | 99d95bb | 2008-07-14 17:04:14 +0800 | [diff] [blame] | 733 | # endif |
| 734 | #elif defined(EBIU_DDRCTL1) |
Michael Hennerich | 1e78042 | 2008-04-25 04:31:23 +0800 | [diff] [blame] | 735 | u32 ddrctl = bfin_read_EBIU_DDRCTL1(); |
| 736 | int ret = 0; |
| 737 | switch (ddrctl & 0xc0000) { |
| 738 | case DEVSZ_64: ret = 64 / 8; |
| 739 | case DEVSZ_128: ret = 128 / 8; |
| 740 | case DEVSZ_256: ret = 256 / 8; |
| 741 | case DEVSZ_512: ret = 512 / 8; |
Mike Frysinger | a086ee2 | 2008-04-25 02:04:05 +0800 | [diff] [blame] | 742 | } |
Michael Hennerich | 1e78042 | 2008-04-25 04:31:23 +0800 | [diff] [blame] | 743 | switch (ddrctl & 0x30000) { |
| 744 | case DEVWD_4: ret *= 2; |
| 745 | case DEVWD_8: ret *= 2; |
| 746 | case DEVWD_16: break; |
| 747 | } |
Mike Frysinger | b1b154e | 2008-07-26 18:02:05 +0800 | [diff] [blame] | 748 | if ((ddrctl & 0xc000) == 0x4000) |
| 749 | ret *= 2; |
Michael Hennerich | 1e78042 | 2008-04-25 04:31:23 +0800 | [diff] [blame] | 750 | return ret; |
Mike Frysinger | a086ee2 | 2008-04-25 02:04:05 +0800 | [diff] [blame] | 751 | #endif |
| 752 | BUG(); |
| 753 | } |
| 754 | |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 755 | void __init setup_arch(char **cmdline_p) |
| 756 | { |
Mike Frysinger | 9f8e895 | 2008-04-24 06:20:11 +0800 | [diff] [blame] | 757 | unsigned long sclk, cclk; |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 758 | |
| 759 | #ifdef CONFIG_DUMMY_CONSOLE |
| 760 | conswitchp = &dummy_con; |
| 761 | #endif |
| 762 | |
| 763 | #if defined(CONFIG_CMDLINE_BOOL) |
| 764 | strncpy(&command_line[0], CONFIG_CMDLINE, sizeof(command_line)); |
| 765 | command_line[sizeof(command_line) - 1] = 0; |
| 766 | #endif |
| 767 | |
| 768 | /* Keep a copy of command line */ |
| 769 | *cmdline_p = &command_line[0]; |
| 770 | memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); |
| 771 | boot_command_line[COMMAND_LINE_SIZE - 1] = '\0'; |
| 772 | |
| 773 | /* setup memory defaults from the user config */ |
| 774 | physical_mem_end = 0; |
Mike Frysinger | a086ee2 | 2008-04-25 02:04:05 +0800 | [diff] [blame] | 775 | _ramend = get_mem_size() * 1024 * 1024; |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 776 | |
| 777 | memset(&bfin_memmap, 0, sizeof(bfin_memmap)); |
| 778 | |
| 779 | parse_cmdline_early(&command_line[0]); |
| 780 | |
| 781 | if (physical_mem_end == 0) |
| 782 | physical_mem_end = _ramend; |
| 783 | |
| 784 | memory_setup(); |
| 785 | |
Mike Frysinger | 7e64aca | 2008-08-06 17:17:10 +0800 | [diff] [blame] | 786 | /* Initialize Async memory banks */ |
| 787 | bfin_write_EBIU_AMBCTL0(AMBCTL0VAL); |
| 788 | bfin_write_EBIU_AMBCTL1(AMBCTL1VAL); |
| 789 | bfin_write_EBIU_AMGCTL(AMGCTLVAL); |
| 790 | #ifdef CONFIG_EBIU_MBSCTLVAL |
| 791 | bfin_write_EBIU_MBSCTL(CONFIG_EBIU_MBSCTLVAL); |
| 792 | bfin_write_EBIU_MODE(CONFIG_EBIU_MODEVAL); |
| 793 | bfin_write_EBIU_FCTL(CONFIG_EBIU_FCTLVAL); |
| 794 | #endif |
| 795 | |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 796 | cclk = get_cclk(); |
| 797 | sclk = get_sclk(); |
| 798 | |
| 799 | #if !defined(CONFIG_BFIN_KERNEL_CLOCK) |
| 800 | if (ANOMALY_05000273 && cclk == sclk) |
| 801 | panic("ANOMALY 05000273, SCLK can not be same as CCLK"); |
| 802 | #endif |
| 803 | |
| 804 | #ifdef BF561_FAMILY |
| 805 | if (ANOMALY_05000266) { |
| 806 | bfin_read_IMDMA_D0_IRQ_STATUS(); |
| 807 | bfin_read_IMDMA_D1_IRQ_STATUS(); |
| 808 | } |
| 809 | #endif |
| 810 | printk(KERN_INFO "Hardware Trace "); |
| 811 | if (bfin_read_TBUFCTL() & 0x1) |
| 812 | printk("Active "); |
| 813 | else |
| 814 | printk("Off "); |
| 815 | if (bfin_read_TBUFCTL() & 0x2) |
| 816 | printk("and Enabled\n"); |
| 817 | else |
| 818 | printk("and Disabled\n"); |
| 819 | |
| 820 | #if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH) |
| 821 | /* we need to initialize the Flashrom device here since we might |
| 822 | * do things with flash early on in the boot |
| 823 | */ |
| 824 | flash_probe(); |
| 825 | #endif |
| 826 | |
Robin Getz | 76e8fe4 | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 827 | printk(KERN_INFO "Boot Mode: %i\n", bfin_read_SYSCR() & 0xF); |
| 828 | |
Mike Frysinger | ed1fb60 | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 829 | /* Newer parts mirror SWRST bits in SYSCR */ |
| 830 | #if defined(CONFIG_BF53x) || defined(CONFIG_BF561) || \ |
| 831 | defined(CONFIG_BF538) || defined(CONFIG_BF539) |
Robin Getz | 7728ec3 | 2007-10-29 18:12:15 +0800 | [diff] [blame] | 832 | _bfin_swrst = bfin_read_SWRST(); |
Mike Frysinger | ed1fb60 | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 833 | #else |
| 834 | _bfin_swrst = bfin_read_SYSCR(); |
| 835 | #endif |
Robin Getz | 7728ec3 | 2007-10-29 18:12:15 +0800 | [diff] [blame] | 836 | |
Robin Getz | 0c7a6b2 | 2008-10-08 16:27:12 +0800 | [diff] [blame] | 837 | #ifdef CONFIG_DEBUG_DOUBLEFAULT_PRINT |
| 838 | bfin_write_SWRST(_bfin_swrst & ~DOUBLE_FAULT); |
| 839 | #endif |
| 840 | #ifdef CONFIG_DEBUG_DOUBLEFAULT_RESET |
| 841 | bfin_write_SWRST(_bfin_swrst | DOUBLE_FAULT); |
| 842 | #endif |
Robin Getz | 2d20098 | 2008-07-26 19:41:40 +0800 | [diff] [blame] | 843 | |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 844 | #ifdef CONFIG_SMP |
| 845 | if (_bfin_swrst & SWRST_DBL_FAULT_A) { |
| 846 | #else |
Robin Getz | 0c7a6b2 | 2008-10-08 16:27:12 +0800 | [diff] [blame] | 847 | if (_bfin_swrst & RESET_DOUBLE) { |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 848 | #endif |
Robin Getz | 0c7a6b2 | 2008-10-08 16:27:12 +0800 | [diff] [blame] | 849 | printk(KERN_EMERG "Recovering from DOUBLE FAULT event\n"); |
| 850 | #ifdef CONFIG_DEBUG_DOUBLEFAULT |
| 851 | /* We assume the crashing kernel, and the current symbol table match */ |
| 852 | printk(KERN_EMERG " While handling exception (EXCAUSE = 0x%x) at %pF\n", |
| 853 | (int)init_saved_seqstat & SEQSTAT_EXCAUSE, init_saved_retx); |
| 854 | printk(KERN_NOTICE " DCPLB_FAULT_ADDR: %pF\n", init_saved_dcplb_fault_addr); |
| 855 | printk(KERN_NOTICE " ICPLB_FAULT_ADDR: %pF\n", init_saved_icplb_fault_addr); |
| 856 | #endif |
| 857 | printk(KERN_NOTICE " The instruction at %pF caused a double exception\n", |
| 858 | init_retx); |
| 859 | } else if (_bfin_swrst & RESET_WDOG) |
Robin Getz | 7728ec3 | 2007-10-29 18:12:15 +0800 | [diff] [blame] | 860 | printk(KERN_INFO "Recovering from Watchdog event\n"); |
| 861 | else if (_bfin_swrst & RESET_SOFTWARE) |
| 862 | printk(KERN_NOTICE "Reset caused by Software reset\n"); |
| 863 | |
Michael Hennerich | 972de7d | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 864 | printk(KERN_INFO "Blackfin support (C) 2004-2009 Analog Devices, Inc.\n"); |
Jie Zhang | de3025f | 2007-06-25 18:04:12 +0800 | [diff] [blame] | 865 | if (bfin_compiled_revid() == 0xffff) |
| 866 | printk(KERN_INFO "Compiled for ADSP-%s Rev any\n", CPU); |
| 867 | else if (bfin_compiled_revid() == -1) |
| 868 | printk(KERN_INFO "Compiled for ADSP-%s Rev none\n", CPU); |
| 869 | else |
| 870 | printk(KERN_INFO "Compiled for ADSP-%s Rev 0.%d\n", CPU, bfin_compiled_revid()); |
Robin Getz | e482cad | 2008-10-10 18:21:45 +0800 | [diff] [blame] | 871 | |
| 872 | if (unlikely(CPUID != bfin_cpuid())) |
| 873 | printk(KERN_ERR "ERROR: Not running on ADSP-%s: unknown CPUID 0x%04x Rev 0.%d\n", |
| 874 | CPU, bfin_cpuid(), bfin_revid()); |
| 875 | else { |
| 876 | if (bfin_revid() != bfin_compiled_revid()) { |
| 877 | if (bfin_compiled_revid() == -1) |
| 878 | printk(KERN_ERR "Warning: Compiled for Rev none, but running on Rev %d\n", |
| 879 | bfin_revid()); |
Robin Getz | 7419a32 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 880 | else if (bfin_compiled_revid() != 0xffff) { |
Robin Getz | e482cad | 2008-10-10 18:21:45 +0800 | [diff] [blame] | 881 | printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n", |
| 882 | bfin_compiled_revid(), bfin_revid()); |
Robin Getz | 7419a32 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 883 | if (bfin_compiled_revid() > bfin_revid()) |
| 884 | panic("Error: you are missing anomaly workarounds for this rev\n"); |
| 885 | } |
Robin Getz | e482cad | 2008-10-10 18:21:45 +0800 | [diff] [blame] | 886 | } |
Mike Frysinger | da986b9 | 2008-10-28 13:58:15 +0800 | [diff] [blame] | 887 | if (bfin_revid() < CONFIG_BF_REV_MIN || bfin_revid() > CONFIG_BF_REV_MAX) |
Robin Getz | e482cad | 2008-10-10 18:21:45 +0800 | [diff] [blame] | 888 | printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n", |
| 889 | CPU, bfin_revid()); |
Jie Zhang | de3025f | 2007-06-25 18:04:12 +0800 | [diff] [blame] | 890 | } |
Mike Frysinger | 0c0497c | 2008-10-09 17:32:28 +0800 | [diff] [blame] | 891 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 892 | printk(KERN_INFO "Blackfin Linux support by http://blackfin.uclinux.org/\n"); |
| 893 | |
Mike Frysinger | b5c0e2e | 2007-09-12 17:31:59 +0800 | [diff] [blame] | 894 | printk(KERN_INFO "Processor Speed: %lu MHz core clock and %lu MHz System Clock\n", |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 895 | cclk / 1000000, sclk / 1000000); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 896 | |
Mike Frysinger | 1aafd90 | 2007-07-25 11:19:14 +0800 | [diff] [blame] | 897 | if (ANOMALY_05000273 && (cclk >> 1) <= sclk) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 898 | printk("\n\n\nANOMALY_05000273: CCLK must be >= 2*SCLK !!!\n\n\n"); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 899 | |
Yi Li | 856783b | 2008-02-09 02:26:01 +0800 | [diff] [blame] | 900 | setup_bootmem_allocator(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 901 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 902 | paging_init(); |
| 903 | |
Bernd Schmidt | 7adfb58 | 2007-06-21 11:34:16 +0800 | [diff] [blame] | 904 | /* Copy atomic sequences to their fixed location, and sanity check that |
| 905 | these locations are the ones that we advertise to userspace. */ |
| 906 | memcpy((void *)FIXED_CODE_START, &fixed_code_start, |
| 907 | FIXED_CODE_END - FIXED_CODE_START); |
| 908 | BUG_ON((char *)&sigreturn_stub - (char *)&fixed_code_start |
| 909 | != SIGRETURN_STUB - FIXED_CODE_START); |
| 910 | BUG_ON((char *)&atomic_xchg32 - (char *)&fixed_code_start |
| 911 | != ATOMIC_XCHG32 - FIXED_CODE_START); |
| 912 | BUG_ON((char *)&atomic_cas32 - (char *)&fixed_code_start |
| 913 | != ATOMIC_CAS32 - FIXED_CODE_START); |
| 914 | BUG_ON((char *)&atomic_add32 - (char *)&fixed_code_start |
| 915 | != ATOMIC_ADD32 - FIXED_CODE_START); |
| 916 | BUG_ON((char *)&atomic_sub32 - (char *)&fixed_code_start |
| 917 | != ATOMIC_SUB32 - FIXED_CODE_START); |
| 918 | BUG_ON((char *)&atomic_ior32 - (char *)&fixed_code_start |
| 919 | != ATOMIC_IOR32 - FIXED_CODE_START); |
| 920 | BUG_ON((char *)&atomic_and32 - (char *)&fixed_code_start |
| 921 | != ATOMIC_AND32 - FIXED_CODE_START); |
| 922 | BUG_ON((char *)&atomic_xor32 - (char *)&fixed_code_start |
| 923 | != ATOMIC_XOR32 - FIXED_CODE_START); |
Robin Getz | 9f336a5 | 2007-10-29 18:23:28 +0800 | [diff] [blame] | 924 | BUG_ON((char *)&safe_user_instruction - (char *)&fixed_code_start |
| 925 | != SAFE_USER_INSTRUCTION - FIXED_CODE_START); |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 926 | |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 927 | #ifdef CONFIG_SMP |
| 928 | platform_init_cpus(); |
| 929 | #endif |
Bernd Schmidt | 8be80ed | 2007-07-25 14:44:49 +0800 | [diff] [blame] | 930 | init_exception_vectors(); |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 931 | bfin_cache_init(); /* Initialize caches for the boot CPU */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 932 | } |
| 933 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 934 | static int __init topology_init(void) |
| 935 | { |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 936 | unsigned int cpu; |
| 937 | /* Record CPU-private information for the boot processor. */ |
| 938 | bfin_setup_cpudata(0); |
Michael Hennerich | 6cda2e9 | 2008-02-02 15:10:51 +0800 | [diff] [blame] | 939 | |
| 940 | for_each_possible_cpu(cpu) { |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 941 | register_cpu(&per_cpu(cpu_data, cpu).cpu, cpu); |
Michael Hennerich | 6cda2e9 | 2008-02-02 15:10:51 +0800 | [diff] [blame] | 942 | } |
| 943 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 944 | return 0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | subsys_initcall(topology_init); |
| 948 | |
Mike Frysinger | 7f1e2f9 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 949 | /* Get the input clock frequency */ |
| 950 | static u_long cached_clkin_hz = CONFIG_CLKIN_HZ; |
| 951 | static u_long get_clkin_hz(void) |
| 952 | { |
| 953 | return cached_clkin_hz; |
| 954 | } |
| 955 | static int __init early_init_clkin_hz(char *buf) |
| 956 | { |
| 957 | cached_clkin_hz = simple_strtoul(buf, NULL, 0); |
Mike Frysinger | 508808c | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 958 | #ifdef BFIN_KERNEL_CLOCK |
| 959 | if (cached_clkin_hz != CONFIG_CLKIN_HZ) |
| 960 | panic("cannot change clkin_hz when reprogramming clocks"); |
| 961 | #endif |
Mike Frysinger | 7f1e2f9 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 962 | return 1; |
| 963 | } |
| 964 | early_param("clkin_hz=", early_init_clkin_hz); |
| 965 | |
Mike Frysinger | 3a2521f | 2008-07-26 18:52:56 +0800 | [diff] [blame] | 966 | /* Get the voltage input multiplier */ |
Mike Frysinger | 52a0781 | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 967 | static u_long get_vco(void) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 968 | { |
Mike Frysinger | e32f55d | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 969 | static u_long cached_vco; |
| 970 | u_long msel, pll_ctl; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 971 | |
Mike Frysinger | e32f55d | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 972 | /* The assumption here is that VCO never changes at runtime. |
| 973 | * If, someday, we support that, then we'll have to change this. |
| 974 | */ |
| 975 | if (cached_vco) |
Mike Frysinger | 3a2521f | 2008-07-26 18:52:56 +0800 | [diff] [blame] | 976 | return cached_vco; |
Mike Frysinger | 3a2521f | 2008-07-26 18:52:56 +0800 | [diff] [blame] | 977 | |
Mike Frysinger | e32f55d | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 978 | pll_ctl = bfin_read_PLL_CTL(); |
Mike Frysinger | 3a2521f | 2008-07-26 18:52:56 +0800 | [diff] [blame] | 979 | msel = (pll_ctl >> 9) & 0x3F; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 980 | if (0 == msel) |
| 981 | msel = 64; |
| 982 | |
Mike Frysinger | 7f1e2f9 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 983 | cached_vco = get_clkin_hz(); |
Mike Frysinger | 3a2521f | 2008-07-26 18:52:56 +0800 | [diff] [blame] | 984 | cached_vco >>= (1 & pll_ctl); /* DF bit */ |
| 985 | cached_vco *= msel; |
| 986 | return cached_vco; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 987 | } |
| 988 | |
Mike Frysinger | 2f6cf7b | 2007-10-21 22:59:49 +0800 | [diff] [blame] | 989 | /* Get the Core clock */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 990 | u_long get_cclk(void) |
| 991 | { |
Mike Frysinger | e32f55d | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 992 | static u_long cached_cclk_pll_div, cached_cclk; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 993 | u_long csel, ssel; |
Mike Frysinger | 3a2521f | 2008-07-26 18:52:56 +0800 | [diff] [blame] | 994 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 995 | if (bfin_read_PLL_STAT() & 0x1) |
Mike Frysinger | 7f1e2f9 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 996 | return get_clkin_hz(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 997 | |
| 998 | ssel = bfin_read_PLL_DIV(); |
Mike Frysinger | 3a2521f | 2008-07-26 18:52:56 +0800 | [diff] [blame] | 999 | if (ssel == cached_cclk_pll_div) |
| 1000 | return cached_cclk; |
| 1001 | else |
| 1002 | cached_cclk_pll_div = ssel; |
| 1003 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1004 | csel = ((ssel >> 4) & 0x03); |
| 1005 | ssel &= 0xf; |
| 1006 | if (ssel && ssel < (1 << csel)) /* SCLK > CCLK */ |
Mike Frysinger | 3a2521f | 2008-07-26 18:52:56 +0800 | [diff] [blame] | 1007 | cached_cclk = get_vco() / ssel; |
| 1008 | else |
| 1009 | cached_cclk = get_vco() >> csel; |
| 1010 | return cached_cclk; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1011 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1012 | EXPORT_SYMBOL(get_cclk); |
| 1013 | |
| 1014 | /* Get the System clock */ |
| 1015 | u_long get_sclk(void) |
| 1016 | { |
Mike Frysinger | e32f55d | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1017 | static u_long cached_sclk; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1018 | u_long ssel; |
| 1019 | |
Mike Frysinger | e32f55d | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1020 | /* The assumption here is that SCLK never changes at runtime. |
| 1021 | * If, someday, we support that, then we'll have to change this. |
| 1022 | */ |
| 1023 | if (cached_sclk) |
| 1024 | return cached_sclk; |
| 1025 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1026 | if (bfin_read_PLL_STAT() & 0x1) |
Mike Frysinger | 7f1e2f9 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 1027 | return get_clkin_hz(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1028 | |
Mike Frysinger | e32f55d | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1029 | ssel = bfin_read_PLL_DIV() & 0xf; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1030 | if (0 == ssel) { |
| 1031 | printk(KERN_WARNING "Invalid System Clock\n"); |
| 1032 | ssel = 1; |
| 1033 | } |
| 1034 | |
Mike Frysinger | 3a2521f | 2008-07-26 18:52:56 +0800 | [diff] [blame] | 1035 | cached_sclk = get_vco() / ssel; |
| 1036 | return cached_sclk; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1037 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1038 | EXPORT_SYMBOL(get_sclk); |
| 1039 | |
Mike Frysinger | 2f6cf7b | 2007-10-21 22:59:49 +0800 | [diff] [blame] | 1040 | unsigned long sclk_to_usecs(unsigned long sclk) |
| 1041 | { |
Mike Frysinger | 1754a5d | 2007-11-23 11:28:11 +0800 | [diff] [blame] | 1042 | u64 tmp = USEC_PER_SEC * (u64)sclk; |
| 1043 | do_div(tmp, get_sclk()); |
| 1044 | return tmp; |
Mike Frysinger | 2f6cf7b | 2007-10-21 22:59:49 +0800 | [diff] [blame] | 1045 | } |
| 1046 | EXPORT_SYMBOL(sclk_to_usecs); |
| 1047 | |
| 1048 | unsigned long usecs_to_sclk(unsigned long usecs) |
| 1049 | { |
Mike Frysinger | 1754a5d | 2007-11-23 11:28:11 +0800 | [diff] [blame] | 1050 | u64 tmp = get_sclk() * (u64)usecs; |
| 1051 | do_div(tmp, USEC_PER_SEC); |
| 1052 | return tmp; |
Mike Frysinger | 2f6cf7b | 2007-10-21 22:59:49 +0800 | [diff] [blame] | 1053 | } |
| 1054 | EXPORT_SYMBOL(usecs_to_sclk); |
| 1055 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1056 | /* |
| 1057 | * Get CPU information for use by the procfs. |
| 1058 | */ |
| 1059 | static int show_cpuinfo(struct seq_file *m, void *v) |
| 1060 | { |
Mike Frysinger | 066954a | 2007-10-21 22:36:06 +0800 | [diff] [blame] | 1061 | char *cpu, *mmu, *fpu, *vendor, *cache; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1062 | uint32_t revid; |
Mike Frysinger | 275123e | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1063 | int cpu_num = *(unsigned int *)v; |
Michael Hennerich | a5f0717 | 2008-11-18 18:04:31 +0800 | [diff] [blame] | 1064 | u_long sclk, cclk; |
Robin Getz | 9de3a0b | 2008-07-26 19:39:19 +0800 | [diff] [blame] | 1065 | u_int icache_size = BFIN_ICACHESIZE / 1024, dcache_size = 0, dsup_banks = 0; |
Mike Frysinger | 275123e | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1066 | struct blackfin_cpudata *cpudata = &per_cpu(cpu_data, cpu_num); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1067 | |
| 1068 | cpu = CPU; |
| 1069 | mmu = "none"; |
| 1070 | fpu = "none"; |
| 1071 | revid = bfin_revid(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1072 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1073 | sclk = get_sclk(); |
Michael Hennerich | a5f0717 | 2008-11-18 18:04:31 +0800 | [diff] [blame] | 1074 | cclk = get_cclk(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1075 | |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1076 | switch (bfin_read_CHIPID() & CHIPID_MANUFACTURE) { |
Mike Frysinger | 066954a | 2007-10-21 22:36:06 +0800 | [diff] [blame] | 1077 | case 0xca: |
| 1078 | vendor = "Analog Devices"; |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1079 | break; |
| 1080 | default: |
Mike Frysinger | 066954a | 2007-10-21 22:36:06 +0800 | [diff] [blame] | 1081 | vendor = "unknown"; |
| 1082 | break; |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1083 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1084 | |
Mike Frysinger | 275123e | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1085 | seq_printf(m, "processor\t: %d\n" "vendor_id\t: %s\n", cpu_num, vendor); |
Robin Getz | e482cad | 2008-10-10 18:21:45 +0800 | [diff] [blame] | 1086 | |
| 1087 | if (CPUID == bfin_cpuid()) |
| 1088 | seq_printf(m, "cpu family\t: 0x%04x\n", CPUID); |
| 1089 | else |
| 1090 | seq_printf(m, "cpu family\t: Compiled for:0x%04x, running on:0x%04x\n", |
| 1091 | CPUID, bfin_cpuid()); |
| 1092 | |
| 1093 | seq_printf(m, "model name\t: ADSP-%s %lu(MHz CCLK) %lu(MHz SCLK) (%s)\n" |
| 1094 | "stepping\t: %d\n", |
Michael Hennerich | a5f0717 | 2008-11-18 18:04:31 +0800 | [diff] [blame] | 1095 | cpu, cclk/1000000, sclk/1000000, |
Robin Getz | 253bcf4 | 2008-04-24 05:57:13 +0800 | [diff] [blame] | 1096 | #ifdef CONFIG_MPU |
| 1097 | "mpu on", |
| 1098 | #else |
| 1099 | "mpu off", |
| 1100 | #endif |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1101 | revid); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1102 | |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1103 | seq_printf(m, "cpu MHz\t\t: %lu.%03lu/%lu.%03lu\n", |
Michael Hennerich | a5f0717 | 2008-11-18 18:04:31 +0800 | [diff] [blame] | 1104 | cclk/1000000, cclk%1000000, |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1105 | sclk/1000000, sclk%1000000); |
| 1106 | seq_printf(m, "bogomips\t: %lu.%02lu\n" |
| 1107 | "Calibration\t: %lu loops\n", |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1108 | (cpudata->loops_per_jiffy * HZ) / 500000, |
| 1109 | ((cpudata->loops_per_jiffy * HZ) / 5000) % 100, |
| 1110 | (cpudata->loops_per_jiffy * HZ)); |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1111 | |
| 1112 | /* Check Cache configutation */ |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1113 | switch (cpudata->dmemctl & (1 << DMC0_P | 1 << DMC1_P)) { |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 1114 | case ACACHE_BSRAM: |
Mike Frysinger | 066954a | 2007-10-21 22:36:06 +0800 | [diff] [blame] | 1115 | cache = "dbank-A/B\t: cache/sram"; |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 1116 | dcache_size = 16; |
| 1117 | dsup_banks = 1; |
| 1118 | break; |
| 1119 | case ACACHE_BCACHE: |
Mike Frysinger | 066954a | 2007-10-21 22:36:06 +0800 | [diff] [blame] | 1120 | cache = "dbank-A/B\t: cache/cache"; |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 1121 | dcache_size = 32; |
| 1122 | dsup_banks = 2; |
| 1123 | break; |
| 1124 | case ASRAM_BSRAM: |
Mike Frysinger | 066954a | 2007-10-21 22:36:06 +0800 | [diff] [blame] | 1125 | cache = "dbank-A/B\t: sram/sram"; |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 1126 | dcache_size = 0; |
| 1127 | dsup_banks = 0; |
| 1128 | break; |
| 1129 | default: |
Mike Frysinger | 066954a | 2007-10-21 22:36:06 +0800 | [diff] [blame] | 1130 | cache = "unknown"; |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1131 | dcache_size = 0; |
| 1132 | dsup_banks = 0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1133 | break; |
| 1134 | } |
| 1135 | |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1136 | /* Is it turned on? */ |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1137 | if ((cpudata->dmemctl & (ENDCPLB | DMC_ENABLE)) != (ENDCPLB | DMC_ENABLE)) |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1138 | dcache_size = 0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1139 | |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1140 | if ((cpudata->imemctl & (IMC | ENICPLB)) != (IMC | ENICPLB)) |
Robin Getz | 9de3a0b | 2008-07-26 19:39:19 +0800 | [diff] [blame] | 1141 | icache_size = 0; |
| 1142 | |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1143 | seq_printf(m, "cache size\t: %d KB(L1 icache) " |
| 1144 | "%d KB(L1 dcache-%s) %d KB(L2 cache)\n", |
Robin Getz | 9de3a0b | 2008-07-26 19:39:19 +0800 | [diff] [blame] | 1145 | icache_size, dcache_size, |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1146 | #if defined CONFIG_BFIN_WB |
| 1147 | "wb" |
| 1148 | #elif defined CONFIG_BFIN_WT |
| 1149 | "wt" |
| 1150 | #endif |
Mike Frysinger | da27abb | 2007-10-22 10:55:35 +0800 | [diff] [blame] | 1151 | "", 0); |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1152 | |
| 1153 | seq_printf(m, "%s\n", cache); |
| 1154 | |
Robin Getz | 9de3a0b | 2008-07-26 19:39:19 +0800 | [diff] [blame] | 1155 | if (icache_size) |
| 1156 | seq_printf(m, "icache setup\t: %d Sub-banks/%d Ways, %d Lines/Way\n", |
| 1157 | BFIN_ISUBBANKS, BFIN_IWAYS, BFIN_ILINES); |
| 1158 | else |
| 1159 | seq_printf(m, "icache setup\t: off\n"); |
| 1160 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1161 | seq_printf(m, |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1162 | "dcache setup\t: %d Super-banks/%d Sub-banks/%d Ways, %d Lines/Way\n", |
Robin Getz | 3bebca2 | 2007-10-10 23:55:26 +0800 | [diff] [blame] | 1163 | dsup_banks, BFIN_DSUBBANKS, BFIN_DWAYS, |
| 1164 | BFIN_DLINES); |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1165 | #ifdef __ARCH_SYNC_CORE_DCACHE |
Mike Frysinger | 275123e | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1166 | seq_printf(m, "SMP Dcache Flushes\t: %lu\n\n", cpudata->dcache_invld_count); |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1167 | #endif |
Robin Getz | 3bebca2 | 2007-10-10 23:55:26 +0800 | [diff] [blame] | 1168 | #ifdef CONFIG_BFIN_ICACHE_LOCK |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1169 | switch ((cpudata->imemctl >> 3) & WAYALL_L) { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1170 | case WAY0_L: |
| 1171 | seq_printf(m, "Way0 Locked-Down\n"); |
| 1172 | break; |
| 1173 | case WAY1_L: |
| 1174 | seq_printf(m, "Way1 Locked-Down\n"); |
| 1175 | break; |
| 1176 | case WAY01_L: |
| 1177 | seq_printf(m, "Way0,Way1 Locked-Down\n"); |
| 1178 | break; |
| 1179 | case WAY2_L: |
| 1180 | seq_printf(m, "Way2 Locked-Down\n"); |
| 1181 | break; |
| 1182 | case WAY02_L: |
| 1183 | seq_printf(m, "Way0,Way2 Locked-Down\n"); |
| 1184 | break; |
| 1185 | case WAY12_L: |
| 1186 | seq_printf(m, "Way1,Way2 Locked-Down\n"); |
| 1187 | break; |
| 1188 | case WAY012_L: |
| 1189 | seq_printf(m, "Way0,Way1 & Way2 Locked-Down\n"); |
| 1190 | break; |
| 1191 | case WAY3_L: |
| 1192 | seq_printf(m, "Way3 Locked-Down\n"); |
| 1193 | break; |
| 1194 | case WAY03_L: |
| 1195 | seq_printf(m, "Way0,Way3 Locked-Down\n"); |
| 1196 | break; |
| 1197 | case WAY13_L: |
| 1198 | seq_printf(m, "Way1,Way3 Locked-Down\n"); |
| 1199 | break; |
| 1200 | case WAY013_L: |
| 1201 | seq_printf(m, "Way 0,Way1,Way3 Locked-Down\n"); |
| 1202 | break; |
| 1203 | case WAY32_L: |
| 1204 | seq_printf(m, "Way3,Way2 Locked-Down\n"); |
| 1205 | break; |
| 1206 | case WAY320_L: |
| 1207 | seq_printf(m, "Way3,Way2,Way0 Locked-Down\n"); |
| 1208 | break; |
| 1209 | case WAY321_L: |
| 1210 | seq_printf(m, "Way3,Way2,Way1 Locked-Down\n"); |
| 1211 | break; |
| 1212 | case WAYALL_L: |
| 1213 | seq_printf(m, "All Ways are locked\n"); |
| 1214 | break; |
| 1215 | default: |
| 1216 | seq_printf(m, "No Ways are locked\n"); |
| 1217 | } |
| 1218 | #endif |
Mike Frysinger | 275123e | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1219 | |
| 1220 | if (cpu_num != num_possible_cpus() - 1) |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1221 | return 0; |
| 1222 | |
Mike Frysinger | 275123e | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1223 | if (L2_LENGTH) |
| 1224 | seq_printf(m, "L2 SRAM\t\t: %dKB\n", L2_LENGTH/0x400); |
Mike Frysinger | 066954a | 2007-10-21 22:36:06 +0800 | [diff] [blame] | 1225 | seq_printf(m, "board name\t: %s\n", bfin_board_name); |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1226 | seq_printf(m, "board memory\t: %ld kB (0x%p -> 0x%p)\n", |
| 1227 | physical_mem_end >> 10, (void *)0, (void *)physical_mem_end); |
| 1228 | seq_printf(m, "kernel memory\t: %d kB (0x%p -> 0x%p)\n", |
| 1229 | ((int)memory_end - (int)_stext) >> 10, |
| 1230 | _stext, |
| 1231 | (void *)memory_end); |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1232 | seq_printf(m, "\n"); |
Robin Getz | 73b0c0b | 2007-10-21 17:03:31 +0800 | [diff] [blame] | 1233 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1234 | return 0; |
| 1235 | } |
| 1236 | |
| 1237 | static void *c_start(struct seq_file *m, loff_t *pos) |
| 1238 | { |
Graf Yang | 55f2fea | 2008-10-09 15:37:47 +0800 | [diff] [blame] | 1239 | if (*pos == 0) |
| 1240 | *pos = first_cpu(cpu_online_map); |
| 1241 | if (*pos >= num_online_cpus()) |
| 1242 | return NULL; |
| 1243 | |
| 1244 | return pos; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1245 | } |
| 1246 | |
| 1247 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) |
| 1248 | { |
Graf Yang | 55f2fea | 2008-10-09 15:37:47 +0800 | [diff] [blame] | 1249 | *pos = next_cpu(*pos, cpu_online_map); |
| 1250 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1251 | return c_start(m, pos); |
| 1252 | } |
| 1253 | |
| 1254 | static void c_stop(struct seq_file *m, void *v) |
| 1255 | { |
| 1256 | } |
| 1257 | |
Jan Engelhardt | 03a4482 | 2008-02-08 04:21:19 -0800 | [diff] [blame] | 1258 | const struct seq_operations cpuinfo_op = { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1259 | .start = c_start, |
| 1260 | .next = c_next, |
| 1261 | .stop = c_stop, |
| 1262 | .show = show_cpuinfo, |
| 1263 | }; |
| 1264 | |
Mike Frysinger | 5e10b4a | 2007-06-11 16:44:09 +0800 | [diff] [blame] | 1265 | void __init cmdline_init(const char *r0) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1266 | { |
| 1267 | if (r0) |
Mike Frysinger | 52a0781 | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 1268 | strncpy(command_line, r0, COMMAND_LINE_SIZE); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1269 | } |