Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Board setup routines for the Emerson/Artesyn MVME7100
0004  *
0005  * Copyright 2016 Elettra-Sincrotrone Trieste S.C.p.A.
0006  *
0007  * Author: Alessio Igor Bogani <alessio.bogani@elettra.eu>
0008  *
0009  * Based on earlier code by:
0010  *
0011  *  Ajit Prem <ajit.prem@emerson.com>
0012  *  Copyright 2008 Emerson
0013  *
0014  * USB host fixup is borrowed by:
0015  *
0016  *  Martyn Welch <martyn.welch@ge.com>
0017  *  Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc.
0018  */
0019 
0020 #include <linux/pci.h>
0021 #include <linux/of.h>
0022 #include <linux/of_fdt.h>
0023 #include <linux/of_platform.h>
0024 #include <linux/of_address.h>
0025 #include <asm/udbg.h>
0026 #include <asm/mpic.h>
0027 #include <sysdev/fsl_soc.h>
0028 #include <sysdev/fsl_pci.h>
0029 
0030 #include "mpc86xx.h"
0031 
0032 #define MVME7100_INTERRUPT_REG_2_OFFSET 0x05
0033 #define MVME7100_DS1375_MASK        0x40
0034 #define MVME7100_MAX6649_MASK       0x20
0035 #define MVME7100_ABORT_MASK     0x10
0036 
0037 /*
0038  * Setup the architecture
0039  */
0040 static void __init mvme7100_setup_arch(void)
0041 {
0042     struct device_node *bcsr_node;
0043     void __iomem *mvme7100_regs = NULL;
0044     u8 reg;
0045 
0046     if (ppc_md.progress)
0047         ppc_md.progress("mvme7100_setup_arch()", 0);
0048 
0049 #ifdef CONFIG_SMP
0050     mpc86xx_smp_init();
0051 #endif
0052 
0053     fsl_pci_assign_primary();
0054 
0055     /* Remap BCSR registers */
0056     bcsr_node = of_find_compatible_node(NULL, NULL,
0057             "artesyn,mvme7100-bcsr");
0058     if (bcsr_node) {
0059         mvme7100_regs = of_iomap(bcsr_node, 0);
0060         of_node_put(bcsr_node);
0061     }
0062 
0063     if (mvme7100_regs) {
0064         /* Disable ds1375, max6649, and abort interrupts */
0065         reg = readb(mvme7100_regs + MVME7100_INTERRUPT_REG_2_OFFSET);
0066         reg |= MVME7100_DS1375_MASK | MVME7100_MAX6649_MASK
0067             | MVME7100_ABORT_MASK;
0068         writeb(reg, mvme7100_regs + MVME7100_INTERRUPT_REG_2_OFFSET);
0069     } else
0070         pr_warn("Unable to map board registers\n");
0071 
0072     pr_info("MVME7100 board from Artesyn\n");
0073 }
0074 
0075 /*
0076  * Called very early, device-tree isn't unflattened
0077  */
0078 static int __init mvme7100_probe(void)
0079 {
0080     unsigned long root = of_get_flat_dt_root();
0081 
0082     return of_flat_dt_is_compatible(root, "artesyn,MVME7100");
0083 }
0084 
0085 static void mvme7100_usb_host_fixup(struct pci_dev *pdev)
0086 {
0087     unsigned int val;
0088 
0089     if (!machine_is(mvme7100))
0090         return;
0091 
0092     /* Ensure only ports 1 & 2 are enabled */
0093     pci_read_config_dword(pdev, 0xe0, &val);
0094     pci_write_config_dword(pdev, 0xe0, (val & ~7) | 0x2);
0095 
0096     /* System clock is 48-MHz Oscillator and EHCI Enabled. */
0097     pci_write_config_dword(pdev, 0xe4, 1 << 5);
0098 }
0099 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,
0100     mvme7100_usb_host_fixup);
0101 
0102 machine_arch_initcall(mvme7100, mpc86xx_common_publish_devices);
0103 
0104 define_machine(mvme7100) {
0105     .name           = "MVME7100",
0106     .probe          = mvme7100_probe,
0107     .setup_arch     = mvme7100_setup_arch,
0108     .init_IRQ       = mpc86xx_init_irq,
0109     .get_irq        = mpic_get_irq,
0110     .time_init      = mpc86xx_time_init,
0111     .calibrate_decr     = generic_calibrate_decr,
0112     .progress       = udbg_progress,
0113 #ifdef CONFIG_PCI
0114     .pcibios_fixup_bus  = fsl_pcibios_fixup_bus,
0115 #endif
0116 };