setup_no.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. #ifndef CPU_NAME
  63. #define CPU_NAME "UNKNOWN"
  64. #endif
  65. /*
  66. * Different cores have different instruction execution timings.
  67. * The old/traditional 68000 cores are basically all the same, at 16.
  68. * The ColdFire cores vary a little, their values are defined in their
  69. * headers. We default to the standard 68000 value here.
  70. */
  71. #ifndef CPU_INSTR_PER_JIFFY
  72. #define CPU_INSTR_PER_JIFFY 16
  73. #endif
  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. static void __init 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. #ifdef CONFIG_DRAGEN2
  187. printk(KERN_INFO "DragonEngine II board support by Georges Menie\n");
  188. #endif
  189. #ifdef CONFIG_M5235EVB
  190. printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)\n");
  191. #endif
  192. pr_debug("KERNEL -> TEXT=0x%p-0x%p DATA=0x%p-0x%p BSS=0x%p-0x%p\n",
  193. _stext, _etext, _sdata, _edata, __bss_start, __bss_stop);
  194. pr_debug("MEMORY -> ROMFS=0x%p-0x%06lx MEM=0x%06lx-0x%06lx\n ",
  195. __bss_stop, memory_start, memory_start, memory_end);
  196. /* Keep a copy of command line */
  197. *cmdline_p = &command_line[0];
  198. memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
  199. boot_command_line[COMMAND_LINE_SIZE-1] = 0;
  200. #if defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_DUMMY_CONSOLE)
  201. conswitchp = &dummy_con;
  202. #endif
  203. /*
  204. * Give all the memory to the bootmap allocator, tell it to put the
  205. * boot mem_map at the start of memory.
  206. */
  207. min_low_pfn = PFN_DOWN(memory_start);
  208. max_pfn = max_low_pfn = PFN_DOWN(memory_end);
  209. bootmap_size = init_bootmem_node(
  210. NODE_DATA(0),
  211. min_low_pfn, /* map goes here */
  212. PFN_DOWN(PAGE_OFFSET),
  213. max_pfn);
  214. /*
  215. * Free the usable memory, we have to make sure we do not free
  216. * the bootmem bitmap so we then reserve it after freeing it :-)
  217. */
  218. free_bootmem(memory_start, memory_end - memory_start);
  219. reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT);
  220. #if defined(CONFIG_UBOOT) && defined(CONFIG_BLK_DEV_INITRD)
  221. if ((initrd_start > 0) && (initrd_start < initrd_end) &&
  222. (initrd_end < memory_end))
  223. reserve_bootmem(initrd_start, initrd_end - initrd_start,
  224. BOOTMEM_DEFAULT);
  225. #endif /* if defined(CONFIG_BLK_DEV_INITRD) */
  226. /*
  227. * Get kmalloc into gear.
  228. */
  229. paging_init();
  230. }
  231. /*
  232. * Get CPU information for use by the procfs.
  233. */
  234. static int show_cpuinfo(struct seq_file *m, void *v)
  235. {
  236. char *cpu, *mmu, *fpu;
  237. u_long clockfreq;
  238. cpu = CPU_NAME;
  239. mmu = "none";
  240. fpu = "none";
  241. clockfreq = (loops_per_jiffy * HZ) * CPU_INSTR_PER_JIFFY;
  242. seq_printf(m, "CPU:\t\t%s\n"
  243. "MMU:\t\t%s\n"
  244. "FPU:\t\t%s\n"
  245. "Clocking:\t%lu.%1luMHz\n"
  246. "BogoMips:\t%lu.%02lu\n"
  247. "Calibration:\t%lu loops\n",
  248. cpu, mmu, fpu,
  249. clockfreq / 1000000,
  250. (clockfreq / 100000) % 10,
  251. (loops_per_jiffy * HZ) / 500000,
  252. ((loops_per_jiffy * HZ) / 5000) % 100,
  253. (loops_per_jiffy * HZ));
  254. return 0;
  255. }
  256. static void *c_start(struct seq_file *m, loff_t *pos)
  257. {
  258. return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
  259. }
  260. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  261. {
  262. ++*pos;
  263. return c_start(m, pos);
  264. }
  265. static void c_stop(struct seq_file *m, void *v)
  266. {
  267. }
  268. const struct seq_operations cpuinfo_op = {
  269. .start = c_start,
  270. .next = c_next,
  271. .stop = c_stop,
  272. .show = show_cpuinfo,
  273. };