pmac_setup.c 18 KB

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