mpc86xx_hpcn.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * MPC86xx HPCN board specific routines
  3. *
  4. * Recode: ZHANG WEI <wei.zhang@freescale.com>
  5. * Initial author: Xianghua Xiao <x.xiao@freescale.com>
  6. *
  7. * Copyright 2006 Freescale Semiconductor Inc.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. */
  14. #include <linux/stddef.h>
  15. #include <linux/kernel.h>
  16. #include <linux/pci.h>
  17. #include <linux/kdev_t.h>
  18. #include <linux/delay.h>
  19. #include <linux/seq_file.h>
  20. #include <linux/of_platform.h>
  21. #include <asm/system.h>
  22. #include <asm/time.h>
  23. #include <asm/machdep.h>
  24. #include <asm/pci-bridge.h>
  25. #include <asm/mpc86xx.h>
  26. #include <asm/prom.h>
  27. #include <mm/mmu_decl.h>
  28. #include <asm/udbg.h>
  29. #include <asm/mpic.h>
  30. #include <sysdev/fsl_pci.h>
  31. #include <sysdev/fsl_soc.h>
  32. #include "mpc86xx.h"
  33. #undef DEBUG
  34. #ifdef DEBUG
  35. #define DBG(fmt...) do { printk(KERN_ERR fmt); } while(0)
  36. #else
  37. #define DBG(fmt...) do { } while(0)
  38. #endif
  39. #ifdef CONFIG_PCI
  40. extern int uli_exclude_device(struct pci_controller *hose,
  41. u_char bus, u_char devfn);
  42. static int mpc86xx_exclude_device(struct pci_controller *hose,
  43. u_char bus, u_char devfn)
  44. {
  45. struct device_node* node;
  46. struct resource rsrc;
  47. node = hose->dn;
  48. of_address_to_resource(node, 0, &rsrc);
  49. if ((rsrc.start & 0xfffff) == 0x8000) {
  50. return uli_exclude_device(hose, bus, devfn);
  51. }
  52. return PCIBIOS_SUCCESSFUL;
  53. }
  54. #endif /* CONFIG_PCI */
  55. static void __init
  56. mpc86xx_hpcn_setup_arch(void)
  57. {
  58. #ifdef CONFIG_PCI
  59. struct device_node *np;
  60. #endif
  61. if (ppc_md.progress)
  62. ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
  63. #ifdef CONFIG_PCI
  64. for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
  65. struct resource rsrc;
  66. of_address_to_resource(np, 0, &rsrc);
  67. if ((rsrc.start & 0xfffff) == 0x8000)
  68. fsl_add_bridge(np, 1);
  69. else
  70. fsl_add_bridge(np, 0);
  71. }
  72. ppc_md.pci_exclude_device = mpc86xx_exclude_device;
  73. #endif
  74. printk("MPC86xx HPCN board from Freescale Semiconductor\n");
  75. #ifdef CONFIG_SMP
  76. mpc86xx_smp_init();
  77. #endif
  78. }
  79. static void
  80. mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
  81. {
  82. uint svid = mfspr(SPRN_SVR);
  83. seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
  84. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  85. }
  86. /*
  87. * Called very early, device-tree isn't unflattened
  88. */
  89. static int __init mpc86xx_hpcn_probe(void)
  90. {
  91. unsigned long root = of_get_flat_dt_root();
  92. if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn"))
  93. return 1; /* Looks good */
  94. /* Be nice and don't give silent boot death. Delete this in 2.6.27 */
  95. if (of_flat_dt_is_compatible(root, "mpc86xx")) {
  96. pr_warning("WARNING: your dts/dtb is old. You must update before the next kernel release\n");
  97. return 1;
  98. }
  99. return 0;
  100. }
  101. static long __init
  102. mpc86xx_time_init(void)
  103. {
  104. unsigned int temp;
  105. /* Set the time base to zero */
  106. mtspr(SPRN_TBWL, 0);
  107. mtspr(SPRN_TBWU, 0);
  108. temp = mfspr(SPRN_HID0);
  109. temp |= HID0_TBEN;
  110. mtspr(SPRN_HID0, temp);
  111. asm volatile("isync");
  112. return 0;
  113. }
  114. static __initdata struct of_device_id of_bus_ids[] = {
  115. { .compatible = "simple-bus", },
  116. { .compatible = "fsl,rapidio-delta", },
  117. { .compatible = "gianfar", },
  118. {},
  119. };
  120. static int __init declare_of_platform_devices(void)
  121. {
  122. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  123. return 0;
  124. }
  125. machine_device_initcall(mpc86xx_hpcn, declare_of_platform_devices);
  126. define_machine(mpc86xx_hpcn) {
  127. .name = "MPC86xx HPCN",
  128. .probe = mpc86xx_hpcn_probe,
  129. .setup_arch = mpc86xx_hpcn_setup_arch,
  130. .init_IRQ = mpc86xx_init_irq,
  131. .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,
  132. .get_irq = mpic_get_irq,
  133. .restart = fsl_rstcr_restart,
  134. .time_init = mpc86xx_time_init,
  135. .calibrate_decr = generic_calibrate_decr,
  136. .progress = udbg_progress,
  137. #ifdef CONFIG_PCI
  138. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  139. #endif
  140. };