setup.c 8.8 KB

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