setup.c 9.5 KB

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