pmac_setup.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. /*
  2. * arch/ppc/platforms/setup.c
  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@cs.anu.edu.au)
  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/bootx.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 "pmac_pic.h"
  73. #include "mem_pieces.h"
  74. #undef SHOW_GATWICK_IRQS
  75. extern long pmac_time_init(void);
  76. extern unsigned long pmac_get_rtc_time(void);
  77. extern int pmac_set_rtc_time(unsigned long nowtime);
  78. extern void pmac_read_rtc_time(void);
  79. extern void pmac_calibrate_decr(void);
  80. extern void pmac_pcibios_fixup(void);
  81. extern void pmac_find_bridges(void);
  82. extern unsigned long pmac_ide_get_base(int index);
  83. extern void pmac_ide_init_hwif_ports(hw_regs_t *hw,
  84. unsigned long data_port, unsigned long ctrl_port, int *irq);
  85. extern void pmac_nvram_update(void);
  86. extern unsigned char pmac_nvram_read_byte(int addr);
  87. extern void pmac_nvram_write_byte(int addr, unsigned char val);
  88. extern int pmac_pci_enable_device_hook(struct pci_dev *dev, int initial);
  89. extern void pmac_pcibios_after_init(void);
  90. extern int of_show_percpuinfo(struct seq_file *m, int i);
  91. struct device_node *memory_node;
  92. unsigned char drive_info;
  93. int ppc_override_l2cr = 0;
  94. int ppc_override_l2cr_value;
  95. int has_l2cache = 0;
  96. static int current_root_goodness = -1;
  97. extern int pmac_newworld;
  98. #define DEFAULT_ROOT_DEVICE Root_SDA1 /* sda1 - slightly silly choice */
  99. extern void zs_kgdb_hook(int tty_num);
  100. static void ohare_init(void);
  101. #ifdef CONFIG_BOOTX_TEXT
  102. static void pmac_progress(char *s, unsigned short hex);
  103. #endif
  104. sys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN;
  105. #ifdef CONFIG_SMP
  106. extern struct smp_ops_t psurge_smp_ops;
  107. extern struct smp_ops_t core99_smp_ops;
  108. #endif /* CONFIG_SMP */
  109. static int __pmac
  110. pmac_show_cpuinfo(struct seq_file *m)
  111. {
  112. struct device_node *np;
  113. char *pp;
  114. int plen;
  115. int mbmodel = pmac_call_feature(PMAC_FTR_GET_MB_INFO,
  116. NULL, PMAC_MB_INFO_MODEL, 0);
  117. unsigned int mbflags = (unsigned int)pmac_call_feature(PMAC_FTR_GET_MB_INFO,
  118. NULL, PMAC_MB_INFO_FLAGS, 0);
  119. char* mbname;
  120. if (pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL, PMAC_MB_INFO_NAME, (int)&mbname) != 0)
  121. mbname = "Unknown";
  122. /* find motherboard type */
  123. seq_printf(m, "machine\t\t: ");
  124. np = find_devices("device-tree");
  125. if (np != NULL) {
  126. pp = (char *) get_property(np, "model", NULL);
  127. if (pp != NULL)
  128. seq_printf(m, "%s\n", pp);
  129. else
  130. seq_printf(m, "PowerMac\n");
  131. pp = (char *) get_property(np, "compatible", &plen);
  132. if (pp != NULL) {
  133. seq_printf(m, "motherboard\t:");
  134. while (plen > 0) {
  135. int l = strlen(pp) + 1;
  136. seq_printf(m, " %s", pp);
  137. plen -= l;
  138. pp += l;
  139. }
  140. seq_printf(m, "\n");
  141. }
  142. } else
  143. seq_printf(m, "PowerMac\n");
  144. /* print parsed model */
  145. seq_printf(m, "detected as\t: %d (%s)\n", mbmodel, mbname);
  146. seq_printf(m, "pmac flags\t: %08x\n", mbflags);
  147. /* find l2 cache info */
  148. np = find_devices("l2-cache");
  149. if (np == 0)
  150. np = find_type_devices("cache");
  151. if (np != 0) {
  152. unsigned int *ic = (unsigned int *)
  153. get_property(np, "i-cache-size", NULL);
  154. unsigned int *dc = (unsigned int *)
  155. get_property(np, "d-cache-size", NULL);
  156. seq_printf(m, "L2 cache\t:");
  157. has_l2cache = 1;
  158. if (get_property(np, "cache-unified", NULL) != 0 && dc) {
  159. seq_printf(m, " %dK unified", *dc / 1024);
  160. } else {
  161. if (ic)
  162. seq_printf(m, " %dK instruction", *ic / 1024);
  163. if (dc)
  164. seq_printf(m, "%s %dK data",
  165. (ic? " +": ""), *dc / 1024);
  166. }
  167. pp = get_property(np, "ram-type", NULL);
  168. if (pp)
  169. seq_printf(m, " %s", pp);
  170. seq_printf(m, "\n");
  171. }
  172. /* find ram info */
  173. np = find_devices("memory");
  174. if (np != 0) {
  175. int n;
  176. struct reg_property *reg = (struct reg_property *)
  177. get_property(np, "reg", &n);
  178. if (reg != 0) {
  179. unsigned long total = 0;
  180. for (n /= sizeof(struct reg_property); n > 0; --n)
  181. total += (reg++)->size;
  182. seq_printf(m, "memory\t\t: %luMB\n", total >> 20);
  183. }
  184. }
  185. /* Checks "l2cr-value" property in the registry */
  186. np = find_devices("cpus");
  187. if (np == 0)
  188. np = find_type_devices("cpu");
  189. if (np != 0) {
  190. unsigned int *l2cr = (unsigned int *)
  191. get_property(np, "l2cr-value", NULL);
  192. if (l2cr != 0) {
  193. seq_printf(m, "l2cr override\t: 0x%x\n", *l2cr);
  194. }
  195. }
  196. /* Indicate newworld/oldworld */
  197. seq_printf(m, "pmac-generation\t: %s\n",
  198. pmac_newworld ? "NewWorld" : "OldWorld");
  199. return 0;
  200. }
  201. static int __openfirmware
  202. pmac_show_percpuinfo(struct seq_file *m, int i)
  203. {
  204. #ifdef CONFIG_CPU_FREQ_PMAC
  205. extern unsigned int pmac_get_one_cpufreq(int i);
  206. unsigned int freq = pmac_get_one_cpufreq(i);
  207. if (freq != 0) {
  208. seq_printf(m, "clock\t\t: %dMHz\n", freq/1000);
  209. return 0;
  210. }
  211. #endif /* CONFIG_CPU_FREQ_PMAC */
  212. return of_show_percpuinfo(m, i);
  213. }
  214. static volatile u32 *sysctrl_regs;
  215. void __init
  216. pmac_setup_arch(void)
  217. {
  218. struct device_node *cpu;
  219. int *fp;
  220. unsigned long pvr;
  221. pvr = PVR_VER(mfspr(SPRN_PVR));
  222. /* Set loops_per_jiffy to a half-way reasonable value,
  223. for use until calibrate_delay gets called. */
  224. cpu = find_type_devices("cpu");
  225. if (cpu != 0) {
  226. fp = (int *) get_property(cpu, "clock-frequency", NULL);
  227. if (fp != 0) {
  228. if (pvr == 4 || pvr >= 8)
  229. /* 604, G3, G4 etc. */
  230. loops_per_jiffy = *fp / HZ;
  231. else
  232. /* 601, 603, etc. */
  233. loops_per_jiffy = *fp / (2*HZ);
  234. } else
  235. loops_per_jiffy = 50000000 / HZ;
  236. }
  237. /* this area has the CPU identification register
  238. and some registers used by smp boards */
  239. sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000);
  240. ohare_init();
  241. /* Lookup PCI hosts */
  242. pmac_find_bridges();
  243. /* Checks "l2cr-value" property in the registry */
  244. if (cpu_has_feature(CPU_FTR_L2CR)) {
  245. struct device_node *np = find_devices("cpus");
  246. if (np == 0)
  247. np = find_type_devices("cpu");
  248. if (np != 0) {
  249. unsigned int *l2cr = (unsigned int *)
  250. get_property(np, "l2cr-value", NULL);
  251. if (l2cr != 0) {
  252. ppc_override_l2cr = 1;
  253. ppc_override_l2cr_value = *l2cr;
  254. _set_L2CR(0);
  255. _set_L2CR(ppc_override_l2cr_value);
  256. }
  257. }
  258. }
  259. if (ppc_override_l2cr)
  260. printk(KERN_INFO "L2CR overriden (0x%x), backside cache is %s\n",
  261. ppc_override_l2cr_value, (ppc_override_l2cr_value & 0x80000000)
  262. ? "enabled" : "disabled");
  263. #ifdef CONFIG_KGDB
  264. zs_kgdb_hook(0);
  265. #endif
  266. #ifdef CONFIG_ADB_CUDA
  267. find_via_cuda();
  268. #else
  269. if (find_devices("via-cuda")) {
  270. printk("WARNING ! Your machine is Cuda based but your kernel\n");
  271. printk(" wasn't compiled with CONFIG_ADB_CUDA option !\n");
  272. }
  273. #endif
  274. #ifdef CONFIG_ADB_PMU
  275. find_via_pmu();
  276. #else
  277. if (find_devices("via-pmu")) {
  278. printk("WARNING ! Your machine is PMU based but your kernel\n");
  279. printk(" wasn't compiled with CONFIG_ADB_PMU option !\n");
  280. }
  281. #endif
  282. #ifdef CONFIG_NVRAM
  283. pmac_nvram_init();
  284. #endif
  285. #ifdef CONFIG_BLK_DEV_INITRD
  286. if (initrd_start)
  287. ROOT_DEV = Root_RAM0;
  288. else
  289. #endif
  290. ROOT_DEV = DEFAULT_ROOT_DEVICE;
  291. #ifdef CONFIG_SMP
  292. /* Check for Core99 */
  293. if (find_devices("uni-n") || find_devices("u3"))
  294. ppc_md.smp_ops = &core99_smp_ops;
  295. else
  296. ppc_md.smp_ops = &psurge_smp_ops;
  297. #endif /* CONFIG_SMP */
  298. pci_create_OF_bus_map();
  299. }
  300. static void __init ohare_init(void)
  301. {
  302. /*
  303. * Turn on the L2 cache.
  304. * We assume that we have a PSX memory controller iff
  305. * we have an ohare I/O controller.
  306. */
  307. if (find_devices("ohare") != NULL) {
  308. if (((sysctrl_regs[2] >> 24) & 0xf) >= 3) {
  309. if (sysctrl_regs[4] & 0x10)
  310. sysctrl_regs[4] |= 0x04000020;
  311. else
  312. sysctrl_regs[4] |= 0x04000000;
  313. if(has_l2cache)
  314. printk(KERN_INFO "Level 2 cache enabled\n");
  315. }
  316. }
  317. }
  318. extern char *bootpath;
  319. extern char *bootdevice;
  320. void *boot_host;
  321. int boot_target;
  322. int boot_part;
  323. extern dev_t boot_dev;
  324. #ifdef CONFIG_SCSI
  325. void __init
  326. note_scsi_host(struct device_node *node, void *host)
  327. {
  328. int l;
  329. char *p;
  330. l = strlen(node->full_name);
  331. if (bootpath != NULL && bootdevice != NULL
  332. && strncmp(node->full_name, bootdevice, l) == 0
  333. && (bootdevice[l] == '/' || bootdevice[l] == 0)) {
  334. boot_host = host;
  335. /*
  336. * There's a bug in OF 1.0.5. (Why am I not surprised.)
  337. * If you pass a path like scsi/sd@1:0 to canon, it returns
  338. * something like /bandit@F2000000/gc@10/53c94@10000/sd@0,0
  339. * That is, the scsi target number doesn't get preserved.
  340. * So we pick the target number out of bootpath and use that.
  341. */
  342. p = strstr(bootpath, "/sd@");
  343. if (p != NULL) {
  344. p += 4;
  345. boot_target = simple_strtoul(p, NULL, 10);
  346. p = strchr(p, ':');
  347. if (p != NULL)
  348. boot_part = simple_strtoul(p + 1, NULL, 10);
  349. }
  350. }
  351. }
  352. #endif
  353. #if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC)
  354. static dev_t __init
  355. find_ide_boot(void)
  356. {
  357. char *p;
  358. int n;
  359. dev_t __init pmac_find_ide_boot(char *bootdevice, int n);
  360. if (bootdevice == NULL)
  361. return 0;
  362. p = strrchr(bootdevice, '/');
  363. if (p == NULL)
  364. return 0;
  365. n = p - bootdevice;
  366. return pmac_find_ide_boot(bootdevice, n);
  367. }
  368. #endif /* CONFIG_BLK_DEV_IDE && CONFIG_BLK_DEV_IDE_PMAC */
  369. static void __init
  370. find_boot_device(void)
  371. {
  372. #if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC)
  373. boot_dev = find_ide_boot();
  374. #endif
  375. }
  376. static int initializing = 1;
  377. /* TODO: Merge the suspend-to-ram with the common code !!!
  378. * currently, this is a stub implementation for suspend-to-disk
  379. * only
  380. */
  381. #ifdef CONFIG_SOFTWARE_SUSPEND
  382. static int pmac_pm_prepare(suspend_state_t state)
  383. {
  384. printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
  385. return 0;
  386. }
  387. static int pmac_pm_enter(suspend_state_t state)
  388. {
  389. printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
  390. /* Giveup the lazy FPU & vec so we don't have to back them
  391. * up from the low level code
  392. */
  393. enable_kernel_fp();
  394. #ifdef CONFIG_ALTIVEC
  395. if (cur_cpu_spec[0]->cpu_features & CPU_FTR_ALTIVEC)
  396. enable_kernel_altivec();
  397. #endif /* CONFIG_ALTIVEC */
  398. return 0;
  399. }
  400. static int pmac_pm_finish(suspend_state_t state)
  401. {
  402. printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
  403. /* Restore userland MMU context */
  404. set_context(current->active_mm->context, current->active_mm->pgd);
  405. return 0;
  406. }
  407. static struct pm_ops pmac_pm_ops = {
  408. .pm_disk_mode = PM_DISK_SHUTDOWN,
  409. .prepare = pmac_pm_prepare,
  410. .enter = pmac_pm_enter,
  411. .finish = pmac_pm_finish,
  412. };
  413. #endif /* CONFIG_SOFTWARE_SUSPEND */
  414. static int pmac_late_init(void)
  415. {
  416. initializing = 0;
  417. #ifdef CONFIG_SOFTWARE_SUSPEND
  418. pm_set_ops(&pmac_pm_ops);
  419. #endif /* CONFIG_SOFTWARE_SUSPEND */
  420. return 0;
  421. }
  422. late_initcall(pmac_late_init);
  423. /* can't be __init - can be called whenever a disk is first accessed */
  424. void __pmac
  425. note_bootable_part(dev_t dev, int part, int goodness)
  426. {
  427. static int found_boot = 0;
  428. char *p;
  429. if (!initializing)
  430. return;
  431. if ((goodness <= current_root_goodness) &&
  432. ROOT_DEV != DEFAULT_ROOT_DEVICE)
  433. return;
  434. p = strstr(saved_command_line, "root=");
  435. if (p != NULL && (p == saved_command_line || p[-1] == ' '))
  436. return;
  437. if (!found_boot) {
  438. find_boot_device();
  439. found_boot = 1;
  440. }
  441. if (!boot_dev || dev == boot_dev) {
  442. ROOT_DEV = dev + part;
  443. boot_dev = 0;
  444. current_root_goodness = goodness;
  445. }
  446. }
  447. static void __pmac
  448. pmac_restart(char *cmd)
  449. {
  450. #ifdef CONFIG_ADB_CUDA
  451. struct adb_request req;
  452. #endif /* CONFIG_ADB_CUDA */
  453. switch (sys_ctrler) {
  454. #ifdef CONFIG_ADB_CUDA
  455. case SYS_CTRLER_CUDA:
  456. cuda_request(&req, NULL, 2, CUDA_PACKET,
  457. CUDA_RESET_SYSTEM);
  458. for (;;)
  459. cuda_poll();
  460. break;
  461. #endif /* CONFIG_ADB_CUDA */
  462. #ifdef CONFIG_ADB_PMU
  463. case SYS_CTRLER_PMU:
  464. pmu_restart();
  465. break;
  466. #endif /* CONFIG_ADB_PMU */
  467. default: ;
  468. }
  469. }
  470. static void __pmac
  471. pmac_power_off(void)
  472. {
  473. #ifdef CONFIG_ADB_CUDA
  474. struct adb_request req;
  475. #endif /* CONFIG_ADB_CUDA */
  476. switch (sys_ctrler) {
  477. #ifdef CONFIG_ADB_CUDA
  478. case SYS_CTRLER_CUDA:
  479. cuda_request(&req, NULL, 2, CUDA_PACKET,
  480. CUDA_POWERDOWN);
  481. for (;;)
  482. cuda_poll();
  483. break;
  484. #endif /* CONFIG_ADB_CUDA */
  485. #ifdef CONFIG_ADB_PMU
  486. case SYS_CTRLER_PMU:
  487. pmu_shutdown();
  488. break;
  489. #endif /* CONFIG_ADB_PMU */
  490. default: ;
  491. }
  492. }
  493. static void __pmac
  494. pmac_halt(void)
  495. {
  496. pmac_power_off();
  497. }
  498. /*
  499. * Read in a property describing some pieces of memory.
  500. */
  501. static int __init
  502. get_mem_prop(char *name, struct mem_pieces *mp)
  503. {
  504. struct reg_property *rp;
  505. int i, s;
  506. unsigned int *ip;
  507. int nac = prom_n_addr_cells(memory_node);
  508. int nsc = prom_n_size_cells(memory_node);
  509. ip = (unsigned int *) get_property(memory_node, name, &s);
  510. if (ip == NULL) {
  511. printk(KERN_ERR "error: couldn't get %s property on /memory\n",
  512. name);
  513. return 0;
  514. }
  515. s /= (nsc + nac) * 4;
  516. rp = mp->regions;
  517. for (i = 0; i < s; ++i, ip += nac+nsc) {
  518. if (nac >= 2 && ip[nac-2] != 0)
  519. continue;
  520. rp->address = ip[nac-1];
  521. if (nsc >= 2 && ip[nac+nsc-2] != 0)
  522. rp->size = ~0U;
  523. else
  524. rp->size = ip[nac+nsc-1];
  525. ++rp;
  526. }
  527. mp->n_regions = rp - mp->regions;
  528. /* Make sure the pieces are sorted. */
  529. mem_pieces_sort(mp);
  530. mem_pieces_coalesce(mp);
  531. return 1;
  532. }
  533. /*
  534. * On systems with Open Firmware, collect information about
  535. * physical RAM and which pieces are already in use.
  536. * At this point, we have (at least) the first 8MB mapped with a BAT.
  537. * Our text, data, bss use something over 1MB, starting at 0.
  538. * Open Firmware may be using 1MB at the 4MB point.
  539. */
  540. unsigned long __init
  541. pmac_find_end_of_memory(void)
  542. {
  543. unsigned long a, total;
  544. struct mem_pieces phys_mem;
  545. /*
  546. * Find out where physical memory is, and check that it
  547. * starts at 0 and is contiguous. It seems that RAM is
  548. * always physically contiguous on Power Macintoshes.
  549. *
  550. * Supporting discontiguous physical memory isn't hard,
  551. * it just makes the virtual <-> physical mapping functions
  552. * more complicated (or else you end up wasting space
  553. * in mem_map).
  554. */
  555. memory_node = find_devices("memory");
  556. if (memory_node == NULL || !get_mem_prop("reg", &phys_mem)
  557. || phys_mem.n_regions == 0)
  558. panic("No RAM??");
  559. a = phys_mem.regions[0].address;
  560. if (a != 0)
  561. panic("RAM doesn't start at physical address 0");
  562. total = phys_mem.regions[0].size;
  563. if (phys_mem.n_regions > 1) {
  564. printk("RAM starting at 0x%x is not contiguous\n",
  565. phys_mem.regions[1].address);
  566. printk("Using RAM from 0 to 0x%lx\n", total-1);
  567. }
  568. return total;
  569. }
  570. void __init
  571. pmac_init(unsigned long r3, unsigned long r4, unsigned long r5,
  572. unsigned long r6, unsigned long r7)
  573. {
  574. /* isa_io_base gets set in pmac_find_bridges */
  575. isa_mem_base = PMAC_ISA_MEM_BASE;
  576. pci_dram_offset = PMAC_PCI_DRAM_OFFSET;
  577. ISA_DMA_THRESHOLD = ~0L;
  578. DMA_MODE_READ = 1;
  579. DMA_MODE_WRITE = 2;
  580. ppc_md.setup_arch = pmac_setup_arch;
  581. ppc_md.show_cpuinfo = pmac_show_cpuinfo;
  582. ppc_md.show_percpuinfo = pmac_show_percpuinfo;
  583. ppc_md.irq_canonicalize = NULL;
  584. ppc_md.init_IRQ = pmac_pic_init;
  585. ppc_md.get_irq = pmac_get_irq; /* Changed later on ... */
  586. ppc_md.pcibios_fixup = pmac_pcibios_fixup;
  587. ppc_md.pcibios_enable_device_hook = pmac_pci_enable_device_hook;
  588. ppc_md.pcibios_after_init = pmac_pcibios_after_init;
  589. ppc_md.phys_mem_access_prot = pci_phys_mem_access_prot;
  590. ppc_md.restart = pmac_restart;
  591. ppc_md.power_off = pmac_power_off;
  592. ppc_md.halt = pmac_halt;
  593. ppc_md.time_init = pmac_time_init;
  594. ppc_md.set_rtc_time = pmac_set_rtc_time;
  595. ppc_md.get_rtc_time = pmac_get_rtc_time;
  596. ppc_md.calibrate_decr = pmac_calibrate_decr;
  597. ppc_md.find_end_of_memory = pmac_find_end_of_memory;
  598. ppc_md.feature_call = pmac_do_feature_call;
  599. #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
  600. #ifdef CONFIG_BLK_DEV_IDE_PMAC
  601. ppc_ide_md.ide_init_hwif = pmac_ide_init_hwif_ports;
  602. ppc_ide_md.default_io_base = pmac_ide_get_base;
  603. #endif /* CONFIG_BLK_DEV_IDE_PMAC */
  604. #endif /* defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) */
  605. #ifdef CONFIG_BOOTX_TEXT
  606. ppc_md.progress = pmac_progress;
  607. #endif /* CONFIG_BOOTX_TEXT */
  608. if (ppc_md.progress) ppc_md.progress("pmac_init(): exit", 0);
  609. }
  610. #ifdef CONFIG_BOOTX_TEXT
  611. static void __init
  612. pmac_progress(char *s, unsigned short hex)
  613. {
  614. if (boot_text_mapped) {
  615. btext_drawstring(s);
  616. btext_drawchar('\n');
  617. }
  618. }
  619. #endif /* CONFIG_BOOTX_TEXT */
  620. static int __init
  621. pmac_declare_of_platform_devices(void)
  622. {
  623. struct device_node *np;
  624. np = find_devices("uni-n");
  625. if (np) {
  626. for (np = np->child; np != NULL; np = np->sibling)
  627. if (strncmp(np->name, "i2c", 3) == 0) {
  628. of_platform_device_create(np, "uni-n-i2c");
  629. break;
  630. }
  631. }
  632. np = find_devices("u3");
  633. if (np) {
  634. for (np = np->child; np != NULL; np = np->sibling)
  635. if (strncmp(np->name, "i2c", 3) == 0) {
  636. of_platform_device_create(np, "u3-i2c");
  637. break;
  638. }
  639. }
  640. np = find_devices("valkyrie");
  641. if (np)
  642. of_platform_device_create(np, "valkyrie");
  643. np = find_devices("platinum");
  644. if (np)
  645. of_platform_device_create(np, "platinum");
  646. return 0;
  647. }
  648. device_initcall(pmac_declare_of_platform_devices);