setup_32.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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/ide.h>
  13. #include <linux/tty.h>
  14. #include <linux/bootmem.h>
  15. #include <linux/seq_file.h>
  16. #include <linux/root_dev.h>
  17. #include <linux/cpu.h>
  18. #include <linux/console.h>
  19. #include <asm/residual.h>
  20. #include <asm/io.h>
  21. #include <asm/prom.h>
  22. #include <asm/processor.h>
  23. #include <asm/pgtable.h>
  24. #include <asm/setup.h>
  25. #include <asm/amigappc.h>
  26. #include <asm/smp.h>
  27. #include <asm/elf.h>
  28. #include <asm/cputable.h>
  29. #include <asm/bootx.h>
  30. #include <asm/btext.h>
  31. #include <asm/machdep.h>
  32. #include <asm/uaccess.h>
  33. #include <asm/system.h>
  34. #include <asm/pmac_feature.h>
  35. #include <asm/sections.h>
  36. #include <asm/nvram.h>
  37. #include <asm/xmon.h>
  38. #include <asm/time.h>
  39. #include <asm/serial.h>
  40. #include <asm/udbg.h>
  41. #include "setup.h"
  42. #define DBG(fmt...)
  43. #if defined CONFIG_KGDB
  44. #include <asm/kgdb.h>
  45. #endif
  46. extern void bootx_init(unsigned long r4, unsigned long phys);
  47. struct ide_machdep_calls ppc_ide_md;
  48. int boot_cpuid;
  49. EXPORT_SYMBOL_GPL(boot_cpuid);
  50. int boot_cpuid_phys;
  51. unsigned long ISA_DMA_THRESHOLD;
  52. unsigned int DMA_MODE_READ;
  53. unsigned int DMA_MODE_WRITE;
  54. int have_of = 1;
  55. #ifdef CONFIG_PPC_MULTIPLATFORM
  56. dev_t boot_dev;
  57. #endif /* CONFIG_PPC_MULTIPLATFORM */
  58. #ifdef CONFIG_MAGIC_SYSRQ
  59. unsigned long SYSRQ_KEY = 0x54;
  60. #endif /* CONFIG_MAGIC_SYSRQ */
  61. #ifdef CONFIG_VGA_CONSOLE
  62. unsigned long vgacon_remap_base;
  63. #endif
  64. /*
  65. * These are used in binfmt_elf.c to put aux entries on the stack
  66. * for each elf executable being started.
  67. */
  68. int dcache_bsize;
  69. int icache_bsize;
  70. int ucache_bsize;
  71. /*
  72. * We're called here very early in the boot. We determine the machine
  73. * type and call the appropriate low-level setup functions.
  74. * -- Cort <cort@fsmlabs.com>
  75. *
  76. * Note that the kernel may be running at an address which is different
  77. * from the address that it was linked at, so we must use RELOC/PTRRELOC
  78. * to access static data (including strings). -- paulus
  79. */
  80. unsigned long __init early_init(unsigned long dt_ptr)
  81. {
  82. unsigned long offset = reloc_offset();
  83. /* First zero the BSS -- use memset_io, some platforms don't have
  84. * caches on yet */
  85. memset_io((void __iomem *)PTRRELOC(&__bss_start), 0, _end - __bss_start);
  86. /*
  87. * Identify the CPU type and fix up code sections
  88. * that depend on which cpu we have.
  89. */
  90. identify_cpu(offset, 0);
  91. do_cpu_ftr_fixups(offset);
  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. void __init machine_init(unsigned long dt_ptr, unsigned long phys)
  101. {
  102. /* If btext is enabled, we might have a BAT setup for early display,
  103. * thus we do enable some very basic udbg output
  104. */
  105. #ifdef CONFIG_BOOTX_TEXT
  106. udbg_putc = btext_drawchar;
  107. #endif
  108. /* Do some early initialization based on the flat device tree */
  109. early_init_devtree(__va(dt_ptr));
  110. probe_machine();
  111. #ifdef CONFIG_6xx
  112. if (cpu_has_feature(CPU_FTR_CAN_DOZE) ||
  113. cpu_has_feature(CPU_FTR_CAN_NAP))
  114. ppc_md.power_save = ppc6xx_idle;
  115. #endif
  116. if (ppc_md.progress)
  117. ppc_md.progress("id mach(): done", 0x200);
  118. }
  119. #ifdef CONFIG_BOOKE_WDT
  120. /* Checks wdt=x and wdt_period=xx command-line option */
  121. int __init early_parse_wdt(char *p)
  122. {
  123. if (p && strncmp(p, "0", 1) != 0)
  124. booke_wdt_enabled = 1;
  125. return 0;
  126. }
  127. early_param("wdt", early_parse_wdt);
  128. int __init early_parse_wdt_period (char *p)
  129. {
  130. if (p)
  131. booke_wdt_period = simple_strtoul(p, NULL, 0);
  132. return 0;
  133. }
  134. early_param("wdt_period", early_parse_wdt_period);
  135. #endif /* CONFIG_BOOKE_WDT */
  136. /* Checks "l2cr=xxxx" command-line option */
  137. int __init ppc_setup_l2cr(char *str)
  138. {
  139. if (cpu_has_feature(CPU_FTR_L2CR)) {
  140. unsigned long val = simple_strtoul(str, NULL, 0);
  141. printk(KERN_INFO "l2cr set to %lx\n", val);
  142. _set_L2CR(0); /* force invalidate by disable cache */
  143. _set_L2CR(val); /* and enable it */
  144. }
  145. return 1;
  146. }
  147. __setup("l2cr=", ppc_setup_l2cr);
  148. #ifdef CONFIG_GENERIC_NVRAM
  149. /* Generic nvram hooks used by drivers/char/gen_nvram.c */
  150. unsigned char nvram_read_byte(int addr)
  151. {
  152. if (ppc_md.nvram_read_val)
  153. return ppc_md.nvram_read_val(addr);
  154. return 0xff;
  155. }
  156. EXPORT_SYMBOL(nvram_read_byte);
  157. void nvram_write_byte(unsigned char val, int addr)
  158. {
  159. if (ppc_md.nvram_write_val)
  160. ppc_md.nvram_write_val(addr, val);
  161. }
  162. EXPORT_SYMBOL(nvram_write_byte);
  163. void nvram_sync(void)
  164. {
  165. if (ppc_md.nvram_sync)
  166. ppc_md.nvram_sync();
  167. }
  168. EXPORT_SYMBOL(nvram_sync);
  169. #endif /* CONFIG_NVRAM */
  170. static struct cpu cpu_devices[NR_CPUS];
  171. int __init ppc_init(void)
  172. {
  173. int i;
  174. /* clear the progress line */
  175. if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff);
  176. /* register CPU devices */
  177. for_each_possible_cpu(i)
  178. register_cpu(&cpu_devices[i], i);
  179. /* call platform init */
  180. if (ppc_md.init != NULL) {
  181. ppc_md.init();
  182. }
  183. return 0;
  184. }
  185. arch_initcall(ppc_init);
  186. /* Warning, IO base is not yet inited */
  187. void __init setup_arch(char **cmdline_p)
  188. {
  189. *cmdline_p = cmd_line;
  190. /* so udelay does something sensible, assume <= 1000 bogomips */
  191. loops_per_jiffy = 500000000 / HZ;
  192. unflatten_device_tree();
  193. check_for_initrd();
  194. if (ppc_md.init_early)
  195. ppc_md.init_early();
  196. find_legacy_serial_ports();
  197. smp_setup_cpu_maps();
  198. #ifdef CONFIG_XMON_DEFAULT
  199. xmon_init(1);
  200. #endif
  201. /* Register early console */
  202. register_early_udbg_console();
  203. #if defined(CONFIG_KGDB)
  204. if (ppc_md.kgdb_map_scc)
  205. ppc_md.kgdb_map_scc();
  206. set_debug_traps();
  207. if (strstr(cmd_line, "gdb")) {
  208. if (ppc_md.progress)
  209. ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
  210. printk("kgdb breakpoint activated\n");
  211. breakpoint();
  212. }
  213. #endif
  214. /*
  215. * Set cache line size based on type of cpu as a default.
  216. * Systems with OF can look in the properties on the cpu node(s)
  217. * for a possibly more accurate value.
  218. */
  219. if (cpu_has_feature(CPU_FTR_SPLIT_ID_CACHE)) {
  220. dcache_bsize = cur_cpu_spec->dcache_bsize;
  221. icache_bsize = cur_cpu_spec->icache_bsize;
  222. ucache_bsize = 0;
  223. } else
  224. ucache_bsize = dcache_bsize = icache_bsize
  225. = cur_cpu_spec->dcache_bsize;
  226. /* reboot on panic */
  227. panic_timeout = 180;
  228. if (ppc_md.panic)
  229. setup_panic();
  230. init_mm.start_code = PAGE_OFFSET;
  231. init_mm.end_code = (unsigned long) _etext;
  232. init_mm.end_data = (unsigned long) _edata;
  233. init_mm.brk = klimit;
  234. if (do_early_xmon)
  235. debugger(NULL);
  236. /* set up the bootmem stuff with available memory */
  237. do_init_bootmem();
  238. if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);
  239. #ifdef CONFIG_DUMMY_CONSOLE
  240. conswitchp = &dummy_con;
  241. #endif
  242. ppc_md.setup_arch();
  243. if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab);
  244. paging_init();
  245. }