mpc86xx_hpcn.c 4.2 KB

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