setup_32.c 8.3 KB

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