setup_no.c 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. /*
  2. * linux/arch/m68knommu/kernel/setup.c
  3. *
  4. * Copyright (C) 1999-2007 Greg Ungerer (gerg@snapgear.com)
  5. * Copyright (C) 1998,1999 D. Jeff Dionne <jeff@uClinux.org>
  6. * Copyleft ()) 2000 James D. Schettine {james@telos-systems.com}
  7. * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
  8. * Copyright (C) 1995 Hamish Macdonald
  9. * Copyright (C) 2000 Lineo Inc. (www.lineo.com)
  10. * Copyright (C) 2001 Lineo, Inc. <www.lineo.com>
  11. *
  12. * 68VZ328 Fixes/support Evan Stawnyczy <e@lineo.ca>
  13. */
  14. /*
  15. * This file handles the architecture-dependent parts of system setup
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/sched.h>
  19. #include <linux/delay.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/fb.h>
  22. #include <linux/module.h>
  23. #include <linux/mm.h>
  24. #include <linux/console.h>
  25. #include <linux/errno.h>
  26. #include <linux/string.h>
  27. #include <linux/bootmem.h>
  28. #include <linux/seq_file.h>
  29. #include <linux/init.h>
  30. #include <linux/initrd.h>
  31. #include <linux/root_dev.h>
  32. #include <asm/setup.h>
  33. #include <asm/irq.h>
  34. #include <asm/machdep.h>
  35. #include <asm/pgtable.h>
  36. #include <asm/sections.h>
  37. unsigned long memory_start;
  38. unsigned long memory_end;
  39. EXPORT_SYMBOL(memory_start);
  40. EXPORT_SYMBOL(memory_end);
  41. char __initdata command_line[COMMAND_LINE_SIZE];
  42. /* machine dependent timer functions */
  43. int (*mach_set_clock_mmss)(unsigned long);
  44. /* machine dependent reboot functions */
  45. void (*mach_reset)(void);
  46. void (*mach_halt)(void);
  47. void (*mach_power_off)(void);
  48. #ifdef CONFIG_M68328
  49. #define CPU_NAME "MC68328"
  50. #endif
  51. #ifdef CONFIG_M68EZ328
  52. #define CPU_NAME "MC68EZ328"
  53. #endif
  54. #ifdef CONFIG_M68VZ328
  55. #define CPU_NAME "MC68VZ328"
  56. #endif
  57. #ifdef CONFIG_M68360
  58. #define CPU_NAME "MC68360"
  59. #endif
  60. #ifndef CPU_NAME
  61. #define CPU_NAME "UNKNOWN"
  62. #endif
  63. /*
  64. * Different cores have different instruction execution timings.
  65. * The old/traditional 68000 cores are basically all the same, at 16.
  66. * The ColdFire cores vary a little, their values are defined in their
  67. * headers. We default to the standard 68000 value here.
  68. */
  69. #ifndef CPU_INSTR_PER_JIFFY
  70. #define CPU_INSTR_PER_JIFFY 16
  71. #endif
  72. #if defined(CONFIG_UBOOT)
  73. /*
  74. * parse_uboot_commandline
  75. *
  76. * Copies u-boot commandline arguments and store them in the proper linux
  77. * variables.
  78. *
  79. * Assumes:
  80. * _init_sp global contains the address in the stack pointer when the
  81. * kernel starts (see head.S::_start)
  82. *
  83. * U-Boot calling convention:
  84. * (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
  85. *
  86. * _init_sp can be parsed as such
  87. *
  88. * _init_sp+00 = u-boot cmd after jsr into kernel (skip)
  89. * _init_sp+04 = &kernel board_info (residual data)
  90. * _init_sp+08 = &initrd_start
  91. * _init_sp+12 = &initrd_end
  92. * _init_sp+16 = &cmd_start
  93. * _init_sp+20 = &cmd_end
  94. *
  95. * This also assumes that the memory locations pointed to are still
  96. * unmodified. U-boot places them near the end of external SDRAM.
  97. *
  98. * Argument(s):
  99. * commandp = the linux commandline arg container to fill.
  100. * size = the sizeof commandp.
  101. *
  102. * Returns:
  103. */
  104. void parse_uboot_commandline(char *commandp, int size)
  105. {
  106. extern unsigned long _init_sp;
  107. unsigned long *sp;
  108. unsigned long uboot_kbd;
  109. unsigned long uboot_initrd_start, uboot_initrd_end;
  110. unsigned long uboot_cmd_start, uboot_cmd_end;
  111. sp = (unsigned long *)_init_sp;
  112. uboot_kbd = sp[1];
  113. uboot_initrd_start = sp[2];
  114. uboot_initrd_end = sp[3];
  115. uboot_cmd_start = sp[4];
  116. uboot_cmd_end = sp[5];
  117. if (uboot_cmd_start && uboot_cmd_end)
  118. strncpy(commandp, (const char *)uboot_cmd_start, size);
  119. #if defined(CONFIG_BLK_DEV_INITRD)
  120. if (uboot_initrd_start && uboot_initrd_end &&
  121. (uboot_initrd_end > uboot_initrd_start)) {
  122. initrd_start = uboot_initrd_start;
  123. initrd_end = uboot_initrd_end;
  124. ROOT_DEV = Root_RAM0;
  125. printk(KERN_INFO "initrd at 0x%lx:0x%lx\n",
  126. initrd_start, initrd_end);
  127. }
  128. #endif /* if defined(CONFIG_BLK_DEV_INITRD) */
  129. }
  130. #endif /* #if defined(CONFIG_UBOOT) */
  131. void __init setup_arch(char **cmdline_p)
  132. {
  133. int bootmap_size;
  134. memory_start = PAGE_ALIGN(_ramstart);
  135. memory_end = _ramend;
  136. init_mm.start_code = (unsigned long) &_stext;
  137. init_mm.end_code = (unsigned long) &_etext;
  138. init_mm.end_data = (unsigned long) &_edata;
  139. init_mm.brk = (unsigned long) 0;
  140. config_BSP(&command_line[0], sizeof(command_line));
  141. #if defined(CONFIG_BOOTPARAM)
  142. strncpy(&command_line[0], CONFIG_BOOTPARAM_STRING, sizeof(command_line));
  143. command_line[sizeof(command_line) - 1] = 0;
  144. #endif /* CONFIG_BOOTPARAM */
  145. #if defined(CONFIG_UBOOT)
  146. /* CONFIG_UBOOT and CONFIG_BOOTPARAM defined, concatenate cmdline */
  147. #if defined(CONFIG_BOOTPARAM)
  148. /* Add the whitespace separator */
  149. command_line[strlen(CONFIG_BOOTPARAM_STRING)] = ' ';
  150. /* Parse uboot command line into the rest of the buffer */
  151. parse_uboot_commandline(
  152. &command_line[(strlen(CONFIG_BOOTPARAM_STRING)+1)],
  153. (sizeof(command_line) -
  154. (strlen(CONFIG_BOOTPARAM_STRING)+1)));
  155. /* Only CONFIG_UBOOT defined, create cmdline */
  156. #else
  157. parse_uboot_commandline(&command_line[0], sizeof(command_line));
  158. #endif /* CONFIG_BOOTPARAM */
  159. command_line[sizeof(command_line) - 1] = 0;
  160. #endif /* CONFIG_UBOOT */
  161. printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU_NAME "\n");
  162. #ifdef CONFIG_UCDIMM
  163. printk(KERN_INFO "uCdimm by Lineo, Inc. <www.lineo.com>\n");
  164. #endif
  165. #ifdef CONFIG_M68VZ328
  166. printk(KERN_INFO "M68VZ328 support by Evan Stawnyczy <e@lineo.ca>\n");
  167. #endif
  168. #ifdef CONFIG_COLDFIRE
  169. printk(KERN_INFO "COLDFIRE port done by Greg Ungerer, gerg@snapgear.com\n");
  170. #ifdef CONFIG_M5307
  171. printk(KERN_INFO "Modified for M5307 by Dave Miller, dmiller@intellistor.com\n");
  172. #endif
  173. #ifdef CONFIG_ELITE
  174. printk(KERN_INFO "Modified for M5206eLITE by Rob Scott, rscott@mtrob.fdns.net\n");
  175. #endif
  176. #endif
  177. printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
  178. #if defined( CONFIG_PILOT ) && defined( CONFIG_M68328 )
  179. printk(KERN_INFO "TRG SuperPilot FLASH card support <info@trgnet.com>\n");
  180. #endif
  181. #if defined( CONFIG_PILOT ) && defined( CONFIG_M68EZ328 )
  182. printk(KERN_INFO "PalmV support by Lineo Inc. <jeff@uclinux.com>\n");
  183. #endif
  184. #if defined (CONFIG_M68360)
  185. printk(KERN_INFO "QUICC port done by SED Systems <hamilton@sedsystems.ca>,\n");
  186. printk(KERN_INFO "based on 2.0.38 port by Lineo Inc. <mleslie@lineo.com>.\n");
  187. #endif
  188. #ifdef CONFIG_DRAGEN2
  189. printk(KERN_INFO "DragonEngine II board support by Georges Menie\n");
  190. #endif
  191. #ifdef CONFIG_M5235EVB
  192. printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)\n");
  193. #endif
  194. pr_debug("KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
  195. "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
  196. (int) &_sdata, (int) &_edata,
  197. (int) &_sbss, (int) &_ebss);
  198. pr_debug("MEMORY -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x\n ",
  199. (int) &_ebss, (int) memory_start,
  200. (int) memory_start, (int) memory_end);
  201. /* Keep a copy of command line */
  202. *cmdline_p = &command_line[0];
  203. memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
  204. boot_command_line[COMMAND_LINE_SIZE-1] = 0;
  205. #if defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_DUMMY_CONSOLE)
  206. conswitchp = &dummy_con;
  207. #endif
  208. /*
  209. * Give all the memory to the bootmap allocator, tell it to put the
  210. * boot mem_map at the start of memory.
  211. */
  212. bootmap_size = init_bootmem_node(
  213. NODE_DATA(0),
  214. memory_start >> PAGE_SHIFT, /* map goes here */
  215. PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
  216. memory_end >> PAGE_SHIFT);
  217. /*
  218. * Free the usable memory, we have to make sure we do not free
  219. * the bootmem bitmap so we then reserve it after freeing it :-)
  220. */
  221. free_bootmem(memory_start, memory_end - memory_start);
  222. reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT);
  223. #if defined(CONFIG_UBOOT) && defined(CONFIG_BLK_DEV_INITRD)
  224. if ((initrd_start > 0) && (initrd_start < initrd_end) &&
  225. (initrd_end < memory_end))
  226. reserve_bootmem(initrd_start, initrd_end - initrd_start,
  227. BOOTMEM_DEFAULT);
  228. #endif /* if defined(CONFIG_BLK_DEV_INITRD) */
  229. /*
  230. * Get kmalloc into gear.
  231. */
  232. paging_init();
  233. }
  234. /*
  235. * Get CPU information for use by the procfs.
  236. */
  237. static int show_cpuinfo(struct seq_file *m, void *v)
  238. {
  239. char *cpu, *mmu, *fpu;
  240. u_long clockfreq;
  241. cpu = CPU_NAME;
  242. mmu = "none";
  243. fpu = "none";
  244. clockfreq = (loops_per_jiffy * HZ) * CPU_INSTR_PER_JIFFY;
  245. seq_printf(m, "CPU:\t\t%s\n"
  246. "MMU:\t\t%s\n"
  247. "FPU:\t\t%s\n"
  248. "Clocking:\t%lu.%1luMHz\n"
  249. "BogoMips:\t%lu.%02lu\n"
  250. "Calibration:\t%lu loops\n",
  251. cpu, mmu, fpu,
  252. clockfreq / 1000000,
  253. (clockfreq / 100000) % 10,
  254. (loops_per_jiffy * HZ) / 500000,
  255. ((loops_per_jiffy * HZ) / 5000) % 100,
  256. (loops_per_jiffy * HZ));
  257. return 0;
  258. }
  259. static void *c_start(struct seq_file *m, loff_t *pos)
  260. {
  261. return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
  262. }
  263. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  264. {
  265. ++*pos;
  266. return c_start(m, pos);
  267. }
  268. static void c_stop(struct seq_file *m, void *v)
  269. {
  270. }
  271. const struct seq_operations cpuinfo_op = {
  272. .start = c_start,
  273. .next = c_next,
  274. .stop = c_stop,
  275. .show = show_cpuinfo,
  276. };