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 <alessio.bogani@elettra.eu> 8 * 9 * Based on earlier code by: 10 * 11 * Ajit Prem <ajit.prem@emerson.com> 12 * Copyright 2008 Emerson 13 * 14 * USB host fixup is borrowed by: 15 * 16 * Martyn Welch <martyn.welch@ge.com> 17 * Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc. 18 */ 19 20 #include <linux/pci.h> 21 #include <linux/of.h> 22 #include <linux/of_fdt.h> 23 #include <linux/of_platform.h> 24 #include <linux/of_address.h> 25 #include <asm/udbg.h> 26 #include <asm/mpic.h> 27 #include <sysdev/fsl_soc.h> 28 #include <sysdev/fsl_pci.h> 29 30 #include "mpc86xx.h" 31 32 #define MVME7100_INTERRUPT_REG_2_OFFSET 0x05 33 #define MVME7100_DS1375_MASK 0x40 34 #define MVME7100_MAX6649_MASK 0x20 35 #define MVME7100_ABORT_MASK 0x10 36 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 46 if (ppc_md.progress) 47 ppc_md.progress("mvme7100_setup_arch()", 0); 48 49 #ifdef CONFIG_SMP 50 mpc86xx_smp_init(); 51 #endif 52 53 fsl_pci_assign_primary(); 54 55 /* Remap BCSR registers */ 56 bcsr_node = of_find_compatible_node(NULL, NULL, 57 "artesyn,mvme7100-bcsr"); 58 if (bcsr_node) { 59 mvme7100_regs = of_iomap(bcsr_node, 0); 60 of_node_put(bcsr_node); 61 } 62 63 if (mvme7100_regs) { 64 /* Disable ds1375, max6649, and abort interrupts */ 65 reg = readb(mvme7100_regs + MVME7100_INTERRUPT_REG_2_OFFSET); 66 reg |= MVME7100_DS1375_MASK | MVME7100_MAX6649_MASK 67 | MVME7100_ABORT_MASK; 68 writeb(reg, mvme7100_regs + MVME7100_INTERRUPT_REG_2_OFFSET); 69 } else 70 pr_warn("Unable to map board registers\n"); 71 72 pr_info("MVME7100 board from Artesyn\n"); 73 } 74 75 /* 76 * Called very early, device-tree isn't unflattened 77 */ 78 static int __init mvme7100_probe(void) 79 { 80 unsigned long root = of_get_flat_dt_root(); 81 82 return of_flat_dt_is_compatible(root, "artesyn,MVME7100"); 83 } 84 85 static void mvme7100_usb_host_fixup(struct pci_dev *pdev) 86 { 87 unsigned int val; 88 89 if (!machine_is(mvme7100)) 90 return; 91 92 /* Ensure only ports 1 & 2 are enabled */ 93 pci_read_config_dword(pdev, 0xe0, &val); 94 pci_write_config_dword(pdev, 0xe0, (val & ~7) | 0x2); 95 96 /* System clock is 48-MHz Oscillator and EHCI Enabled. */ 97 pci_write_config_dword(pdev, 0xe4, 1 << 5); 98 } 99 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB, 100 mvme7100_usb_host_fixup); 101 102 machine_arch_initcall(mvme7100, mpc86xx_common_publish_devices); 103 104 define_machine(mvme7100) { 105 .name = "MVME7100", 106 .probe = mvme7100_probe, 107 .setup_arch = mvme7100_setup_arch, 108 .init_IRQ = mpc86xx_init_irq, 109 .get_irq = mpic_get_irq, 110 .time_init = mpc86xx_time_init, 111 .progress = udbg_progress, 112 #ifdef CONFIG_PCI 113 .pcibios_fixup_bus = fsl_pcibios_fixup_bus, 114 #endif 115 }; 116