setup.c 35 KB

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