/kernel/2.6.32_froyo_photon_nightly/arch/m68k/kernel/setup.c

http://photon-android.googlecode.com/ · C · 534 lines · 458 code · 57 blank · 19 comment · 76 complexity · 681e534f7308a0bc3d3aea610fc7cde1 MD5 · raw file

  1. /*
  2. * linux/arch/m68k/kernel/setup.c
  3. *
  4. * Copyright (C) 1995 Hamish Macdonald
  5. */
  6. /*
  7. * This file handles the architecture-dependent parts of system setup
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/mm.h>
  11. #include <linux/sched.h>
  12. #include <linux/delay.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/fs.h>
  15. #include <linux/console.h>
  16. #include <linux/genhd.h>
  17. #include <linux/errno.h>
  18. #include <linux/string.h>
  19. #include <linux/init.h>
  20. #include <linux/bootmem.h>
  21. #include <linux/proc_fs.h>
  22. #include <linux/seq_file.h>
  23. #include <linux/module.h>
  24. #include <linux/initrd.h>
  25. #include <asm/bootinfo.h>
  26. #include <asm/sections.h>
  27. #include <asm/setup.h>
  28. #include <asm/fpu.h>
  29. #include <asm/irq.h>
  30. #include <asm/io.h>
  31. #include <asm/machdep.h>
  32. #ifdef CONFIG_AMIGA
  33. #include <asm/amigahw.h>
  34. #endif
  35. #ifdef CONFIG_ATARI
  36. #include <asm/atarihw.h>
  37. #include <asm/atari_stram.h>
  38. #endif
  39. #ifdef CONFIG_SUN3X
  40. #include <asm/dvma.h>
  41. #endif
  42. #if !FPSTATESIZE || !NR_IRQS
  43. #warning No CPU/platform type selected, your kernel will not work!
  44. #warning Are you building an allnoconfig kernel?
  45. #endif
  46. unsigned long m68k_machtype;
  47. EXPORT_SYMBOL(m68k_machtype);
  48. unsigned long m68k_cputype;
  49. EXPORT_SYMBOL(m68k_cputype);
  50. unsigned long m68k_fputype;
  51. unsigned long m68k_mmutype;
  52. EXPORT_SYMBOL(m68k_mmutype);
  53. #ifdef CONFIG_VME
  54. unsigned long vme_brdtype;
  55. EXPORT_SYMBOL(vme_brdtype);
  56. #endif
  57. int m68k_is040or060;
  58. EXPORT_SYMBOL(m68k_is040or060);
  59. extern unsigned long availmem;
  60. int m68k_num_memory;
  61. EXPORT_SYMBOL(m68k_num_memory);
  62. int m68k_realnum_memory;
  63. EXPORT_SYMBOL(m68k_realnum_memory);
  64. unsigned long m68k_memoffset;
  65. struct mem_info m68k_memory[NUM_MEMINFO];
  66. EXPORT_SYMBOL(m68k_memory);
  67. struct mem_info m68k_ramdisk;
  68. static char m68k_command_line[CL_SIZE];
  69. void (*mach_sched_init) (irq_handler_t handler) __initdata = NULL;
  70. /* machine dependent irq functions */
  71. void (*mach_init_IRQ) (void) __initdata = NULL;
  72. void (*mach_get_model) (char *model);
  73. void (*mach_get_hardware_list) (struct seq_file *m);
  74. /* machine dependent timer functions */
  75. unsigned long (*mach_gettimeoffset) (void);
  76. int (*mach_hwclk) (int, struct rtc_time*);
  77. EXPORT_SYMBOL(mach_hwclk);
  78. int (*mach_set_clock_mmss) (unsigned long);
  79. unsigned int (*mach_get_ss)(void);
  80. int (*mach_get_rtc_pll)(struct rtc_pll_info *);
  81. int (*mach_set_rtc_pll)(struct rtc_pll_info *);
  82. EXPORT_SYMBOL(mach_get_ss);
  83. EXPORT_SYMBOL(mach_get_rtc_pll);
  84. EXPORT_SYMBOL(mach_set_rtc_pll);
  85. void (*mach_reset)( void );
  86. void (*mach_halt)( void );
  87. void (*mach_power_off)( void );
  88. long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
  89. #ifdef CONFIG_HEARTBEAT
  90. void (*mach_heartbeat) (int);
  91. EXPORT_SYMBOL(mach_heartbeat);
  92. #endif
  93. #ifdef CONFIG_M68K_L2_CACHE
  94. void (*mach_l2_flush) (int);
  95. #endif
  96. #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
  97. void (*mach_beep)(unsigned int, unsigned int);
  98. EXPORT_SYMBOL(mach_beep);
  99. #endif
  100. #if defined(CONFIG_ISA) && defined(MULTI_ISA)
  101. int isa_type;
  102. int isa_sex;
  103. EXPORT_SYMBOL(isa_type);
  104. EXPORT_SYMBOL(isa_sex);
  105. #endif
  106. extern int amiga_parse_bootinfo(const struct bi_record *);
  107. extern int atari_parse_bootinfo(const struct bi_record *);
  108. extern int mac_parse_bootinfo(const struct bi_record *);
  109. extern int q40_parse_bootinfo(const struct bi_record *);
  110. extern int bvme6000_parse_bootinfo(const struct bi_record *);
  111. extern int mvme16x_parse_bootinfo(const struct bi_record *);
  112. extern int mvme147_parse_bootinfo(const struct bi_record *);
  113. extern int hp300_parse_bootinfo(const struct bi_record *);
  114. extern int apollo_parse_bootinfo(const struct bi_record *);
  115. extern void config_amiga(void);
  116. extern void config_atari(void);
  117. extern void config_mac(void);
  118. extern void config_sun3(void);
  119. extern void config_apollo(void);
  120. extern void config_mvme147(void);
  121. extern void config_mvme16x(void);
  122. extern void config_bvme6000(void);
  123. extern void config_hp300(void);
  124. extern void config_q40(void);
  125. extern void config_sun3x(void);
  126. #define MASK_256K 0xfffc0000
  127. extern void paging_init(void);
  128. static void __init m68k_parse_bootinfo(const struct bi_record *record)
  129. {
  130. while (record->tag != BI_LAST) {
  131. int unknown = 0;
  132. const unsigned long *data = record->data;
  133. switch (record->tag) {
  134. case BI_MACHTYPE:
  135. case BI_CPUTYPE:
  136. case BI_FPUTYPE:
  137. case BI_MMUTYPE:
  138. /* Already set up by head.S */
  139. break;
  140. case BI_MEMCHUNK:
  141. if (m68k_num_memory < NUM_MEMINFO) {
  142. m68k_memory[m68k_num_memory].addr = data[0];
  143. m68k_memory[m68k_num_memory].size = data[1];
  144. m68k_num_memory++;
  145. } else
  146. printk("m68k_parse_bootinfo: too many memory chunks\n");
  147. break;
  148. case BI_RAMDISK:
  149. m68k_ramdisk.addr = data[0];
  150. m68k_ramdisk.size = data[1];
  151. break;
  152. case BI_COMMAND_LINE:
  153. strlcpy(m68k_command_line, (const char *)data,
  154. sizeof(m68k_command_line));
  155. break;
  156. default:
  157. if (MACH_IS_AMIGA)
  158. unknown = amiga_parse_bootinfo(record);
  159. else if (MACH_IS_ATARI)
  160. unknown = atari_parse_bootinfo(record);
  161. else if (MACH_IS_MAC)
  162. unknown = mac_parse_bootinfo(record);
  163. else if (MACH_IS_Q40)
  164. unknown = q40_parse_bootinfo(record);
  165. else if (MACH_IS_BVME6000)
  166. unknown = bvme6000_parse_bootinfo(record);
  167. else if (MACH_IS_MVME16x)
  168. unknown = mvme16x_parse_bootinfo(record);
  169. else if (MACH_IS_MVME147)
  170. unknown = mvme147_parse_bootinfo(record);
  171. else if (MACH_IS_HP300)
  172. unknown = hp300_parse_bootinfo(record);
  173. else if (MACH_IS_APOLLO)
  174. unknown = apollo_parse_bootinfo(record);
  175. else
  176. unknown = 1;
  177. }
  178. if (unknown)
  179. printk("m68k_parse_bootinfo: unknown tag 0x%04x ignored\n",
  180. record->tag);
  181. record = (struct bi_record *)((unsigned long)record +
  182. record->size);
  183. }
  184. m68k_realnum_memory = m68k_num_memory;
  185. #ifdef CONFIG_SINGLE_MEMORY_CHUNK
  186. if (m68k_num_memory > 1) {
  187. printk("Ignoring last %i chunks of physical memory\n",
  188. (m68k_num_memory - 1));
  189. m68k_num_memory = 1;
  190. }
  191. #endif
  192. }
  193. void __init setup_arch(char **cmdline_p)
  194. {
  195. int i;
  196. /* The bootinfo is located right after the kernel bss */
  197. m68k_parse_bootinfo((const struct bi_record *)_end);
  198. if (CPU_IS_040)
  199. m68k_is040or060 = 4;
  200. else if (CPU_IS_060)
  201. m68k_is040or060 = 6;
  202. /* FIXME: m68k_fputype is passed in by Penguin booter, which can
  203. * be confused by software FPU emulation. BEWARE.
  204. * We should really do our own FPU check at startup.
  205. * [what do we do with buggy 68LC040s? if we have problems
  206. * with them, we should add a test to check_bugs() below] */
  207. #ifndef CONFIG_M68KFPU_EMU_ONLY
  208. /* clear the fpu if we have one */
  209. if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) {
  210. volatile int zero = 0;
  211. asm volatile ("frestore %0" : : "m" (zero));
  212. }
  213. #endif
  214. if (CPU_IS_060) {
  215. u32 pcr;
  216. asm (".chip 68060; movec %%pcr,%0; .chip 68k"
  217. : "=d" (pcr));
  218. if (((pcr >> 8) & 0xff) <= 5) {
  219. printk("Enabling workaround for errata I14\n");
  220. asm (".chip 68060; movec %0,%%pcr; .chip 68k"
  221. : : "d" (pcr | 0x20));
  222. }
  223. }
  224. init_mm.start_code = PAGE_OFFSET;
  225. init_mm.end_code = (unsigned long)_etext;
  226. init_mm.end_data = (unsigned long)_edata;
  227. init_mm.brk = (unsigned long)_end;
  228. *cmdline_p = m68k_command_line;
  229. memcpy(boot_command_line, *cmdline_p, CL_SIZE);
  230. parse_early_param();
  231. #ifdef CONFIG_DUMMY_CONSOLE
  232. conswitchp = &dummy_con;
  233. #endif
  234. switch (m68k_machtype) {
  235. #ifdef CONFIG_AMIGA
  236. case MACH_AMIGA:
  237. config_amiga();
  238. break;
  239. #endif
  240. #ifdef CONFIG_ATARI
  241. case MACH_ATARI:
  242. config_atari();
  243. break;
  244. #endif
  245. #ifdef CONFIG_MAC
  246. case MACH_MAC:
  247. config_mac();
  248. break;
  249. #endif
  250. #ifdef CONFIG_SUN3
  251. case MACH_SUN3:
  252. config_sun3();
  253. break;
  254. #endif
  255. #ifdef CONFIG_APOLLO
  256. case MACH_APOLLO:
  257. config_apollo();
  258. break;
  259. #endif
  260. #ifdef CONFIG_MVME147
  261. case MACH_MVME147:
  262. config_mvme147();
  263. break;
  264. #endif
  265. #ifdef CONFIG_MVME16x
  266. case MACH_MVME16x:
  267. config_mvme16x();
  268. break;
  269. #endif
  270. #ifdef CONFIG_BVME6000
  271. case MACH_BVME6000:
  272. config_bvme6000();
  273. break;
  274. #endif
  275. #ifdef CONFIG_HP300
  276. case MACH_HP300:
  277. config_hp300();
  278. break;
  279. #endif
  280. #ifdef CONFIG_Q40
  281. case MACH_Q40:
  282. config_q40();
  283. break;
  284. #endif
  285. #ifdef CONFIG_SUN3X
  286. case MACH_SUN3X:
  287. config_sun3x();
  288. break;
  289. #endif
  290. default:
  291. panic("No configuration setup");
  292. }
  293. paging_init();
  294. #ifndef CONFIG_SUN3
  295. for (i = 1; i < m68k_num_memory; i++)
  296. free_bootmem_node(NODE_DATA(i), m68k_memory[i].addr,
  297. m68k_memory[i].size);
  298. #ifdef CONFIG_BLK_DEV_INITRD
  299. if (m68k_ramdisk.size) {
  300. reserve_bootmem_node(__virt_to_node(phys_to_virt(m68k_ramdisk.addr)),
  301. m68k_ramdisk.addr, m68k_ramdisk.size,
  302. BOOTMEM_DEFAULT);
  303. initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
  304. initrd_end = initrd_start + m68k_ramdisk.size;
  305. printk("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
  306. }
  307. #endif
  308. #ifdef CONFIG_ATARI
  309. if (MACH_IS_ATARI)
  310. atari_stram_reserve_pages((void *)availmem);
  311. #endif
  312. #ifdef CONFIG_SUN3X
  313. if (MACH_IS_SUN3X) {
  314. dvma_init();
  315. }
  316. #endif
  317. #endif /* !CONFIG_SUN3 */
  318. /* set ISA defs early as possible */
  319. #if defined(CONFIG_ISA) && defined(MULTI_ISA)
  320. if (MACH_IS_Q40) {
  321. isa_type = ISA_TYPE_Q40;
  322. isa_sex = 0;
  323. }
  324. #ifdef CONFIG_GG2
  325. if (MACH_IS_AMIGA && AMIGAHW_PRESENT(GG2_ISA)) {
  326. isa_type = ISA_TYPE_GG2;
  327. isa_sex = 0;
  328. }
  329. #endif
  330. #ifdef CONFIG_AMIGA_PCMCIA
  331. if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)) {
  332. isa_type = ISA_TYPE_AG;
  333. isa_sex = 1;
  334. }
  335. #endif
  336. #endif
  337. }
  338. static int show_cpuinfo(struct seq_file *m, void *v)
  339. {
  340. const char *cpu, *mmu, *fpu;
  341. unsigned long clockfreq, clockfactor;
  342. #define LOOP_CYCLES_68020 (8)
  343. #define LOOP_CYCLES_68030 (8)
  344. #define LOOP_CYCLES_68040 (3)
  345. #define LOOP_CYCLES_68060 (1)
  346. if (CPU_IS_020) {
  347. cpu = "68020";
  348. clockfactor = LOOP_CYCLES_68020;
  349. } else if (CPU_IS_030) {
  350. cpu = "68030";
  351. clockfactor = LOOP_CYCLES_68030;
  352. } else if (CPU_IS_040) {
  353. cpu = "68040";
  354. clockfactor = LOOP_CYCLES_68040;
  355. } else if (CPU_IS_060) {
  356. cpu = "68060";
  357. clockfactor = LOOP_CYCLES_68060;
  358. } else {
  359. cpu = "680x0";
  360. clockfactor = 0;
  361. }
  362. #ifdef CONFIG_M68KFPU_EMU_ONLY
  363. fpu = "none(soft float)";
  364. #else
  365. if (m68k_fputype & FPU_68881)
  366. fpu = "68881";
  367. else if (m68k_fputype & FPU_68882)
  368. fpu = "68882";
  369. else if (m68k_fputype & FPU_68040)
  370. fpu = "68040";
  371. else if (m68k_fputype & FPU_68060)
  372. fpu = "68060";
  373. else if (m68k_fputype & FPU_SUNFPA)
  374. fpu = "Sun FPA";
  375. else
  376. fpu = "none";
  377. #endif
  378. if (m68k_mmutype & MMU_68851)
  379. mmu = "68851";
  380. else if (m68k_mmutype & MMU_68030)
  381. mmu = "68030";
  382. else if (m68k_mmutype & MMU_68040)
  383. mmu = "68040";
  384. else if (m68k_mmutype & MMU_68060)
  385. mmu = "68060";
  386. else if (m68k_mmutype & MMU_SUN3)
  387. mmu = "Sun-3";
  388. else if (m68k_mmutype & MMU_APOLLO)
  389. mmu = "Apollo";
  390. else
  391. mmu = "unknown";
  392. clockfreq = loops_per_jiffy * HZ * clockfactor;
  393. seq_printf(m, "CPU:\t\t%s\n"
  394. "MMU:\t\t%s\n"
  395. "FPU:\t\t%s\n"
  396. "Clocking:\t%lu.%1luMHz\n"
  397. "BogoMips:\t%lu.%02lu\n"
  398. "Calibration:\t%lu loops\n",
  399. cpu, mmu, fpu,
  400. clockfreq/1000000,(clockfreq/100000)%10,
  401. loops_per_jiffy/(500000/HZ),(loops_per_jiffy/(5000/HZ))%100,
  402. loops_per_jiffy);
  403. return 0;
  404. }
  405. static void *c_start(struct seq_file *m, loff_t *pos)
  406. {
  407. return *pos < 1 ? (void *)1 : NULL;
  408. }
  409. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  410. {
  411. ++*pos;
  412. return NULL;
  413. }
  414. static void c_stop(struct seq_file *m, void *v)
  415. {
  416. }
  417. const struct seq_operations cpuinfo_op = {
  418. .start = c_start,
  419. .next = c_next,
  420. .stop = c_stop,
  421. .show = show_cpuinfo,
  422. };
  423. #ifdef CONFIG_PROC_HARDWARE
  424. static int hardware_proc_show(struct seq_file *m, void *v)
  425. {
  426. char model[80];
  427. unsigned long mem;
  428. int i;
  429. if (mach_get_model)
  430. mach_get_model(model);
  431. else
  432. strcpy(model, "Unknown m68k");
  433. seq_printf(m, "Model:\t\t%s\n", model);
  434. for (mem = 0, i = 0; i < m68k_num_memory; i++)
  435. mem += m68k_memory[i].size;
  436. seq_printf(m, "System Memory:\t%ldK\n", mem >> 10);
  437. if (mach_get_hardware_list)
  438. mach_get_hardware_list(m);
  439. return 0;
  440. }
  441. static int hardware_proc_open(struct inode *inode, struct file *file)
  442. {
  443. return single_open(file, hardware_proc_show, NULL);
  444. }
  445. static const struct file_operations hardware_proc_fops = {
  446. .open = hardware_proc_open,
  447. .read = seq_read,
  448. .llseek = seq_lseek,
  449. .release = single_release,
  450. };
  451. static int __init proc_hardware_init(void)
  452. {
  453. proc_create("hardware", 0, NULL, &hardware_proc_fops);
  454. return 0;
  455. }
  456. module_init(proc_hardware_init);
  457. #endif
  458. void check_bugs(void)
  459. {
  460. #ifndef CONFIG_M68KFPU_EMU
  461. if (m68k_fputype == 0) {
  462. printk(KERN_EMERG "*** YOU DO NOT HAVE A FLOATING POINT UNIT, "
  463. "WHICH IS REQUIRED BY LINUX/M68K ***\n");
  464. printk(KERN_EMERG "Upgrade your hardware or join the FPU "
  465. "emulation project\n");
  466. panic("no FPU");
  467. }
  468. #endif /* !CONFIG_M68KFPU_EMU */
  469. }
  470. #ifdef CONFIG_ADB
  471. static int __init adb_probe_sync_enable (char *str) {
  472. extern int __adb_probe_sync;
  473. __adb_probe_sync = 1;
  474. return 1;
  475. }
  476. __setup("adb_sync", adb_probe_sync_enable);
  477. #endif /* CONFIG_ADB */