setup_no.c 9.0 KB

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