setup.c 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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. unsigned long memory_start;
  37. unsigned long memory_end;
  38. EXPORT_SYMBOL(memory_start);
  39. EXPORT_SYMBOL(memory_end);
  40. char __initdata command_line[COMMAND_LINE_SIZE];
  41. /* machine dependent timer functions */
  42. void (*mach_gettod)(int*, int*, int*, int*, int*, int*);
  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 "MC68328"
  50. #endif
  51. #ifdef CONFIG_M68EZ328
  52. #define CPU "MC68EZ328"
  53. #endif
  54. #ifdef CONFIG_M68VZ328
  55. #define CPU "MC68VZ328"
  56. #endif
  57. #ifdef CONFIG_M68360
  58. #define CPU "MC68360"
  59. #endif
  60. #if defined(CONFIG_M5206)
  61. #define CPU "COLDFIRE(m5206)"
  62. #endif
  63. #if defined(CONFIG_M5206e)
  64. #define CPU "COLDFIRE(m5206e)"
  65. #endif
  66. #if defined(CONFIG_M520x)
  67. #define CPU "COLDFIRE(m520x)"
  68. #endif
  69. #if defined(CONFIG_M523x)
  70. #define CPU "COLDFIRE(m523x)"
  71. #endif
  72. #if defined(CONFIG_M5249)
  73. #define CPU "COLDFIRE(m5249)"
  74. #endif
  75. #if defined(CONFIG_M5271)
  76. #define CPU "COLDFIRE(m5270/5271)"
  77. #endif
  78. #if defined(CONFIG_M5272)
  79. #define CPU "COLDFIRE(m5272)"
  80. #endif
  81. #if defined(CONFIG_M5275)
  82. #define CPU "COLDFIRE(m5274/5275)"
  83. #endif
  84. #if defined(CONFIG_M528x)
  85. #define CPU "COLDFIRE(m5280/5282)"
  86. #endif
  87. #if defined(CONFIG_M5307)
  88. #define CPU "COLDFIRE(m5307)"
  89. #endif
  90. #if defined(CONFIG_M532x)
  91. #define CPU "COLDFIRE(m532x)"
  92. #endif
  93. #if defined(CONFIG_M5407)
  94. #define CPU "COLDFIRE(m5407)"
  95. #endif
  96. #ifndef CPU
  97. #define CPU "UNKNOWN"
  98. #endif
  99. extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end;
  100. extern int _ramstart, _ramend;
  101. #if defined(CONFIG_UBOOT)
  102. /*
  103. * parse_uboot_commandline
  104. *
  105. * Copies u-boot commandline arguments and store them in the proper linux
  106. * variables.
  107. *
  108. * Assumes:
  109. * _init_sp global contains the address in the stack pointer when the
  110. * kernel starts (see head.S::_start)
  111. *
  112. * U-Boot calling convention:
  113. * (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
  114. *
  115. * _init_sp can be parsed as such
  116. *
  117. * _init_sp+00 = u-boot cmd after jsr into kernel (skip)
  118. * _init_sp+04 = &kernel board_info (residual data)
  119. * _init_sp+08 = &initrd_start
  120. * _init_sp+12 = &initrd_end
  121. * _init_sp+16 = &cmd_start
  122. * _init_sp+20 = &cmd_end
  123. *
  124. * This also assumes that the memory locations pointed to are still
  125. * unmodified. U-boot places them near the end of external SDRAM.
  126. *
  127. * Argument(s):
  128. * commandp = the linux commandline arg container to fill.
  129. * size = the sizeof commandp.
  130. *
  131. * Returns:
  132. */
  133. void parse_uboot_commandline(char *commandp, int size)
  134. {
  135. extern unsigned long _init_sp;
  136. unsigned long *sp;
  137. unsigned long uboot_kbd;
  138. unsigned long uboot_initrd_start, uboot_initrd_end;
  139. unsigned long uboot_cmd_start, uboot_cmd_end;
  140. sp = (unsigned long *)_init_sp;
  141. uboot_kbd = sp[1];
  142. uboot_initrd_start = sp[2];
  143. uboot_initrd_end = sp[3];
  144. uboot_cmd_start = sp[4];
  145. uboot_cmd_end = sp[5];
  146. if (uboot_cmd_start && uboot_cmd_end)
  147. strncpy(commandp, (const char *)uboot_cmd_start, size);
  148. #if defined(CONFIG_BLK_DEV_INITRD)
  149. if (uboot_initrd_start && uboot_initrd_end &&
  150. (uboot_initrd_end > uboot_initrd_start)) {
  151. initrd_start = uboot_initrd_start;
  152. initrd_end = uboot_initrd_end;
  153. ROOT_DEV = Root_RAM0;
  154. printk(KERN_INFO "initrd at 0x%lx:0x%lx\n",
  155. initrd_start, initrd_end);
  156. }
  157. #endif /* if defined(CONFIG_BLK_DEV_INITRD) */
  158. }
  159. #endif /* #if defined(CONFIG_UBOOT) */
  160. void __init setup_arch(char **cmdline_p)
  161. {
  162. int bootmap_size;
  163. memory_start = PAGE_ALIGN(_ramstart);
  164. memory_end = _ramend;
  165. init_mm.start_code = (unsigned long) &_stext;
  166. init_mm.end_code = (unsigned long) &_etext;
  167. init_mm.end_data = (unsigned long) &_edata;
  168. init_mm.brk = (unsigned long) 0;
  169. config_BSP(&command_line[0], sizeof(command_line));
  170. #if defined(CONFIG_BOOTPARAM)
  171. strncpy(&command_line[0], CONFIG_BOOTPARAM_STRING, sizeof(command_line));
  172. command_line[sizeof(command_line) - 1] = 0;
  173. #endif /* CONFIG_BOOTPARAM */
  174. #if defined(CONFIG_UBOOT)
  175. /* CONFIG_UBOOT and CONFIG_BOOTPARAM defined, concatenate cmdline */
  176. #if defined(CONFIG_BOOTPARAM)
  177. /* Add the whitespace separator */
  178. command_line[strlen(CONFIG_BOOTPARAM_STRING)] = ' ';
  179. /* Parse uboot command line into the rest of the buffer */
  180. parse_uboot_commandline(
  181. &command_line[(strlen(CONFIG_BOOTPARAM_STRING)+1)],
  182. (sizeof(command_line) -
  183. (strlen(CONFIG_BOOTPARAM_STRING)+1)));
  184. /* Only CONFIG_UBOOT defined, create cmdline */
  185. #else
  186. parse_uboot_commandline(&command_line[0], sizeof(command_line));
  187. #endif /* CONFIG_BOOTPARAM */
  188. command_line[sizeof(command_line) - 1] = 0;
  189. #endif /* CONFIG_UBOOT */
  190. printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU "\n");
  191. #ifdef CONFIG_UCDIMM
  192. printk(KERN_INFO "uCdimm by Lineo, Inc. <www.lineo.com>\n");
  193. #endif
  194. #ifdef CONFIG_M68VZ328
  195. printk(KERN_INFO "M68VZ328 support by Evan Stawnyczy <e@lineo.ca>\n");
  196. #endif
  197. #ifdef CONFIG_COLDFIRE
  198. printk(KERN_INFO "COLDFIRE port done by Greg Ungerer, gerg@snapgear.com\n");
  199. #ifdef CONFIG_M5307
  200. printk(KERN_INFO "Modified for M5307 by Dave Miller, dmiller@intellistor.com\n");
  201. #endif
  202. #ifdef CONFIG_ELITE
  203. printk(KERN_INFO "Modified for M5206eLITE by Rob Scott, rscott@mtrob.fdns.net\n");
  204. #endif
  205. #endif
  206. printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
  207. #if defined( CONFIG_PILOT ) && defined( CONFIG_M68328 )
  208. printk(KERN_INFO "TRG SuperPilot FLASH card support <info@trgnet.com>\n");
  209. #endif
  210. #if defined( CONFIG_PILOT ) && defined( CONFIG_M68EZ328 )
  211. printk(KERN_INFO "PalmV support by Lineo Inc. <jeff@uclinux.com>\n");
  212. #endif
  213. #if defined (CONFIG_M68360)
  214. printk(KERN_INFO "QUICC port done by SED Systems <hamilton@sedsystems.ca>,\n");
  215. printk(KERN_INFO "based on 2.0.38 port by Lineo Inc. <mleslie@lineo.com>.\n");
  216. #endif
  217. #ifdef CONFIG_DRAGEN2
  218. printk(KERN_INFO "DragonEngine II board support by Georges Menie\n");
  219. #endif
  220. #ifdef CONFIG_M5235EVB
  221. printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)\n");
  222. #endif
  223. pr_debug("KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
  224. "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
  225. (int) &_sdata, (int) &_edata,
  226. (int) &_sbss, (int) &_ebss);
  227. pr_debug("MEMORY -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x\n ",
  228. (int) &_ebss, (int) memory_start,
  229. (int) memory_start, (int) memory_end);
  230. /* Keep a copy of command line */
  231. *cmdline_p = &command_line[0];
  232. memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
  233. boot_command_line[COMMAND_LINE_SIZE-1] = 0;
  234. #ifdef DEBUG
  235. if (strlen(*cmdline_p))
  236. printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
  237. #endif
  238. #if defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_DUMMY_CONSOLE)
  239. conswitchp = &dummy_con;
  240. #endif
  241. /*
  242. * Give all the memory to the bootmap allocator, tell it to put the
  243. * boot mem_map at the start of memory.
  244. */
  245. bootmap_size = init_bootmem_node(
  246. NODE_DATA(0),
  247. memory_start >> PAGE_SHIFT, /* map goes here */
  248. PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
  249. memory_end >> PAGE_SHIFT);
  250. /*
  251. * Free the usable memory, we have to make sure we do not free
  252. * the bootmem bitmap so we then reserve it after freeing it :-)
  253. */
  254. free_bootmem(memory_start, memory_end - memory_start);
  255. reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT);
  256. #if defined(CONFIG_UBOOT) && defined(CONFIG_BLK_DEV_INITRD)
  257. if ((initrd_start > 0) && (initrd_start < initrd_end) &&
  258. (initrd_end < memory_end))
  259. reserve_bootmem(initrd_start, initrd_end - initrd_start,
  260. BOOTMEM_DEFAULT);
  261. #endif /* if defined(CONFIG_BLK_DEV_INITRD) */
  262. /*
  263. * Get kmalloc into gear.
  264. */
  265. paging_init();
  266. }
  267. /*
  268. * Get CPU information for use by the procfs.
  269. */
  270. static int show_cpuinfo(struct seq_file *m, void *v)
  271. {
  272. char *cpu, *mmu, *fpu;
  273. u_long clockfreq;
  274. cpu = CPU;
  275. mmu = "none";
  276. fpu = "none";
  277. #ifdef CONFIG_COLDFIRE
  278. clockfreq = (loops_per_jiffy * HZ) * 3;
  279. #else
  280. clockfreq = (loops_per_jiffy * HZ) * 16;
  281. #endif
  282. seq_printf(m, "CPU:\t\t%s\n"
  283. "MMU:\t\t%s\n"
  284. "FPU:\t\t%s\n"
  285. "Clocking:\t%lu.%1luMHz\n"
  286. "BogoMips:\t%lu.%02lu\n"
  287. "Calibration:\t%lu loops\n",
  288. cpu, mmu, fpu,
  289. clockfreq / 1000000,
  290. (clockfreq / 100000) % 10,
  291. (loops_per_jiffy * HZ) / 500000,
  292. ((loops_per_jiffy * HZ) / 5000) % 100,
  293. (loops_per_jiffy * HZ));
  294. return 0;
  295. }
  296. static void *c_start(struct seq_file *m, loff_t *pos)
  297. {
  298. return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
  299. }
  300. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  301. {
  302. ++*pos;
  303. return c_start(m, pos);
  304. }
  305. static void c_stop(struct seq_file *m, void *v)
  306. {
  307. }
  308. const struct seq_operations cpuinfo_op = {
  309. .start = c_start,
  310. .next = c_next,
  311. .stop = c_stop,
  312. .show = show_cpuinfo,
  313. };