setup.c 18 KB

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