setup.c 12 KB

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