mpc86xx_hpcn.c 4.1 KB

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