setup.c 13 KB

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