2 * arch/arm/mach-orion/common.c
4 * Core functions for Marvell Orion System On Chip
6 * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/serial_8250.h>
17 #include <linux/mv643xx_eth.h>
19 #include <asm/timex.h>
20 #include <asm/mach/map.h>
21 #include <asm/arch/orion.h>
24 /*****************************************************************************
26 ****************************************************************************/
27 static struct map_desc orion_io_desc[] __initdata = {
29 .virtual = ORION_REGS_BASE,
30 .pfn = __phys_to_pfn(ORION_REGS_BASE),
31 .length = ORION_REGS_SIZE,
35 .virtual = ORION_PCIE_IO_BASE,
36 .pfn = __phys_to_pfn(ORION_PCIE_IO_BASE),
37 .length = ORION_PCIE_IO_SIZE,
41 .virtual = ORION_PCI_IO_BASE,
42 .pfn = __phys_to_pfn(ORION_PCI_IO_BASE),
43 .length = ORION_PCI_IO_SIZE,
47 .virtual = ORION_PCIE_WA_BASE,
48 .pfn = __phys_to_pfn(ORION_PCIE_WA_BASE),
49 .length = ORION_PCIE_WA_SIZE,
54 void __init orion_map_io(void)
56 iotable_init(orion_io_desc, ARRAY_SIZE(orion_io_desc));
59 /*****************************************************************************
61 ****************************************************************************/
63 static struct resource orion_uart_resources[] = {
66 .end = UART0_BASE + 0xff,
67 .flags = IORESOURCE_MEM,
70 .start = IRQ_ORION_UART0,
71 .end = IRQ_ORION_UART0,
72 .flags = IORESOURCE_IRQ,
76 .end = UART1_BASE + 0xff,
77 .flags = IORESOURCE_MEM,
80 .start = IRQ_ORION_UART1,
81 .end = IRQ_ORION_UART1,
82 .flags = IORESOURCE_IRQ,
86 static struct plat_serial8250_port orion_uart_data[] = {
88 .mapbase = UART0_BASE,
89 .membase = (char *)UART0_BASE,
90 .irq = IRQ_ORION_UART0,
91 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
94 .uartclk = ORION_TCLK,
97 .mapbase = UART1_BASE,
98 .membase = (char *)UART1_BASE,
99 .irq = IRQ_ORION_UART1,
100 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
103 .uartclk = ORION_TCLK,
108 static struct platform_device orion_uart = {
109 .name = "serial8250",
110 .id = PLAT8250_DEV_PLATFORM,
112 .platform_data = orion_uart_data,
114 .resource = orion_uart_resources,
115 .num_resources = ARRAY_SIZE(orion_uart_resources),
118 /*******************************************************************************
119 * USB Controller - 2 interfaces
120 ******************************************************************************/
122 static struct resource orion_ehci0_resources[] = {
124 .start = ORION_USB0_REG_BASE,
125 .end = ORION_USB0_REG_BASE + SZ_4K,
126 .flags = IORESOURCE_MEM,
129 .start = IRQ_ORION_USB0_CTRL,
130 .end = IRQ_ORION_USB0_CTRL,
131 .flags = IORESOURCE_IRQ,
135 static struct resource orion_ehci1_resources[] = {
137 .start = ORION_USB1_REG_BASE,
138 .end = ORION_USB1_REG_BASE + SZ_4K,
139 .flags = IORESOURCE_MEM,
142 .start = IRQ_ORION_USB1_CTRL,
143 .end = IRQ_ORION_USB1_CTRL,
144 .flags = IORESOURCE_IRQ,
148 static u64 ehci_dmamask = 0xffffffffUL;
150 static struct platform_device orion_ehci0 = {
151 .name = "orion-ehci",
154 .dma_mask = &ehci_dmamask,
155 .coherent_dma_mask = 0xffffffff,
157 .resource = orion_ehci0_resources,
158 .num_resources = ARRAY_SIZE(orion_ehci0_resources),
161 static struct platform_device orion_ehci1 = {
162 .name = "orion-ehci",
165 .dma_mask = &ehci_dmamask,
166 .coherent_dma_mask = 0xffffffff,
168 .resource = orion_ehci1_resources,
169 .num_resources = ARRAY_SIZE(orion_ehci1_resources),
172 /*****************************************************************************
173 * Gigabit Ethernet port
174 * (The Orion and Discovery (MV643xx) families use the same Ethernet driver)
175 ****************************************************************************/
177 static struct resource orion_eth_shared_resources[] = {
179 .start = ORION_ETH_REG_BASE,
180 .end = ORION_ETH_REG_BASE + 0xffff,
181 .flags = IORESOURCE_MEM,
185 static struct platform_device orion_eth_shared = {
186 .name = MV643XX_ETH_SHARED_NAME,
189 .resource = orion_eth_shared_resources,
192 static struct resource orion_eth_resources[] = {
195 .start = IRQ_ORION_ETH_SUM,
196 .end = IRQ_ORION_ETH_SUM,
197 .flags = IORESOURCE_IRQ,
201 static struct platform_device orion_eth = {
202 .name = MV643XX_ETH_NAME,
205 .resource = orion_eth_resources,
208 void __init orion_eth_init(struct mv643xx_eth_platform_data *eth_data)
210 orion_eth.dev.platform_data = eth_data;
211 platform_device_register(&orion_eth_shared);
212 platform_device_register(&orion_eth);
215 /*****************************************************************************
217 ****************************************************************************/
220 * Identify device ID and rev from PCIE configuration header space '0'.
222 static void orion_id(u32 *dev, u32 *rev, char **dev_name)
224 orion_pcie_id(dev, rev);
226 if (*dev == MV88F5281_DEV_ID) {
227 if (*rev == MV88F5281_REV_D2) {
228 *dev_name = "MV88F5281-D2";
229 } else if (*rev == MV88F5281_REV_D1) {
230 *dev_name = "MV88F5281-D1";
232 *dev_name = "MV88F5281-Rev-Unsupported";
234 } else if (*dev == MV88F5182_DEV_ID) {
235 if (*rev == MV88F5182_REV_A2) {
236 *dev_name = "MV88F5182-A2";
238 *dev_name = "MV88F5182-Rev-Unsupported";
240 } else if (*dev == MV88F5181_DEV_ID) {
241 if (*rev == MV88F5181_REV_B1) {
242 *dev_name = "MV88F5181-Rev-B1";
244 *dev_name = "MV88F5181-Rev-Unsupported";
247 *dev_name = "Device-Unknown";
251 void __init orion_init(void)
256 orion_id(&dev, &rev, &dev_name);
257 printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, ORION_TCLK);
260 * Setup Orion address map
262 orion_setup_cpu_wins();
263 orion_setup_usb_wins();
264 orion_setup_eth_wins();
265 orion_setup_pci_wins();
266 orion_setup_pcie_wins();
267 if (dev == MV88F5182_DEV_ID)
268 orion_setup_sata_wins();
273 platform_device_register(&orion_uart);
274 platform_device_register(&orion_ehci0);
275 if (dev == MV88F5182_DEV_ID)
276 platform_device_register(&orion_ehci1);