setup.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  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. #include <linux/delay.h>
  30. #include <linux/console.h>
  31. #include <linux/bootmem.h>
  32. #include <linux/seq_file.h>
  33. #include <linux/cpu.h>
  34. #include <linux/module.h>
  35. #include <linux/tty.h>
  36. #include <linux/ext2_fs.h>
  37. #include <linux/cramfs_fs.h>
  38. #include <linux/romfs_fs.h>
  39. #include <asm/cacheflush.h>
  40. #include <asm/blackfin.h>
  41. #include <asm/cplbinit.h>
  42. u16 _bfin_swrst;
  43. unsigned long memory_start, memory_end, physical_mem_end;
  44. unsigned long reserved_mem_dcache_on;
  45. unsigned long reserved_mem_icache_on;
  46. EXPORT_SYMBOL(memory_start);
  47. EXPORT_SYMBOL(memory_end);
  48. EXPORT_SYMBOL(physical_mem_end);
  49. EXPORT_SYMBOL(_ramend);
  50. #ifdef CONFIG_MTD_UCLINUX
  51. unsigned long memory_mtd_end, memory_mtd_start, mtd_size;
  52. unsigned long _ebss;
  53. EXPORT_SYMBOL(memory_mtd_end);
  54. EXPORT_SYMBOL(memory_mtd_start);
  55. EXPORT_SYMBOL(mtd_size);
  56. #endif
  57. char command_line[COMMAND_LINE_SIZE];
  58. #if defined(CONFIG_BLKFIN_DCACHE) || defined(CONFIG_BLKFIN_CACHE)
  59. static void generate_cpl_tables(void);
  60. #endif
  61. void __init bf53x_cache_init(void)
  62. {
  63. #if defined(CONFIG_BLKFIN_DCACHE) || defined(CONFIG_BLKFIN_CACHE)
  64. generate_cpl_tables();
  65. #endif
  66. #ifdef CONFIG_BLKFIN_CACHE
  67. bfin_icache_init();
  68. printk(KERN_INFO "Instruction Cache Enabled\n");
  69. #endif
  70. #ifdef CONFIG_BLKFIN_DCACHE
  71. bfin_dcache_init();
  72. printk(KERN_INFO "Data Cache Enabled"
  73. # if defined CONFIG_BLKFIN_WB
  74. " (write-back)"
  75. # elif defined CONFIG_BLKFIN_WT
  76. " (write-through)"
  77. # endif
  78. "\n");
  79. #endif
  80. }
  81. void bf53x_relocate_l1_mem(void)
  82. {
  83. unsigned long l1_code_length;
  84. unsigned long l1_data_a_length;
  85. unsigned long l1_data_b_length;
  86. l1_code_length = _etext_l1 - _stext_l1;
  87. if (l1_code_length > L1_CODE_LENGTH)
  88. l1_code_length = L1_CODE_LENGTH;
  89. /* cannot complain as printk is not available as yet.
  90. * But we can continue booting and complain later!
  91. */
  92. /* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */
  93. dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length);
  94. l1_data_a_length = _ebss_l1 - _sdata_l1;
  95. if (l1_data_a_length > L1_DATA_A_LENGTH)
  96. l1_data_a_length = L1_DATA_A_LENGTH;
  97. /* Copy _sdata_l1 to _ebss_l1 to L1 data bank A SRAM */
  98. dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length);
  99. l1_data_b_length = _ebss_b_l1 - _sdata_b_l1;
  100. if (l1_data_b_length > L1_DATA_B_LENGTH)
  101. l1_data_b_length = L1_DATA_B_LENGTH;
  102. /* Copy _sdata_b_l1 to _ebss_b_l1 to L1 data bank B SRAM */
  103. dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length +
  104. l1_data_a_length, l1_data_b_length);
  105. }
  106. /*
  107. * Initial parsing of the command line. Currently, we support:
  108. * - Controlling the linux memory size: mem=xxx[KMG]
  109. * - Controlling the physical memory size: max_mem=xxx[KMG][$][#]
  110. * $ -> reserved memory is dcacheable
  111. * # -> reserved memory is icacheable
  112. */
  113. static __init void parse_cmdline_early(char *cmdline_p)
  114. {
  115. char c = ' ', *to = cmdline_p;
  116. unsigned int memsize;
  117. for (;;) {
  118. if (c == ' ') {
  119. if (!memcmp(to, "mem=", 4)) {
  120. to += 4;
  121. memsize = memparse(to, &to);
  122. if (memsize)
  123. _ramend = memsize;
  124. } else if (!memcmp(to, "max_mem=", 8)) {
  125. to += 8;
  126. memsize = memparse(to, &to);
  127. if (memsize) {
  128. physical_mem_end = memsize;
  129. if (*to != ' ') {
  130. if (*to == '$'
  131. || *(to + 1) == '$')
  132. reserved_mem_dcache_on =
  133. 1;
  134. if (*to == '#'
  135. || *(to + 1) == '#')
  136. reserved_mem_icache_on =
  137. 1;
  138. }
  139. }
  140. }
  141. }
  142. c = *(to++);
  143. if (!c)
  144. break;
  145. }
  146. }
  147. void __init setup_arch(char **cmdline_p)
  148. {
  149. int bootmap_size;
  150. unsigned long l1_length, sclk, cclk;
  151. #ifdef CONFIG_MTD_UCLINUX
  152. unsigned long mtd_phys = 0;
  153. #endif
  154. #ifdef CONFIG_DUMMY_CONSOLE
  155. conswitchp = &dummy_con;
  156. #endif
  157. cclk = get_cclk();
  158. sclk = get_sclk();
  159. #if !defined(CONFIG_BFIN_KERNEL_CLOCK) && defined(ANOMALY_05000273)
  160. if (cclk == sclk)
  161. panic("ANOMALY 05000273, SCLK can not be same as CCLK");
  162. #endif
  163. #if defined(ANOMALY_05000266)
  164. bfin_read_IMDMA_D0_IRQ_STATUS();
  165. bfin_read_IMDMA_D1_IRQ_STATUS();
  166. #endif
  167. #ifdef DEBUG_SERIAL_EARLY_INIT
  168. bfin_console_init(); /* early console registration */
  169. /* this give a chance to get printk() working before crash. */
  170. #endif
  171. #if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH)
  172. /* we need to initialize the Flashrom device here since we might
  173. * do things with flash early on in the boot
  174. */
  175. flash_probe();
  176. #endif
  177. #if defined(CONFIG_CMDLINE_BOOL)
  178. memset(command_line, 0, sizeof(command_line));
  179. strncpy(&command_line[0], CONFIG_CMDLINE, sizeof(command_line));
  180. command_line[sizeof(command_line) - 1] = 0;
  181. #endif
  182. /* Keep a copy of command line */
  183. *cmdline_p = &command_line[0];
  184. memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
  185. boot_command_line[COMMAND_LINE_SIZE - 1] = 0;
  186. /* setup memory defaults from the user config */
  187. physical_mem_end = 0;
  188. _ramend = CONFIG_MEM_SIZE * 1024 * 1024;
  189. parse_cmdline_early(&command_line[0]);
  190. if (physical_mem_end == 0)
  191. physical_mem_end = _ramend;
  192. /* by now the stack is part of the init task */
  193. memory_end = _ramend - DMA_UNCACHED_REGION;
  194. _ramstart = (unsigned long)__bss_stop;
  195. memory_start = PAGE_ALIGN(_ramstart);
  196. #if defined(CONFIG_MTD_UCLINUX)
  197. /* generic memory mapped MTD driver */
  198. memory_mtd_end = memory_end;
  199. mtd_phys = _ramstart;
  200. mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8)));
  201. # if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS)
  202. if (*((unsigned short *)(mtd_phys + 0x438)) == EXT2_SUPER_MAGIC)
  203. mtd_size =
  204. PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x404)) << 10);
  205. # endif
  206. # if defined(CONFIG_CRAMFS)
  207. if (*((unsigned long *)(mtd_phys)) == CRAMFS_MAGIC)
  208. mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x4)));
  209. # endif
  210. # if defined(CONFIG_ROMFS_FS)
  211. if (((unsigned long *)mtd_phys)[0] == ROMSB_WORD0
  212. && ((unsigned long *)mtd_phys)[1] == ROMSB_WORD1)
  213. mtd_size =
  214. PAGE_ALIGN(be32_to_cpu(((unsigned long *)mtd_phys)[2]));
  215. # if (defined(CONFIG_BLKFIN_CACHE) && defined(ANOMALY_05000263))
  216. /* Due to a Hardware Anomaly we need to limit the size of usable
  217. * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on
  218. * 05000263 - Hardware loop corrupted when taking an ICPLB exception
  219. */
  220. # if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO))
  221. if (memory_end >= 56 * 1024 * 1024)
  222. memory_end = 56 * 1024 * 1024;
  223. # else
  224. if (memory_end >= 60 * 1024 * 1024)
  225. memory_end = 60 * 1024 * 1024;
  226. # endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */
  227. # endif /* ANOMALY_05000263 */
  228. # endif /* CONFIG_ROMFS_FS */
  229. memory_end -= mtd_size;
  230. if (mtd_size == 0) {
  231. console_init();
  232. panic("Don't boot kernel without rootfs attached.\n");
  233. }
  234. /* Relocate MTD image to the top of memory after the uncached memory area */
  235. dma_memcpy((char *)memory_end, __bss_stop, mtd_size);
  236. memory_mtd_start = memory_end;
  237. _ebss = memory_mtd_start; /* define _ebss for compatible */
  238. #endif /* CONFIG_MTD_UCLINUX */
  239. #if (defined(CONFIG_BLKFIN_CACHE) && defined(ANOMALY_05000263))
  240. /* Due to a Hardware Anomaly we need to limit the size of usable
  241. * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on
  242. * 05000263 - Hardware loop corrupted when taking an ICPLB exception
  243. */
  244. #if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO))
  245. if (memory_end >= 56 * 1024 * 1024)
  246. memory_end = 56 * 1024 * 1024;
  247. #else
  248. if (memory_end >= 60 * 1024 * 1024)
  249. memory_end = 60 * 1024 * 1024;
  250. #endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */
  251. printk(KERN_NOTICE "Warning: limiting memory to %liMB due to hardware anomaly 05000263\n", memory_end >> 20);
  252. #endif /* ANOMALY_05000263 */
  253. #if !defined(CONFIG_MTD_UCLINUX)
  254. memory_end -= SIZE_4K; /*In case there is no valid CPLB behind memory_end make sure we don't get to close*/
  255. #endif
  256. init_mm.start_code = (unsigned long)_stext;
  257. init_mm.end_code = (unsigned long)_etext;
  258. init_mm.end_data = (unsigned long)_edata;
  259. init_mm.brk = (unsigned long)0;
  260. init_leds();
  261. printk(KERN_INFO "Blackfin support (C) 2004-2007 Analog Devices, Inc.\n");
  262. printk(KERN_INFO "Compiled for ADSP-%s Rev 0.%d\n", CPU, bfin_compiled_revid());
  263. if (bfin_revid() != bfin_compiled_revid())
  264. printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n",
  265. bfin_compiled_revid(), bfin_revid());
  266. if (bfin_revid() < SUPPORTED_REVID)
  267. printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n",
  268. CPU, bfin_revid());
  269. printk(KERN_INFO "Blackfin Linux support by http://blackfin.uclinux.org/\n");
  270. printk(KERN_INFO "Processor Speed: %lu MHz core clock and %lu Mhz System Clock\n",
  271. cclk / 1000000, sclk / 1000000);
  272. #if defined(ANOMALY_05000273)
  273. if ((cclk >> 1) <= sclk)
  274. printk("\n\n\nANOMALY_05000273: CCLK must be >= 2*SCLK !!!\n\n\n");
  275. #endif
  276. printk(KERN_INFO "Board Memory: %ldMB\n", physical_mem_end >> 20);
  277. printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20);
  278. printk(KERN_INFO "Memory map:\n"
  279. KERN_INFO " text = 0x%p-0x%p\n"
  280. KERN_INFO " init = 0x%p-0x%p\n"
  281. KERN_INFO " data = 0x%p-0x%p\n"
  282. KERN_INFO " stack = 0x%p-0x%p\n"
  283. KERN_INFO " bss = 0x%p-0x%p\n"
  284. KERN_INFO " available = 0x%p-0x%p\n"
  285. #ifdef CONFIG_MTD_UCLINUX
  286. KERN_INFO " rootfs = 0x%p-0x%p\n"
  287. #endif
  288. #if DMA_UNCACHED_REGION > 0
  289. KERN_INFO " DMA Zone = 0x%p-0x%p\n"
  290. #endif
  291. , _stext, _etext,
  292. __init_begin, __init_end,
  293. _sdata, _edata,
  294. (void*)&init_thread_union, (void*)((int)(&init_thread_union) + 0x2000),
  295. __bss_start, __bss_stop,
  296. (void*)_ramstart, (void*)memory_end
  297. #ifdef CONFIG_MTD_UCLINUX
  298. , (void*)memory_mtd_start, (void*)(memory_mtd_start + mtd_size)
  299. #endif
  300. #if DMA_UNCACHED_REGION > 0
  301. , (void*)(_ramend - DMA_UNCACHED_REGION), (void*)(_ramend)
  302. #endif
  303. );
  304. /*
  305. * give all the memory to the bootmap allocator, tell it to put the
  306. * boot mem_map at the start of memory
  307. */
  308. bootmap_size = init_bootmem_node(NODE_DATA(0), memory_start >> PAGE_SHIFT, /* map goes here */
  309. PAGE_OFFSET >> PAGE_SHIFT,
  310. memory_end >> PAGE_SHIFT);
  311. /*
  312. * free the usable memory, we have to make sure we do not free
  313. * the bootmem bitmap so we then reserve it after freeing it :-)
  314. */
  315. free_bootmem(memory_start, memory_end - memory_start);
  316. reserve_bootmem(memory_start, bootmap_size);
  317. /*
  318. * get kmalloc into gear
  319. */
  320. paging_init();
  321. /* check the size of the l1 area */
  322. l1_length = _etext_l1 - _stext_l1;
  323. if (l1_length > L1_CODE_LENGTH)
  324. panic("L1 memory overflow\n");
  325. l1_length = _ebss_l1 - _sdata_l1;
  326. if (l1_length > L1_DATA_A_LENGTH)
  327. panic("L1 memory overflow\n");
  328. #ifdef BF561_FAMILY
  329. _bfin_swrst = bfin_read_SICA_SWRST();
  330. #else
  331. _bfin_swrst = bfin_read_SWRST();
  332. #endif
  333. bf53x_cache_init();
  334. printk(KERN_INFO "Hardware Trace Enabled\n");
  335. bfin_write_TBUFCTL(0x03);
  336. }
  337. static int __init topology_init(void)
  338. {
  339. #if defined (CONFIG_BF561)
  340. static struct cpu cpu[2];
  341. register_cpu(&cpu[0], 0);
  342. register_cpu(&cpu[1], 1);
  343. return 0;
  344. #else
  345. static struct cpu cpu[1];
  346. return register_cpu(cpu, 0);
  347. #endif
  348. }
  349. subsys_initcall(topology_init);
  350. #if defined(CONFIG_BLKFIN_DCACHE) || defined(CONFIG_BLKFIN_CACHE)
  351. u16 lock_kernel_check(u32 start, u32 end)
  352. {
  353. if ((start <= (u32) _stext && end >= (u32) _end)
  354. || (start >= (u32) _stext && end <= (u32) _end))
  355. return IN_KERNEL;
  356. return 0;
  357. }
  358. static unsigned short __init
  359. fill_cplbtab(struct cplb_tab *table,
  360. unsigned long start, unsigned long end,
  361. unsigned long block_size, unsigned long cplb_data)
  362. {
  363. int i;
  364. switch (block_size) {
  365. case SIZE_4M:
  366. i = 3;
  367. break;
  368. case SIZE_1M:
  369. i = 2;
  370. break;
  371. case SIZE_4K:
  372. i = 1;
  373. break;
  374. case SIZE_1K:
  375. default:
  376. i = 0;
  377. break;
  378. }
  379. cplb_data = (cplb_data & ~(3 << 16)) | (i << 16);
  380. while ((start < end) && (table->pos < table->size)) {
  381. table->tab[table->pos++] = start;
  382. if (lock_kernel_check(start, start + block_size) == IN_KERNEL)
  383. table->tab[table->pos++] =
  384. cplb_data | CPLB_LOCK | CPLB_DIRTY;
  385. else
  386. table->tab[table->pos++] = cplb_data;
  387. start += block_size;
  388. }
  389. return 0;
  390. }
  391. static unsigned short __init
  392. close_cplbtab(struct cplb_tab *table)
  393. {
  394. while (table->pos < table->size) {
  395. table->tab[table->pos++] = 0;
  396. table->tab[table->pos++] = 0; /* !CPLB_VALID */
  397. }
  398. return 0;
  399. }
  400. static void __init generate_cpl_tables(void)
  401. {
  402. u16 i, j, process;
  403. u32 a_start, a_end, as, ae, as_1m;
  404. struct cplb_tab *t_i = NULL;
  405. struct cplb_tab *t_d = NULL;
  406. struct s_cplb cplb;
  407. cplb.init_i.size = MAX_CPLBS;
  408. cplb.init_d.size = MAX_CPLBS;
  409. cplb.switch_i.size = MAX_SWITCH_I_CPLBS;
  410. cplb.switch_d.size = MAX_SWITCH_D_CPLBS;
  411. cplb.init_i.pos = 0;
  412. cplb.init_d.pos = 0;
  413. cplb.switch_i.pos = 0;
  414. cplb.switch_d.pos = 0;
  415. cplb.init_i.tab = icplb_table;
  416. cplb.init_d.tab = dcplb_table;
  417. cplb.switch_i.tab = ipdt_table;
  418. cplb.switch_d.tab = dpdt_table;
  419. cplb_data[SDRAM_KERN].end = memory_end;
  420. #ifdef CONFIG_MTD_UCLINUX
  421. cplb_data[SDRAM_RAM_MTD].start = memory_mtd_start;
  422. cplb_data[SDRAM_RAM_MTD].end = memory_mtd_start + mtd_size;
  423. cplb_data[SDRAM_RAM_MTD].valid = mtd_size > 0;
  424. # if defined(CONFIG_ROMFS_FS)
  425. cplb_data[SDRAM_RAM_MTD].attr |= I_CPLB;
  426. /*
  427. * The ROMFS_FS size is often not multiple of 1MB.
  428. * This can cause multiple CPLB sets covering the same memory area.
  429. * This will then cause multiple CPLB hit exceptions.
  430. * Workaround: We ensure a contiguous memory area by extending the kernel
  431. * memory section over the mtd section.
  432. * For ROMFS_FS memory must be covered with ICPLBs anyways.
  433. * So there is no difference between kernel and mtd memory setup.
  434. */
  435. cplb_data[SDRAM_KERN].end = memory_mtd_start + mtd_size;;
  436. cplb_data[SDRAM_RAM_MTD].valid = 0;
  437. # endif
  438. #else
  439. cplb_data[SDRAM_RAM_MTD].valid = 0;
  440. #endif
  441. cplb_data[SDRAM_DMAZ].start = _ramend - DMA_UNCACHED_REGION;
  442. cplb_data[SDRAM_DMAZ].end = _ramend;
  443. cplb_data[RES_MEM].start = _ramend;
  444. cplb_data[RES_MEM].end = physical_mem_end;
  445. if (reserved_mem_dcache_on)
  446. cplb_data[RES_MEM].d_conf = SDRAM_DGENERIC;
  447. else
  448. cplb_data[RES_MEM].d_conf = SDRAM_DNON_CHBL;
  449. if (reserved_mem_icache_on)
  450. cplb_data[RES_MEM].i_conf = SDRAM_IGENERIC;
  451. else
  452. cplb_data[RES_MEM].i_conf = SDRAM_INON_CHBL;
  453. for (i = ZERO_P; i <= L2_MEM; i++) {
  454. if (cplb_data[i].valid) {
  455. as_1m = cplb_data[i].start % SIZE_1M;
  456. /* We need to make sure all sections are properly 1M aligned
  457. * However between Kernel Memory and the Kernel mtd section, depending on the
  458. * rootfs size, there can be overlapping memory areas.
  459. */
  460. if (as_1m && i!=L1I_MEM && i!=L1D_MEM) {
  461. #ifdef CONFIG_MTD_UCLINUX
  462. if (i == SDRAM_RAM_MTD) {
  463. if ((cplb_data[SDRAM_KERN].end + 1) > cplb_data[SDRAM_RAM_MTD].start)
  464. cplb_data[SDRAM_RAM_MTD].start = (cplb_data[i].start & (-2*SIZE_1M)) + SIZE_1M;
  465. else
  466. cplb_data[SDRAM_RAM_MTD].start = (cplb_data[i].start & (-2*SIZE_1M));
  467. } else
  468. #endif
  469. printk(KERN_WARNING "Unaligned Start of %s at 0x%X\n",
  470. cplb_data[i].name, cplb_data[i].start);
  471. }
  472. as = cplb_data[i].start % SIZE_4M;
  473. ae = cplb_data[i].end % SIZE_4M;
  474. if (as)
  475. a_start = cplb_data[i].start + (SIZE_4M - (as));
  476. else
  477. a_start = cplb_data[i].start;
  478. a_end = cplb_data[i].end - ae;
  479. for (j = INITIAL_T; j <= SWITCH_T; j++) {
  480. switch (j) {
  481. case INITIAL_T:
  482. if (cplb_data[i].attr & INITIAL_T) {
  483. t_i = &cplb.init_i;
  484. t_d = &cplb.init_d;
  485. process = 1;
  486. } else
  487. process = 0;
  488. break;
  489. case SWITCH_T:
  490. if (cplb_data[i].attr & SWITCH_T) {
  491. t_i = &cplb.switch_i;
  492. t_d = &cplb.switch_d;
  493. process = 1;
  494. } else
  495. process = 0;
  496. break;
  497. default:
  498. process = 0;
  499. break;
  500. }
  501. if (process) {
  502. if (cplb_data[i].attr & I_CPLB) {
  503. if (cplb_data[i].psize) {
  504. fill_cplbtab(t_i,
  505. cplb_data[i].start,
  506. cplb_data[i].end,
  507. cplb_data[i].psize,
  508. cplb_data[i].i_conf);
  509. } else {
  510. /*icplb_table */
  511. #if (defined(CONFIG_BLKFIN_CACHE) && defined(ANOMALY_05000263))
  512. if (i == SDRAM_KERN) {
  513. fill_cplbtab(t_i,
  514. cplb_data[i].start,
  515. cplb_data[i].end,
  516. SIZE_4M,
  517. cplb_data[i].i_conf);
  518. } else
  519. #endif
  520. {
  521. fill_cplbtab(t_i,
  522. cplb_data[i].start,
  523. a_start,
  524. SIZE_1M,
  525. cplb_data[i].i_conf);
  526. fill_cplbtab(t_i,
  527. a_start,
  528. a_end,
  529. SIZE_4M,
  530. cplb_data[i].i_conf);
  531. fill_cplbtab(t_i, a_end,
  532. cplb_data[i].end,
  533. SIZE_1M,
  534. cplb_data[i].i_conf);
  535. }
  536. }
  537. }
  538. if (cplb_data[i].attr & D_CPLB) {
  539. if (cplb_data[i].psize) {
  540. fill_cplbtab(t_d,
  541. cplb_data[i].start,
  542. cplb_data[i].end,
  543. cplb_data[i].psize,
  544. cplb_data[i].d_conf);
  545. } else {
  546. /*dcplb_table*/
  547. fill_cplbtab(t_d,
  548. cplb_data[i].start,
  549. a_start, SIZE_1M,
  550. cplb_data[i].d_conf);
  551. fill_cplbtab(t_d, a_start,
  552. a_end, SIZE_4M,
  553. cplb_data[i].d_conf);
  554. fill_cplbtab(t_d, a_end,
  555. cplb_data[i].end,
  556. SIZE_1M,
  557. cplb_data[i].d_conf);
  558. }
  559. }
  560. }
  561. }
  562. }
  563. }
  564. /* close tables */
  565. close_cplbtab(&cplb.init_i);
  566. close_cplbtab(&cplb.init_d);
  567. cplb.init_i.tab[cplb.init_i.pos] = -1;
  568. cplb.init_d.tab[cplb.init_d.pos] = -1;
  569. cplb.switch_i.tab[cplb.switch_i.pos] = -1;
  570. cplb.switch_d.tab[cplb.switch_d.pos] = -1;
  571. }
  572. #endif
  573. static inline u_long get_vco(void)
  574. {
  575. u_long msel;
  576. u_long vco;
  577. msel = (bfin_read_PLL_CTL() >> 9) & 0x3F;
  578. if (0 == msel)
  579. msel = 64;
  580. vco = CONFIG_CLKIN_HZ;
  581. vco >>= (1 & bfin_read_PLL_CTL()); /* DF bit */
  582. vco = msel * vco;
  583. return vco;
  584. }
  585. /*Get the Core clock*/
  586. u_long get_cclk(void)
  587. {
  588. u_long csel, ssel;
  589. if (bfin_read_PLL_STAT() & 0x1)
  590. return CONFIG_CLKIN_HZ;
  591. ssel = bfin_read_PLL_DIV();
  592. csel = ((ssel >> 4) & 0x03);
  593. ssel &= 0xf;
  594. if (ssel && ssel < (1 << csel)) /* SCLK > CCLK */
  595. return get_vco() / ssel;
  596. return get_vco() >> csel;
  597. }
  598. EXPORT_SYMBOL(get_cclk);
  599. /* Get the System clock */
  600. u_long get_sclk(void)
  601. {
  602. u_long ssel;
  603. if (bfin_read_PLL_STAT() & 0x1)
  604. return CONFIG_CLKIN_HZ;
  605. ssel = (bfin_read_PLL_DIV() & 0xf);
  606. if (0 == ssel) {
  607. printk(KERN_WARNING "Invalid System Clock\n");
  608. ssel = 1;
  609. }
  610. return get_vco() / ssel;
  611. }
  612. EXPORT_SYMBOL(get_sclk);
  613. /*
  614. * Get CPU information for use by the procfs.
  615. */
  616. static int show_cpuinfo(struct seq_file *m, void *v)
  617. {
  618. char *cpu, *mmu, *fpu, *name;
  619. uint32_t revid;
  620. u_long cclk = 0, sclk = 0;
  621. u_int dcache_size = 0, dsup_banks = 0;
  622. cpu = CPU;
  623. mmu = "none";
  624. fpu = "none";
  625. revid = bfin_revid();
  626. name = bfin_board_name;
  627. cclk = get_cclk();
  628. sclk = get_sclk();
  629. seq_printf(m, "CPU:\t\tADSP-%s Rev. 0.%d\n"
  630. "MMU:\t\t%s\n"
  631. "FPU:\t\t%s\n"
  632. "Core Clock:\t%9lu Hz\n"
  633. "System Clock:\t%9lu Hz\n"
  634. "BogoMips:\t%lu.%02lu\n"
  635. "Calibration:\t%lu loops\n",
  636. cpu, revid, mmu, fpu,
  637. cclk,
  638. sclk,
  639. (loops_per_jiffy * HZ) / 500000,
  640. ((loops_per_jiffy * HZ) / 5000) % 100,
  641. (loops_per_jiffy * HZ));
  642. seq_printf(m, "Board Name:\t%s\n", name);
  643. seq_printf(m, "Board Memory:\t%ld MB\n", physical_mem_end >> 20);
  644. seq_printf(m, "Kernel Memory:\t%ld MB\n", (unsigned long)_ramend >> 20);
  645. if (bfin_read_IMEM_CONTROL() & (ENICPLB | IMC))
  646. seq_printf(m, "I-CACHE:\tON\n");
  647. else
  648. seq_printf(m, "I-CACHE:\tOFF\n");
  649. if ((bfin_read_DMEM_CONTROL()) & (ENDCPLB | DMC_ENABLE))
  650. seq_printf(m, "D-CACHE:\tON"
  651. #if defined CONFIG_BLKFIN_WB
  652. " (write-back)"
  653. #elif defined CONFIG_BLKFIN_WT
  654. " (write-through)"
  655. #endif
  656. "\n");
  657. else
  658. seq_printf(m, "D-CACHE:\tOFF\n");
  659. switch(bfin_read_DMEM_CONTROL() & (1 << DMC0_P | 1 << DMC1_P)) {
  660. case ACACHE_BSRAM:
  661. seq_printf(m, "DBANK-A:\tCACHE\n" "DBANK-B:\tSRAM\n");
  662. dcache_size = 16;
  663. dsup_banks = 1;
  664. break;
  665. case ACACHE_BCACHE:
  666. seq_printf(m, "DBANK-A:\tCACHE\n" "DBANK-B:\tCACHE\n");
  667. dcache_size = 32;
  668. dsup_banks = 2;
  669. break;
  670. case ASRAM_BSRAM:
  671. seq_printf(m, "DBANK-A:\tSRAM\n" "DBANK-B:\tSRAM\n");
  672. dcache_size = 0;
  673. dsup_banks = 0;
  674. break;
  675. default:
  676. break;
  677. }
  678. seq_printf(m, "I-CACHE Size:\t%dKB\n", BLKFIN_ICACHESIZE / 1024);
  679. seq_printf(m, "D-CACHE Size:\t%dKB\n", dcache_size);
  680. seq_printf(m, "I-CACHE Setup:\t%d Sub-banks/%d Ways, %d Lines/Way\n",
  681. BLKFIN_ISUBBANKS, BLKFIN_IWAYS, BLKFIN_ILINES);
  682. seq_printf(m,
  683. "D-CACHE Setup:\t%d Super-banks/%d Sub-banks/%d Ways, %d Lines/Way\n",
  684. dsup_banks, BLKFIN_DSUBBANKS, BLKFIN_DWAYS,
  685. BLKFIN_DLINES);
  686. #ifdef CONFIG_BLKFIN_CACHE_LOCK
  687. switch (read_iloc()) {
  688. case WAY0_L:
  689. seq_printf(m, "Way0 Locked-Down\n");
  690. break;
  691. case WAY1_L:
  692. seq_printf(m, "Way1 Locked-Down\n");
  693. break;
  694. case WAY01_L:
  695. seq_printf(m, "Way0,Way1 Locked-Down\n");
  696. break;
  697. case WAY2_L:
  698. seq_printf(m, "Way2 Locked-Down\n");
  699. break;
  700. case WAY02_L:
  701. seq_printf(m, "Way0,Way2 Locked-Down\n");
  702. break;
  703. case WAY12_L:
  704. seq_printf(m, "Way1,Way2 Locked-Down\n");
  705. break;
  706. case WAY012_L:
  707. seq_printf(m, "Way0,Way1 & Way2 Locked-Down\n");
  708. break;
  709. case WAY3_L:
  710. seq_printf(m, "Way3 Locked-Down\n");
  711. break;
  712. case WAY03_L:
  713. seq_printf(m, "Way0,Way3 Locked-Down\n");
  714. break;
  715. case WAY13_L:
  716. seq_printf(m, "Way1,Way3 Locked-Down\n");
  717. break;
  718. case WAY013_L:
  719. seq_printf(m, "Way 0,Way1,Way3 Locked-Down\n");
  720. break;
  721. case WAY32_L:
  722. seq_printf(m, "Way3,Way2 Locked-Down\n");
  723. break;
  724. case WAY320_L:
  725. seq_printf(m, "Way3,Way2,Way0 Locked-Down\n");
  726. break;
  727. case WAY321_L:
  728. seq_printf(m, "Way3,Way2,Way1 Locked-Down\n");
  729. break;
  730. case WAYALL_L:
  731. seq_printf(m, "All Ways are locked\n");
  732. break;
  733. default:
  734. seq_printf(m, "No Ways are locked\n");
  735. }
  736. #endif
  737. return 0;
  738. }
  739. static void *c_start(struct seq_file *m, loff_t *pos)
  740. {
  741. return *pos < NR_CPUS ? ((void *)0x12345678) : NULL;
  742. }
  743. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  744. {
  745. ++*pos;
  746. return c_start(m, pos);
  747. }
  748. static void c_stop(struct seq_file *m, void *v)
  749. {
  750. }
  751. struct seq_operations cpuinfo_op = {
  752. .start = c_start,
  753. .next = c_next,
  754. .stop = c_stop,
  755. .show = show_cpuinfo,
  756. };
  757. void cmdline_init(unsigned long r0)
  758. {
  759. if (r0)
  760. strncpy(command_line, (char *)r0, COMMAND_LINE_SIZE);
  761. }