setup.c 18 KB

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