setup.c 19 KB

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