setup.c 18 KB

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