setup_mm.c 13 KB

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