setup.c 12 KB

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