setup_no.c 8.9 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 <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_M68328
  52. #define CPU_NAME "MC68328"
  53. #endif
  54. #ifdef CONFIG_M68EZ328
  55. #define CPU_NAME "MC68EZ328"
  56. #endif
  57. #ifdef CONFIG_M68VZ328
  58. #define CPU_NAME "MC68VZ328"
  59. #endif
  60. #ifdef CONFIG_M68360
  61. #define CPU_NAME "MC68360"
  62. #endif
  63. #ifndef CPU_NAME
  64. #define CPU_NAME "UNKNOWN"
  65. #endif
  66. /*
  67. * Different cores have different instruction execution timings.
  68. * The old/traditional 68000 cores are basically all the same, at 16.
  69. * The ColdFire cores vary a little, their values are defined in their
  70. * headers. We default to the standard 68000 value here.
  71. */
  72. #ifndef CPU_INSTR_PER_JIFFY
  73. #define CPU_INSTR_PER_JIFFY 16
  74. #endif
  75. #if defined(CONFIG_UBOOT)
  76. /*
  77. * parse_uboot_commandline
  78. *
  79. * Copies u-boot commandline arguments and store them in the proper linux
  80. * variables.
  81. *
  82. * Assumes:
  83. * _init_sp global contains the address in the stack pointer when the
  84. * kernel starts (see head.S::_start)
  85. *
  86. * U-Boot calling convention:
  87. * (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
  88. *
  89. * _init_sp can be parsed as such
  90. *
  91. * _init_sp+00 = u-boot cmd after jsr into kernel (skip)
  92. * _init_sp+04 = &kernel board_info (residual data)
  93. * _init_sp+08 = &initrd_start
  94. * _init_sp+12 = &initrd_end
  95. * _init_sp+16 = &cmd_start
  96. * _init_sp+20 = &cmd_end
  97. *
  98. * This also assumes that the memory locations pointed to are still
  99. * unmodified. U-boot places them near the end of external SDRAM.
  100. *
  101. * Argument(s):
  102. * commandp = the linux commandline arg container to fill.
  103. * size = the sizeof commandp.
  104. *
  105. * Returns:
  106. */
  107. void parse_uboot_commandline(char *commandp, int size)
  108. {
  109. extern unsigned long _init_sp;
  110. unsigned long *sp;
  111. unsigned long uboot_kbd;
  112. unsigned long uboot_initrd_start, uboot_initrd_end;
  113. unsigned long uboot_cmd_start, uboot_cmd_end;
  114. sp = (unsigned long *)_init_sp;
  115. uboot_kbd = sp[1];
  116. uboot_initrd_start = sp[2];
  117. uboot_initrd_end = sp[3];
  118. uboot_cmd_start = sp[4];
  119. uboot_cmd_end = sp[5];
  120. if (uboot_cmd_start && uboot_cmd_end)
  121. strncpy(commandp, (const char *)uboot_cmd_start, size);
  122. #if defined(CONFIG_BLK_DEV_INITRD)
  123. if (uboot_initrd_start && uboot_initrd_end &&
  124. (uboot_initrd_end > uboot_initrd_start)) {
  125. initrd_start = uboot_initrd_start;
  126. initrd_end = uboot_initrd_end;
  127. ROOT_DEV = Root_RAM0;
  128. printk(KERN_INFO "initrd at 0x%lx:0x%lx\n",
  129. initrd_start, initrd_end);
  130. }
  131. #endif /* if defined(CONFIG_BLK_DEV_INITRD) */
  132. }
  133. #endif /* #if defined(CONFIG_UBOOT) */
  134. void __init setup_arch(char **cmdline_p)
  135. {
  136. int bootmap_size;
  137. memory_start = PAGE_ALIGN(_ramstart);
  138. memory_end = _ramend;
  139. init_mm.start_code = (unsigned long) &_stext;
  140. init_mm.end_code = (unsigned long) &_etext;
  141. init_mm.end_data = (unsigned long) &_edata;
  142. init_mm.brk = (unsigned long) 0;
  143. config_BSP(&command_line[0], sizeof(command_line));
  144. #if defined(CONFIG_BOOTPARAM)
  145. strncpy(&command_line[0], CONFIG_BOOTPARAM_STRING, sizeof(command_line));
  146. command_line[sizeof(command_line) - 1] = 0;
  147. #endif /* CONFIG_BOOTPARAM */
  148. #if defined(CONFIG_UBOOT)
  149. /* CONFIG_UBOOT and CONFIG_BOOTPARAM defined, concatenate cmdline */
  150. #if defined(CONFIG_BOOTPARAM)
  151. /* Add the whitespace separator */
  152. command_line[strlen(CONFIG_BOOTPARAM_STRING)] = ' ';
  153. /* Parse uboot command line into the rest of the buffer */
  154. parse_uboot_commandline(
  155. &command_line[(strlen(CONFIG_BOOTPARAM_STRING)+1)],
  156. (sizeof(command_line) -
  157. (strlen(CONFIG_BOOTPARAM_STRING)+1)));
  158. /* Only CONFIG_UBOOT defined, create cmdline */
  159. #else
  160. parse_uboot_commandline(&command_line[0], sizeof(command_line));
  161. #endif /* CONFIG_BOOTPARAM */
  162. command_line[sizeof(command_line) - 1] = 0;
  163. #endif /* CONFIG_UBOOT */
  164. printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU_NAME "\n");
  165. #ifdef CONFIG_UCDIMM
  166. printk(KERN_INFO "uCdimm by Lineo, Inc. <www.lineo.com>\n");
  167. #endif
  168. #ifdef CONFIG_M68VZ328
  169. printk(KERN_INFO "M68VZ328 support by Evan Stawnyczy <e@lineo.ca>\n");
  170. #endif
  171. #ifdef CONFIG_COLDFIRE
  172. printk(KERN_INFO "COLDFIRE port done by Greg Ungerer, gerg@snapgear.com\n");
  173. #ifdef CONFIG_M5307
  174. printk(KERN_INFO "Modified for M5307 by Dave Miller, dmiller@intellistor.com\n");
  175. #endif
  176. #ifdef CONFIG_ELITE
  177. printk(KERN_INFO "Modified for M5206eLITE by Rob Scott, rscott@mtrob.fdns.net\n");
  178. #endif
  179. #endif
  180. printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
  181. #if defined( CONFIG_PILOT ) && defined( CONFIG_M68328 )
  182. printk(KERN_INFO "TRG SuperPilot FLASH card support <info@trgnet.com>\n");
  183. #endif
  184. #if defined( CONFIG_PILOT ) && defined( CONFIG_M68EZ328 )
  185. printk(KERN_INFO "PalmV support by Lineo Inc. <jeff@uclinux.com>\n");
  186. #endif
  187. #if defined (CONFIG_M68360)
  188. printk(KERN_INFO "QUICC port done by SED Systems <hamilton@sedsystems.ca>,\n");
  189. printk(KERN_INFO "based on 2.0.38 port by Lineo Inc. <mleslie@lineo.com>.\n");
  190. #endif
  191. #ifdef CONFIG_DRAGEN2
  192. printk(KERN_INFO "DragonEngine II board support by Georges Menie\n");
  193. #endif
  194. #ifdef CONFIG_M5235EVB
  195. printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)\n");
  196. #endif
  197. pr_debug("KERNEL -> TEXT=0x%p-0x%p DATA=0x%p-0x%p BSS=0x%p-0x%p\n",
  198. _stext, _etext, _sdata, _edata, __bss_start, __bss_stop);
  199. pr_debug("MEMORY -> ROMFS=0x%p-0x%06lx MEM=0x%06lx-0x%06lx\n ",
  200. __bss_stop, memory_start, memory_start, 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. };