gef_sbc610.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * GE Fanuc SBC610 board support
  3. *
  4. * Author: Martyn Welch <martyn.welch@gefanuc.com>
  5. *
  6. * Copyright 2008 GE Fanuc Intelligent Platforms Embedded Systems, Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * Based on: mpc86xx_hpcn.c (MPC86xx HPCN board specific routines)
  14. * Copyright 2006 Freescale Semiconductor Inc.
  15. *
  16. * NEC fixup adapted from arch/mips/pci/fixup-lm2e.c
  17. */
  18. #include <linux/stddef.h>
  19. #include <linux/kernel.h>
  20. #include <linux/pci.h>
  21. #include <linux/kdev_t.h>
  22. #include <linux/delay.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/of_platform.h>
  25. #include <asm/system.h>
  26. #include <asm/time.h>
  27. #include <asm/machdep.h>
  28. #include <asm/pci-bridge.h>
  29. #include <asm/mpc86xx.h>
  30. #include <asm/prom.h>
  31. #include <mm/mmu_decl.h>
  32. #include <asm/udbg.h>
  33. #include <asm/mpic.h>
  34. #include <sysdev/fsl_pci.h>
  35. #include <sysdev/fsl_soc.h>
  36. #include "mpc86xx.h"
  37. #undef DEBUG
  38. #ifdef DEBUG
  39. #define DBG (fmt...) do { printk(KERN_ERR "SBC610: " fmt); } while (0)
  40. #else
  41. #define DBG (fmt...) do { } while (0)
  42. #endif
  43. static void __init gef_sbc610_setup_arch(void)
  44. {
  45. #ifdef CONFIG_PCI
  46. struct device_node *np;
  47. for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
  48. fsl_add_bridge(np, 1);
  49. }
  50. #endif
  51. printk(KERN_INFO "GE Fanuc Intelligent Platforms SBC610 6U VPX SBC\n");
  52. #ifdef CONFIG_SMP
  53. mpc86xx_smp_init();
  54. #endif
  55. }
  56. static void gef_sbc610_show_cpuinfo(struct seq_file *m)
  57. {
  58. uint memsize = total_memory;
  59. uint svid = mfspr(SPRN_SVR);
  60. seq_printf(m, "Vendor\t\t: GE Fanuc Intelligent Platforms\n");
  61. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  62. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  63. }
  64. static void __init gef_sbc610_nec_fixup(struct pci_dev *pdev)
  65. {
  66. unsigned int val;
  67. printk(KERN_INFO "Running NEC uPD720101 Fixup\n");
  68. /* Ensure ports 1, 2, 3, 4 & 5 are enabled */
  69. pci_read_config_dword(pdev, 0xe0, &val);
  70. pci_write_config_dword(pdev, 0xe0, (val & ~7) | 0x5);
  71. /* System clock is 48-MHz Oscillator and EHCI Enabled. */
  72. pci_write_config_dword(pdev, 0xe4, 1 << 5);
  73. }
  74. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,
  75. gef_sbc610_nec_fixup);
  76. /*
  77. * Called very early, device-tree isn't unflattened
  78. *
  79. * This function is called to determine whether the BSP is compatible with the
  80. * supplied device-tree, which is assumed to be the correct one for the actual
  81. * board. It is expected thati, in the future, a kernel may support multiple
  82. * boards.
  83. */
  84. static int __init gef_sbc610_probe(void)
  85. {
  86. unsigned long root = of_get_flat_dt_root();
  87. if (of_flat_dt_is_compatible(root, "gef,sbc610"))
  88. return 1;
  89. return 0;
  90. }
  91. static long __init mpc86xx_time_init(void)
  92. {
  93. unsigned int temp;
  94. /* Set the time base to zero */
  95. mtspr(SPRN_TBWL, 0);
  96. mtspr(SPRN_TBWU, 0);
  97. temp = mfspr(SPRN_HID0);
  98. temp |= HID0_TBEN;
  99. mtspr(SPRN_HID0, temp);
  100. asm volatile("isync");
  101. return 0;
  102. }
  103. static __initdata struct of_device_id of_bus_ids[] = {
  104. { .compatible = "simple-bus", },
  105. {},
  106. };
  107. static int __init declare_of_platform_devices(void)
  108. {
  109. printk(KERN_DEBUG "Probe platform devices\n");
  110. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  111. return 0;
  112. }
  113. machine_device_initcall(gef_sbc610, declare_of_platform_devices);
  114. define_machine(gef_sbc610) {
  115. .name = "GE Fanuc SBC610",
  116. .probe = gef_sbc610_probe,
  117. .setup_arch = gef_sbc610_setup_arch,
  118. .init_IRQ = mpc86xx_init_irq,
  119. .show_cpuinfo = gef_sbc610_show_cpuinfo,
  120. .get_irq = mpic_get_irq,
  121. .restart = fsl_rstcr_restart,
  122. .time_init = mpc86xx_time_init,
  123. .calibrate_decr = generic_calibrate_decr,
  124. .progress = udbg_progress,
  125. #ifdef CONFIG_PCI
  126. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  127. #endif
  128. };