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