setup.c 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. /*
  2. * linux/arch/m68knommu/kernel/setup.c
  3. *
  4. * Copyright (C) 1999-2004 Greg Ungerer (gerg@snapgear.com)
  5. * Copyright (C) 1998,1999 D. Jeff Dionne <jeff@lineo.ca>
  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/config.h>
  18. #include <linux/kernel.h>
  19. #include <linux/sched.h>
  20. #include <linux/delay.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/fs.h>
  23. #include <linux/fb.h>
  24. #include <linux/console.h>
  25. #include <linux/genhd.h>
  26. #include <linux/errno.h>
  27. #include <linux/string.h>
  28. #include <linux/major.h>
  29. #include <linux/bootmem.h>
  30. #include <linux/seq_file.h>
  31. #include <linux/root_dev.h>
  32. #include <linux/init.h>
  33. #include <asm/setup.h>
  34. #include <asm/irq.h>
  35. #include <asm/machdep.h>
  36. #ifdef CONFIG_BLK_DEV_INITRD
  37. #include <asm/pgtable.h>
  38. #endif
  39. unsigned long rom_length;
  40. unsigned long memory_start;
  41. unsigned long memory_end;
  42. char command_line[COMMAND_LINE_SIZE];
  43. /* setup some dummy routines */
  44. static void dummy_waitbut(void)
  45. {
  46. }
  47. void (*mach_sched_init) (irqreturn_t (*handler)(int, void *, struct pt_regs *)) = NULL;
  48. void (*mach_tick)( void ) = NULL;
  49. /* machine dependent keyboard functions */
  50. int (*mach_keyb_init) (void) = NULL;
  51. int (*mach_kbdrate) (struct kbd_repeat *) = NULL;
  52. void (*mach_kbd_leds) (unsigned int) = NULL;
  53. /* machine dependent irq functions */
  54. void (*mach_init_IRQ) (void) = NULL;
  55. irqreturn_t (*(*mach_default_handler)[]) (int, void *, struct pt_regs *) = NULL;
  56. void (*mach_enable_irq) (unsigned int) = NULL;
  57. void (*mach_disable_irq) (unsigned int) = NULL;
  58. int (*mach_get_irq_list) (struct seq_file *, void *) = NULL;
  59. void (*mach_process_int) (int irq, struct pt_regs *fp) = NULL;
  60. void (*mach_trap_init) (void);
  61. /* machine dependent timer functions */
  62. unsigned long (*mach_gettimeoffset) (void) = NULL;
  63. void (*mach_gettod) (int*, int*, int*, int*, int*, int*) = NULL;
  64. int (*mach_hwclk) (int, struct hwclk_time*) = NULL;
  65. int (*mach_set_clock_mmss) (unsigned long) = NULL;
  66. void (*mach_mksound)( unsigned int count, unsigned int ticks ) = NULL;
  67. void (*mach_reset)( void ) = NULL;
  68. void (*waitbut)(void) = dummy_waitbut;
  69. void (*mach_debug_init)(void) = NULL;
  70. void (*mach_halt)( void ) = NULL;
  71. void (*mach_power_off)( void ) = NULL;
  72. #ifdef CONFIG_M68000
  73. #define CPU "MC68000"
  74. #endif
  75. #ifdef CONFIG_M68328
  76. #define CPU "MC68328"
  77. #endif
  78. #ifdef CONFIG_M68EZ328
  79. #define CPU "MC68EZ328"
  80. #endif
  81. #ifdef CONFIG_M68VZ328
  82. #define CPU "MC68VZ328"
  83. #endif
  84. #ifdef CONFIG_M68332
  85. #define CPU "MC68332"
  86. #endif
  87. #ifdef CONFIG_M68360
  88. #define CPU "MC68360"
  89. #endif
  90. #if defined(CONFIG_M5206)
  91. #define CPU "COLDFIRE(m5206)"
  92. #endif
  93. #if defined(CONFIG_M5206e)
  94. #define CPU "COLDFIRE(m5206e)"
  95. #endif
  96. #if defined(CONFIG_M5249)
  97. #define CPU "COLDFIRE(m5249)"
  98. #endif
  99. #if defined(CONFIG_M527x)
  100. #define CPU "COLDFIRE(m5270/5271/5274/5275)"
  101. #endif
  102. #if defined(CONFIG_M5272)
  103. #define CPU "COLDFIRE(m5272)"
  104. #endif
  105. #if defined(CONFIG_M528x)
  106. #define CPU "COLDFIRE(m5280/5282)"
  107. #endif
  108. #if defined(CONFIG_M5307)
  109. #define CPU "COLDFIRE(m5307)"
  110. #endif
  111. #if defined(CONFIG_M5407)
  112. #define CPU "COLDFIRE(m5407)"
  113. #endif
  114. #ifndef CPU
  115. #define CPU "UNKOWN"
  116. #endif
  117. /* (es) */
  118. /* note: why is this defined here? the must be a better place to put this */
  119. #if defined( CONFIG_TELOS) || defined( CONFIG_UCDIMM ) || defined( CONFIG_UCSIMM ) || defined(CONFIG_DRAGEN2) || (defined( CONFIG_PILOT ) && defined( CONFIG_M68328 ))
  120. #define CAT_ROMARRAY
  121. #endif
  122. /* (/es) */
  123. extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end;
  124. extern int _ramstart, _ramend;
  125. void setup_arch(char **cmdline_p)
  126. {
  127. int bootmap_size;
  128. #if defined(CAT_ROMARRAY) && defined(DEBUG)
  129. extern int __data_rom_start;
  130. extern int __data_start;
  131. int *romarray = (int *)((int) &__data_rom_start +
  132. (int)&_edata - (int)&__data_start);
  133. #endif
  134. memory_start = PAGE_ALIGN(_ramstart);
  135. memory_end = _ramend; /* by now the stack is part of the init task */
  136. init_mm.start_code = (unsigned long) &_stext;
  137. init_mm.end_code = (unsigned long) &_etext;
  138. init_mm.end_data = (unsigned long) &_edata;
  139. init_mm.brk = (unsigned long) 0;
  140. config_BSP(&command_line[0], sizeof(command_line));
  141. printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU "\n");
  142. #ifdef CONFIG_UCDIMM
  143. printk(KERN_INFO "uCdimm by Lineo, Inc. <www.lineo.com>\n");
  144. #endif
  145. #ifdef CONFIG_M68VZ328
  146. printk(KERN_INFO "M68VZ328 support by Evan Stawnyczy <e@lineo.ca>\n");
  147. #endif
  148. #ifdef CONFIG_COLDFIRE
  149. printk(KERN_INFO "COLDFIRE port done by Greg Ungerer, gerg@snapgear.com\n");
  150. #ifdef CONFIG_M5307
  151. printk(KERN_INFO "Modified for M5307 by Dave Miller, dmiller@intellistor.com\n");
  152. #endif
  153. #ifdef CONFIG_ELITE
  154. printk(KERN_INFO "Modified for M5206eLITE by Rob Scott, rscott@mtrob.fdns.net\n");
  155. #endif
  156. #ifdef CONFIG_TELOS
  157. printk(KERN_INFO "Modified for Omnia ToolVox by James D. Schettine, james@telos-systems.com\n");
  158. #endif
  159. #endif
  160. printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
  161. #if defined( CONFIG_PILOT ) && defined( CONFIG_M68328 )
  162. printk(KERN_INFO "TRG SuperPilot FLASH card support <info@trgnet.com>\n");
  163. #endif
  164. #if defined( CONFIG_PILOT ) && defined( CONFIG_M68EZ328 )
  165. printk(KERN_INFO "PalmV support by Lineo Inc. <jeff@uclinux.com>\n");
  166. #endif
  167. #ifdef CONFIG_M68EZ328ADS
  168. printk(KERN_INFO "M68EZ328ADS board support (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>\n");
  169. #endif
  170. #ifdef CONFIG_ALMA_ANS
  171. printk(KERN_INFO "Alma Electronics board support (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>\n");
  172. #endif
  173. #if defined (CONFIG_M68360)
  174. printk(KERN_INFO "QUICC port done by SED Systems <hamilton@sedsystems.ca>,\n");
  175. printk(KERN_INFO "based on 2.0.38 port by Lineo Inc. <mleslie@lineo.com>.\n");
  176. #endif
  177. #ifdef CONFIG_DRAGEN2
  178. printk(KERN_INFO "DragonEngine II board support by Georges Menie\n");
  179. #endif
  180. #ifdef DEBUG
  181. printk(KERN_DEBUG "KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
  182. "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
  183. (int) &_sdata, (int) &_edata,
  184. (int) &_sbss, (int) &_ebss);
  185. printk(KERN_DEBUG "KERNEL -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x "
  186. "STACK=0x%06x-0x%06x\n",
  187. #ifdef CAT_ROMARRAY
  188. (int) romarray, ((int) romarray) + romarray[2],
  189. #else
  190. (int) &_ebss, (int) memory_start,
  191. #endif
  192. (int) memory_start, (int) memory_end,
  193. (int) memory_end, (int) _ramend);
  194. #endif
  195. /* Keep a copy of command line */
  196. *cmdline_p = &command_line[0];
  197. memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
  198. saved_command_line[COMMAND_LINE_SIZE-1] = 0;
  199. #ifdef DEBUG
  200. if (strlen(*cmdline_p))
  201. printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
  202. #endif
  203. #if defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_DUMMY_CONSOLE)
  204. conswitchp = &dummy_con;
  205. #endif
  206. /*
  207. * Give all the memory to the bootmap allocator, tell it to put the
  208. * boot mem_map at the start of memory.
  209. */
  210. bootmap_size = init_bootmem_node(
  211. NODE_DATA(0),
  212. memory_start >> PAGE_SHIFT, /* map goes here */
  213. PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
  214. memory_end >> PAGE_SHIFT);
  215. /*
  216. * Free the usable memory, we have to make sure we do not free
  217. * the bootmem bitmap so we then reserve it after freeing it :-)
  218. */
  219. free_bootmem(memory_start, memory_end - memory_start);
  220. reserve_bootmem(memory_start, bootmap_size);
  221. /*
  222. * Get kmalloc into gear.
  223. */
  224. paging_init();
  225. }
  226. int get_cpuinfo(char * buffer)
  227. {
  228. char *cpu, *mmu, *fpu;
  229. u_long clockfreq;
  230. cpu = CPU;
  231. mmu = "none";
  232. fpu = "none";
  233. #ifdef CONFIG_COLDFIRE
  234. clockfreq = (loops_per_jiffy*HZ)*3;
  235. #else
  236. clockfreq = (loops_per_jiffy*HZ)*16;
  237. #endif
  238. return(sprintf(buffer, "CPU:\t\t%s\n"
  239. "MMU:\t\t%s\n"
  240. "FPU:\t\t%s\n"
  241. "Clocking:\t%lu.%1luMHz\n"
  242. "BogoMips:\t%lu.%02lu\n"
  243. "Calibration:\t%lu loops\n",
  244. cpu, mmu, fpu,
  245. clockfreq/1000000,(clockfreq/100000)%10,
  246. (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
  247. (loops_per_jiffy*HZ)));
  248. }
  249. /*
  250. * Get CPU information for use by the procfs.
  251. */
  252. static int show_cpuinfo(struct seq_file *m, void *v)
  253. {
  254. char *cpu, *mmu, *fpu;
  255. u_long clockfreq;
  256. cpu = CPU;
  257. mmu = "none";
  258. fpu = "none";
  259. #ifdef CONFIG_COLDFIRE
  260. clockfreq = (loops_per_jiffy*HZ)*3;
  261. #else
  262. clockfreq = (loops_per_jiffy*HZ)*16;
  263. #endif
  264. seq_printf(m, "CPU:\t\t%s\n"
  265. "MMU:\t\t%s\n"
  266. "FPU:\t\t%s\n"
  267. "Clocking:\t%lu.%1luMHz\n"
  268. "BogoMips:\t%lu.%02lu\n"
  269. "Calibration:\t%lu loops\n",
  270. cpu, mmu, fpu,
  271. clockfreq/1000000,(clockfreq/100000)%10,
  272. (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
  273. (loops_per_jiffy*HZ));
  274. return 0;
  275. }
  276. static void *c_start(struct seq_file *m, loff_t *pos)
  277. {
  278. return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
  279. }
  280. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  281. {
  282. ++*pos;
  283. return c_start(m, pos);
  284. }
  285. static void c_stop(struct seq_file *m, void *v)
  286. {
  287. }
  288. struct seq_operations cpuinfo_op = {
  289. .start = c_start,
  290. .next = c_next,
  291. .stop = c_stop,
  292. .show = show_cpuinfo,
  293. };
  294. void arch_gettod(int *year, int *mon, int *day, int *hour,
  295. int *min, int *sec)
  296. {
  297. if (mach_gettod)
  298. mach_gettod(year, mon, day, hour, min, sec);
  299. else
  300. *year = *mon = *day = *hour = *min = *sec = 0;
  301. }