setup.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. /*
  2. * Common prep/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/bootinfo.h>
  26. #include <asm/setup.h>
  27. #include <asm/amigappc.h>
  28. #include <asm/smp.h>
  29. #include <asm/elf.h>
  30. #include <asm/cputable.h>
  31. #include <asm/bootx.h>
  32. #include <asm/btext.h>
  33. #include <asm/machdep.h>
  34. #include <asm/uaccess.h>
  35. #include <asm/system.h>
  36. #include <asm/sections.h>
  37. #include <asm/nvram.h>
  38. #include <asm/xmon.h>
  39. #include <asm/ocp.h>
  40. #define USES_PPC_SYS (defined(CONFIG_85xx) || defined(CONFIG_83xx) || \
  41. defined(CONFIG_MPC10X_BRIDGE) || defined(CONFIG_8260) || \
  42. defined(CONFIG_PPC_MPC52xx))
  43. #if USES_PPC_SYS
  44. #include <asm/ppc_sys.h>
  45. #endif
  46. #if defined CONFIG_KGDB
  47. #include <asm/kgdb.h>
  48. #endif
  49. extern void platform_init(unsigned long r3, unsigned long r4,
  50. unsigned long r5, unsigned long r6, unsigned long r7);
  51. extern void identify_cpu(unsigned long offset, unsigned long cpu);
  52. extern void do_cpu_ftr_fixups(unsigned long offset);
  53. extern void reloc_got2(unsigned long offset);
  54. extern void ppc6xx_idle(void);
  55. extern void power4_idle(void);
  56. extern boot_infos_t *boot_infos;
  57. struct ide_machdep_calls ppc_ide_md;
  58. /* Used with the BI_MEMSIZE bootinfo parameter to store the memory
  59. size value reported by the boot loader. */
  60. unsigned long boot_mem_size;
  61. unsigned long ISA_DMA_THRESHOLD;
  62. unsigned int DMA_MODE_READ;
  63. unsigned int DMA_MODE_WRITE;
  64. #ifdef CONFIG_PPC_MULTIPLATFORM
  65. int _machine = 0;
  66. EXPORT_SYMBOL(_machine);
  67. extern void prep_init(unsigned long r3, unsigned long r4,
  68. unsigned long r5, unsigned long r6, unsigned long r7);
  69. extern void chrp_init(unsigned long r3, unsigned long r4,
  70. unsigned long r5, unsigned long r6, unsigned long r7);
  71. dev_t boot_dev;
  72. #endif /* CONFIG_PPC_MULTIPLATFORM */
  73. int have_of;
  74. EXPORT_SYMBOL(have_of);
  75. #ifdef __DO_IRQ_CANON
  76. int ppc_do_canonicalize_irqs;
  77. EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
  78. #endif
  79. #ifdef CONFIG_MAGIC_SYSRQ
  80. unsigned long SYSRQ_KEY = 0x54;
  81. #endif /* CONFIG_MAGIC_SYSRQ */
  82. #ifdef CONFIG_VGA_CONSOLE
  83. unsigned long vgacon_remap_base;
  84. #endif
  85. struct machdep_calls ppc_md;
  86. /*
  87. * These are used in binfmt_elf.c to put aux entries on the stack
  88. * for each elf executable being started.
  89. */
  90. int dcache_bsize;
  91. int icache_bsize;
  92. int ucache_bsize;
  93. #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_FB_VGA16) || \
  94. defined(CONFIG_FB_VGA16_MODULE) || defined(CONFIG_FB_VESA)
  95. struct screen_info screen_info = {
  96. 0, 25, /* orig-x, orig-y */
  97. 0, /* unused */
  98. 0, /* orig-video-page */
  99. 0, /* orig-video-mode */
  100. 80, /* orig-video-cols */
  101. 0,0,0, /* ega_ax, ega_bx, ega_cx */
  102. 25, /* orig-video-lines */
  103. 1, /* orig-video-isVGA */
  104. 16 /* orig-video-points */
  105. };
  106. #endif /* CONFIG_VGA_CONSOLE || CONFIG_FB_VGA16 || CONFIG_FB_VESA */
  107. void machine_restart(char *cmd)
  108. {
  109. #ifdef CONFIG_NVRAM
  110. nvram_sync();
  111. #endif
  112. ppc_md.restart(cmd);
  113. }
  114. void machine_power_off(void)
  115. {
  116. #ifdef CONFIG_NVRAM
  117. nvram_sync();
  118. #endif
  119. ppc_md.power_off();
  120. }
  121. void machine_halt(void)
  122. {
  123. #ifdef CONFIG_NVRAM
  124. nvram_sync();
  125. #endif
  126. ppc_md.halt();
  127. }
  128. void (*pm_power_off)(void) = machine_power_off;
  129. #ifdef CONFIG_TAU
  130. extern u32 cpu_temp(unsigned long cpu);
  131. extern u32 cpu_temp_both(unsigned long cpu);
  132. #endif /* CONFIG_TAU */
  133. int show_cpuinfo(struct seq_file *m, void *v)
  134. {
  135. int i = (int) v - 1;
  136. int err = 0;
  137. unsigned int pvr;
  138. unsigned short maj, min;
  139. unsigned long lpj;
  140. if (i >= NR_CPUS) {
  141. /* Show summary information */
  142. #ifdef CONFIG_SMP
  143. unsigned long bogosum = 0;
  144. for_each_online_cpu(i)
  145. bogosum += cpu_data[i].loops_per_jiffy;
  146. seq_printf(m, "total bogomips\t: %lu.%02lu\n",
  147. bogosum/(500000/HZ), bogosum/(5000/HZ) % 100);
  148. #endif /* CONFIG_SMP */
  149. if (ppc_md.show_cpuinfo != NULL)
  150. err = ppc_md.show_cpuinfo(m);
  151. return err;
  152. }
  153. #ifdef CONFIG_SMP
  154. if (!cpu_online(i))
  155. return 0;
  156. pvr = cpu_data[i].pvr;
  157. lpj = cpu_data[i].loops_per_jiffy;
  158. #else
  159. pvr = mfspr(SPRN_PVR);
  160. lpj = loops_per_jiffy;
  161. #endif
  162. seq_printf(m, "processor\t: %d\n", i);
  163. seq_printf(m, "cpu\t\t: ");
  164. if (cur_cpu_spec->pvr_mask)
  165. seq_printf(m, "%s", cur_cpu_spec->cpu_name);
  166. else
  167. seq_printf(m, "unknown (%08x)", pvr);
  168. #ifdef CONFIG_ALTIVEC
  169. if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC)
  170. seq_printf(m, ", altivec supported");
  171. #endif
  172. seq_printf(m, "\n");
  173. #ifdef CONFIG_TAU
  174. if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) {
  175. #ifdef CONFIG_TAU_AVERAGE
  176. /* more straightforward, but potentially misleading */
  177. seq_printf(m, "temperature \t: %u C (uncalibrated)\n",
  178. cpu_temp(i));
  179. #else
  180. /* show the actual temp sensor range */
  181. u32 temp;
  182. temp = cpu_temp_both(i);
  183. seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n",
  184. temp & 0xff, temp >> 16);
  185. #endif
  186. }
  187. #endif /* CONFIG_TAU */
  188. if (ppc_md.show_percpuinfo != NULL) {
  189. err = ppc_md.show_percpuinfo(m, i);
  190. if (err)
  191. return err;
  192. }
  193. /* If we are a Freescale core do a simple check so
  194. * we dont have to keep adding cases in the future */
  195. if ((PVR_VER(pvr) & 0x8000) == 0x8000) {
  196. maj = PVR_MAJ(pvr);
  197. min = PVR_MIN(pvr);
  198. } else {
  199. switch (PVR_VER(pvr)) {
  200. case 0x0020: /* 403 family */
  201. maj = PVR_MAJ(pvr) + 1;
  202. min = PVR_MIN(pvr);
  203. break;
  204. case 0x1008: /* 740P/750P ?? */
  205. maj = ((pvr >> 8) & 0xFF) - 1;
  206. min = pvr & 0xFF;
  207. break;
  208. default:
  209. maj = (pvr >> 8) & 0xFF;
  210. min = pvr & 0xFF;
  211. break;
  212. }
  213. }
  214. seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n",
  215. maj, min, PVR_VER(pvr), PVR_REV(pvr));
  216. seq_printf(m, "bogomips\t: %lu.%02lu\n",
  217. lpj / (500000/HZ), (lpj / (5000/HZ)) % 100);
  218. #if USES_PPC_SYS
  219. if (cur_ppc_sys_spec->ppc_sys_name)
  220. seq_printf(m, "chipset\t\t: %s\n",
  221. cur_ppc_sys_spec->ppc_sys_name);
  222. #endif
  223. #ifdef CONFIG_SMP
  224. seq_printf(m, "\n");
  225. #endif
  226. return 0;
  227. }
  228. static void *c_start(struct seq_file *m, loff_t *pos)
  229. {
  230. int i = *pos;
  231. return i <= NR_CPUS? (void *) (i + 1): NULL;
  232. }
  233. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  234. {
  235. ++*pos;
  236. return c_start(m, pos);
  237. }
  238. static void c_stop(struct seq_file *m, void *v)
  239. {
  240. }
  241. struct seq_operations cpuinfo_op = {
  242. .start =c_start,
  243. .next = c_next,
  244. .stop = c_stop,
  245. .show = show_cpuinfo,
  246. };
  247. /*
  248. * We're called here very early in the boot. We determine the machine
  249. * type and call the appropriate low-level setup functions.
  250. * -- Cort <cort@fsmlabs.com>
  251. *
  252. * Note that the kernel may be running at an address which is different
  253. * from the address that it was linked at, so we must use RELOC/PTRRELOC
  254. * to access static data (including strings). -- paulus
  255. */
  256. __init
  257. unsigned long
  258. early_init(int r3, int r4, int r5)
  259. {
  260. unsigned long phys;
  261. unsigned long offset = reloc_offset();
  262. /* Default */
  263. phys = offset + KERNELBASE;
  264. /* First zero the BSS -- use memset, some arches don't have
  265. * caches on yet */
  266. memset_io(PTRRELOC(&__bss_start), 0, _end - __bss_start);
  267. /*
  268. * Identify the CPU type and fix up code sections
  269. * that depend on which cpu we have.
  270. */
  271. identify_cpu(offset, 0);
  272. do_cpu_ftr_fixups(offset);
  273. #if defined(CONFIG_PPC_OF)
  274. reloc_got2(offset);
  275. /*
  276. * don't do anything on prep
  277. * for now, don't use bootinfo because it breaks yaboot 0.5
  278. * and assume that if we didn't find a magic number, we have OF
  279. */
  280. if (*(unsigned long *)(0) != 0xdeadc0de)
  281. phys = prom_init(r3, r4, (prom_entry)r5);
  282. reloc_got2(-offset);
  283. #endif
  284. return phys;
  285. }
  286. #ifdef CONFIG_PPC_OF
  287. /*
  288. * Assume here that all clock rates are the same in a
  289. * smp system. -- Cort
  290. */
  291. int
  292. of_show_percpuinfo(struct seq_file *m, int i)
  293. {
  294. struct device_node *cpu_node;
  295. u32 *fp;
  296. int s;
  297. cpu_node = find_type_devices("cpu");
  298. if (!cpu_node)
  299. return 0;
  300. for (s = 0; s < i && cpu_node->next; s++)
  301. cpu_node = cpu_node->next;
  302. fp = (u32 *)get_property(cpu_node, "clock-frequency", NULL);
  303. if (fp)
  304. seq_printf(m, "clock\t\t: %dMHz\n", *fp / 1000000);
  305. return 0;
  306. }
  307. void __init
  308. intuit_machine_type(void)
  309. {
  310. char *model;
  311. struct device_node *root;
  312. /* ask the OF info if we're a chrp or pmac */
  313. root = find_path_device("/");
  314. if (root != 0) {
  315. /* assume pmac unless proven to be chrp -- Cort */
  316. _machine = _MACH_Pmac;
  317. model = get_property(root, "device_type", NULL);
  318. if (model && !strncmp("chrp", model, 4))
  319. _machine = _MACH_chrp;
  320. else {
  321. model = get_property(root, "model", NULL);
  322. if (model && !strncmp(model, "IBM", 3))
  323. _machine = _MACH_chrp;
  324. }
  325. }
  326. }
  327. #endif
  328. #ifdef CONFIG_PPC_MULTIPLATFORM
  329. /*
  330. * The PPC_MULTIPLATFORM version of platform_init...
  331. */
  332. void __init
  333. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  334. unsigned long r6, unsigned long r7)
  335. {
  336. #ifdef CONFIG_BOOTX_TEXT
  337. if (boot_text_mapped) {
  338. btext_clearscreen();
  339. btext_welcome();
  340. }
  341. #endif
  342. parse_bootinfo(find_bootinfo());
  343. /* if we didn't get any bootinfo telling us what we are... */
  344. if (_machine == 0) {
  345. /* prep boot loader tells us if we're prep or not */
  346. if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) )
  347. _machine = _MACH_prep;
  348. }
  349. #ifdef CONFIG_PPC_PREP
  350. /* not much more to do here, if prep */
  351. if (_machine == _MACH_prep) {
  352. prep_init(r3, r4, r5, r6, r7);
  353. return;
  354. }
  355. #endif
  356. #ifdef CONFIG_PPC_OF
  357. have_of = 1;
  358. /* prom_init has already been called from __start */
  359. if (boot_infos)
  360. relocate_nodes();
  361. /* If we aren't PReP, we can find out if we're Pmac
  362. * or CHRP with this. */
  363. if (_machine == 0)
  364. intuit_machine_type();
  365. /* finish_device_tree may need _machine defined. */
  366. finish_device_tree();
  367. /*
  368. * If we were booted via quik, r3 points to the physical
  369. * address of the command-line parameters.
  370. * If we were booted from an xcoff image (i.e. netbooted or
  371. * booted from floppy), we get the command line from the
  372. * bootargs property of the /chosen node.
  373. * If an initial ramdisk is present, r3 and r4
  374. * are used for initrd_start and initrd_size,
  375. * otherwise they contain 0xdeadbeef.
  376. */
  377. if (r3 >= 0x4000 && r3 < 0x800000 && r4 == 0) {
  378. strlcpy(cmd_line, (char *)r3 + KERNELBASE,
  379. sizeof(cmd_line));
  380. } else if (boot_infos != 0) {
  381. /* booted by BootX - check for ramdisk */
  382. if (boot_infos->kernelParamsOffset != 0)
  383. strlcpy(cmd_line, (char *) boot_infos
  384. + boot_infos->kernelParamsOffset,
  385. sizeof(cmd_line));
  386. #ifdef CONFIG_BLK_DEV_INITRD
  387. if (boot_infos->ramDisk) {
  388. initrd_start = (unsigned long) boot_infos
  389. + boot_infos->ramDisk;
  390. initrd_end = initrd_start + boot_infos->ramDiskSize;
  391. initrd_below_start_ok = 1;
  392. }
  393. #endif
  394. } else {
  395. struct device_node *chosen;
  396. char *p;
  397. #ifdef CONFIG_BLK_DEV_INITRD
  398. if (r3 && r4 && r4 != 0xdeadbeef) {
  399. if (r3 < KERNELBASE)
  400. r3 += KERNELBASE;
  401. initrd_start = r3;
  402. initrd_end = r3 + r4;
  403. ROOT_DEV = Root_RAM0;
  404. initrd_below_start_ok = 1;
  405. }
  406. #endif
  407. chosen = find_devices("chosen");
  408. if (chosen != NULL) {
  409. p = get_property(chosen, "bootargs", NULL);
  410. if (p && *p) {
  411. strlcpy(cmd_line, p, sizeof(cmd_line));
  412. }
  413. }
  414. }
  415. #ifdef CONFIG_ADB
  416. if (strstr(cmd_line, "adb_sync")) {
  417. extern int __adb_probe_sync;
  418. __adb_probe_sync = 1;
  419. }
  420. #endif /* CONFIG_ADB */
  421. switch (_machine) {
  422. #ifdef CONFIG_PPC_CHRP
  423. case _MACH_chrp:
  424. chrp_init(r3, r4, r5, r6, r7);
  425. break;
  426. #endif
  427. }
  428. #endif /* CONFIG_PPC_OF */
  429. }
  430. #endif /* CONFIG_PPC_MULTIPLATFORM */
  431. #ifdef CONFIG_PPC_OF
  432. #ifdef CONFIG_SERIAL_CORE_CONSOLE
  433. extern char *of_stdout_device;
  434. static int __init set_preferred_console(void)
  435. {
  436. struct device_node *prom_stdout;
  437. char *name;
  438. int offset = 0;
  439. if (of_stdout_device == NULL)
  440. return -ENODEV;
  441. /* The user has requested a console so this is already set up. */
  442. if (strstr(saved_command_line, "console="))
  443. return -EBUSY;
  444. prom_stdout = find_path_device(of_stdout_device);
  445. if (!prom_stdout)
  446. return -ENODEV;
  447. name = (char *)get_property(prom_stdout, "name", NULL);
  448. if (!name)
  449. return -ENODEV;
  450. if (strcmp(name, "serial") == 0) {
  451. int i;
  452. u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i);
  453. if (i > 8) {
  454. switch (reg[1]) {
  455. case 0x3f8:
  456. offset = 0;
  457. break;
  458. case 0x2f8:
  459. offset = 1;
  460. break;
  461. case 0x898:
  462. offset = 2;
  463. break;
  464. case 0x890:
  465. offset = 3;
  466. break;
  467. default:
  468. /* We dont recognise the serial port */
  469. return -ENODEV;
  470. }
  471. }
  472. } else if (strcmp(name, "ch-a") == 0)
  473. offset = 0;
  474. else if (strcmp(name, "ch-b") == 0)
  475. offset = 1;
  476. else
  477. return -ENODEV;
  478. return add_preferred_console("ttyS", offset, NULL);
  479. }
  480. console_initcall(set_preferred_console);
  481. #endif /* CONFIG_SERIAL_CORE_CONSOLE */
  482. #endif /* CONFIG_PPC_OF */
  483. struct bi_record *find_bootinfo(void)
  484. {
  485. struct bi_record *rec;
  486. rec = (struct bi_record *)_ALIGN((ulong)__bss_start+(1<<20)-1,(1<<20));
  487. if ( rec->tag != BI_FIRST ) {
  488. /*
  489. * This 0x10000 offset is a terrible hack but it will go away when
  490. * we have the bootloader handle all the relocation and
  491. * prom calls -- Cort
  492. */
  493. rec = (struct bi_record *)_ALIGN((ulong)__bss_start+0x10000+(1<<20)-1,(1<<20));
  494. if ( rec->tag != BI_FIRST )
  495. return NULL;
  496. }
  497. return rec;
  498. }
  499. void parse_bootinfo(struct bi_record *rec)
  500. {
  501. if (rec == NULL || rec->tag != BI_FIRST)
  502. return;
  503. while (rec->tag != BI_LAST) {
  504. ulong *data = rec->data;
  505. switch (rec->tag) {
  506. case BI_CMD_LINE:
  507. strlcpy(cmd_line, (void *)data, sizeof(cmd_line));
  508. break;
  509. #ifdef CONFIG_BLK_DEV_INITRD
  510. case BI_INITRD:
  511. initrd_start = data[0] + KERNELBASE;
  512. initrd_end = data[0] + data[1] + KERNELBASE;
  513. break;
  514. #endif /* CONFIG_BLK_DEV_INITRD */
  515. #ifdef CONFIG_PPC_MULTIPLATFORM
  516. case BI_MACHTYPE:
  517. /* Machine types changed with the merge. Since the
  518. * bootinfo are now deprecated, we can just hard code
  519. * the appropriate conversion here for when we are
  520. * called with yaboot which passes us a machine type
  521. * this way.
  522. */
  523. switch(data[0]) {
  524. case 1: _machine = _MACH_prep; break;
  525. case 2: _machine = _MACH_Pmac; break;
  526. case 4: _machine = _MACH_chrp; break;
  527. default:
  528. _machine = data[0];
  529. }
  530. break;
  531. #endif
  532. case BI_MEMSIZE:
  533. boot_mem_size = data[0];
  534. break;
  535. }
  536. rec = (struct bi_record *)((ulong)rec + rec->size);
  537. }
  538. }
  539. /*
  540. * Find out what kind of machine we're on and save any data we need
  541. * from the early boot process (devtree is copied on pmac by prom_init()).
  542. * This is called very early on the boot process, after a minimal
  543. * MMU environment has been set up but before MMU_init is called.
  544. */
  545. void __init
  546. machine_init(unsigned long r3, unsigned long r4, unsigned long r5,
  547. unsigned long r6, unsigned long r7)
  548. {
  549. #ifdef CONFIG_CMDLINE
  550. strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
  551. #endif /* CONFIG_CMDLINE */
  552. #ifdef CONFIG_6xx
  553. ppc_md.power_save = ppc6xx_idle;
  554. #endif
  555. #ifdef CONFIG_POWER4
  556. ppc_md.power_save = power4_idle;
  557. #endif
  558. platform_init(r3, r4, r5, r6, r7);
  559. if (ppc_md.progress)
  560. ppc_md.progress("id mach(): done", 0x200);
  561. }
  562. #ifdef CONFIG_BOOKE_WDT
  563. /* Checks wdt=x and wdt_period=xx command-line option */
  564. int __init early_parse_wdt(char *p)
  565. {
  566. if (p && strncmp(p, "0", 1) != 0)
  567. booke_wdt_enabled = 1;
  568. return 0;
  569. }
  570. early_param("wdt", early_parse_wdt);
  571. int __init early_parse_wdt_period (char *p)
  572. {
  573. if (p)
  574. booke_wdt_period = simple_strtoul(p, NULL, 0);
  575. return 0;
  576. }
  577. early_param("wdt_period", early_parse_wdt_period);
  578. #endif /* CONFIG_BOOKE_WDT */
  579. /* Checks "l2cr=xxxx" command-line option */
  580. int __init ppc_setup_l2cr(char *str)
  581. {
  582. if (cpu_has_feature(CPU_FTR_L2CR)) {
  583. unsigned long val = simple_strtoul(str, NULL, 0);
  584. printk(KERN_INFO "l2cr set to %lx\n", val);
  585. _set_L2CR(0); /* force invalidate by disable cache */
  586. _set_L2CR(val); /* and enable it */
  587. }
  588. return 1;
  589. }
  590. __setup("l2cr=", ppc_setup_l2cr);
  591. #ifdef CONFIG_GENERIC_NVRAM
  592. /* Generic nvram hooks used by drivers/char/gen_nvram.c */
  593. unsigned char nvram_read_byte(int addr)
  594. {
  595. if (ppc_md.nvram_read_val)
  596. return ppc_md.nvram_read_val(addr);
  597. return 0xff;
  598. }
  599. EXPORT_SYMBOL(nvram_read_byte);
  600. void nvram_write_byte(unsigned char val, int addr)
  601. {
  602. if (ppc_md.nvram_write_val)
  603. ppc_md.nvram_write_val(addr, val);
  604. }
  605. EXPORT_SYMBOL(nvram_write_byte);
  606. void nvram_sync(void)
  607. {
  608. if (ppc_md.nvram_sync)
  609. ppc_md.nvram_sync();
  610. }
  611. EXPORT_SYMBOL(nvram_sync);
  612. #endif /* CONFIG_NVRAM */
  613. static struct cpu cpu_devices[NR_CPUS];
  614. int __init ppc_init(void)
  615. {
  616. int i;
  617. /* clear the progress line */
  618. if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff);
  619. /* register CPU devices */
  620. for_each_cpu(i)
  621. register_cpu(&cpu_devices[i], i, NULL);
  622. /* call platform init */
  623. if (ppc_md.init != NULL) {
  624. ppc_md.init();
  625. }
  626. return 0;
  627. }
  628. arch_initcall(ppc_init);
  629. /* Warning, IO base is not yet inited */
  630. void __init setup_arch(char **cmdline_p)
  631. {
  632. extern char *klimit;
  633. extern void do_init_bootmem(void);
  634. /* so udelay does something sensible, assume <= 1000 bogomips */
  635. loops_per_jiffy = 500000000 / HZ;
  636. if (ppc_md.init_early)
  637. ppc_md.init_early();
  638. #ifdef CONFIG_XMON
  639. xmon_init(1);
  640. if (strstr(cmd_line, "xmon"))
  641. xmon(NULL);
  642. #endif /* CONFIG_XMON */
  643. if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab);
  644. #if defined(CONFIG_KGDB)
  645. if (ppc_md.kgdb_map_scc)
  646. ppc_md.kgdb_map_scc();
  647. set_debug_traps();
  648. if (strstr(cmd_line, "gdb")) {
  649. if (ppc_md.progress)
  650. ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
  651. printk("kgdb breakpoint activated\n");
  652. breakpoint();
  653. }
  654. #endif
  655. /*
  656. * Set cache line size based on type of cpu as a default.
  657. * Systems with OF can look in the properties on the cpu node(s)
  658. * for a possibly more accurate value.
  659. */
  660. if (cpu_has_feature(CPU_FTR_SPLIT_ID_CACHE)) {
  661. dcache_bsize = cur_cpu_spec->dcache_bsize;
  662. icache_bsize = cur_cpu_spec->icache_bsize;
  663. ucache_bsize = 0;
  664. } else
  665. ucache_bsize = dcache_bsize = icache_bsize
  666. = cur_cpu_spec->dcache_bsize;
  667. /* reboot on panic */
  668. panic_timeout = 180;
  669. init_mm.start_code = PAGE_OFFSET;
  670. init_mm.end_code = (unsigned long) _etext;
  671. init_mm.end_data = (unsigned long) _edata;
  672. init_mm.brk = (unsigned long) klimit;
  673. /* Save unparsed command line copy for /proc/cmdline */
  674. strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
  675. *cmdline_p = cmd_line;
  676. parse_early_param();
  677. /* set up the bootmem stuff with available memory */
  678. do_init_bootmem();
  679. if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);
  680. #ifdef CONFIG_PPC_OCP
  681. /* Initialize OCP device list */
  682. ocp_early_init();
  683. if ( ppc_md.progress ) ppc_md.progress("ocp: exit", 0x3eab);
  684. #endif
  685. #ifdef CONFIG_DUMMY_CONSOLE
  686. conswitchp = &dummy_con;
  687. #endif
  688. ppc_md.setup_arch();
  689. if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab);
  690. paging_init();
  691. /* this is for modules since _machine can be a define -- Cort */
  692. ppc_md.ppc_machine = _machine;
  693. }