mvme7100.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Board setup routines for the Emerson/Artesyn MVME7100
  4. *
  5. * Copyright 2016 Elettra-Sincrotrone Trieste S.C.p.A.
  6. *
  7. * Author: Alessio Igor Bogani <[email protected]>
  8. *
  9. * Based on earlier code by:
  10. *
  11. * Ajit Prem <[email protected]>
  12. * Copyright 2008 Emerson
  13. *
  14. * USB host fixup is borrowed by:
  15. *
  16. * Martyn Welch <[email protected]>
  17. * Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc.
  18. */
  19. #include <linux/pci.h>
  20. #include <linux/of.h>
  21. #include <linux/of_fdt.h>
  22. #include <linux/of_platform.h>
  23. #include <linux/of_address.h>
  24. #include <asm/udbg.h>
  25. #include <asm/mpic.h>
  26. #include <sysdev/fsl_soc.h>
  27. #include <sysdev/fsl_pci.h>
  28. #include "mpc86xx.h"
  29. #define MVME7100_INTERRUPT_REG_2_OFFSET 0x05
  30. #define MVME7100_DS1375_MASK 0x40
  31. #define MVME7100_MAX6649_MASK 0x20
  32. #define MVME7100_ABORT_MASK 0x10
  33. /*
  34. * Setup the architecture
  35. */
  36. static void __init mvme7100_setup_arch(void)
  37. {
  38. struct device_node *bcsr_node;
  39. void __iomem *mvme7100_regs = NULL;
  40. u8 reg;
  41. if (ppc_md.progress)
  42. ppc_md.progress("mvme7100_setup_arch()", 0);
  43. #ifdef CONFIG_SMP
  44. mpc86xx_smp_init();
  45. #endif
  46. fsl_pci_assign_primary();
  47. /* Remap BCSR registers */
  48. bcsr_node = of_find_compatible_node(NULL, NULL,
  49. "artesyn,mvme7100-bcsr");
  50. if (bcsr_node) {
  51. mvme7100_regs = of_iomap(bcsr_node, 0);
  52. of_node_put(bcsr_node);
  53. }
  54. if (mvme7100_regs) {
  55. /* Disable ds1375, max6649, and abort interrupts */
  56. reg = readb(mvme7100_regs + MVME7100_INTERRUPT_REG_2_OFFSET);
  57. reg |= MVME7100_DS1375_MASK | MVME7100_MAX6649_MASK
  58. | MVME7100_ABORT_MASK;
  59. writeb(reg, mvme7100_regs + MVME7100_INTERRUPT_REG_2_OFFSET);
  60. } else
  61. pr_warn("Unable to map board registers\n");
  62. pr_info("MVME7100 board from Artesyn\n");
  63. }
  64. /*
  65. * Called very early, device-tree isn't unflattened
  66. */
  67. static int __init mvme7100_probe(void)
  68. {
  69. unsigned long root = of_get_flat_dt_root();
  70. return of_flat_dt_is_compatible(root, "artesyn,MVME7100");
  71. }
  72. static void mvme7100_usb_host_fixup(struct pci_dev *pdev)
  73. {
  74. unsigned int val;
  75. if (!machine_is(mvme7100))
  76. return;
  77. /* Ensure only ports 1 & 2 are enabled */
  78. pci_read_config_dword(pdev, 0xe0, &val);
  79. pci_write_config_dword(pdev, 0xe0, (val & ~7) | 0x2);
  80. /* System clock is 48-MHz Oscillator and EHCI Enabled. */
  81. pci_write_config_dword(pdev, 0xe4, 1 << 5);
  82. }
  83. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,
  84. mvme7100_usb_host_fixup);
  85. machine_arch_initcall(mvme7100, mpc86xx_common_publish_devices);
  86. define_machine(mvme7100) {
  87. .name = "MVME7100",
  88. .probe = mvme7100_probe,
  89. .setup_arch = mvme7100_setup_arch,
  90. .init_IRQ = mpc86xx_init_irq,
  91. .get_irq = mpic_get_irq,
  92. .time_init = mpc86xx_time_init,
  93. .calibrate_decr = generic_calibrate_decr,
  94. .progress = udbg_progress,
  95. #ifdef CONFIG_PCI
  96. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  97. #endif
  98. };