PageRenderTime 51ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/arch/m68knommu/kernel/setup.c

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