setup.c 36 KB

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