setup_no.c 8.9 KB

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