setup_mm.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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. 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. #ifndef CONFIG_SUN3
  196. int i;
  197. #endif
  198. /* The bootinfo is located right after the kernel bss */
  199. if (!CPU_IS_COLDFIRE)
  200. m68k_parse_bootinfo((const struct bi_record *)_end);
  201. if (CPU_IS_040)
  202. m68k_is040or060 = 4;
  203. else if (CPU_IS_060)
  204. m68k_is040or060 = 6;
  205. /* FIXME: m68k_fputype is passed in by Penguin booter, which can
  206. * be confused by software FPU emulation. BEWARE.
  207. * We should really do our own FPU check at startup.
  208. * [what do we do with buggy 68LC040s? if we have problems
  209. * with them, we should add a test to check_bugs() below] */
  210. #ifndef CONFIG_M68KFPU_EMU_ONLY
  211. /* clear the fpu if we have one */
  212. if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060|FPU_COLDFIRE)) {
  213. volatile int zero = 0;
  214. asm volatile ("frestore %0" : : "m" (zero));
  215. }
  216. #endif
  217. if (CPU_IS_060) {
  218. u32 pcr;
  219. asm (".chip 68060; movec %%pcr,%0; .chip 68k"
  220. : "=d" (pcr));
  221. if (((pcr >> 8) & 0xff) <= 5) {
  222. printk("Enabling workaround for errata I14\n");
  223. asm (".chip 68060; movec %0,%%pcr; .chip 68k"
  224. : : "d" (pcr | 0x20));
  225. }
  226. }
  227. init_mm.start_code = PAGE_OFFSET;
  228. init_mm.end_code = (unsigned long)_etext;
  229. init_mm.end_data = (unsigned long)_edata;
  230. init_mm.brk = (unsigned long)_end;
  231. #if defined(CONFIG_BOOTPARAM)
  232. strncpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE);
  233. m68k_command_line[CL_SIZE - 1] = 0;
  234. #endif /* CONFIG_BOOTPARAM */
  235. *cmdline_p = m68k_command_line;
  236. memcpy(boot_command_line, *cmdline_p, CL_SIZE);
  237. parse_early_param();
  238. #ifdef CONFIG_DUMMY_CONSOLE
  239. conswitchp = &dummy_con;
  240. #endif
  241. switch (m68k_machtype) {
  242. #ifdef CONFIG_AMIGA
  243. case MACH_AMIGA:
  244. config_amiga();
  245. break;
  246. #endif
  247. #ifdef CONFIG_ATARI
  248. case MACH_ATARI:
  249. config_atari();
  250. break;
  251. #endif
  252. #ifdef CONFIG_MAC
  253. case MACH_MAC:
  254. config_mac();
  255. break;
  256. #endif
  257. #ifdef CONFIG_SUN3
  258. case MACH_SUN3:
  259. config_sun3();
  260. break;
  261. #endif
  262. #ifdef CONFIG_APOLLO
  263. case MACH_APOLLO:
  264. config_apollo();
  265. break;
  266. #endif
  267. #ifdef CONFIG_MVME147
  268. case MACH_MVME147:
  269. config_mvme147();
  270. break;
  271. #endif
  272. #ifdef CONFIG_MVME16x
  273. case MACH_MVME16x:
  274. config_mvme16x();
  275. break;
  276. #endif
  277. #ifdef CONFIG_BVME6000
  278. case MACH_BVME6000:
  279. config_bvme6000();
  280. break;
  281. #endif
  282. #ifdef CONFIG_HP300
  283. case MACH_HP300:
  284. config_hp300();
  285. break;
  286. #endif
  287. #ifdef CONFIG_Q40
  288. case MACH_Q40:
  289. config_q40();
  290. break;
  291. #endif
  292. #ifdef CONFIG_SUN3X
  293. case MACH_SUN3X:
  294. config_sun3x();
  295. break;
  296. #endif
  297. #ifdef CONFIG_COLDFIRE
  298. case MACH_M54XX:
  299. config_BSP(NULL, 0);
  300. break;
  301. #endif
  302. default:
  303. panic("No configuration setup");
  304. }
  305. #ifdef CONFIG_NATFEAT
  306. nf_init();
  307. #endif
  308. paging_init();
  309. #ifndef CONFIG_SUN3
  310. for (i = 1; i < m68k_num_memory; i++)
  311. free_bootmem_node(NODE_DATA(i), m68k_memory[i].addr,
  312. m68k_memory[i].size);
  313. #ifdef CONFIG_BLK_DEV_INITRD
  314. if (m68k_ramdisk.size) {
  315. reserve_bootmem_node(__virt_to_node(phys_to_virt(m68k_ramdisk.addr)),
  316. m68k_ramdisk.addr, m68k_ramdisk.size,
  317. BOOTMEM_DEFAULT);
  318. initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
  319. initrd_end = initrd_start + m68k_ramdisk.size;
  320. printk("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
  321. }
  322. #endif
  323. #ifdef CONFIG_ATARI
  324. if (MACH_IS_ATARI)
  325. atari_stram_reserve_pages((void *)availmem);
  326. #endif
  327. #ifdef CONFIG_SUN3X
  328. if (MACH_IS_SUN3X) {
  329. dvma_init();
  330. }
  331. #endif
  332. #endif /* !CONFIG_SUN3 */
  333. /* set ISA defs early as possible */
  334. #if defined(CONFIG_ISA) && defined(MULTI_ISA)
  335. if (MACH_IS_Q40) {
  336. isa_type = ISA_TYPE_Q40;
  337. isa_sex = 0;
  338. }
  339. #ifdef CONFIG_AMIGA_PCMCIA
  340. if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)) {
  341. isa_type = ISA_TYPE_AG;
  342. isa_sex = 1;
  343. }
  344. #endif
  345. #ifdef CONFIG_ATARI_ROM_ISA
  346. if (MACH_IS_ATARI) {
  347. isa_type = ISA_TYPE_ENEC;
  348. isa_sex = 0;
  349. }
  350. #endif
  351. #endif
  352. }
  353. static int show_cpuinfo(struct seq_file *m, void *v)
  354. {
  355. const char *cpu, *mmu, *fpu;
  356. unsigned long clockfreq, clockfactor;
  357. #define LOOP_CYCLES_68020 (8)
  358. #define LOOP_CYCLES_68030 (8)
  359. #define LOOP_CYCLES_68040 (3)
  360. #define LOOP_CYCLES_68060 (1)
  361. #define LOOP_CYCLES_COLDFIRE (2)
  362. if (CPU_IS_020) {
  363. cpu = "68020";
  364. clockfactor = LOOP_CYCLES_68020;
  365. } else if (CPU_IS_030) {
  366. cpu = "68030";
  367. clockfactor = LOOP_CYCLES_68030;
  368. } else if (CPU_IS_040) {
  369. cpu = "68040";
  370. clockfactor = LOOP_CYCLES_68040;
  371. } else if (CPU_IS_060) {
  372. cpu = "68060";
  373. clockfactor = LOOP_CYCLES_68060;
  374. } else if (CPU_IS_COLDFIRE) {
  375. cpu = "ColdFire";
  376. clockfactor = LOOP_CYCLES_COLDFIRE;
  377. } else {
  378. cpu = "680x0";
  379. clockfactor = 0;
  380. }
  381. #ifdef CONFIG_M68KFPU_EMU_ONLY
  382. fpu = "none(soft float)";
  383. #else
  384. if (m68k_fputype & FPU_68881)
  385. fpu = "68881";
  386. else if (m68k_fputype & FPU_68882)
  387. fpu = "68882";
  388. else if (m68k_fputype & FPU_68040)
  389. fpu = "68040";
  390. else if (m68k_fputype & FPU_68060)
  391. fpu = "68060";
  392. else if (m68k_fputype & FPU_SUNFPA)
  393. fpu = "Sun FPA";
  394. else if (m68k_fputype & FPU_COLDFIRE)
  395. fpu = "ColdFire";
  396. else
  397. fpu = "none";
  398. #endif
  399. if (m68k_mmutype & MMU_68851)
  400. mmu = "68851";
  401. else if (m68k_mmutype & MMU_68030)
  402. mmu = "68030";
  403. else if (m68k_mmutype & MMU_68040)
  404. mmu = "68040";
  405. else if (m68k_mmutype & MMU_68060)
  406. mmu = "68060";
  407. else if (m68k_mmutype & MMU_SUN3)
  408. mmu = "Sun-3";
  409. else if (m68k_mmutype & MMU_APOLLO)
  410. mmu = "Apollo";
  411. else if (m68k_mmutype & MMU_COLDFIRE)
  412. mmu = "ColdFire";
  413. else
  414. mmu = "unknown";
  415. clockfreq = loops_per_jiffy * HZ * clockfactor;
  416. seq_printf(m, "CPU:\t\t%s\n"
  417. "MMU:\t\t%s\n"
  418. "FPU:\t\t%s\n"
  419. "Clocking:\t%lu.%1luMHz\n"
  420. "BogoMips:\t%lu.%02lu\n"
  421. "Calibration:\t%lu loops\n",
  422. cpu, mmu, fpu,
  423. clockfreq/1000000,(clockfreq/100000)%10,
  424. loops_per_jiffy/(500000/HZ),(loops_per_jiffy/(5000/HZ))%100,
  425. loops_per_jiffy);
  426. return 0;
  427. }
  428. static void *c_start(struct seq_file *m, loff_t *pos)
  429. {
  430. return *pos < 1 ? (void *)1 : NULL;
  431. }
  432. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  433. {
  434. ++*pos;
  435. return NULL;
  436. }
  437. static void c_stop(struct seq_file *m, void *v)
  438. {
  439. }
  440. const struct seq_operations cpuinfo_op = {
  441. .start = c_start,
  442. .next = c_next,
  443. .stop = c_stop,
  444. .show = show_cpuinfo,
  445. };
  446. #ifdef CONFIG_PROC_HARDWARE
  447. static int hardware_proc_show(struct seq_file *m, void *v)
  448. {
  449. char model[80];
  450. unsigned long mem;
  451. int i;
  452. if (mach_get_model)
  453. mach_get_model(model);
  454. else
  455. strcpy(model, "Unknown m68k");
  456. seq_printf(m, "Model:\t\t%s\n", model);
  457. for (mem = 0, i = 0; i < m68k_num_memory; i++)
  458. mem += m68k_memory[i].size;
  459. seq_printf(m, "System Memory:\t%ldK\n", mem >> 10);
  460. if (mach_get_hardware_list)
  461. mach_get_hardware_list(m);
  462. return 0;
  463. }
  464. static int hardware_proc_open(struct inode *inode, struct file *file)
  465. {
  466. return single_open(file, hardware_proc_show, NULL);
  467. }
  468. static const struct file_operations hardware_proc_fops = {
  469. .open = hardware_proc_open,
  470. .read = seq_read,
  471. .llseek = seq_lseek,
  472. .release = single_release,
  473. };
  474. static int __init proc_hardware_init(void)
  475. {
  476. proc_create("hardware", 0, NULL, &hardware_proc_fops);
  477. return 0;
  478. }
  479. module_init(proc_hardware_init);
  480. #endif
  481. void check_bugs(void)
  482. {
  483. #ifndef CONFIG_M68KFPU_EMU
  484. if (m68k_fputype == 0) {
  485. printk(KERN_EMERG "*** YOU DO NOT HAVE A FLOATING POINT UNIT, "
  486. "WHICH IS REQUIRED BY LINUX/M68K ***\n");
  487. printk(KERN_EMERG "Upgrade your hardware or join the FPU "
  488. "emulation project\n");
  489. panic("no FPU");
  490. }
  491. #endif /* !CONFIG_M68KFPU_EMU */
  492. }
  493. #ifdef CONFIG_ADB
  494. static int __init adb_probe_sync_enable (char *str) {
  495. extern int __adb_probe_sync;
  496. __adb_probe_sync = 1;
  497. return 1;
  498. }
  499. __setup("adb_sync", adb_probe_sync_enable);
  500. #endif /* CONFIG_ADB */