mvme7100.c 3.0 KB

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