setup.c 19 KB

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