setup.c 36 KB

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