setup.c 34 KB

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