setup.c 18 KB

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