mpc86xx_hpcn.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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/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/swiotlb.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. struct pci_controller *hose;
  61. #endif
  62. dma_addr_t max = 0xffffffff;
  63. if (ppc_md.progress)
  64. ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
  65. #ifdef CONFIG_PCI
  66. for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
  67. struct resource rsrc;
  68. of_address_to_resource(np, 0, &rsrc);
  69. if ((rsrc.start & 0xfffff) == 0x8000)
  70. fsl_add_bridge(np, 1);
  71. else
  72. fsl_add_bridge(np, 0);
  73. hose = pci_find_hose_for_OF_device(np);
  74. max = min(max, hose->dma_window_base_cur +
  75. hose->dma_window_size);
  76. }
  77. ppc_md.pci_exclude_device = mpc86xx_exclude_device;
  78. #endif
  79. printk("MPC86xx HPCN board from Freescale Semiconductor\n");
  80. #ifdef CONFIG_SMP
  81. mpc86xx_smp_init();
  82. #endif
  83. #ifdef CONFIG_SWIOTLB
  84. if (memblock_end_of_DRAM() > max) {
  85. ppc_swiotlb_enable = 1;
  86. set_pci_dma_ops(&swiotlb_dma_ops);
  87. ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
  88. }
  89. #endif
  90. }
  91. static void
  92. mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
  93. {
  94. uint svid = mfspr(SPRN_SVR);
  95. seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
  96. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  97. }
  98. /*
  99. * Called very early, device-tree isn't unflattened
  100. */
  101. static int __init mpc86xx_hpcn_probe(void)
  102. {
  103. unsigned long root = of_get_flat_dt_root();
  104. if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn"))
  105. return 1; /* Looks good */
  106. /* Be nice and don't give silent boot death. Delete this in 2.6.27 */
  107. if (of_flat_dt_is_compatible(root, "mpc86xx")) {
  108. pr_warning("WARNING: your dts/dtb is old. You must update before the next kernel release\n");
  109. return 1;
  110. }
  111. return 0;
  112. }
  113. static long __init
  114. mpc86xx_time_init(void)
  115. {
  116. unsigned int temp;
  117. /* Set the time base to zero */
  118. mtspr(SPRN_TBWL, 0);
  119. mtspr(SPRN_TBWU, 0);
  120. temp = mfspr(SPRN_HID0);
  121. temp |= HID0_TBEN;
  122. mtspr(SPRN_HID0, temp);
  123. asm volatile("isync");
  124. return 0;
  125. }
  126. static __initdata struct of_device_id of_bus_ids[] = {
  127. { .compatible = "simple-bus", },
  128. { .compatible = "fsl,srio", },
  129. { .compatible = "gianfar", },
  130. {},
  131. };
  132. static int __init declare_of_platform_devices(void)
  133. {
  134. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  135. return 0;
  136. }
  137. machine_device_initcall(mpc86xx_hpcn, declare_of_platform_devices);
  138. machine_arch_initcall(mpc86xx_hpcn, swiotlb_setup_bus_notifier);
  139. define_machine(mpc86xx_hpcn) {
  140. .name = "MPC86xx HPCN",
  141. .probe = mpc86xx_hpcn_probe,
  142. .setup_arch = mpc86xx_hpcn_setup_arch,
  143. .init_IRQ = mpc86xx_init_irq,
  144. .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,
  145. .get_irq = mpic_get_irq,
  146. .restart = fsl_rstcr_restart,
  147. .time_init = mpc86xx_time_init,
  148. .calibrate_decr = generic_calibrate_decr,
  149. .progress = udbg_progress,
  150. #ifdef CONFIG_PCI
  151. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  152. #endif
  153. };