sbc8548.c 3.6 KB

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