setup_no.c 8.9 KB

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