sbc8548.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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/interrupt.h>
  29. #include <linux/fsl_devices.h>
  30. #include <linux/of_platform.h>
  31. #include <asm/system.h>
  32. #include <asm/pgtable.h>
  33. #include <asm/page.h>
  34. #include <linux/atomic.h>
  35. #include <asm/time.h>
  36. #include <asm/io.h>
  37. #include <asm/machdep.h>
  38. #include <asm/ipic.h>
  39. #include <asm/pci-bridge.h>
  40. #include <asm/irq.h>
  41. #include <mm/mmu_decl.h>
  42. #include <asm/prom.h>
  43. #include <asm/udbg.h>
  44. #include <asm/mpic.h>
  45. #include <sysdev/fsl_soc.h>
  46. #include <sysdev/fsl_pci.h>
  47. #include "mpc85xx.h"
  48. static int sbc_rev;
  49. static void __init sbc8548_pic_init(void)
  50. {
  51. struct mpic *mpic = mpic_alloc(NULL, 0,
  52. MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  53. 0, 256, " OpenPIC ");
  54. BUG_ON(mpic == NULL);
  55. mpic_init(mpic);
  56. }
  57. /* Extract the HW Rev from the EPLD on the board */
  58. static int __init sbc8548_hw_rev(void)
  59. {
  60. struct device_node *np;
  61. struct resource res;
  62. unsigned int *rev;
  63. int board_rev = 0;
  64. np = of_find_compatible_node(NULL, NULL, "hw-rev");
  65. if (np == NULL) {
  66. printk("No HW-REV found in DTB.\n");
  67. return -ENODEV;
  68. }
  69. of_address_to_resource(np, 0, &res);
  70. of_node_put(np);
  71. rev = ioremap(res.start,sizeof(unsigned int));
  72. board_rev = (*rev) >> 28;
  73. iounmap(rev);
  74. return board_rev;
  75. }
  76. /*
  77. * Setup the architecture
  78. */
  79. static void __init sbc8548_setup_arch(void)
  80. {
  81. #ifdef CONFIG_PCI
  82. struct device_node *np;
  83. #endif
  84. if (ppc_md.progress)
  85. ppc_md.progress("sbc8548_setup_arch()", 0);
  86. #ifdef CONFIG_PCI
  87. for_each_node_by_type(np, "pci") {
  88. if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  89. of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
  90. struct resource rsrc;
  91. of_address_to_resource(np, 0, &rsrc);
  92. if ((rsrc.start & 0xfffff) == 0x8000)
  93. fsl_add_bridge(np, 1);
  94. else
  95. fsl_add_bridge(np, 0);
  96. }
  97. }
  98. #endif
  99. sbc_rev = sbc8548_hw_rev();
  100. }
  101. static void sbc8548_show_cpuinfo(struct seq_file *m)
  102. {
  103. uint pvid, svid, phid1;
  104. pvid = mfspr(SPRN_PVR);
  105. svid = mfspr(SPRN_SVR);
  106. seq_printf(m, "Vendor\t\t: Wind River\n");
  107. seq_printf(m, "Machine\t\t: SBC8548 v%d\n", sbc_rev);
  108. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  109. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  110. /* Display cpu Pll setting */
  111. phid1 = mfspr(SPRN_HID1);
  112. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  113. }
  114. machine_device_initcall(sbc8548, mpc85xx_common_publish_devices);
  115. /*
  116. * Called very early, device-tree isn't unflattened
  117. */
  118. static int __init sbc8548_probe(void)
  119. {
  120. unsigned long root = of_get_flat_dt_root();
  121. return of_flat_dt_is_compatible(root, "SBC8548");
  122. }
  123. define_machine(sbc8548) {
  124. .name = "SBC8548",
  125. .probe = sbc8548_probe,
  126. .setup_arch = sbc8548_setup_arch,
  127. .init_IRQ = sbc8548_pic_init,
  128. .show_cpuinfo = sbc8548_show_cpuinfo,
  129. .get_irq = mpic_get_irq,
  130. .restart = fsl_rstcr_restart,
  131. #ifdef CONFIG_PCI
  132. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  133. #endif
  134. .calibrate_decr = generic_calibrate_decr,
  135. .progress = udbg_progress,
  136. };