setup.c 18 KB

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