setup.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. /*
  2. * File: arch/blackfin/kernel/setup.c
  3. * Based on:
  4. * Author:
  5. *
  6. * Created:
  7. * Description:
  8. *
  9. * Modified:
  10. * Copyright 2004-2006 Analog Devices Inc.
  11. *
  12. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, see the file COPYING, or write
  26. * to the Free Software Foundation, Inc.,
  27. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  28. */
  29. #include <linux/delay.h>
  30. #include <linux/console.h>
  31. #include <linux/bootmem.h>
  32. #include <linux/seq_file.h>
  33. #include <linux/cpu.h>
  34. #include <linux/module.h>
  35. #include <linux/tty.h>
  36. #include <linux/ext2_fs.h>
  37. #include <linux/cramfs_fs.h>
  38. #include <linux/romfs_fs.h>
  39. #include <asm/cplb.h>
  40. #include <asm/cacheflush.h>
  41. #include <asm/blackfin.h>
  42. #include <asm/cplbinit.h>
  43. #include <asm/div64.h>
  44. #include <asm/fixed_code.h>
  45. #include <asm/early_printk.h>
  46. u16 _bfin_swrst;
  47. unsigned long memory_start, memory_end, physical_mem_end;
  48. unsigned long reserved_mem_dcache_on;
  49. unsigned long reserved_mem_icache_on;
  50. EXPORT_SYMBOL(memory_start);
  51. EXPORT_SYMBOL(memory_end);
  52. EXPORT_SYMBOL(physical_mem_end);
  53. EXPORT_SYMBOL(_ramend);
  54. #ifdef CONFIG_MTD_UCLINUX
  55. unsigned long memory_mtd_end, memory_mtd_start, mtd_size;
  56. unsigned long _ebss;
  57. EXPORT_SYMBOL(memory_mtd_end);
  58. EXPORT_SYMBOL(memory_mtd_start);
  59. EXPORT_SYMBOL(mtd_size);
  60. #endif
  61. char __initdata command_line[COMMAND_LINE_SIZE];
  62. void __init bf53x_cache_init(void)
  63. {
  64. #if defined(CONFIG_BFIN_DCACHE) || defined(CONFIG_BFIN_ICACHE)
  65. generate_cpl_tables();
  66. #endif
  67. #ifdef CONFIG_BFIN_ICACHE
  68. bfin_icache_init();
  69. printk(KERN_INFO "Instruction Cache Enabled\n");
  70. #endif
  71. #ifdef CONFIG_BFIN_DCACHE
  72. bfin_dcache_init();
  73. printk(KERN_INFO "Data Cache Enabled"
  74. # if defined CONFIG_BFIN_WB
  75. " (write-back)"
  76. # elif defined CONFIG_BFIN_WT
  77. " (write-through)"
  78. # endif
  79. "\n");
  80. #endif
  81. }
  82. void __init bf53x_relocate_l1_mem(void)
  83. {
  84. unsigned long l1_code_length;
  85. unsigned long l1_data_a_length;
  86. unsigned long l1_data_b_length;
  87. l1_code_length = _etext_l1 - _stext_l1;
  88. if (l1_code_length > L1_CODE_LENGTH)
  89. l1_code_length = L1_CODE_LENGTH;
  90. /* cannot complain as printk is not available as yet.
  91. * But we can continue booting and complain later!
  92. */
  93. /* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */
  94. dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length);
  95. l1_data_a_length = _ebss_l1 - _sdata_l1;
  96. if (l1_data_a_length > L1_DATA_A_LENGTH)
  97. l1_data_a_length = L1_DATA_A_LENGTH;
  98. /* Copy _sdata_l1 to _ebss_l1 to L1 data bank A SRAM */
  99. dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length);
  100. l1_data_b_length = _ebss_b_l1 - _sdata_b_l1;
  101. if (l1_data_b_length > L1_DATA_B_LENGTH)
  102. l1_data_b_length = L1_DATA_B_LENGTH;
  103. /* Copy _sdata_b_l1 to _ebss_b_l1 to L1 data bank B SRAM */
  104. dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length +
  105. l1_data_a_length, l1_data_b_length);
  106. }
  107. /*
  108. * Initial parsing of the command line. Currently, we support:
  109. * - Controlling the linux memory size: mem=xxx[KMG]
  110. * - Controlling the physical memory size: max_mem=xxx[KMG][$][#]
  111. * $ -> reserved memory is dcacheable
  112. * # -> reserved memory is icacheable
  113. */
  114. static __init void parse_cmdline_early(char *cmdline_p)
  115. {
  116. char c = ' ', *to = cmdline_p;
  117. unsigned int memsize;
  118. for (;;) {
  119. if (c == ' ') {
  120. if (!memcmp(to, "mem=", 4)) {
  121. to += 4;
  122. memsize = memparse(to, &to);
  123. if (memsize)
  124. _ramend = memsize;
  125. } else if (!memcmp(to, "max_mem=", 8)) {
  126. to += 8;
  127. memsize = memparse(to, &to);
  128. if (memsize) {
  129. physical_mem_end = memsize;
  130. if (*to != ' ') {
  131. if (*to == '$'
  132. || *(to + 1) == '$')
  133. reserved_mem_dcache_on =
  134. 1;
  135. if (*to == '#'
  136. || *(to + 1) == '#')
  137. reserved_mem_icache_on =
  138. 1;
  139. }
  140. }
  141. } else if (!memcmp(to, "earlyprintk=", 12)) {
  142. to += 12;
  143. setup_early_printk(to);
  144. }
  145. }
  146. c = *(to++);
  147. if (!c)
  148. break;
  149. }
  150. }
  151. void __init setup_arch(char **cmdline_p)
  152. {
  153. int bootmap_size;
  154. unsigned long l1_length, sclk, cclk;
  155. #ifdef CONFIG_MTD_UCLINUX
  156. unsigned long mtd_phys = 0;
  157. #endif
  158. #ifdef CONFIG_DUMMY_CONSOLE
  159. conswitchp = &dummy_con;
  160. #endif
  161. #if defined(CONFIG_CMDLINE_BOOL)
  162. strncpy(&command_line[0], CONFIG_CMDLINE, sizeof(command_line));
  163. command_line[sizeof(command_line) - 1] = 0;
  164. #endif
  165. /* Keep a copy of command line */
  166. *cmdline_p = &command_line[0];
  167. memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
  168. boot_command_line[COMMAND_LINE_SIZE - 1] = '\0';
  169. /* setup memory defaults from the user config */
  170. physical_mem_end = 0;
  171. _ramend = CONFIG_MEM_SIZE * 1024 * 1024;
  172. parse_cmdline_early(&command_line[0]);
  173. cclk = get_cclk();
  174. sclk = get_sclk();
  175. #if !defined(CONFIG_BFIN_KERNEL_CLOCK)
  176. if (ANOMALY_05000273 && cclk == sclk)
  177. panic("ANOMALY 05000273, SCLK can not be same as CCLK");
  178. #endif
  179. #ifdef BF561_FAMILY
  180. if (ANOMALY_05000266) {
  181. bfin_read_IMDMA_D0_IRQ_STATUS();
  182. bfin_read_IMDMA_D1_IRQ_STATUS();
  183. }
  184. #endif
  185. printk(KERN_INFO "Hardware Trace ");
  186. if (bfin_read_TBUFCTL() & 0x1 )
  187. printk("Active ");
  188. else
  189. printk("Off ");
  190. if (bfin_read_TBUFCTL() & 0x2)
  191. printk("and Enabled\n");
  192. else
  193. printk("and Disabled\n");
  194. #if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH)
  195. /* we need to initialize the Flashrom device here since we might
  196. * do things with flash early on in the boot
  197. */
  198. flash_probe();
  199. #endif
  200. if (physical_mem_end == 0)
  201. physical_mem_end = _ramend;
  202. /* by now the stack is part of the init task */
  203. memory_end = _ramend - DMA_UNCACHED_REGION;
  204. _ramstart = (unsigned long)__bss_stop;
  205. _rambase = (unsigned long)_stext;
  206. #ifdef CONFIG_MPU
  207. /* Round up to multiple of 4MB. */
  208. memory_start = (_ramstart + 0x3fffff) & ~0x3fffff;
  209. #else
  210. memory_start = PAGE_ALIGN(_ramstart);
  211. #endif
  212. #if defined(CONFIG_MTD_UCLINUX)
  213. /* generic memory mapped MTD driver */
  214. memory_mtd_end = memory_end;
  215. mtd_phys = _ramstart;
  216. mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8)));
  217. # if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS)
  218. if (*((unsigned short *)(mtd_phys + 0x438)) == EXT2_SUPER_MAGIC)
  219. mtd_size =
  220. PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x404)) << 10);
  221. # endif
  222. # if defined(CONFIG_CRAMFS)
  223. if (*((unsigned long *)(mtd_phys)) == CRAMFS_MAGIC)
  224. mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x4)));
  225. # endif
  226. # if defined(CONFIG_ROMFS_FS)
  227. if (((unsigned long *)mtd_phys)[0] == ROMSB_WORD0
  228. && ((unsigned long *)mtd_phys)[1] == ROMSB_WORD1)
  229. mtd_size =
  230. PAGE_ALIGN(be32_to_cpu(((unsigned long *)mtd_phys)[2]));
  231. # if (defined(CONFIG_BFIN_ICACHE) && ANOMALY_05000263)
  232. /* Due to a Hardware Anomaly we need to limit the size of usable
  233. * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on
  234. * 05000263 - Hardware loop corrupted when taking an ICPLB exception
  235. */
  236. # if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO))
  237. if (memory_end >= 56 * 1024 * 1024)
  238. memory_end = 56 * 1024 * 1024;
  239. # else
  240. if (memory_end >= 60 * 1024 * 1024)
  241. memory_end = 60 * 1024 * 1024;
  242. # endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */
  243. # endif /* ANOMALY_05000263 */
  244. # endif /* CONFIG_ROMFS_FS */
  245. memory_end -= mtd_size;
  246. if (mtd_size == 0) {
  247. console_init();
  248. panic("Don't boot kernel without rootfs attached.\n");
  249. }
  250. /* Relocate MTD image to the top of memory after the uncached memory area */
  251. dma_memcpy((char *)memory_end, __bss_stop, mtd_size);
  252. memory_mtd_start = memory_end;
  253. _ebss = memory_mtd_start; /* define _ebss for compatible */
  254. #endif /* CONFIG_MTD_UCLINUX */
  255. #if (defined(CONFIG_BFIN_ICACHE) && ANOMALY_05000263)
  256. /* Due to a Hardware Anomaly we need to limit the size of usable
  257. * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on
  258. * 05000263 - Hardware loop corrupted when taking an ICPLB exception
  259. */
  260. #if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO))
  261. if (memory_end >= 56 * 1024 * 1024)
  262. memory_end = 56 * 1024 * 1024;
  263. #else
  264. if (memory_end >= 60 * 1024 * 1024)
  265. memory_end = 60 * 1024 * 1024;
  266. #endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */
  267. printk(KERN_NOTICE "Warning: limiting memory to %liMB due to hardware anomaly 05000263\n", memory_end >> 20);
  268. #endif /* ANOMALY_05000263 */
  269. #ifdef CONFIG_MPU
  270. page_mask_nelts = ((_ramend >> PAGE_SHIFT) + 31) / 32;
  271. page_mask_order = get_order(3 * page_mask_nelts * sizeof(long));
  272. #endif
  273. #if !defined(CONFIG_MTD_UCLINUX)
  274. memory_end -= SIZE_4K; /*In case there is no valid CPLB behind memory_end make sure we don't get to close*/
  275. #endif
  276. init_mm.start_code = (unsigned long)_stext;
  277. init_mm.end_code = (unsigned long)_etext;
  278. init_mm.end_data = (unsigned long)_edata;
  279. init_mm.brk = (unsigned long)0;
  280. _bfin_swrst = bfin_read_SWRST();
  281. if (_bfin_swrst & RESET_DOUBLE)
  282. printk(KERN_INFO "Recovering from Double Fault event\n");
  283. else if (_bfin_swrst & RESET_WDOG)
  284. printk(KERN_INFO "Recovering from Watchdog event\n");
  285. else if (_bfin_swrst & RESET_SOFTWARE)
  286. printk(KERN_NOTICE "Reset caused by Software reset\n");
  287. printk(KERN_INFO "Blackfin support (C) 2004-2007 Analog Devices, Inc.\n");
  288. if (bfin_compiled_revid() == 0xffff)
  289. printk(KERN_INFO "Compiled for ADSP-%s Rev any\n", CPU);
  290. else if (bfin_compiled_revid() == -1)
  291. printk(KERN_INFO "Compiled for ADSP-%s Rev none\n", CPU);
  292. else
  293. printk(KERN_INFO "Compiled for ADSP-%s Rev 0.%d\n", CPU, bfin_compiled_revid());
  294. if (bfin_revid() != bfin_compiled_revid()) {
  295. if (bfin_compiled_revid() == -1)
  296. printk(KERN_ERR "Warning: Compiled for Rev none, but running on Rev %d\n",
  297. bfin_revid());
  298. else if (bfin_compiled_revid() != 0xffff)
  299. printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n",
  300. bfin_compiled_revid(), bfin_revid());
  301. }
  302. if (bfin_revid() < SUPPORTED_REVID)
  303. printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n",
  304. CPU, bfin_revid());
  305. printk(KERN_INFO "Blackfin Linux support by http://blackfin.uclinux.org/\n");
  306. printk(KERN_INFO "Processor Speed: %lu MHz core clock and %lu MHz System Clock\n",
  307. cclk / 1000000, sclk / 1000000);
  308. if (ANOMALY_05000273 && (cclk >> 1) <= sclk)
  309. printk("\n\n\nANOMALY_05000273: CCLK must be >= 2*SCLK !!!\n\n\n");
  310. printk(KERN_INFO "Board Memory: %ldMB\n", physical_mem_end >> 20);
  311. printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20);
  312. printk(KERN_INFO "Memory map:\n"
  313. KERN_INFO " text = 0x%p-0x%p\n"
  314. KERN_INFO " rodata = 0x%p-0x%p\n"
  315. KERN_INFO " data = 0x%p-0x%p\n"
  316. KERN_INFO " stack = 0x%p-0x%p\n"
  317. KERN_INFO " init = 0x%p-0x%p\n"
  318. KERN_INFO " bss = 0x%p-0x%p\n"
  319. KERN_INFO " available = 0x%p-0x%p\n"
  320. #ifdef CONFIG_MTD_UCLINUX
  321. KERN_INFO " rootfs = 0x%p-0x%p\n"
  322. #endif
  323. #if DMA_UNCACHED_REGION > 0
  324. KERN_INFO " DMA Zone = 0x%p-0x%p\n"
  325. #endif
  326. , _stext, _etext,
  327. __start_rodata, __end_rodata,
  328. _sdata, _edata,
  329. (void *)&init_thread_union, (void *)((int)(&init_thread_union) + 0x2000),
  330. __init_begin, __init_end,
  331. __bss_start, __bss_stop,
  332. (void *)_ramstart, (void *)memory_end
  333. #ifdef CONFIG_MTD_UCLINUX
  334. , (void *)memory_mtd_start, (void *)(memory_mtd_start + mtd_size)
  335. #endif
  336. #if DMA_UNCACHED_REGION > 0
  337. , (void *)(_ramend - DMA_UNCACHED_REGION), (void *)(_ramend)
  338. #endif
  339. );
  340. /*
  341. * give all the memory to the bootmap allocator, tell it to put the
  342. * boot mem_map at the start of memory
  343. */
  344. bootmap_size = init_bootmem_node(NODE_DATA(0), memory_start >> PAGE_SHIFT, /* map goes here */
  345. PAGE_OFFSET >> PAGE_SHIFT,
  346. memory_end >> PAGE_SHIFT);
  347. /*
  348. * free the usable memory, we have to make sure we do not free
  349. * the bootmem bitmap so we then reserve it after freeing it :-)
  350. */
  351. free_bootmem(memory_start, memory_end - memory_start);
  352. reserve_bootmem(memory_start, bootmap_size);
  353. /*
  354. * get kmalloc into gear
  355. */
  356. paging_init();
  357. /* check the size of the l1 area */
  358. l1_length = _etext_l1 - _stext_l1;
  359. if (l1_length > L1_CODE_LENGTH)
  360. panic("L1 code memory overflow\n");
  361. l1_length = _ebss_l1 - _sdata_l1;
  362. if (l1_length > L1_DATA_A_LENGTH)
  363. panic("L1 data memory overflow\n");
  364. /* Copy atomic sequences to their fixed location, and sanity check that
  365. these locations are the ones that we advertise to userspace. */
  366. memcpy((void *)FIXED_CODE_START, &fixed_code_start,
  367. FIXED_CODE_END - FIXED_CODE_START);
  368. BUG_ON((char *)&sigreturn_stub - (char *)&fixed_code_start
  369. != SIGRETURN_STUB - FIXED_CODE_START);
  370. BUG_ON((char *)&atomic_xchg32 - (char *)&fixed_code_start
  371. != ATOMIC_XCHG32 - FIXED_CODE_START);
  372. BUG_ON((char *)&atomic_cas32 - (char *)&fixed_code_start
  373. != ATOMIC_CAS32 - FIXED_CODE_START);
  374. BUG_ON((char *)&atomic_add32 - (char *)&fixed_code_start
  375. != ATOMIC_ADD32 - FIXED_CODE_START);
  376. BUG_ON((char *)&atomic_sub32 - (char *)&fixed_code_start
  377. != ATOMIC_SUB32 - FIXED_CODE_START);
  378. BUG_ON((char *)&atomic_ior32 - (char *)&fixed_code_start
  379. != ATOMIC_IOR32 - FIXED_CODE_START);
  380. BUG_ON((char *)&atomic_and32 - (char *)&fixed_code_start
  381. != ATOMIC_AND32 - FIXED_CODE_START);
  382. BUG_ON((char *)&atomic_xor32 - (char *)&fixed_code_start
  383. != ATOMIC_XOR32 - FIXED_CODE_START);
  384. BUG_ON((char *)&safe_user_instruction - (char *)&fixed_code_start
  385. != SAFE_USER_INSTRUCTION - FIXED_CODE_START);
  386. init_exception_vectors();
  387. bf53x_cache_init();
  388. }
  389. static int __init topology_init(void)
  390. {
  391. #if defined (CONFIG_BF561)
  392. static struct cpu cpu[2];
  393. register_cpu(&cpu[0], 0);
  394. register_cpu(&cpu[1], 1);
  395. return 0;
  396. #else
  397. static struct cpu cpu[1];
  398. return register_cpu(cpu, 0);
  399. #endif
  400. }
  401. subsys_initcall(topology_init);
  402. static u_long get_vco(void)
  403. {
  404. u_long msel;
  405. u_long vco;
  406. msel = (bfin_read_PLL_CTL() >> 9) & 0x3F;
  407. if (0 == msel)
  408. msel = 64;
  409. vco = CONFIG_CLKIN_HZ;
  410. vco >>= (1 & bfin_read_PLL_CTL()); /* DF bit */
  411. vco = msel * vco;
  412. return vco;
  413. }
  414. /* Get the Core clock */
  415. u_long get_cclk(void)
  416. {
  417. u_long csel, ssel;
  418. if (bfin_read_PLL_STAT() & 0x1)
  419. return CONFIG_CLKIN_HZ;
  420. ssel = bfin_read_PLL_DIV();
  421. csel = ((ssel >> 4) & 0x03);
  422. ssel &= 0xf;
  423. if (ssel && ssel < (1 << csel)) /* SCLK > CCLK */
  424. return get_vco() / ssel;
  425. return get_vco() >> csel;
  426. }
  427. EXPORT_SYMBOL(get_cclk);
  428. /* Get the System clock */
  429. u_long get_sclk(void)
  430. {
  431. u_long ssel;
  432. if (bfin_read_PLL_STAT() & 0x1)
  433. return CONFIG_CLKIN_HZ;
  434. ssel = (bfin_read_PLL_DIV() & 0xf);
  435. if (0 == ssel) {
  436. printk(KERN_WARNING "Invalid System Clock\n");
  437. ssel = 1;
  438. }
  439. return get_vco() / ssel;
  440. }
  441. EXPORT_SYMBOL(get_sclk);
  442. unsigned long sclk_to_usecs(unsigned long sclk)
  443. {
  444. u64 tmp = USEC_PER_SEC * (u64)sclk;
  445. do_div(tmp, get_sclk());
  446. return tmp;
  447. }
  448. EXPORT_SYMBOL(sclk_to_usecs);
  449. unsigned long usecs_to_sclk(unsigned long usecs)
  450. {
  451. u64 tmp = get_sclk() * (u64)usecs;
  452. do_div(tmp, USEC_PER_SEC);
  453. return tmp;
  454. }
  455. EXPORT_SYMBOL(usecs_to_sclk);
  456. /*
  457. * Get CPU information for use by the procfs.
  458. */
  459. static int show_cpuinfo(struct seq_file *m, void *v)
  460. {
  461. char *cpu, *mmu, *fpu, *vendor, *cache;
  462. uint32_t revid;
  463. u_long cclk = 0, sclk = 0;
  464. u_int dcache_size = 0, dsup_banks = 0;
  465. cpu = CPU;
  466. mmu = "none";
  467. fpu = "none";
  468. revid = bfin_revid();
  469. cclk = get_cclk();
  470. sclk = get_sclk();
  471. switch (bfin_read_CHIPID() & CHIPID_MANUFACTURE) {
  472. case 0xca:
  473. vendor = "Analog Devices";
  474. break;
  475. default:
  476. vendor = "unknown";
  477. break;
  478. }
  479. seq_printf(m, "processor\t: %d\n"
  480. "vendor_id\t: %s\n"
  481. "cpu family\t: 0x%x\n"
  482. "model name\t: ADSP-%s %lu(MHz CCLK) %lu(MHz SCLK)\n"
  483. "stepping\t: %d\n",
  484. 0,
  485. vendor,
  486. (bfin_read_CHIPID() & CHIPID_FAMILY),
  487. cpu, cclk/1000000, sclk/1000000,
  488. revid);
  489. seq_printf(m, "cpu MHz\t\t: %lu.%03lu/%lu.%03lu\n",
  490. cclk/1000000, cclk%1000000,
  491. sclk/1000000, sclk%1000000);
  492. seq_printf(m, "bogomips\t: %lu.%02lu\n"
  493. "Calibration\t: %lu loops\n",
  494. (loops_per_jiffy * HZ) / 500000,
  495. ((loops_per_jiffy * HZ) / 5000) % 100,
  496. (loops_per_jiffy * HZ));
  497. /* Check Cache configutation */
  498. switch (bfin_read_DMEM_CONTROL() & (1 << DMC0_P | 1 << DMC1_P)) {
  499. case ACACHE_BSRAM:
  500. cache = "dbank-A/B\t: cache/sram";
  501. dcache_size = 16;
  502. dsup_banks = 1;
  503. break;
  504. case ACACHE_BCACHE:
  505. cache = "dbank-A/B\t: cache/cache";
  506. dcache_size = 32;
  507. dsup_banks = 2;
  508. break;
  509. case ASRAM_BSRAM:
  510. cache = "dbank-A/B\t: sram/sram";
  511. dcache_size = 0;
  512. dsup_banks = 0;
  513. break;
  514. default:
  515. cache = "unknown";
  516. dcache_size = 0;
  517. dsup_banks = 0;
  518. break;
  519. }
  520. /* Is it turned on? */
  521. if (!((bfin_read_DMEM_CONTROL()) & (ENDCPLB | DMC_ENABLE)))
  522. dcache_size = 0;
  523. seq_printf(m, "cache size\t: %d KB(L1 icache) "
  524. "%d KB(L1 dcache-%s) %d KB(L2 cache)\n",
  525. BFIN_ICACHESIZE / 1024, dcache_size,
  526. #if defined CONFIG_BFIN_WB
  527. "wb"
  528. #elif defined CONFIG_BFIN_WT
  529. "wt"
  530. #endif
  531. "", 0);
  532. seq_printf(m, "%s\n", cache);
  533. seq_printf(m, "icache setup\t: %d Sub-banks/%d Ways, %d Lines/Way\n",
  534. BFIN_ISUBBANKS, BFIN_IWAYS, BFIN_ILINES);
  535. seq_printf(m,
  536. "dcache setup\t: %d Super-banks/%d Sub-banks/%d Ways, %d Lines/Way\n",
  537. dsup_banks, BFIN_DSUBBANKS, BFIN_DWAYS,
  538. BFIN_DLINES);
  539. #ifdef CONFIG_BFIN_ICACHE_LOCK
  540. switch (read_iloc()) {
  541. case WAY0_L:
  542. seq_printf(m, "Way0 Locked-Down\n");
  543. break;
  544. case WAY1_L:
  545. seq_printf(m, "Way1 Locked-Down\n");
  546. break;
  547. case WAY01_L:
  548. seq_printf(m, "Way0,Way1 Locked-Down\n");
  549. break;
  550. case WAY2_L:
  551. seq_printf(m, "Way2 Locked-Down\n");
  552. break;
  553. case WAY02_L:
  554. seq_printf(m, "Way0,Way2 Locked-Down\n");
  555. break;
  556. case WAY12_L:
  557. seq_printf(m, "Way1,Way2 Locked-Down\n");
  558. break;
  559. case WAY012_L:
  560. seq_printf(m, "Way0,Way1 & Way2 Locked-Down\n");
  561. break;
  562. case WAY3_L:
  563. seq_printf(m, "Way3 Locked-Down\n");
  564. break;
  565. case WAY03_L:
  566. seq_printf(m, "Way0,Way3 Locked-Down\n");
  567. break;
  568. case WAY13_L:
  569. seq_printf(m, "Way1,Way3 Locked-Down\n");
  570. break;
  571. case WAY013_L:
  572. seq_printf(m, "Way 0,Way1,Way3 Locked-Down\n");
  573. break;
  574. case WAY32_L:
  575. seq_printf(m, "Way3,Way2 Locked-Down\n");
  576. break;
  577. case WAY320_L:
  578. seq_printf(m, "Way3,Way2,Way0 Locked-Down\n");
  579. break;
  580. case WAY321_L:
  581. seq_printf(m, "Way3,Way2,Way1 Locked-Down\n");
  582. break;
  583. case WAYALL_L:
  584. seq_printf(m, "All Ways are locked\n");
  585. break;
  586. default:
  587. seq_printf(m, "No Ways are locked\n");
  588. }
  589. #endif
  590. seq_printf(m, "board name\t: %s\n", bfin_board_name);
  591. seq_printf(m, "board memory\t: %ld kB (0x%p -> 0x%p)\n",
  592. physical_mem_end >> 10, (void *)0, (void *)physical_mem_end);
  593. seq_printf(m, "kernel memory\t: %d kB (0x%p -> 0x%p)\n",
  594. ((int)memory_end - (int)_stext) >> 10,
  595. _stext,
  596. (void *)memory_end);
  597. return 0;
  598. }
  599. static void *c_start(struct seq_file *m, loff_t *pos)
  600. {
  601. return *pos < NR_CPUS ? ((void *)0x12345678) : NULL;
  602. }
  603. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  604. {
  605. ++*pos;
  606. return c_start(m, pos);
  607. }
  608. static void c_stop(struct seq_file *m, void *v)
  609. {
  610. }
  611. struct seq_operations cpuinfo_op = {
  612. .start = c_start,
  613. .next = c_next,
  614. .stop = c_stop,
  615. .show = show_cpuinfo,
  616. };
  617. void __init cmdline_init(const char *r0)
  618. {
  619. if (r0)
  620. strncpy(command_line, r0, COMMAND_LINE_SIZE);
  621. }