setup.c 36 KB

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