mpc86xx_hpcn.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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/prom.h>
  26. #include <mm/mmu_decl.h>
  27. #include <asm/udbg.h>
  28. #include <asm/mpic.h>
  29. #include <sysdev/fsl_pci.h>
  30. #include <sysdev/fsl_soc.h>
  31. #include "mpc86xx.h"
  32. #undef DEBUG
  33. #ifdef DEBUG
  34. #define DBG(fmt...) do { printk(KERN_ERR fmt); } while(0)
  35. #else
  36. #define DBG(fmt...) do { } while(0)
  37. #endif
  38. #ifdef CONFIG_PCI
  39. extern int uli_exclude_device(struct pci_controller *hose,
  40. u_char bus, u_char devfn);
  41. static int mpc86xx_exclude_device(struct pci_controller *hose,
  42. u_char bus, u_char devfn)
  43. {
  44. struct device_node* node;
  45. struct resource rsrc;
  46. node = hose->dn;
  47. of_address_to_resource(node, 0, &rsrc);
  48. if ((rsrc.start & 0xfffff) == 0x8000) {
  49. return uli_exclude_device(hose, bus, devfn);
  50. }
  51. return PCIBIOS_SUCCESSFUL;
  52. }
  53. #endif /* CONFIG_PCI */
  54. static void __init
  55. mpc86xx_hpcn_setup_arch(void)
  56. {
  57. #ifdef CONFIG_PCI
  58. struct device_node *np;
  59. #endif
  60. if (ppc_md.progress)
  61. ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
  62. #ifdef CONFIG_PCI
  63. for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
  64. struct resource rsrc;
  65. of_address_to_resource(np, 0, &rsrc);
  66. if ((rsrc.start & 0xfffff) == 0x8000)
  67. fsl_add_bridge(np, 1);
  68. else
  69. fsl_add_bridge(np, 0);
  70. }
  71. ppc_md.pci_exclude_device = mpc86xx_exclude_device;
  72. #endif
  73. printk("MPC86xx HPCN board from Freescale Semiconductor\n");
  74. #ifdef CONFIG_SMP
  75. mpc86xx_smp_init();
  76. #endif
  77. }
  78. static void
  79. mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
  80. {
  81. uint svid = mfspr(SPRN_SVR);
  82. seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
  83. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  84. }
  85. /*
  86. * Called very early, device-tree isn't unflattened
  87. */
  88. static int __init mpc86xx_hpcn_probe(void)
  89. {
  90. unsigned long root = of_get_flat_dt_root();
  91. if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn"))
  92. return 1; /* Looks good */
  93. /* Be nice and don't give silent boot death. Delete this in 2.6.27 */
  94. if (of_flat_dt_is_compatible(root, "mpc86xx")) {
  95. pr_warning("WARNING: your dts/dtb is old. You must update before the next kernel release\n");
  96. return 1;
  97. }
  98. return 0;
  99. }
  100. static long __init
  101. mpc86xx_time_init(void)
  102. {
  103. unsigned int temp;
  104. /* Set the time base to zero */
  105. mtspr(SPRN_TBWL, 0);
  106. mtspr(SPRN_TBWU, 0);
  107. temp = mfspr(SPRN_HID0);
  108. temp |= HID0_TBEN;
  109. mtspr(SPRN_HID0, temp);
  110. asm volatile("isync");
  111. return 0;
  112. }
  113. static __initdata struct of_device_id of_bus_ids[] = {
  114. { .compatible = "simple-bus", },
  115. { .compatible = "fsl,rapidio-delta", },
  116. { .compatible = "gianfar", },
  117. {},
  118. };
  119. static int __init declare_of_platform_devices(void)
  120. {
  121. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  122. return 0;
  123. }
  124. machine_device_initcall(mpc86xx_hpcn, declare_of_platform_devices);
  125. define_machine(mpc86xx_hpcn) {
  126. .name = "MPC86xx HPCN",
  127. .probe = mpc86xx_hpcn_probe,
  128. .setup_arch = mpc86xx_hpcn_setup_arch,
  129. .init_IRQ = mpc86xx_init_irq,
  130. .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,
  131. .get_irq = mpic_get_irq,
  132. .restart = fsl_rstcr_restart,
  133. .time_init = mpc86xx_time_init,
  134. .calibrate_decr = generic_calibrate_decr,
  135. .progress = udbg_progress,
  136. #ifdef CONFIG_PCI
  137. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  138. #endif
  139. };