setup.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. /*
  2. * Powermac setup and early boot code plus other random bits.
  3. *
  4. * PowerPC version
  5. * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  6. *
  7. * Adapted for Power Macintosh by Paul Mackerras
  8. * Copyright (C) 1996 Paul Mackerras (paulus@samba.org)
  9. *
  10. * Derived from "arch/alpha/kernel/setup.c"
  11. * Copyright (C) 1995 Linus Torvalds
  12. *
  13. * Maintained by Benjamin Herrenschmidt (benh@kernel.crashing.org)
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * as published by the Free Software Foundation; either version
  18. * 2 of the License, or (at your option) any later version.
  19. *
  20. */
  21. /*
  22. * bootup setup stuff..
  23. */
  24. #include <linux/config.h>
  25. #include <linux/init.h>
  26. #include <linux/errno.h>
  27. #include <linux/sched.h>
  28. #include <linux/kernel.h>
  29. #include <linux/mm.h>
  30. #include <linux/stddef.h>
  31. #include <linux/unistd.h>
  32. #include <linux/ptrace.h>
  33. #include <linux/slab.h>
  34. #include <linux/user.h>
  35. #include <linux/a.out.h>
  36. #include <linux/tty.h>
  37. #include <linux/string.h>
  38. #include <linux/delay.h>
  39. #include <linux/ioport.h>
  40. #include <linux/major.h>
  41. #include <linux/initrd.h>
  42. #include <linux/vt_kern.h>
  43. #include <linux/console.h>
  44. #include <linux/ide.h>
  45. #include <linux/pci.h>
  46. #include <linux/adb.h>
  47. #include <linux/cuda.h>
  48. #include <linux/pmu.h>
  49. #include <linux/irq.h>
  50. #include <linux/seq_file.h>
  51. #include <linux/root_dev.h>
  52. #include <linux/bitops.h>
  53. #include <linux/suspend.h>
  54. #include <asm/reg.h>
  55. #include <asm/sections.h>
  56. #include <asm/prom.h>
  57. #include <asm/system.h>
  58. #include <asm/pgtable.h>
  59. #include <asm/io.h>
  60. #include <asm/kexec.h>
  61. #include <asm/pci-bridge.h>
  62. #include <asm/ohare.h>
  63. #include <asm/mediabay.h>
  64. #include <asm/machdep.h>
  65. #include <asm/dma.h>
  66. #include <asm/cputable.h>
  67. #include <asm/btext.h>
  68. #include <asm/pmac_feature.h>
  69. #include <asm/time.h>
  70. #include <asm/of_device.h>
  71. #include <asm/mmu_context.h>
  72. #include <asm/iommu.h>
  73. #include <asm/smu.h>
  74. #include <asm/pmc.h>
  75. #include <asm/mpic.h>
  76. #include <asm/lmb.h>
  77. #include "pmac.h"
  78. #undef SHOW_GATWICK_IRQS
  79. unsigned char drive_info;
  80. int ppc_override_l2cr = 0;
  81. int ppc_override_l2cr_value;
  82. int has_l2cache = 0;
  83. int pmac_newworld = 1;
  84. static int current_root_goodness = -1;
  85. extern int pmac_newworld;
  86. extern struct machdep_calls pmac_md;
  87. #define DEFAULT_ROOT_DEVICE Root_SDA1 /* sda1 - slightly silly choice */
  88. #ifdef CONFIG_PPC64
  89. #include <asm/udbg.h>
  90. int sccdbg;
  91. #endif
  92. extern void zs_kgdb_hook(int tty_num);
  93. sys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN;
  94. EXPORT_SYMBOL(sys_ctrler);
  95. #ifdef CONFIG_PMAC_SMU
  96. unsigned long smu_cmdbuf_abs;
  97. EXPORT_SYMBOL(smu_cmdbuf_abs);
  98. #endif
  99. #ifdef CONFIG_SMP
  100. extern struct smp_ops_t psurge_smp_ops;
  101. extern struct smp_ops_t core99_smp_ops;
  102. #endif /* CONFIG_SMP */
  103. static void pmac_show_cpuinfo(struct seq_file *m)
  104. {
  105. struct device_node *np;
  106. char *pp;
  107. int plen;
  108. int mbmodel;
  109. unsigned int mbflags;
  110. char* mbname;
  111. mbmodel = pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL,
  112. PMAC_MB_INFO_MODEL, 0);
  113. mbflags = pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL,
  114. PMAC_MB_INFO_FLAGS, 0);
  115. if (pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL, PMAC_MB_INFO_NAME,
  116. (long) &mbname) != 0)
  117. mbname = "Unknown";
  118. /* find motherboard type */
  119. seq_printf(m, "machine\t\t: ");
  120. np = of_find_node_by_path("/");
  121. if (np != NULL) {
  122. pp = (char *) get_property(np, "model", NULL);
  123. if (pp != NULL)
  124. seq_printf(m, "%s\n", pp);
  125. else
  126. seq_printf(m, "PowerMac\n");
  127. pp = (char *) get_property(np, "compatible", &plen);
  128. if (pp != NULL) {
  129. seq_printf(m, "motherboard\t:");
  130. while (plen > 0) {
  131. int l = strlen(pp) + 1;
  132. seq_printf(m, " %s", pp);
  133. plen -= l;
  134. pp += l;
  135. }
  136. seq_printf(m, "\n");
  137. }
  138. of_node_put(np);
  139. } else
  140. seq_printf(m, "PowerMac\n");
  141. /* print parsed model */
  142. seq_printf(m, "detected as\t: %d (%s)\n", mbmodel, mbname);
  143. seq_printf(m, "pmac flags\t: %08x\n", mbflags);
  144. /* find l2 cache info */
  145. np = of_find_node_by_name(NULL, "l2-cache");
  146. if (np == NULL)
  147. np = of_find_node_by_type(NULL, "cache");
  148. if (np != NULL) {
  149. unsigned int *ic = (unsigned int *)
  150. get_property(np, "i-cache-size", NULL);
  151. unsigned int *dc = (unsigned int *)
  152. get_property(np, "d-cache-size", NULL);
  153. seq_printf(m, "L2 cache\t:");
  154. has_l2cache = 1;
  155. if (get_property(np, "cache-unified", NULL) != 0 && dc) {
  156. seq_printf(m, " %dK unified", *dc / 1024);
  157. } else {
  158. if (ic)
  159. seq_printf(m, " %dK instruction", *ic / 1024);
  160. if (dc)
  161. seq_printf(m, "%s %dK data",
  162. (ic? " +": ""), *dc / 1024);
  163. }
  164. pp = get_property(np, "ram-type", NULL);
  165. if (pp)
  166. seq_printf(m, " %s", pp);
  167. seq_printf(m, "\n");
  168. of_node_put(np);
  169. }
  170. /* Indicate newworld/oldworld */
  171. seq_printf(m, "pmac-generation\t: %s\n",
  172. pmac_newworld ? "NewWorld" : "OldWorld");
  173. }
  174. #ifndef CONFIG_ADB_CUDA
  175. int find_via_cuda(void)
  176. {
  177. if (!find_devices("via-cuda"))
  178. return 0;
  179. printk("WARNING ! Your machine is CUDA-based but your kernel\n");
  180. printk(" wasn't compiled with CONFIG_ADB_CUDA option !\n");
  181. return 0;
  182. }
  183. #endif
  184. #ifndef CONFIG_ADB_PMU
  185. int find_via_pmu(void)
  186. {
  187. if (!find_devices("via-pmu"))
  188. return 0;
  189. printk("WARNING ! Your machine is PMU-based but your kernel\n");
  190. printk(" wasn't compiled with CONFIG_ADB_PMU option !\n");
  191. return 0;
  192. }
  193. #endif
  194. #ifndef CONFIG_PMAC_SMU
  195. int smu_init(void)
  196. {
  197. /* should check and warn if SMU is present */
  198. return 0;
  199. }
  200. #endif
  201. #ifdef CONFIG_PPC32
  202. static volatile u32 *sysctrl_regs;
  203. static void __init ohare_init(void)
  204. {
  205. /* this area has the CPU identification register
  206. and some registers used by smp boards */
  207. sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000);
  208. /*
  209. * Turn on the L2 cache.
  210. * We assume that we have a PSX memory controller iff
  211. * we have an ohare I/O controller.
  212. */
  213. if (find_devices("ohare") != NULL) {
  214. if (((sysctrl_regs[2] >> 24) & 0xf) >= 3) {
  215. if (sysctrl_regs[4] & 0x10)
  216. sysctrl_regs[4] |= 0x04000020;
  217. else
  218. sysctrl_regs[4] |= 0x04000000;
  219. if(has_l2cache)
  220. printk(KERN_INFO "Level 2 cache enabled\n");
  221. }
  222. }
  223. }
  224. static void __init l2cr_init(void)
  225. {
  226. /* Checks "l2cr-value" property in the registry */
  227. if (cpu_has_feature(CPU_FTR_L2CR)) {
  228. struct device_node *np = find_devices("cpus");
  229. if (np == 0)
  230. np = find_type_devices("cpu");
  231. if (np != 0) {
  232. unsigned int *l2cr = (unsigned int *)
  233. get_property(np, "l2cr-value", NULL);
  234. if (l2cr != 0) {
  235. ppc_override_l2cr = 1;
  236. ppc_override_l2cr_value = *l2cr;
  237. _set_L2CR(0);
  238. _set_L2CR(ppc_override_l2cr_value);
  239. }
  240. }
  241. }
  242. if (ppc_override_l2cr)
  243. printk(KERN_INFO "L2CR overridden (0x%x), "
  244. "backside cache is %s\n",
  245. ppc_override_l2cr_value,
  246. (ppc_override_l2cr_value & 0x80000000)
  247. ? "enabled" : "disabled");
  248. }
  249. #endif
  250. void __init pmac_setup_arch(void)
  251. {
  252. struct device_node *cpu, *ic;
  253. int *fp;
  254. unsigned long pvr;
  255. pvr = PVR_VER(mfspr(SPRN_PVR));
  256. /* Set loops_per_jiffy to a half-way reasonable value,
  257. for use until calibrate_delay gets called. */
  258. loops_per_jiffy = 50000000 / HZ;
  259. cpu = of_find_node_by_type(NULL, "cpu");
  260. if (cpu != NULL) {
  261. fp = (int *) get_property(cpu, "clock-frequency", NULL);
  262. if (fp != NULL) {
  263. if (pvr >= 0x30 && pvr < 0x80)
  264. /* PPC970 etc. */
  265. loops_per_jiffy = *fp / (3 * HZ);
  266. else if (pvr == 4 || pvr >= 8)
  267. /* 604, G3, G4 etc. */
  268. loops_per_jiffy = *fp / HZ;
  269. else
  270. /* 601, 603, etc. */
  271. loops_per_jiffy = *fp / (2 * HZ);
  272. }
  273. of_node_put(cpu);
  274. }
  275. /* See if newworld or oldworld */
  276. for (ic = NULL; (ic = of_find_all_nodes(ic)) != NULL; )
  277. if (get_property(ic, "interrupt-controller", NULL))
  278. break;
  279. pmac_newworld = (ic != NULL);
  280. if (ic)
  281. of_node_put(ic);
  282. /* Lookup PCI hosts */
  283. pmac_pci_init();
  284. #ifdef CONFIG_PPC32
  285. ohare_init();
  286. l2cr_init();
  287. #endif /* CONFIG_PPC32 */
  288. #ifdef CONFIG_PPC64
  289. /* Probe motherboard chipset */
  290. /* this is done earlier in setup_arch for 32-bit */
  291. pmac_feature_init();
  292. /* We can NAP */
  293. powersave_nap = 1;
  294. printk(KERN_INFO "Using native/NAP idle loop\n");
  295. #endif
  296. #ifdef CONFIG_KGDB
  297. zs_kgdb_hook(0);
  298. #endif
  299. find_via_cuda();
  300. find_via_pmu();
  301. smu_init();
  302. #if defined(CONFIG_NVRAM) || defined(CONFIG_PPC64)
  303. pmac_nvram_init();
  304. #endif
  305. #ifdef CONFIG_PPC32
  306. #ifdef CONFIG_BLK_DEV_INITRD
  307. if (initrd_start)
  308. ROOT_DEV = Root_RAM0;
  309. else
  310. #endif
  311. ROOT_DEV = DEFAULT_ROOT_DEVICE;
  312. #endif
  313. #ifdef CONFIG_SMP
  314. /* Check for Core99 */
  315. if (find_devices("uni-n") || find_devices("u3"))
  316. smp_ops = &core99_smp_ops;
  317. #ifdef CONFIG_PPC32
  318. else
  319. smp_ops = &psurge_smp_ops;
  320. #endif
  321. #endif /* CONFIG_SMP */
  322. }
  323. char *bootpath;
  324. char *bootdevice;
  325. void *boot_host;
  326. int boot_target;
  327. int boot_part;
  328. extern dev_t boot_dev;
  329. #ifdef CONFIG_SCSI
  330. void __init note_scsi_host(struct device_node *node, void *host)
  331. {
  332. int l;
  333. char *p;
  334. l = strlen(node->full_name);
  335. if (bootpath != NULL && bootdevice != NULL
  336. && strncmp(node->full_name, bootdevice, l) == 0
  337. && (bootdevice[l] == '/' || bootdevice[l] == 0)) {
  338. boot_host = host;
  339. /*
  340. * There's a bug in OF 1.0.5. (Why am I not surprised.)
  341. * If you pass a path like scsi/sd@1:0 to canon, it returns
  342. * something like /bandit@F2000000/gc@10/53c94@10000/sd@0,0
  343. * That is, the scsi target number doesn't get preserved.
  344. * So we pick the target number out of bootpath and use that.
  345. */
  346. p = strstr(bootpath, "/sd@");
  347. if (p != NULL) {
  348. p += 4;
  349. boot_target = simple_strtoul(p, NULL, 10);
  350. p = strchr(p, ':');
  351. if (p != NULL)
  352. boot_part = simple_strtoul(p + 1, NULL, 10);
  353. }
  354. }
  355. }
  356. EXPORT_SYMBOL(note_scsi_host);
  357. #endif
  358. #if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC)
  359. static dev_t __init find_ide_boot(void)
  360. {
  361. char *p;
  362. int n;
  363. dev_t __init pmac_find_ide_boot(char *bootdevice, int n);
  364. if (bootdevice == NULL)
  365. return 0;
  366. p = strrchr(bootdevice, '/');
  367. if (p == NULL)
  368. return 0;
  369. n = p - bootdevice;
  370. return pmac_find_ide_boot(bootdevice, n);
  371. }
  372. #endif /* CONFIG_BLK_DEV_IDE && CONFIG_BLK_DEV_IDE_PMAC */
  373. static void __init find_boot_device(void)
  374. {
  375. #if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC)
  376. boot_dev = find_ide_boot();
  377. #endif
  378. }
  379. /* TODO: Merge the suspend-to-ram with the common code !!!
  380. * currently, this is a stub implementation for suspend-to-disk
  381. * only
  382. */
  383. #ifdef CONFIG_SOFTWARE_SUSPEND
  384. static int pmac_pm_prepare(suspend_state_t state)
  385. {
  386. printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
  387. return 0;
  388. }
  389. static int pmac_pm_enter(suspend_state_t state)
  390. {
  391. printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
  392. /* Giveup the lazy FPU & vec so we don't have to back them
  393. * up from the low level code
  394. */
  395. enable_kernel_fp();
  396. #ifdef CONFIG_ALTIVEC
  397. if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC)
  398. enable_kernel_altivec();
  399. #endif /* CONFIG_ALTIVEC */
  400. return 0;
  401. }
  402. static int pmac_pm_finish(suspend_state_t state)
  403. {
  404. printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
  405. /* Restore userland MMU context */
  406. set_context(current->active_mm->context, current->active_mm->pgd);
  407. return 0;
  408. }
  409. static struct pm_ops pmac_pm_ops = {
  410. .pm_disk_mode = PM_DISK_SHUTDOWN,
  411. .prepare = pmac_pm_prepare,
  412. .enter = pmac_pm_enter,
  413. .finish = pmac_pm_finish,
  414. };
  415. #endif /* CONFIG_SOFTWARE_SUSPEND */
  416. static int initializing = 1;
  417. static int pmac_late_init(void)
  418. {
  419. initializing = 0;
  420. #ifdef CONFIG_SOFTWARE_SUSPEND
  421. pm_set_ops(&pmac_pm_ops);
  422. #endif /* CONFIG_SOFTWARE_SUSPEND */
  423. return 0;
  424. }
  425. late_initcall(pmac_late_init);
  426. /* can't be __init - can be called whenever a disk is first accessed */
  427. void note_bootable_part(dev_t dev, int part, int goodness)
  428. {
  429. static int found_boot = 0;
  430. char *p;
  431. if (!initializing)
  432. return;
  433. if ((goodness <= current_root_goodness) &&
  434. ROOT_DEV != DEFAULT_ROOT_DEVICE)
  435. return;
  436. p = strstr(saved_command_line, "root=");
  437. if (p != NULL && (p == saved_command_line || p[-1] == ' '))
  438. return;
  439. if (!found_boot) {
  440. find_boot_device();
  441. found_boot = 1;
  442. }
  443. if (!boot_dev || dev == boot_dev) {
  444. ROOT_DEV = dev + part;
  445. boot_dev = 0;
  446. current_root_goodness = goodness;
  447. }
  448. }
  449. #ifdef CONFIG_ADB_CUDA
  450. static void cuda_restart(void)
  451. {
  452. struct adb_request req;
  453. cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_RESET_SYSTEM);
  454. for (;;)
  455. cuda_poll();
  456. }
  457. static void cuda_shutdown(void)
  458. {
  459. struct adb_request req;
  460. cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_POWERDOWN);
  461. for (;;)
  462. cuda_poll();
  463. }
  464. #else
  465. #define cuda_restart()
  466. #define cuda_shutdown()
  467. #endif
  468. #ifndef CONFIG_ADB_PMU
  469. #define pmu_restart()
  470. #define pmu_shutdown()
  471. #endif
  472. #ifndef CONFIG_PMAC_SMU
  473. #define smu_restart()
  474. #define smu_shutdown()
  475. #endif
  476. static void pmac_restart(char *cmd)
  477. {
  478. switch (sys_ctrler) {
  479. case SYS_CTRLER_CUDA:
  480. cuda_restart();
  481. break;
  482. case SYS_CTRLER_PMU:
  483. pmu_restart();
  484. break;
  485. case SYS_CTRLER_SMU:
  486. smu_restart();
  487. break;
  488. default: ;
  489. }
  490. }
  491. static void pmac_power_off(void)
  492. {
  493. switch (sys_ctrler) {
  494. case SYS_CTRLER_CUDA:
  495. cuda_shutdown();
  496. break;
  497. case SYS_CTRLER_PMU:
  498. pmu_shutdown();
  499. break;
  500. case SYS_CTRLER_SMU:
  501. smu_shutdown();
  502. break;
  503. default: ;
  504. }
  505. }
  506. static void
  507. pmac_halt(void)
  508. {
  509. pmac_power_off();
  510. }
  511. #ifdef CONFIG_PPC32
  512. void __init pmac_init(void)
  513. {
  514. /* isa_io_base gets set in pmac_pci_init */
  515. isa_mem_base = PMAC_ISA_MEM_BASE;
  516. pci_dram_offset = PMAC_PCI_DRAM_OFFSET;
  517. ISA_DMA_THRESHOLD = ~0L;
  518. DMA_MODE_READ = 1;
  519. DMA_MODE_WRITE = 2;
  520. ppc_md = pmac_md;
  521. #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
  522. #ifdef CONFIG_BLK_DEV_IDE_PMAC
  523. ppc_ide_md.ide_init_hwif = pmac_ide_init_hwif_ports;
  524. ppc_ide_md.default_io_base = pmac_ide_get_base;
  525. #endif /* CONFIG_BLK_DEV_IDE_PMAC */
  526. #endif /* defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) */
  527. if (ppc_md.progress) ppc_md.progress("pmac_init(): exit", 0);
  528. }
  529. #endif
  530. /*
  531. * Early initialization.
  532. */
  533. static void __init pmac_init_early(void)
  534. {
  535. #ifdef CONFIG_PPC64
  536. /* Initialize hash table, from now on, we can take hash faults
  537. * and call ioremap
  538. */
  539. hpte_init_native();
  540. /* Init SCC */
  541. if (strstr(cmd_line, "sccdbg")) {
  542. sccdbg = 1;
  543. udbg_init_scc(NULL);
  544. }
  545. /* Setup interrupt mapping options */
  546. ppc64_interrupt_controller = IC_OPEN_PIC;
  547. iommu_init_early_u3();
  548. #endif
  549. }
  550. static void __init pmac_progress(char *s, unsigned short hex)
  551. {
  552. #ifdef CONFIG_PPC64
  553. if (sccdbg) {
  554. udbg_puts(s);
  555. udbg_puts("\n");
  556. return;
  557. }
  558. #endif
  559. #ifdef CONFIG_BOOTX_TEXT
  560. if (boot_text_mapped) {
  561. btext_drawstring(s);
  562. btext_drawchar('\n');
  563. }
  564. #endif /* CONFIG_BOOTX_TEXT */
  565. }
  566. /*
  567. * pmac has no legacy IO, anything calling this function has to
  568. * fail or bad things will happen
  569. */
  570. static int pmac_check_legacy_ioport(unsigned int baseport)
  571. {
  572. return -ENODEV;
  573. }
  574. static int __init pmac_declare_of_platform_devices(void)
  575. {
  576. struct device_node *np, *npp;
  577. np = find_devices("uni-n");
  578. if (np) {
  579. for (np = np->child; np != NULL; np = np->sibling)
  580. if (strncmp(np->name, "i2c", 3) == 0) {
  581. of_platform_device_create(np, "uni-n-i2c",
  582. NULL);
  583. break;
  584. }
  585. }
  586. np = find_devices("valkyrie");
  587. if (np)
  588. of_platform_device_create(np, "valkyrie", NULL);
  589. np = find_devices("platinum");
  590. if (np)
  591. of_platform_device_create(np, "platinum", NULL);
  592. npp = of_find_node_by_name(NULL, "u3");
  593. if (npp) {
  594. for (np = NULL; (np = of_get_next_child(npp, np)) != NULL;) {
  595. if (strncmp(np->name, "i2c", 3) == 0) {
  596. of_platform_device_create(np, "u3-i2c", NULL);
  597. of_node_put(np);
  598. break;
  599. }
  600. }
  601. of_node_put(npp);
  602. }
  603. np = of_find_node_by_type(NULL, "smu");
  604. if (np) {
  605. of_platform_device_create(np, "smu", NULL);
  606. of_node_put(np);
  607. }
  608. return 0;
  609. }
  610. device_initcall(pmac_declare_of_platform_devices);
  611. /*
  612. * Called very early, MMU is off, device-tree isn't unflattened
  613. */
  614. static int __init pmac_probe(int platform)
  615. {
  616. #ifdef CONFIG_PPC64
  617. if (platform != PLATFORM_POWERMAC)
  618. return 0;
  619. /*
  620. * On U3, the DART (iommu) must be allocated now since it
  621. * has an impact on htab_initialize (due to the large page it
  622. * occupies having to be broken up so the DART itself is not
  623. * part of the cacheable linar mapping
  624. */
  625. alloc_u3_dart_table();
  626. #endif
  627. #ifdef CONFIG_PMAC_SMU
  628. /*
  629. * SMU based G5s need some memory below 2Gb, at least the current
  630. * driver needs that. We have to allocate it now. We allocate 4k
  631. * (1 small page) for now.
  632. */
  633. smu_cmdbuf_abs = lmb_alloc_base(4096, 4096, 0x80000000UL);
  634. #endif /* CONFIG_PMAC_SMU */
  635. return 1;
  636. }
  637. #ifdef CONFIG_PPC64
  638. static int pmac_probe_mode(struct pci_bus *bus)
  639. {
  640. struct device_node *node = bus->sysdata;
  641. /* We need to use normal PCI probing for the AGP bus,
  642. since the device for the AGP bridge isn't in the tree. */
  643. if (bus->self == NULL && device_is_compatible(node, "u3-agp"))
  644. return PCI_PROBE_NORMAL;
  645. return PCI_PROBE_DEVTREE;
  646. }
  647. #endif
  648. struct machdep_calls __initdata pmac_md = {
  649. #if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PPC64)
  650. .cpu_die = generic_mach_cpu_die,
  651. #endif
  652. .probe = pmac_probe,
  653. .setup_arch = pmac_setup_arch,
  654. .init_early = pmac_init_early,
  655. .show_cpuinfo = pmac_show_cpuinfo,
  656. .init_IRQ = pmac_pic_init,
  657. .get_irq = mpic_get_irq, /* changed later */
  658. .pcibios_fixup = pmac_pcibios_fixup,
  659. .restart = pmac_restart,
  660. .power_off = pmac_power_off,
  661. .halt = pmac_halt,
  662. .time_init = pmac_time_init,
  663. .get_boot_time = pmac_get_boot_time,
  664. .set_rtc_time = pmac_set_rtc_time,
  665. .get_rtc_time = pmac_get_rtc_time,
  666. .calibrate_decr = pmac_calibrate_decr,
  667. .feature_call = pmac_do_feature_call,
  668. .check_legacy_ioport = pmac_check_legacy_ioport,
  669. .progress = pmac_progress,
  670. #ifdef CONFIG_PPC64
  671. .pci_probe_mode = pmac_probe_mode,
  672. .idle_loop = native_idle,
  673. .enable_pmcs = power4_enable_pmcs,
  674. #ifdef CONFIG_KEXEC
  675. .machine_kexec = default_machine_kexec,
  676. .machine_kexec_prepare = default_machine_kexec_prepare,
  677. #endif
  678. #endif /* CONFIG_PPC64 */
  679. #ifdef CONFIG_PPC32
  680. .pcibios_enable_device_hook = pmac_pci_enable_device_hook,
  681. .pcibios_after_init = pmac_pcibios_after_init,
  682. .phys_mem_access_prot = pci_phys_mem_access_prot,
  683. #endif
  684. };