setup.c 13 KB

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