2 * arch/arm/mach-orion5x/common.c
4 * Core functions for Marvell Orion 5x SoCs
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/mbus.h>
18 #include <linux/mv643xx_eth.h>
19 #include <linux/mv643xx_i2c.h>
20 #include <linux/ata_platform.h>
22 #include <asm/setup.h>
23 #include <asm/timex.h>
24 #include <asm/mach/arch.h>
25 #include <asm/mach/map.h>
26 #include <asm/mach/time.h>
27 #include <asm/arch/hardware.h>
28 #include <asm/arch/orion5x.h>
29 #include <asm/plat-orion/ehci-orion.h>
30 #include <asm/plat-orion/orion_nand.h>
31 #include <asm/plat-orion/time.h>
34 /*****************************************************************************
36 ****************************************************************************/
37 static struct map_desc orion5x_io_desc[] __initdata = {
39 .virtual = ORION5X_REGS_VIRT_BASE,
40 .pfn = __phys_to_pfn(ORION5X_REGS_PHYS_BASE),
41 .length = ORION5X_REGS_SIZE,
44 .virtual = ORION5X_PCIE_IO_VIRT_BASE,
45 .pfn = __phys_to_pfn(ORION5X_PCIE_IO_PHYS_BASE),
46 .length = ORION5X_PCIE_IO_SIZE,
49 .virtual = ORION5X_PCI_IO_VIRT_BASE,
50 .pfn = __phys_to_pfn(ORION5X_PCI_IO_PHYS_BASE),
51 .length = ORION5X_PCI_IO_SIZE,
54 .virtual = ORION5X_PCIE_WA_VIRT_BASE,
55 .pfn = __phys_to_pfn(ORION5X_PCIE_WA_PHYS_BASE),
56 .length = ORION5X_PCIE_WA_SIZE,
61 void __init orion5x_map_io(void)
63 iotable_init(orion5x_io_desc, ARRAY_SIZE(orion5x_io_desc));
66 /*****************************************************************************
68 ****************************************************************************/
70 static struct resource orion5x_uart_resources[] = {
72 .start = UART0_PHYS_BASE,
73 .end = UART0_PHYS_BASE + 0xff,
74 .flags = IORESOURCE_MEM,
76 .start = IRQ_ORION5X_UART0,
77 .end = IRQ_ORION5X_UART0,
78 .flags = IORESOURCE_IRQ,
80 .start = UART1_PHYS_BASE,
81 .end = UART1_PHYS_BASE + 0xff,
82 .flags = IORESOURCE_MEM,
84 .start = IRQ_ORION5X_UART1,
85 .end = IRQ_ORION5X_UART1,
86 .flags = IORESOURCE_IRQ,
90 static struct plat_serial8250_port orion5x_uart_data[] = {
92 .mapbase = UART0_PHYS_BASE,
93 .membase = (char *)UART0_VIRT_BASE,
94 .irq = IRQ_ORION5X_UART0,
95 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
98 .uartclk = ORION5X_TCLK,
100 .mapbase = UART1_PHYS_BASE,
101 .membase = (char *)UART1_VIRT_BASE,
102 .irq = IRQ_ORION5X_UART1,
103 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
106 .uartclk = ORION5X_TCLK,
111 static struct platform_device orion5x_uart = {
112 .name = "serial8250",
113 .id = PLAT8250_DEV_PLATFORM,
115 .platform_data = orion5x_uart_data,
117 .resource = orion5x_uart_resources,
118 .num_resources = ARRAY_SIZE(orion5x_uart_resources),
121 /*******************************************************************************
122 * USB Controller - 2 interfaces
123 ******************************************************************************/
125 static struct resource orion5x_ehci0_resources[] = {
127 .start = ORION5X_USB0_PHYS_BASE,
128 .end = ORION5X_USB0_PHYS_BASE + SZ_4K - 1,
129 .flags = IORESOURCE_MEM,
131 .start = IRQ_ORION5X_USB0_CTRL,
132 .end = IRQ_ORION5X_USB0_CTRL,
133 .flags = IORESOURCE_IRQ,
137 static struct resource orion5x_ehci1_resources[] = {
139 .start = ORION5X_USB1_PHYS_BASE,
140 .end = ORION5X_USB1_PHYS_BASE + SZ_4K - 1,
141 .flags = IORESOURCE_MEM,
143 .start = IRQ_ORION5X_USB1_CTRL,
144 .end = IRQ_ORION5X_USB1_CTRL,
145 .flags = IORESOURCE_IRQ,
149 static struct orion_ehci_data orion5x_ehci_data = {
150 .dram = &orion5x_mbus_dram_info,
153 static u64 ehci_dmamask = 0xffffffffUL;
155 static struct platform_device orion5x_ehci0 = {
156 .name = "orion-ehci",
159 .dma_mask = &ehci_dmamask,
160 .coherent_dma_mask = 0xffffffff,
161 .platform_data = &orion5x_ehci_data,
163 .resource = orion5x_ehci0_resources,
164 .num_resources = ARRAY_SIZE(orion5x_ehci0_resources),
167 static struct platform_device orion5x_ehci1 = {
168 .name = "orion-ehci",
171 .dma_mask = &ehci_dmamask,
172 .coherent_dma_mask = 0xffffffff,
173 .platform_data = &orion5x_ehci_data,
175 .resource = orion5x_ehci1_resources,
176 .num_resources = ARRAY_SIZE(orion5x_ehci1_resources),
179 /*****************************************************************************
180 * Gigabit Ethernet port
181 * (The Orion and Discovery (MV643xx) families use the same Ethernet driver)
182 ****************************************************************************/
184 struct mv643xx_eth_shared_platform_data orion5x_eth_shared_data = {
185 .dram = &orion5x_mbus_dram_info,
186 .t_clk = ORION5X_TCLK,
189 static struct resource orion5x_eth_shared_resources[] = {
191 .start = ORION5X_ETH_PHYS_BASE + 0x2000,
192 .end = ORION5X_ETH_PHYS_BASE + 0x3fff,
193 .flags = IORESOURCE_MEM,
197 static struct platform_device orion5x_eth_shared = {
198 .name = MV643XX_ETH_SHARED_NAME,
201 .platform_data = &orion5x_eth_shared_data,
204 .resource = orion5x_eth_shared_resources,
207 static struct resource orion5x_eth_resources[] = {
210 .start = IRQ_ORION5X_ETH_SUM,
211 .end = IRQ_ORION5X_ETH_SUM,
212 .flags = IORESOURCE_IRQ,
216 static struct platform_device orion5x_eth = {
217 .name = MV643XX_ETH_NAME,
220 .resource = orion5x_eth_resources,
223 void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data)
225 eth_data->shared = &orion5x_eth_shared;
226 orion5x_eth.dev.platform_data = eth_data;
228 platform_device_register(&orion5x_eth_shared);
229 platform_device_register(&orion5x_eth);
232 /*****************************************************************************
234 * (The Orion and Discovery (MV643xx) families share the same I2C controller)
235 ****************************************************************************/
237 static struct mv64xxx_i2c_pdata orion5x_i2c_pdata = {
238 .freq_m = 8, /* assumes 166 MHz TCLK */
240 .timeout = 1000, /* Default timeout of 1 second */
243 static struct resource orion5x_i2c_resources[] = {
246 .start = I2C_PHYS_BASE,
247 .end = I2C_PHYS_BASE + 0x20 -1,
248 .flags = IORESOURCE_MEM,
251 .start = IRQ_ORION5X_I2C,
252 .end = IRQ_ORION5X_I2C,
253 .flags = IORESOURCE_IRQ,
257 static struct platform_device orion5x_i2c = {
258 .name = MV64XXX_I2C_CTLR_NAME,
260 .num_resources = ARRAY_SIZE(orion5x_i2c_resources),
261 .resource = orion5x_i2c_resources,
263 .platform_data = &orion5x_i2c_pdata,
267 /*****************************************************************************
269 ****************************************************************************/
270 static struct resource orion5x_sata_resources[] = {
273 .start = ORION5X_SATA_PHYS_BASE,
274 .end = ORION5X_SATA_PHYS_BASE + 0x5000 - 1,
275 .flags = IORESOURCE_MEM,
278 .start = IRQ_ORION5X_SATA,
279 .end = IRQ_ORION5X_SATA,
280 .flags = IORESOURCE_IRQ,
284 static struct platform_device orion5x_sata = {
288 .coherent_dma_mask = 0xffffffff,
290 .num_resources = ARRAY_SIZE(orion5x_sata_resources),
291 .resource = orion5x_sata_resources,
294 void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data)
296 sata_data->dram = &orion5x_mbus_dram_info;
297 orion5x_sata.dev.platform_data = sata_data;
298 platform_device_register(&orion5x_sata);
301 /*****************************************************************************
303 ****************************************************************************/
305 static void orion5x_timer_init(void)
307 orion_time_init(IRQ_ORION5X_BRIDGE, ORION5X_TCLK);
310 struct sys_timer orion5x_timer = {
311 .init = orion5x_timer_init,
314 /*****************************************************************************
316 ****************************************************************************/
319 * Identify device ID and rev from PCIe configuration header space '0'.
321 static void __init orion5x_id(u32 *dev, u32 *rev, char **dev_name)
323 orion5x_pcie_id(dev, rev);
325 if (*dev == MV88F5281_DEV_ID) {
326 if (*rev == MV88F5281_REV_D2) {
327 *dev_name = "MV88F5281-D2";
328 } else if (*rev == MV88F5281_REV_D1) {
329 *dev_name = "MV88F5281-D1";
331 *dev_name = "MV88F5281-Rev-Unsupported";
333 } else if (*dev == MV88F5182_DEV_ID) {
334 if (*rev == MV88F5182_REV_A2) {
335 *dev_name = "MV88F5182-A2";
337 *dev_name = "MV88F5182-Rev-Unsupported";
339 } else if (*dev == MV88F5181_DEV_ID) {
340 if (*rev == MV88F5181_REV_B1) {
341 *dev_name = "MV88F5181-Rev-B1";
343 *dev_name = "MV88F5181-Rev-Unsupported";
346 *dev_name = "Device-Unknown";
350 void __init orion5x_init(void)
355 orion5x_id(&dev, &rev, &dev_name);
356 printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, ORION5X_TCLK);
359 * Setup Orion address map
361 orion5x_setup_cpu_mbus_bridge();
366 platform_device_register(&orion5x_uart);
367 platform_device_register(&orion5x_ehci0);
368 if (dev == MV88F5182_DEV_ID)
369 platform_device_register(&orion5x_ehci1);
370 platform_device_register(&orion5x_i2c);
374 * Many orion-based systems have buggy bootloader implementations.
375 * This is a common fixup for bogus memory tags.
377 void __init tag_fixup_mem32(struct machine_desc *mdesc, struct tag *t,
378 char **from, struct meminfo *meminfo)
380 for (; t->hdr.size; t = tag_next(t))
381 if (t->hdr.tag == ATAG_MEM &&
382 (!t->u.mem.size || t->u.mem.size & ~PAGE_MASK ||
383 t->u.mem.start & ~PAGE_MASK)) {
385 "Clearing invalid memory bank %dKB@0x%08x\n",
386 t->u.mem.size / 1024, t->u.mem.start);