setup_32.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. /*
  2. * Common prep/pmac/chrp boot and setup code.
  3. */
  4. #include <linux/module.h>
  5. #include <linux/string.h>
  6. #include <linux/sched.h>
  7. #include <linux/init.h>
  8. #include <linux/kernel.h>
  9. #include <linux/reboot.h>
  10. #include <linux/delay.h>
  11. #include <linux/initrd.h>
  12. #include <linux/tty.h>
  13. #include <linux/bootmem.h>
  14. #include <linux/seq_file.h>
  15. #include <linux/root_dev.h>
  16. #include <linux/cpu.h>
  17. #include <linux/console.h>
  18. #include <linux/lmb.h>
  19. #include <asm/io.h>
  20. #include <asm/prom.h>
  21. #include <asm/processor.h>
  22. #include <asm/pgtable.h>
  23. #include <asm/setup.h>
  24. #include <asm/smp.h>
  25. #include <asm/elf.h>
  26. #include <asm/cputable.h>
  27. #include <asm/bootx.h>
  28. #include <asm/btext.h>
  29. #include <asm/machdep.h>
  30. #include <asm/uaccess.h>
  31. #include <asm/system.h>
  32. #include <asm/pmac_feature.h>
  33. #include <asm/sections.h>
  34. #include <asm/nvram.h>
  35. #include <asm/xmon.h>
  36. #include <asm/time.h>
  37. #include <asm/serial.h>
  38. #include <asm/udbg.h>
  39. #include "setup.h"
  40. #define DBG(fmt...)
  41. #if defined CONFIG_KGDB
  42. #include <asm/kgdb.h>
  43. #endif
  44. #ifdef CONFIG_FTRACE
  45. extern void _mcount(void);
  46. EXPORT_SYMBOL(_mcount);
  47. #endif
  48. extern void bootx_init(unsigned long r4, unsigned long phys);
  49. int boot_cpuid;
  50. EXPORT_SYMBOL_GPL(boot_cpuid);
  51. int boot_cpuid_phys;
  52. unsigned long ISA_DMA_THRESHOLD;
  53. unsigned int DMA_MODE_READ;
  54. unsigned int DMA_MODE_WRITE;
  55. int have_of = 1;
  56. #ifdef CONFIG_VGA_CONSOLE
  57. unsigned long vgacon_remap_base;
  58. EXPORT_SYMBOL(vgacon_remap_base);
  59. #endif
  60. /*
  61. * These are used in binfmt_elf.c to put aux entries on the stack
  62. * for each elf executable being started.
  63. */
  64. int dcache_bsize;
  65. int icache_bsize;
  66. int ucache_bsize;
  67. /*
  68. * We're called here very early in the boot. We determine the machine
  69. * type and call the appropriate low-level setup functions.
  70. * -- Cort <cort@fsmlabs.com>
  71. *
  72. * Note that the kernel may be running at an address which is different
  73. * from the address that it was linked at, so we must use RELOC/PTRRELOC
  74. * to access static data (including strings). -- paulus
  75. */
  76. notrace unsigned long __init early_init(unsigned long dt_ptr)
  77. {
  78. unsigned long offset = reloc_offset();
  79. struct cpu_spec *spec;
  80. /* First zero the BSS -- use memset_io, some platforms don't have
  81. * caches on yet */
  82. memset_io((void __iomem *)PTRRELOC(&__bss_start), 0,
  83. __bss_stop - __bss_start);
  84. /*
  85. * Identify the CPU type and fix up code sections
  86. * that depend on which cpu we have.
  87. */
  88. spec = identify_cpu(offset, mfspr(SPRN_PVR));
  89. do_feature_fixups(spec->cpu_features,
  90. PTRRELOC(&__start___ftr_fixup),
  91. PTRRELOC(&__stop___ftr_fixup));
  92. return KERNELBASE + offset;
  93. }
  94. /*
  95. * Find out what kind of machine we're on and save any data we need
  96. * from the early boot process (devtree is copied on pmac by prom_init()).
  97. * This is called very early on the boot process, after a minimal
  98. * MMU environment has been set up but before MMU_init is called.
  99. */
  100. notrace void __init machine_init(unsigned long dt_ptr, unsigned long phys)
  101. {
  102. /* Enable early debugging if any specified (see udbg.h) */
  103. udbg_early_init();
  104. /* Do some early initialization based on the flat device tree */
  105. early_init_devtree(__va(dt_ptr));
  106. probe_machine();
  107. #ifdef CONFIG_6xx
  108. if (cpu_has_feature(CPU_FTR_CAN_DOZE) ||
  109. cpu_has_feature(CPU_FTR_CAN_NAP))
  110. ppc_md.power_save = ppc6xx_idle;
  111. #endif
  112. if (ppc_md.progress)
  113. ppc_md.progress("id mach(): done", 0x200);
  114. }
  115. #ifdef CONFIG_BOOKE_WDT
  116. /* Checks wdt=x and wdt_period=xx command-line option */
  117. notrace int __init early_parse_wdt(char *p)
  118. {
  119. if (p && strncmp(p, "0", 1) != 0)
  120. booke_wdt_enabled = 1;
  121. return 0;
  122. }
  123. early_param("wdt", early_parse_wdt);
  124. int __init early_parse_wdt_period (char *p)
  125. {
  126. if (p)
  127. booke_wdt_period = simple_strtoul(p, NULL, 0);
  128. return 0;
  129. }
  130. early_param("wdt_period", early_parse_wdt_period);
  131. #endif /* CONFIG_BOOKE_WDT */
  132. /* Checks "l2cr=xxxx" command-line option */
  133. int __init ppc_setup_l2cr(char *str)
  134. {
  135. if (cpu_has_feature(CPU_FTR_L2CR)) {
  136. unsigned long val = simple_strtoul(str, NULL, 0);
  137. printk(KERN_INFO "l2cr set to %lx\n", val);
  138. _set_L2CR(0); /* force invalidate by disable cache */
  139. _set_L2CR(val); /* and enable it */
  140. }
  141. return 1;
  142. }
  143. __setup("l2cr=", ppc_setup_l2cr);
  144. /* Checks "l3cr=xxxx" command-line option */
  145. int __init ppc_setup_l3cr(char *str)
  146. {
  147. if (cpu_has_feature(CPU_FTR_L3CR)) {
  148. unsigned long val = simple_strtoul(str, NULL, 0);
  149. printk(KERN_INFO "l3cr set to %lx\n", val);
  150. _set_L3CR(val); /* and enable it */
  151. }
  152. return 1;
  153. }
  154. __setup("l3cr=", ppc_setup_l3cr);
  155. #ifdef CONFIG_GENERIC_NVRAM
  156. /* Generic nvram hooks used by drivers/char/gen_nvram.c */
  157. unsigned char nvram_read_byte(int addr)
  158. {
  159. if (ppc_md.nvram_read_val)
  160. return ppc_md.nvram_read_val(addr);
  161. return 0xff;
  162. }
  163. EXPORT_SYMBOL(nvram_read_byte);
  164. void nvram_write_byte(unsigned char val, int addr)
  165. {
  166. if (ppc_md.nvram_write_val)
  167. ppc_md.nvram_write_val(addr, val);
  168. }
  169. EXPORT_SYMBOL(nvram_write_byte);
  170. void nvram_sync(void)
  171. {
  172. if (ppc_md.nvram_sync)
  173. ppc_md.nvram_sync();
  174. }
  175. EXPORT_SYMBOL(nvram_sync);
  176. #endif /* CONFIG_NVRAM */
  177. static DEFINE_PER_CPU(struct cpu, cpu_devices);
  178. int __init ppc_init(void)
  179. {
  180. int cpu;
  181. /* clear the progress line */
  182. if (ppc_md.progress)
  183. ppc_md.progress(" ", 0xffff);
  184. /* register CPU devices */
  185. for_each_possible_cpu(cpu) {
  186. struct cpu *c = &per_cpu(cpu_devices, cpu);
  187. c->hotpluggable = 1;
  188. register_cpu(c, cpu);
  189. }
  190. /* call platform init */
  191. if (ppc_md.init != NULL) {
  192. ppc_md.init();
  193. }
  194. return 0;
  195. }
  196. arch_initcall(ppc_init);
  197. #ifdef CONFIG_IRQSTACKS
  198. static void __init irqstack_early_init(void)
  199. {
  200. unsigned int i;
  201. /* interrupt stacks must be in lowmem, we get that for free on ppc32
  202. * as the lmb is limited to lowmem by LMB_REAL_LIMIT */
  203. for_each_possible_cpu(i) {
  204. softirq_ctx[i] = (struct thread_info *)
  205. __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE));
  206. hardirq_ctx[i] = (struct thread_info *)
  207. __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE));
  208. }
  209. }
  210. #else
  211. #define irqstack_early_init()
  212. #endif
  213. /* Warning, IO base is not yet inited */
  214. void __init setup_arch(char **cmdline_p)
  215. {
  216. *cmdline_p = cmd_line;
  217. /* so udelay does something sensible, assume <= 1000 bogomips */
  218. loops_per_jiffy = 500000000 / HZ;
  219. unflatten_device_tree();
  220. check_for_initrd();
  221. if (ppc_md.init_early)
  222. ppc_md.init_early();
  223. find_legacy_serial_ports();
  224. smp_setup_cpu_maps();
  225. /* Register early console */
  226. register_early_udbg_console();
  227. xmon_setup();
  228. #if defined(CONFIG_KGDB)
  229. if (ppc_md.kgdb_map_scc)
  230. ppc_md.kgdb_map_scc();
  231. set_debug_traps();
  232. if (strstr(cmd_line, "gdb")) {
  233. if (ppc_md.progress)
  234. ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
  235. printk("kgdb breakpoint activated\n");
  236. breakpoint();
  237. }
  238. #endif
  239. /*
  240. * Set cache line size based on type of cpu as a default.
  241. * Systems with OF can look in the properties on the cpu node(s)
  242. * for a possibly more accurate value.
  243. */
  244. dcache_bsize = cur_cpu_spec->dcache_bsize;
  245. icache_bsize = cur_cpu_spec->icache_bsize;
  246. ucache_bsize = 0;
  247. if (cpu_has_feature(CPU_FTR_UNIFIED_ID_CACHE))
  248. ucache_bsize = icache_bsize = dcache_bsize;
  249. /* reboot on panic */
  250. panic_timeout = 180;
  251. if (ppc_md.panic)
  252. setup_panic();
  253. init_mm.start_code = (unsigned long)_stext;
  254. init_mm.end_code = (unsigned long) _etext;
  255. init_mm.end_data = (unsigned long) _edata;
  256. init_mm.brk = klimit;
  257. irqstack_early_init();
  258. /* set up the bootmem stuff with available memory */
  259. do_init_bootmem();
  260. if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);
  261. #ifdef CONFIG_DUMMY_CONSOLE
  262. conswitchp = &dummy_con;
  263. #endif
  264. if (ppc_md.setup_arch)
  265. ppc_md.setup_arch();
  266. if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab);
  267. paging_init();
  268. }