setup_32.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. /*
  2. * Common prep/pmac/chrp boot and setup code.
  3. */
  4. #include <linux/config.h>
  5. #include <linux/module.h>
  6. #include <linux/string.h>
  7. #include <linux/sched.h>
  8. #include <linux/init.h>
  9. #include <linux/kernel.h>
  10. #include <linux/reboot.h>
  11. #include <linux/delay.h>
  12. #include <linux/initrd.h>
  13. #include <linux/ide.h>
  14. #include <linux/tty.h>
  15. #include <linux/bootmem.h>
  16. #include <linux/seq_file.h>
  17. #include <linux/root_dev.h>
  18. #include <linux/cpu.h>
  19. #include <linux/console.h>
  20. #include <asm/residual.h>
  21. #include <asm/io.h>
  22. #include <asm/prom.h>
  23. #include <asm/processor.h>
  24. #include <asm/pgtable.h>
  25. #include <asm/setup.h>
  26. #include <asm/amigappc.h>
  27. #include <asm/smp.h>
  28. #include <asm/elf.h>
  29. #include <asm/cputable.h>
  30. #include <asm/bootx.h>
  31. #include <asm/btext.h>
  32. #include <asm/machdep.h>
  33. #include <asm/uaccess.h>
  34. #include <asm/system.h>
  35. #include <asm/pmac_feature.h>
  36. #include <asm/sections.h>
  37. #include <asm/nvram.h>
  38. #include <asm/xmon.h>
  39. #include <asm/time.h>
  40. #define DBG(fmt...)
  41. #if defined CONFIG_KGDB
  42. #include <asm/kgdb.h>
  43. #endif
  44. extern void platform_init(void);
  45. extern void bootx_init(unsigned long r4, unsigned long phys);
  46. extern void ppc6xx_idle(void);
  47. extern void power4_idle(void);
  48. boot_infos_t *boot_infos;
  49. struct ide_machdep_calls ppc_ide_md;
  50. /* XXX should go elsewhere */
  51. int __irq_offset_value;
  52. EXPORT_SYMBOL(__irq_offset_value);
  53. int boot_cpuid;
  54. EXPORT_SYMBOL_GPL(boot_cpuid);
  55. int boot_cpuid_phys;
  56. unsigned long ISA_DMA_THRESHOLD;
  57. unsigned int DMA_MODE_READ;
  58. unsigned int DMA_MODE_WRITE;
  59. int have_of = 1;
  60. #ifdef CONFIG_PPC_MULTIPLATFORM
  61. int _machine = 0;
  62. extern void prep_init(void);
  63. extern void pmac_init(void);
  64. extern void chrp_init(void);
  65. dev_t boot_dev;
  66. #endif /* CONFIG_PPC_MULTIPLATFORM */
  67. #ifdef CONFIG_MAGIC_SYSRQ
  68. unsigned long SYSRQ_KEY = 0x54;
  69. #endif /* CONFIG_MAGIC_SYSRQ */
  70. #ifdef CONFIG_VGA_CONSOLE
  71. unsigned long vgacon_remap_base;
  72. #endif
  73. struct machdep_calls ppc_md;
  74. EXPORT_SYMBOL(ppc_md);
  75. /*
  76. * These are used in binfmt_elf.c to put aux entries on the stack
  77. * for each elf executable being started.
  78. */
  79. int dcache_bsize;
  80. int icache_bsize;
  81. int ucache_bsize;
  82. /*
  83. * We're called here very early in the boot. We determine the machine
  84. * type and call the appropriate low-level setup functions.
  85. * -- Cort <cort@fsmlabs.com>
  86. *
  87. * Note that the kernel may be running at an address which is different
  88. * from the address that it was linked at, so we must use RELOC/PTRRELOC
  89. * to access static data (including strings). -- paulus
  90. */
  91. unsigned long __init early_init(unsigned long dt_ptr)
  92. {
  93. unsigned long offset = reloc_offset();
  94. /* First zero the BSS -- use memset_io, some platforms don't have
  95. * caches on yet */
  96. memset_io(PTRRELOC(&__bss_start), 0, _end - __bss_start);
  97. /*
  98. * Identify the CPU type and fix up code sections
  99. * that depend on which cpu we have.
  100. */
  101. identify_cpu(offset, 0);
  102. do_cpu_ftr_fixups(offset);
  103. return KERNELBASE + offset;
  104. }
  105. #ifdef CONFIG_PPC_MULTIPLATFORM
  106. /*
  107. * The PPC_MULTIPLATFORM version of platform_init...
  108. */
  109. void __init platform_init(void)
  110. {
  111. /* if we didn't get any bootinfo telling us what we are... */
  112. if (_machine == 0) {
  113. /* prep boot loader tells us if we're prep or not */
  114. if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) )
  115. _machine = _MACH_prep;
  116. }
  117. #ifdef CONFIG_PPC_PREP
  118. /* not much more to do here, if prep */
  119. if (_machine == _MACH_prep) {
  120. prep_init();
  121. return;
  122. }
  123. #endif
  124. #ifdef CONFIG_ADB
  125. if (strstr(cmd_line, "adb_sync")) {
  126. extern int __adb_probe_sync;
  127. __adb_probe_sync = 1;
  128. }
  129. #endif /* CONFIG_ADB */
  130. switch (_machine) {
  131. #ifdef CONFIG_PPC_PMAC
  132. case _MACH_Pmac:
  133. pmac_init();
  134. break;
  135. #endif
  136. #ifdef CONFIG_PPC_CHRP
  137. case _MACH_chrp:
  138. chrp_init();
  139. break;
  140. #endif
  141. }
  142. }
  143. #endif
  144. /*
  145. * Find out what kind of machine we're on and save any data we need
  146. * from the early boot process (devtree is copied on pmac by prom_init()).
  147. * This is called very early on the boot process, after a minimal
  148. * MMU environment has been set up but before MMU_init is called.
  149. */
  150. void __init machine_init(unsigned long dt_ptr, unsigned long phys)
  151. {
  152. early_init_devtree(__va(dt_ptr));
  153. #ifdef CONFIG_CMDLINE
  154. strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
  155. #endif /* CONFIG_CMDLINE */
  156. platform_init();
  157. #ifdef CONFIG_6xx
  158. ppc_md.power_save = ppc6xx_idle;
  159. #endif
  160. if (ppc_md.progress)
  161. ppc_md.progress("id mach(): done", 0x200);
  162. }
  163. #ifdef CONFIG_BOOKE_WDT
  164. /* Checks wdt=x and wdt_period=xx command-line option */
  165. int __init early_parse_wdt(char *p)
  166. {
  167. if (p && strncmp(p, "0", 1) != 0)
  168. booke_wdt_enabled = 1;
  169. return 0;
  170. }
  171. early_param("wdt", early_parse_wdt);
  172. int __init early_parse_wdt_period (char *p)
  173. {
  174. if (p)
  175. booke_wdt_period = simple_strtoul(p, NULL, 0);
  176. return 0;
  177. }
  178. early_param("wdt_period", early_parse_wdt_period);
  179. #endif /* CONFIG_BOOKE_WDT */
  180. /* Checks "l2cr=xxxx" command-line option */
  181. int __init ppc_setup_l2cr(char *str)
  182. {
  183. if (cpu_has_feature(CPU_FTR_L2CR)) {
  184. unsigned long val = simple_strtoul(str, NULL, 0);
  185. printk(KERN_INFO "l2cr set to %lx\n", val);
  186. _set_L2CR(0); /* force invalidate by disable cache */
  187. _set_L2CR(val); /* and enable it */
  188. }
  189. return 1;
  190. }
  191. __setup("l2cr=", ppc_setup_l2cr);
  192. #ifdef CONFIG_GENERIC_NVRAM
  193. /* Generic nvram hooks used by drivers/char/gen_nvram.c */
  194. unsigned char nvram_read_byte(int addr)
  195. {
  196. if (ppc_md.nvram_read_val)
  197. return ppc_md.nvram_read_val(addr);
  198. return 0xff;
  199. }
  200. EXPORT_SYMBOL(nvram_read_byte);
  201. void nvram_write_byte(unsigned char val, int addr)
  202. {
  203. if (ppc_md.nvram_write_val)
  204. ppc_md.nvram_write_val(addr, val);
  205. }
  206. EXPORT_SYMBOL(nvram_write_byte);
  207. void nvram_sync(void)
  208. {
  209. if (ppc_md.nvram_sync)
  210. ppc_md.nvram_sync();
  211. }
  212. EXPORT_SYMBOL(nvram_sync);
  213. #endif /* CONFIG_NVRAM */
  214. static struct cpu cpu_devices[NR_CPUS];
  215. int __init ppc_init(void)
  216. {
  217. int i;
  218. /* clear the progress line */
  219. if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff);
  220. /* register CPU devices */
  221. for (i = 0; i < NR_CPUS; i++)
  222. if (cpu_possible(i))
  223. register_cpu(&cpu_devices[i], i, NULL);
  224. /* call platform init */
  225. if (ppc_md.init != NULL) {
  226. ppc_md.init();
  227. }
  228. return 0;
  229. }
  230. arch_initcall(ppc_init);
  231. /* Warning, IO base is not yet inited */
  232. void __init setup_arch(char **cmdline_p)
  233. {
  234. extern char *klimit;
  235. extern void do_init_bootmem(void);
  236. /* so udelay does something sensible, assume <= 1000 bogomips */
  237. loops_per_jiffy = 500000000 / HZ;
  238. unflatten_device_tree();
  239. finish_device_tree();
  240. smp_setup_cpu_maps();
  241. #ifdef CONFIG_BOOTX_TEXT
  242. init_boot_display();
  243. #endif
  244. #ifdef CONFIG_PPC_PMAC
  245. /* This could be called "early setup arch", it must be done
  246. * now because xmon need it
  247. */
  248. if (_machine == _MACH_Pmac)
  249. pmac_feature_init(); /* New cool way */
  250. #endif
  251. #ifdef CONFIG_XMON
  252. xmon_map_scc();
  253. if (strstr(cmd_line, "xmon")) {
  254. xmon_init(1);
  255. debugger(NULL);
  256. }
  257. #endif /* CONFIG_XMON */
  258. if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab);
  259. #if defined(CONFIG_KGDB)
  260. if (ppc_md.kgdb_map_scc)
  261. ppc_md.kgdb_map_scc();
  262. set_debug_traps();
  263. if (strstr(cmd_line, "gdb")) {
  264. if (ppc_md.progress)
  265. ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
  266. printk("kgdb breakpoint activated\n");
  267. breakpoint();
  268. }
  269. #endif
  270. /*
  271. * Set cache line size based on type of cpu as a default.
  272. * Systems with OF can look in the properties on the cpu node(s)
  273. * for a possibly more accurate value.
  274. */
  275. if (cpu_has_feature(CPU_FTR_SPLIT_ID_CACHE)) {
  276. dcache_bsize = cur_cpu_spec->dcache_bsize;
  277. icache_bsize = cur_cpu_spec->icache_bsize;
  278. ucache_bsize = 0;
  279. } else
  280. ucache_bsize = dcache_bsize = icache_bsize
  281. = cur_cpu_spec->dcache_bsize;
  282. /* reboot on panic */
  283. panic_timeout = 180;
  284. init_mm.start_code = PAGE_OFFSET;
  285. init_mm.end_code = (unsigned long) _etext;
  286. init_mm.end_data = (unsigned long) _edata;
  287. init_mm.brk = (unsigned long) klimit;
  288. /* Save unparsed command line copy for /proc/cmdline */
  289. strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
  290. *cmdline_p = cmd_line;
  291. parse_early_param();
  292. /* set up the bootmem stuff with available memory */
  293. do_init_bootmem();
  294. if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);
  295. #ifdef CONFIG_PPC_OCP
  296. /* Initialize OCP device list */
  297. ocp_early_init();
  298. if ( ppc_md.progress ) ppc_md.progress("ocp: exit", 0x3eab);
  299. #endif
  300. #ifdef CONFIG_DUMMY_CONSOLE
  301. conswitchp = &dummy_con;
  302. #endif
  303. ppc_md.setup_arch();
  304. if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab);
  305. paging_init();
  306. /* this is for modules since _machine can be a define -- Cort */
  307. ppc_md.ppc_machine = _machine;
  308. }