setup.c 18 KB

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