sbc8548.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * Wind River SBC8548 setup and early boot code.
  3. *
  4. * Copyright 2007 Wind River Systems Inc.
  5. *
  6. * By Paul Gortmaker (see MAINTAINERS for contact information)
  7. *
  8. * Based largely on the MPC8548CDS support - Copyright 2005 Freescale Inc.
  9. *
  10. *
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License as published by the
  13. * Free Software Foundation; either version 2 of the License, or (at your
  14. * option) any later version.
  15. */
  16. #include <linux/stddef.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/errno.h>
  20. #include <linux/reboot.h>
  21. #include <linux/pci.h>
  22. #include <linux/kdev_t.h>
  23. #include <linux/major.h>
  24. #include <linux/console.h>
  25. #include <linux/delay.h>
  26. #include <linux/seq_file.h>
  27. #include <linux/initrd.h>
  28. #include <linux/module.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/fsl_devices.h>
  31. #include <linux/of_platform.h>
  32. #include <asm/system.h>
  33. #include <asm/pgtable.h>
  34. #include <asm/page.h>
  35. #include <asm/atomic.h>
  36. #include <asm/time.h>
  37. #include <asm/io.h>
  38. #include <asm/machdep.h>
  39. #include <asm/ipic.h>
  40. #include <asm/pci-bridge.h>
  41. #include <asm/irq.h>
  42. #include <mm/mmu_decl.h>
  43. #include <asm/prom.h>
  44. #include <asm/udbg.h>
  45. #include <asm/mpic.h>
  46. #include <sysdev/fsl_soc.h>
  47. #include <sysdev/fsl_pci.h>
  48. static int sbc_rev;
  49. static void __init sbc8548_pic_init(void)
  50. {
  51. struct mpic *mpic;
  52. struct resource r;
  53. struct device_node *np = NULL;
  54. np = of_find_node_by_type(np, "open-pic");
  55. if (np == NULL) {
  56. printk(KERN_ERR "Could not find open-pic node\n");
  57. return;
  58. }
  59. if (of_address_to_resource(np, 0, &r)) {
  60. printk(KERN_ERR "Failed to map mpic register space\n");
  61. of_node_put(np);
  62. return;
  63. }
  64. mpic = mpic_alloc(np, r.start,
  65. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  66. 0, 256, " OpenPIC ");
  67. BUG_ON(mpic == NULL);
  68. /* Return the mpic node */
  69. of_node_put(np);
  70. mpic_init(mpic);
  71. }
  72. /* Extract the HW Rev from the EPLD on the board */
  73. static int __init sbc8548_hw_rev(void)
  74. {
  75. struct device_node *np;
  76. struct resource res;
  77. unsigned int *rev;
  78. int board_rev = 0;
  79. np = of_find_compatible_node(NULL, NULL, "hw-rev");
  80. if (np == NULL) {
  81. printk("No HW-REV found in DTB.\n");
  82. return -ENODEV;
  83. }
  84. of_address_to_resource(np, 0, &res);
  85. of_node_put(np);
  86. rev = ioremap(res.start,sizeof(unsigned int));
  87. board_rev = (*rev) >> 28;
  88. iounmap(rev);
  89. return board_rev;
  90. }
  91. /*
  92. * Setup the architecture
  93. */
  94. static void __init sbc8548_setup_arch(void)
  95. {
  96. #ifdef CONFIG_PCI
  97. struct device_node *np;
  98. #endif
  99. if (ppc_md.progress)
  100. ppc_md.progress("sbc8548_setup_arch()", 0);
  101. #ifdef CONFIG_PCI
  102. for_each_node_by_type(np, "pci") {
  103. if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  104. of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
  105. struct resource rsrc;
  106. of_address_to_resource(np, 0, &rsrc);
  107. if ((rsrc.start & 0xfffff) == 0x8000)
  108. fsl_add_bridge(np, 1);
  109. else
  110. fsl_add_bridge(np, 0);
  111. }
  112. }
  113. #endif
  114. sbc_rev = sbc8548_hw_rev();
  115. }
  116. static void sbc8548_show_cpuinfo(struct seq_file *m)
  117. {
  118. uint pvid, svid, phid1;
  119. pvid = mfspr(SPRN_PVR);
  120. svid = mfspr(SPRN_SVR);
  121. seq_printf(m, "Vendor\t\t: Wind River\n");
  122. seq_printf(m, "Machine\t\t: SBC8548 v%d\n", sbc_rev);
  123. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  124. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  125. /* Display cpu Pll setting */
  126. phid1 = mfspr(SPRN_HID1);
  127. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  128. }
  129. static struct of_device_id __initdata of_bus_ids[] = {
  130. { .name = "soc", },
  131. { .type = "soc", },
  132. { .compatible = "simple-bus", },
  133. { .compatible = "gianfar", },
  134. {},
  135. };
  136. static int __init declare_of_platform_devices(void)
  137. {
  138. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  139. return 0;
  140. }
  141. machine_device_initcall(sbc8548, declare_of_platform_devices);
  142. /*
  143. * Called very early, device-tree isn't unflattened
  144. */
  145. static int __init sbc8548_probe(void)
  146. {
  147. unsigned long root = of_get_flat_dt_root();
  148. return of_flat_dt_is_compatible(root, "SBC8548");
  149. }
  150. define_machine(sbc8548) {
  151. .name = "SBC8548",
  152. .probe = sbc8548_probe,
  153. .setup_arch = sbc8548_setup_arch,
  154. .init_IRQ = sbc8548_pic_init,
  155. .show_cpuinfo = sbc8548_show_cpuinfo,
  156. .get_irq = mpic_get_irq,
  157. .restart = fsl_rstcr_restart,
  158. #ifdef CONFIG_PCI
  159. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  160. #endif
  161. .calibrate_decr = generic_calibrate_decr,
  162. .progress = udbg_progress,
  163. };