setup.c 9.5 KB

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