setup.c 17 KB

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