setup.c 19 KB

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