Commit | Line | Data |
---|---|---|
97493e2e AIB |
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 | ||
25 | #include <linux/pci.h> | |
26 | #include <linux/of.h> | |
27 | #include <linux/of_platform.h> | |
28 | #include <linux/of_address.h> | |
29 | #include <asm/udbg.h> | |
30 | #include <asm/mpic.h> | |
31 | #include <sysdev/fsl_soc.h> | |
32 | #include <sysdev/fsl_pci.h> | |
33 | ||
34 | #include "mpc86xx.h" | |
35 | ||
36 | #define MVME7100_INTERRUPT_REG_2_OFFSET 0x05 | |
37 | #define MVME7100_DS1375_MASK 0x40 | |
38 | #define MVME7100_MAX6649_MASK 0x20 | |
39 | #define MVME7100_ABORT_MASK 0x10 | |
40 | ||
41 | /* | |
42 | * Setup the architecture | |
43 | */ | |
44 | static void __init mvme7100_setup_arch(void) | |
45 | { | |
46 | struct device_node *bcsr_node; | |
47 | void __iomem *mvme7100_regs = NULL; | |
48 | u8 reg; | |
49 | ||
50 | if (ppc_md.progress) | |
51 | ppc_md.progress("mvme7100_setup_arch()", 0); | |
52 | ||
53 | #ifdef CONFIG_SMP | |
54 | mpc86xx_smp_init(); | |
55 | #endif | |
56 | ||
57 | fsl_pci_assign_primary(); | |
58 | ||
59 | /* Remap BCSR registers */ | |
60 | bcsr_node = of_find_compatible_node(NULL, NULL, | |
61 | "artesyn,mvme7100-bcsr"); | |
62 | if (bcsr_node) { | |
63 | mvme7100_regs = of_iomap(bcsr_node, 0); | |
64 | of_node_put(bcsr_node); | |
65 | } | |
66 | ||
67 | if (mvme7100_regs) { | |
68 | /* Disable ds1375, max6649, and abort interrupts */ | |
69 | reg = readb(mvme7100_regs + MVME7100_INTERRUPT_REG_2_OFFSET); | |
70 | reg |= MVME7100_DS1375_MASK | MVME7100_MAX6649_MASK | |
71 | | MVME7100_ABORT_MASK; | |
72 | writeb(reg, mvme7100_regs + MVME7100_INTERRUPT_REG_2_OFFSET); | |
73 | } else | |
74 | pr_warn("Unable to map board registers\n"); | |
75 | ||
76 | pr_info("MVME7100 board from Artesyn\n"); | |
77 | } | |
78 | ||
79 | /* | |
80 | * Called very early, device-tree isn't unflattened | |
81 | */ | |
82 | static int __init mvme7100_probe(void) | |
83 | { | |
84 | unsigned long root = of_get_flat_dt_root(); | |
85 | ||
86 | return of_flat_dt_is_compatible(root, "artesyn,MVME7100"); | |
87 | } | |
88 | ||
89 | static void mvme7100_usb_host_fixup(struct pci_dev *pdev) | |
90 | { | |
91 | unsigned int val; | |
92 | ||
93 | if (!machine_is(mvme7100)) | |
94 | return; | |
95 | ||
96 | /* Ensure only ports 1 & 2 are enabled */ | |
97 | pci_read_config_dword(pdev, 0xe0, &val); | |
98 | pci_write_config_dword(pdev, 0xe0, (val & ~7) | 0x2); | |
99 | ||
100 | /* System clock is 48-MHz Oscillator and EHCI Enabled. */ | |
101 | pci_write_config_dword(pdev, 0xe4, 1 << 5); | |
102 | } | |
103 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB, | |
104 | mvme7100_usb_host_fixup); | |
105 | ||
106 | machine_arch_initcall(mvme7100, mpc86xx_common_publish_devices); | |
107 | ||
108 | define_machine(mvme7100) { | |
109 | .name = "MVME7100", | |
110 | .probe = mvme7100_probe, | |
111 | .setup_arch = mvme7100_setup_arch, | |
112 | .init_IRQ = mpc86xx_init_irq, | |
113 | .get_irq = mpic_get_irq, | |
114 | .restart = fsl_rstcr_restart, | |
115 | .time_init = mpc86xx_time_init, | |
116 | .calibrate_decr = generic_calibrate_decr, | |
117 | .progress = udbg_progress, | |
118 | #ifdef CONFIG_PCI | |
119 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, | |
120 | #endif | |
121 | }; |