setup.c 13 KB

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