setup_32.c 8.0 KB

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