Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File: arch/blackfin/kernel/setup.c |
| 3 | * Based on: |
| 4 | * Author: |
| 5 | * |
| 6 | * Created: |
| 7 | * Description: |
| 8 | * |
| 9 | * Modified: |
| 10 | * Copyright 2004-2006 Analog Devices Inc. |
| 11 | * |
| 12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, see the file COPYING, or write |
| 26 | * to the Free Software Foundation, Inc., |
| 27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 28 | */ |
| 29 | |
| 30 | #include <linux/delay.h> |
| 31 | #include <linux/console.h> |
| 32 | #include <linux/bootmem.h> |
| 33 | #include <linux/seq_file.h> |
| 34 | #include <linux/cpu.h> |
| 35 | #include <linux/module.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 36 | #include <linux/tty.h> |
| 37 | |
| 38 | #include <linux/ext2_fs.h> |
| 39 | #include <linux/cramfs_fs.h> |
| 40 | #include <linux/romfs_fs.h> |
| 41 | |
| 42 | #include <asm/cacheflush.h> |
| 43 | #include <asm/blackfin.h> |
| 44 | #include <asm/cplbinit.h> |
Bernd Schmidt | 7adfb58 | 2007-06-21 11:34:16 +0800 | [diff] [blame] | 45 | #include <asm/fixed_code.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 46 | |
Mike Frysinger | a9c59c2 | 2007-05-21 18:09:32 +0800 | [diff] [blame] | 47 | u16 _bfin_swrst; |
| 48 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 49 | unsigned long memory_start, memory_end, physical_mem_end; |
| 50 | unsigned long reserved_mem_dcache_on; |
| 51 | unsigned long reserved_mem_icache_on; |
| 52 | EXPORT_SYMBOL(memory_start); |
| 53 | EXPORT_SYMBOL(memory_end); |
| 54 | EXPORT_SYMBOL(physical_mem_end); |
| 55 | EXPORT_SYMBOL(_ramend); |
| 56 | |
| 57 | #ifdef CONFIG_MTD_UCLINUX |
| 58 | unsigned long memory_mtd_end, memory_mtd_start, mtd_size; |
| 59 | unsigned long _ebss; |
| 60 | EXPORT_SYMBOL(memory_mtd_end); |
| 61 | EXPORT_SYMBOL(memory_mtd_start); |
| 62 | EXPORT_SYMBOL(mtd_size); |
| 63 | #endif |
| 64 | |
Mike Frysinger | 5e10b4a | 2007-06-11 16:44:09 +0800 | [diff] [blame] | 65 | char __initdata command_line[COMMAND_LINE_SIZE]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 66 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 67 | void __init bf53x_cache_init(void) |
| 68 | { |
| 69 | #if defined(CONFIG_BLKFIN_DCACHE) || defined(CONFIG_BLKFIN_CACHE) |
| 70 | generate_cpl_tables(); |
| 71 | #endif |
| 72 | |
| 73 | #ifdef CONFIG_BLKFIN_CACHE |
| 74 | bfin_icache_init(); |
| 75 | printk(KERN_INFO "Instruction Cache Enabled\n"); |
| 76 | #endif |
| 77 | |
| 78 | #ifdef CONFIG_BLKFIN_DCACHE |
| 79 | bfin_dcache_init(); |
| 80 | printk(KERN_INFO "Data Cache Enabled" |
| 81 | # if defined CONFIG_BLKFIN_WB |
| 82 | " (write-back)" |
| 83 | # elif defined CONFIG_BLKFIN_WT |
| 84 | " (write-through)" |
| 85 | # endif |
| 86 | "\n"); |
| 87 | #endif |
| 88 | } |
| 89 | |
Mike Frysinger | 52a0781 | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 90 | void __init bf53x_relocate_l1_mem(void) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 91 | { |
| 92 | unsigned long l1_code_length; |
| 93 | unsigned long l1_data_a_length; |
| 94 | unsigned long l1_data_b_length; |
| 95 | |
| 96 | l1_code_length = _etext_l1 - _stext_l1; |
| 97 | if (l1_code_length > L1_CODE_LENGTH) |
| 98 | l1_code_length = L1_CODE_LENGTH; |
| 99 | /* cannot complain as printk is not available as yet. |
| 100 | * But we can continue booting and complain later! |
| 101 | */ |
| 102 | |
| 103 | /* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */ |
| 104 | dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length); |
| 105 | |
| 106 | l1_data_a_length = _ebss_l1 - _sdata_l1; |
| 107 | if (l1_data_a_length > L1_DATA_A_LENGTH) |
| 108 | l1_data_a_length = L1_DATA_A_LENGTH; |
| 109 | |
| 110 | /* Copy _sdata_l1 to _ebss_l1 to L1 data bank A SRAM */ |
| 111 | dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length); |
| 112 | |
| 113 | l1_data_b_length = _ebss_b_l1 - _sdata_b_l1; |
| 114 | if (l1_data_b_length > L1_DATA_B_LENGTH) |
| 115 | l1_data_b_length = L1_DATA_B_LENGTH; |
| 116 | |
| 117 | /* Copy _sdata_b_l1 to _ebss_b_l1 to L1 data bank B SRAM */ |
| 118 | dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length + |
| 119 | l1_data_a_length, l1_data_b_length); |
| 120 | |
| 121 | } |
| 122 | |
| 123 | /* |
| 124 | * Initial parsing of the command line. Currently, we support: |
| 125 | * - Controlling the linux memory size: mem=xxx[KMG] |
| 126 | * - Controlling the physical memory size: max_mem=xxx[KMG][$][#] |
| 127 | * $ -> reserved memory is dcacheable |
| 128 | * # -> reserved memory is icacheable |
| 129 | */ |
| 130 | static __init void parse_cmdline_early(char *cmdline_p) |
| 131 | { |
| 132 | char c = ' ', *to = cmdline_p; |
| 133 | unsigned int memsize; |
| 134 | for (;;) { |
| 135 | if (c == ' ') { |
| 136 | |
| 137 | if (!memcmp(to, "mem=", 4)) { |
| 138 | to += 4; |
| 139 | memsize = memparse(to, &to); |
| 140 | if (memsize) |
| 141 | _ramend = memsize; |
| 142 | |
| 143 | } else if (!memcmp(to, "max_mem=", 8)) { |
| 144 | to += 8; |
| 145 | memsize = memparse(to, &to); |
| 146 | if (memsize) { |
| 147 | physical_mem_end = memsize; |
| 148 | if (*to != ' ') { |
| 149 | if (*to == '$' |
| 150 | || *(to + 1) == '$') |
| 151 | reserved_mem_dcache_on = |
| 152 | 1; |
| 153 | if (*to == '#' |
| 154 | || *(to + 1) == '#') |
| 155 | reserved_mem_icache_on = |
| 156 | 1; |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | } |
| 162 | c = *(to++); |
| 163 | if (!c) |
| 164 | break; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | void __init setup_arch(char **cmdline_p) |
| 169 | { |
| 170 | int bootmap_size; |
| 171 | unsigned long l1_length, sclk, cclk; |
| 172 | #ifdef CONFIG_MTD_UCLINUX |
| 173 | unsigned long mtd_phys = 0; |
| 174 | #endif |
| 175 | |
Michael Hennerich | 6e537e9 | 2007-05-21 18:09:20 +0800 | [diff] [blame] | 176 | #ifdef CONFIG_DUMMY_CONSOLE |
| 177 | conswitchp = &dummy_con; |
| 178 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 179 | cclk = get_cclk(); |
| 180 | sclk = get_sclk(); |
| 181 | |
| 182 | #if !defined(CONFIG_BFIN_KERNEL_CLOCK) && defined(ANOMALY_05000273) |
| 183 | if (cclk == sclk) |
| 184 | panic("ANOMALY 05000273, SCLK can not be same as CCLK"); |
| 185 | #endif |
| 186 | |
| 187 | #if defined(ANOMALY_05000266) |
| 188 | bfin_read_IMDMA_D0_IRQ_STATUS(); |
| 189 | bfin_read_IMDMA_D1_IRQ_STATUS(); |
| 190 | #endif |
| 191 | |
| 192 | #ifdef DEBUG_SERIAL_EARLY_INIT |
| 193 | bfin_console_init(); /* early console registration */ |
| 194 | /* this give a chance to get printk() working before crash. */ |
| 195 | #endif |
| 196 | |
Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 197 | printk(KERN_INFO "Hardware Trace "); |
| 198 | if (bfin_read_TBUFCTL() & 0x1 ) |
| 199 | printk("Active "); |
| 200 | else |
| 201 | printk("Off "); |
| 202 | if (bfin_read_TBUFCTL() & 0x2) |
| 203 | printk("and Enabled\n"); |
| 204 | else |
| 205 | printk("and Disabled\n"); |
| 206 | |
| 207 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 208 | #if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH) |
| 209 | /* we need to initialize the Flashrom device here since we might |
| 210 | * do things with flash early on in the boot |
| 211 | */ |
| 212 | flash_probe(); |
| 213 | #endif |
| 214 | |
| 215 | #if defined(CONFIG_CMDLINE_BOOL) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 216 | strncpy(&command_line[0], CONFIG_CMDLINE, sizeof(command_line)); |
| 217 | command_line[sizeof(command_line) - 1] = 0; |
| 218 | #endif |
| 219 | |
| 220 | /* Keep a copy of command line */ |
| 221 | *cmdline_p = &command_line[0]; |
| 222 | memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); |
Mike Frysinger | 5e10b4a | 2007-06-11 16:44:09 +0800 | [diff] [blame] | 223 | boot_command_line[COMMAND_LINE_SIZE - 1] = '\0'; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 224 | |
| 225 | /* setup memory defaults from the user config */ |
| 226 | physical_mem_end = 0; |
| 227 | _ramend = CONFIG_MEM_SIZE * 1024 * 1024; |
| 228 | |
| 229 | parse_cmdline_early(&command_line[0]); |
| 230 | |
| 231 | if (physical_mem_end == 0) |
| 232 | physical_mem_end = _ramend; |
| 233 | |
| 234 | /* by now the stack is part of the init task */ |
| 235 | memory_end = _ramend - DMA_UNCACHED_REGION; |
| 236 | |
| 237 | _ramstart = (unsigned long)__bss_stop; |
| 238 | memory_start = PAGE_ALIGN(_ramstart); |
| 239 | |
| 240 | #if defined(CONFIG_MTD_UCLINUX) |
| 241 | /* generic memory mapped MTD driver */ |
| 242 | memory_mtd_end = memory_end; |
| 243 | |
| 244 | mtd_phys = _ramstart; |
| 245 | mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8))); |
| 246 | |
| 247 | # if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS) |
| 248 | if (*((unsigned short *)(mtd_phys + 0x438)) == EXT2_SUPER_MAGIC) |
| 249 | mtd_size = |
| 250 | PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x404)) << 10); |
| 251 | # endif |
| 252 | |
| 253 | # if defined(CONFIG_CRAMFS) |
| 254 | if (*((unsigned long *)(mtd_phys)) == CRAMFS_MAGIC) |
| 255 | mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x4))); |
| 256 | # endif |
| 257 | |
| 258 | # if defined(CONFIG_ROMFS_FS) |
| 259 | if (((unsigned long *)mtd_phys)[0] == ROMSB_WORD0 |
| 260 | && ((unsigned long *)mtd_phys)[1] == ROMSB_WORD1) |
| 261 | mtd_size = |
| 262 | PAGE_ALIGN(be32_to_cpu(((unsigned long *)mtd_phys)[2])); |
| 263 | # if (defined(CONFIG_BLKFIN_CACHE) && defined(ANOMALY_05000263)) |
| 264 | /* Due to a Hardware Anomaly we need to limit the size of usable |
| 265 | * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on |
| 266 | * 05000263 - Hardware loop corrupted when taking an ICPLB exception |
| 267 | */ |
| 268 | # if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO)) |
| 269 | if (memory_end >= 56 * 1024 * 1024) |
| 270 | memory_end = 56 * 1024 * 1024; |
| 271 | # else |
| 272 | if (memory_end >= 60 * 1024 * 1024) |
| 273 | memory_end = 60 * 1024 * 1024; |
| 274 | # endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */ |
| 275 | # endif /* ANOMALY_05000263 */ |
| 276 | # endif /* CONFIG_ROMFS_FS */ |
| 277 | |
| 278 | memory_end -= mtd_size; |
| 279 | |
| 280 | if (mtd_size == 0) { |
| 281 | console_init(); |
| 282 | panic("Don't boot kernel without rootfs attached.\n"); |
| 283 | } |
| 284 | |
| 285 | /* Relocate MTD image to the top of memory after the uncached memory area */ |
| 286 | dma_memcpy((char *)memory_end, __bss_stop, mtd_size); |
| 287 | |
| 288 | memory_mtd_start = memory_end; |
| 289 | _ebss = memory_mtd_start; /* define _ebss for compatible */ |
| 290 | #endif /* CONFIG_MTD_UCLINUX */ |
| 291 | |
| 292 | #if (defined(CONFIG_BLKFIN_CACHE) && defined(ANOMALY_05000263)) |
| 293 | /* Due to a Hardware Anomaly we need to limit the size of usable |
| 294 | * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on |
| 295 | * 05000263 - Hardware loop corrupted when taking an ICPLB exception |
| 296 | */ |
| 297 | #if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO)) |
| 298 | if (memory_end >= 56 * 1024 * 1024) |
| 299 | memory_end = 56 * 1024 * 1024; |
| 300 | #else |
| 301 | if (memory_end >= 60 * 1024 * 1024) |
| 302 | memory_end = 60 * 1024 * 1024; |
| 303 | #endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */ |
| 304 | printk(KERN_NOTICE "Warning: limiting memory to %liMB due to hardware anomaly 05000263\n", memory_end >> 20); |
| 305 | #endif /* ANOMALY_05000263 */ |
| 306 | |
| 307 | #if !defined(CONFIG_MTD_UCLINUX) |
| 308 | memory_end -= SIZE_4K; /*In case there is no valid CPLB behind memory_end make sure we don't get to close*/ |
| 309 | #endif |
| 310 | init_mm.start_code = (unsigned long)_stext; |
| 311 | init_mm.end_code = (unsigned long)_etext; |
| 312 | init_mm.end_data = (unsigned long)_edata; |
| 313 | init_mm.brk = (unsigned long)0; |
| 314 | |
| 315 | init_leds(); |
| 316 | |
| 317 | printk(KERN_INFO "Blackfin support (C) 2004-2007 Analog Devices, Inc.\n"); |
Jie Zhang | de3025f | 2007-06-25 18:04:12 +0800 | [diff] [blame] | 318 | if (bfin_compiled_revid() == 0xffff) |
| 319 | printk(KERN_INFO "Compiled for ADSP-%s Rev any\n", CPU); |
| 320 | else if (bfin_compiled_revid() == -1) |
| 321 | printk(KERN_INFO "Compiled for ADSP-%s Rev none\n", CPU); |
| 322 | else |
| 323 | printk(KERN_INFO "Compiled for ADSP-%s Rev 0.%d\n", CPU, bfin_compiled_revid()); |
| 324 | if (bfin_revid() != bfin_compiled_revid()) { |
| 325 | if (bfin_compiled_revid() == -1) |
| 326 | printk(KERN_ERR "Warning: Compiled for Rev none, but running on Rev %d\n", |
| 327 | bfin_revid()); |
| 328 | else if (bfin_compiled_revid() != 0xffff) |
| 329 | printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n", |
| 330 | bfin_compiled_revid(), bfin_revid()); |
| 331 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 332 | if (bfin_revid() < SUPPORTED_REVID) |
| 333 | printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n", |
| 334 | CPU, bfin_revid()); |
| 335 | printk(KERN_INFO "Blackfin Linux support by http://blackfin.uclinux.org/\n"); |
| 336 | |
| 337 | printk(KERN_INFO "Processor Speed: %lu MHz core clock and %lu Mhz System Clock\n", |
| 338 | cclk / 1000000, sclk / 1000000); |
| 339 | |
| 340 | #if defined(ANOMALY_05000273) |
| 341 | if ((cclk >> 1) <= sclk) |
| 342 | printk("\n\n\nANOMALY_05000273: CCLK must be >= 2*SCLK !!!\n\n\n"); |
| 343 | #endif |
| 344 | |
| 345 | printk(KERN_INFO "Board Memory: %ldMB\n", physical_mem_end >> 20); |
| 346 | printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20); |
| 347 | |
| 348 | printk(KERN_INFO "Memory map:\n" |
| 349 | KERN_INFO " text = 0x%p-0x%p\n" |
Robin Getz | 86b73c8 | 2007-06-21 11:34:16 +0800 | [diff] [blame] | 350 | KERN_INFO " rodata = 0x%p-0x%p\n" |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 351 | KERN_INFO " data = 0x%p-0x%p\n" |
Robin Getz | 86b73c8 | 2007-06-21 11:34:16 +0800 | [diff] [blame] | 352 | KERN_INFO " stack = 0x%p-0x%p\n" |
| 353 | KERN_INFO " init = 0x%p-0x%p\n" |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 354 | KERN_INFO " bss = 0x%p-0x%p\n" |
| 355 | KERN_INFO " available = 0x%p-0x%p\n" |
| 356 | #ifdef CONFIG_MTD_UCLINUX |
| 357 | KERN_INFO " rootfs = 0x%p-0x%p\n" |
| 358 | #endif |
| 359 | #if DMA_UNCACHED_REGION > 0 |
| 360 | KERN_INFO " DMA Zone = 0x%p-0x%p\n" |
| 361 | #endif |
| 362 | , _stext, _etext, |
Robin Getz | 86b73c8 | 2007-06-21 11:34:16 +0800 | [diff] [blame] | 363 | __start_rodata, __end_rodata, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 364 | _sdata, _edata, |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 365 | (void *)&init_thread_union, (void *)((int)(&init_thread_union) + 0x2000), |
Robin Getz | 86b73c8 | 2007-06-21 11:34:16 +0800 | [diff] [blame] | 366 | __init_begin, __init_end, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 367 | __bss_start, __bss_stop, |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 368 | (void *)_ramstart, (void *)memory_end |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 369 | #ifdef CONFIG_MTD_UCLINUX |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 370 | , (void *)memory_mtd_start, (void *)(memory_mtd_start + mtd_size) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 371 | #endif |
| 372 | #if DMA_UNCACHED_REGION > 0 |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 373 | , (void *)(_ramend - DMA_UNCACHED_REGION), (void *)(_ramend) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 374 | #endif |
| 375 | ); |
| 376 | |
| 377 | /* |
| 378 | * give all the memory to the bootmap allocator, tell it to put the |
| 379 | * boot mem_map at the start of memory |
| 380 | */ |
| 381 | bootmap_size = init_bootmem_node(NODE_DATA(0), memory_start >> PAGE_SHIFT, /* map goes here */ |
| 382 | PAGE_OFFSET >> PAGE_SHIFT, |
| 383 | memory_end >> PAGE_SHIFT); |
| 384 | /* |
| 385 | * free the usable memory, we have to make sure we do not free |
| 386 | * the bootmem bitmap so we then reserve it after freeing it :-) |
| 387 | */ |
| 388 | free_bootmem(memory_start, memory_end - memory_start); |
| 389 | |
| 390 | reserve_bootmem(memory_start, bootmap_size); |
| 391 | /* |
| 392 | * get kmalloc into gear |
| 393 | */ |
| 394 | paging_init(); |
| 395 | |
| 396 | /* check the size of the l1 area */ |
| 397 | l1_length = _etext_l1 - _stext_l1; |
| 398 | if (l1_length > L1_CODE_LENGTH) |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame^] | 399 | panic("L1 code memory overflow\n"); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 400 | |
| 401 | l1_length = _ebss_l1 - _sdata_l1; |
| 402 | if (l1_length > L1_DATA_A_LENGTH) |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame^] | 403 | panic("L1 data memory overflow\n"); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 404 | |
Mike Frysinger | a9c59c2 | 2007-05-21 18:09:32 +0800 | [diff] [blame] | 405 | #ifdef BF561_FAMILY |
| 406 | _bfin_swrst = bfin_read_SICA_SWRST(); |
| 407 | #else |
| 408 | _bfin_swrst = bfin_read_SWRST(); |
| 409 | #endif |
| 410 | |
Bernd Schmidt | 7adfb58 | 2007-06-21 11:34:16 +0800 | [diff] [blame] | 411 | /* Copy atomic sequences to their fixed location, and sanity check that |
| 412 | these locations are the ones that we advertise to userspace. */ |
| 413 | memcpy((void *)FIXED_CODE_START, &fixed_code_start, |
| 414 | FIXED_CODE_END - FIXED_CODE_START); |
| 415 | BUG_ON((char *)&sigreturn_stub - (char *)&fixed_code_start |
| 416 | != SIGRETURN_STUB - FIXED_CODE_START); |
| 417 | BUG_ON((char *)&atomic_xchg32 - (char *)&fixed_code_start |
| 418 | != ATOMIC_XCHG32 - FIXED_CODE_START); |
| 419 | BUG_ON((char *)&atomic_cas32 - (char *)&fixed_code_start |
| 420 | != ATOMIC_CAS32 - FIXED_CODE_START); |
| 421 | BUG_ON((char *)&atomic_add32 - (char *)&fixed_code_start |
| 422 | != ATOMIC_ADD32 - FIXED_CODE_START); |
| 423 | BUG_ON((char *)&atomic_sub32 - (char *)&fixed_code_start |
| 424 | != ATOMIC_SUB32 - FIXED_CODE_START); |
| 425 | BUG_ON((char *)&atomic_ior32 - (char *)&fixed_code_start |
| 426 | != ATOMIC_IOR32 - FIXED_CODE_START); |
| 427 | BUG_ON((char *)&atomic_and32 - (char *)&fixed_code_start |
| 428 | != ATOMIC_AND32 - FIXED_CODE_START); |
| 429 | BUG_ON((char *)&atomic_xor32 - (char *)&fixed_code_start |
| 430 | != ATOMIC_XOR32 - FIXED_CODE_START); |
Bernd Schmidt | 29440a2 | 2007-07-12 16:25:29 +0800 | [diff] [blame] | 431 | |
| 432 | bf53x_cache_init(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 433 | } |
| 434 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 435 | static int __init topology_init(void) |
| 436 | { |
| 437 | #if defined (CONFIG_BF561) |
Mike Frysinger | c0fc525 | 2007-05-21 18:09:25 +0800 | [diff] [blame] | 438 | static struct cpu cpu[2]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 439 | register_cpu(&cpu[0], 0); |
| 440 | register_cpu(&cpu[1], 1); |
| 441 | return 0; |
| 442 | #else |
Mike Frysinger | c0fc525 | 2007-05-21 18:09:25 +0800 | [diff] [blame] | 443 | static struct cpu cpu[1]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 444 | return register_cpu(cpu, 0); |
| 445 | #endif |
| 446 | } |
| 447 | |
| 448 | subsys_initcall(topology_init); |
| 449 | |
Mike Frysinger | 52a0781 | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 450 | static u_long get_vco(void) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 451 | { |
| 452 | u_long msel; |
| 453 | u_long vco; |
| 454 | |
| 455 | msel = (bfin_read_PLL_CTL() >> 9) & 0x3F; |
| 456 | if (0 == msel) |
| 457 | msel = 64; |
| 458 | |
| 459 | vco = CONFIG_CLKIN_HZ; |
| 460 | vco >>= (1 & bfin_read_PLL_CTL()); /* DF bit */ |
| 461 | vco = msel * vco; |
| 462 | return vco; |
| 463 | } |
| 464 | |
| 465 | /*Get the Core clock*/ |
| 466 | u_long get_cclk(void) |
| 467 | { |
| 468 | u_long csel, ssel; |
| 469 | if (bfin_read_PLL_STAT() & 0x1) |
| 470 | return CONFIG_CLKIN_HZ; |
| 471 | |
| 472 | ssel = bfin_read_PLL_DIV(); |
| 473 | csel = ((ssel >> 4) & 0x03); |
| 474 | ssel &= 0xf; |
| 475 | if (ssel && ssel < (1 << csel)) /* SCLK > CCLK */ |
| 476 | return get_vco() / ssel; |
| 477 | return get_vco() >> csel; |
| 478 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 479 | EXPORT_SYMBOL(get_cclk); |
| 480 | |
| 481 | /* Get the System clock */ |
| 482 | u_long get_sclk(void) |
| 483 | { |
| 484 | u_long ssel; |
| 485 | |
| 486 | if (bfin_read_PLL_STAT() & 0x1) |
| 487 | return CONFIG_CLKIN_HZ; |
| 488 | |
| 489 | ssel = (bfin_read_PLL_DIV() & 0xf); |
| 490 | if (0 == ssel) { |
| 491 | printk(KERN_WARNING "Invalid System Clock\n"); |
| 492 | ssel = 1; |
| 493 | } |
| 494 | |
| 495 | return get_vco() / ssel; |
| 496 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 497 | EXPORT_SYMBOL(get_sclk); |
| 498 | |
| 499 | /* |
| 500 | * Get CPU information for use by the procfs. |
| 501 | */ |
| 502 | static int show_cpuinfo(struct seq_file *m, void *v) |
| 503 | { |
| 504 | char *cpu, *mmu, *fpu, *name; |
| 505 | uint32_t revid; |
| 506 | |
| 507 | u_long cclk = 0, sclk = 0; |
| 508 | u_int dcache_size = 0, dsup_banks = 0; |
| 509 | |
| 510 | cpu = CPU; |
| 511 | mmu = "none"; |
| 512 | fpu = "none"; |
| 513 | revid = bfin_revid(); |
| 514 | name = bfin_board_name; |
| 515 | |
| 516 | cclk = get_cclk(); |
| 517 | sclk = get_sclk(); |
| 518 | |
| 519 | seq_printf(m, "CPU:\t\tADSP-%s Rev. 0.%d\n" |
| 520 | "MMU:\t\t%s\n" |
| 521 | "FPU:\t\t%s\n" |
| 522 | "Core Clock:\t%9lu Hz\n" |
| 523 | "System Clock:\t%9lu Hz\n" |
| 524 | "BogoMips:\t%lu.%02lu\n" |
| 525 | "Calibration:\t%lu loops\n", |
| 526 | cpu, revid, mmu, fpu, |
| 527 | cclk, |
| 528 | sclk, |
| 529 | (loops_per_jiffy * HZ) / 500000, |
| 530 | ((loops_per_jiffy * HZ) / 5000) % 100, |
| 531 | (loops_per_jiffy * HZ)); |
| 532 | seq_printf(m, "Board Name:\t%s\n", name); |
| 533 | seq_printf(m, "Board Memory:\t%ld MB\n", physical_mem_end >> 20); |
| 534 | seq_printf(m, "Kernel Memory:\t%ld MB\n", (unsigned long)_ramend >> 20); |
| 535 | if (bfin_read_IMEM_CONTROL() & (ENICPLB | IMC)) |
| 536 | seq_printf(m, "I-CACHE:\tON\n"); |
| 537 | else |
| 538 | seq_printf(m, "I-CACHE:\tOFF\n"); |
| 539 | if ((bfin_read_DMEM_CONTROL()) & (ENDCPLB | DMC_ENABLE)) |
| 540 | seq_printf(m, "D-CACHE:\tON" |
| 541 | #if defined CONFIG_BLKFIN_WB |
| 542 | " (write-back)" |
| 543 | #elif defined CONFIG_BLKFIN_WT |
| 544 | " (write-through)" |
| 545 | #endif |
| 546 | "\n"); |
| 547 | else |
| 548 | seq_printf(m, "D-CACHE:\tOFF\n"); |
| 549 | |
| 550 | |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 551 | switch (bfin_read_DMEM_CONTROL() & (1 << DMC0_P | 1 << DMC1_P)) { |
| 552 | case ACACHE_BSRAM: |
| 553 | seq_printf(m, "DBANK-A:\tCACHE\n" "DBANK-B:\tSRAM\n"); |
| 554 | dcache_size = 16; |
| 555 | dsup_banks = 1; |
| 556 | break; |
| 557 | case ACACHE_BCACHE: |
| 558 | seq_printf(m, "DBANK-A:\tCACHE\n" "DBANK-B:\tCACHE\n"); |
| 559 | dcache_size = 32; |
| 560 | dsup_banks = 2; |
| 561 | break; |
| 562 | case ASRAM_BSRAM: |
| 563 | seq_printf(m, "DBANK-A:\tSRAM\n" "DBANK-B:\tSRAM\n"); |
| 564 | dcache_size = 0; |
| 565 | dsup_banks = 0; |
| 566 | break; |
| 567 | default: |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 568 | break; |
| 569 | } |
| 570 | |
| 571 | |
| 572 | seq_printf(m, "I-CACHE Size:\t%dKB\n", BLKFIN_ICACHESIZE / 1024); |
| 573 | seq_printf(m, "D-CACHE Size:\t%dKB\n", dcache_size); |
| 574 | seq_printf(m, "I-CACHE Setup:\t%d Sub-banks/%d Ways, %d Lines/Way\n", |
| 575 | BLKFIN_ISUBBANKS, BLKFIN_IWAYS, BLKFIN_ILINES); |
| 576 | seq_printf(m, |
| 577 | "D-CACHE Setup:\t%d Super-banks/%d Sub-banks/%d Ways, %d Lines/Way\n", |
| 578 | dsup_banks, BLKFIN_DSUBBANKS, BLKFIN_DWAYS, |
| 579 | BLKFIN_DLINES); |
| 580 | #ifdef CONFIG_BLKFIN_CACHE_LOCK |
| 581 | switch (read_iloc()) { |
| 582 | case WAY0_L: |
| 583 | seq_printf(m, "Way0 Locked-Down\n"); |
| 584 | break; |
| 585 | case WAY1_L: |
| 586 | seq_printf(m, "Way1 Locked-Down\n"); |
| 587 | break; |
| 588 | case WAY01_L: |
| 589 | seq_printf(m, "Way0,Way1 Locked-Down\n"); |
| 590 | break; |
| 591 | case WAY2_L: |
| 592 | seq_printf(m, "Way2 Locked-Down\n"); |
| 593 | break; |
| 594 | case WAY02_L: |
| 595 | seq_printf(m, "Way0,Way2 Locked-Down\n"); |
| 596 | break; |
| 597 | case WAY12_L: |
| 598 | seq_printf(m, "Way1,Way2 Locked-Down\n"); |
| 599 | break; |
| 600 | case WAY012_L: |
| 601 | seq_printf(m, "Way0,Way1 & Way2 Locked-Down\n"); |
| 602 | break; |
| 603 | case WAY3_L: |
| 604 | seq_printf(m, "Way3 Locked-Down\n"); |
| 605 | break; |
| 606 | case WAY03_L: |
| 607 | seq_printf(m, "Way0,Way3 Locked-Down\n"); |
| 608 | break; |
| 609 | case WAY13_L: |
| 610 | seq_printf(m, "Way1,Way3 Locked-Down\n"); |
| 611 | break; |
| 612 | case WAY013_L: |
| 613 | seq_printf(m, "Way 0,Way1,Way3 Locked-Down\n"); |
| 614 | break; |
| 615 | case WAY32_L: |
| 616 | seq_printf(m, "Way3,Way2 Locked-Down\n"); |
| 617 | break; |
| 618 | case WAY320_L: |
| 619 | seq_printf(m, "Way3,Way2,Way0 Locked-Down\n"); |
| 620 | break; |
| 621 | case WAY321_L: |
| 622 | seq_printf(m, "Way3,Way2,Way1 Locked-Down\n"); |
| 623 | break; |
| 624 | case WAYALL_L: |
| 625 | seq_printf(m, "All Ways are locked\n"); |
| 626 | break; |
| 627 | default: |
| 628 | seq_printf(m, "No Ways are locked\n"); |
| 629 | } |
| 630 | #endif |
| 631 | return 0; |
| 632 | } |
| 633 | |
| 634 | static void *c_start(struct seq_file *m, loff_t *pos) |
| 635 | { |
| 636 | return *pos < NR_CPUS ? ((void *)0x12345678) : NULL; |
| 637 | } |
| 638 | |
| 639 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) |
| 640 | { |
| 641 | ++*pos; |
| 642 | return c_start(m, pos); |
| 643 | } |
| 644 | |
| 645 | static void c_stop(struct seq_file *m, void *v) |
| 646 | { |
| 647 | } |
| 648 | |
| 649 | struct seq_operations cpuinfo_op = { |
| 650 | .start = c_start, |
| 651 | .next = c_next, |
| 652 | .stop = c_stop, |
| 653 | .show = show_cpuinfo, |
| 654 | }; |
| 655 | |
Mike Frysinger | 5e10b4a | 2007-06-11 16:44:09 +0800 | [diff] [blame] | 656 | void __init cmdline_init(const char *r0) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 657 | { |
| 658 | if (r0) |
Mike Frysinger | 52a0781 | 2007-06-11 15:31:30 +0800 | [diff] [blame] | 659 | strncpy(command_line, r0, COMMAND_LINE_SIZE); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 660 | } |