setup.c 13 KB

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