Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / arm / mach-orion / common.c
blob19de581588b040a03142ef78c27a12d3f781a269
1 /*
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>
18 #include <linux/mv643xx_i2c.h>
19 #include <asm/page.h>
20 <<<<<<< HEAD:arch/arm/mach-orion/common.c
21 =======
22 #include <asm/setup.h>
23 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mach-orion/common.c
24 #include <asm/timex.h>
25 <<<<<<< HEAD:arch/arm/mach-orion/common.c
26 =======
27 #include <asm/mach/arch.h>
28 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mach-orion/common.c
29 #include <asm/mach/map.h>
30 #include <asm/arch/hardware.h>
31 #include "common.h"
33 /*****************************************************************************
34 * I/O Address Mapping
35 ****************************************************************************/
36 static struct map_desc orion_io_desc[] __initdata = {
38 .virtual = ORION_REGS_VIRT_BASE,
39 .pfn = __phys_to_pfn(ORION_REGS_PHYS_BASE),
40 .length = ORION_REGS_SIZE,
41 .type = MT_DEVICE
44 .virtual = ORION_PCIE_IO_VIRT_BASE,
45 .pfn = __phys_to_pfn(ORION_PCIE_IO_PHYS_BASE),
46 .length = ORION_PCIE_IO_SIZE,
47 .type = MT_DEVICE
50 .virtual = ORION_PCI_IO_VIRT_BASE,
51 .pfn = __phys_to_pfn(ORION_PCI_IO_PHYS_BASE),
52 .length = ORION_PCI_IO_SIZE,
53 .type = MT_DEVICE
56 .virtual = ORION_PCIE_WA_VIRT_BASE,
57 .pfn = __phys_to_pfn(ORION_PCIE_WA_PHYS_BASE),
58 .length = ORION_PCIE_WA_SIZE,
59 .type = MT_DEVICE
63 void __init orion_map_io(void)
65 iotable_init(orion_io_desc, ARRAY_SIZE(orion_io_desc));
68 /*****************************************************************************
69 * UART
70 ****************************************************************************/
72 static struct resource orion_uart_resources[] = {
74 .start = UART0_PHYS_BASE,
75 .end = UART0_PHYS_BASE + 0xff,
76 .flags = IORESOURCE_MEM,
79 .start = IRQ_ORION_UART0,
80 .end = IRQ_ORION_UART0,
81 .flags = IORESOURCE_IRQ,
84 .start = UART1_PHYS_BASE,
85 .end = UART1_PHYS_BASE + 0xff,
86 .flags = IORESOURCE_MEM,
89 .start = IRQ_ORION_UART1,
90 .end = IRQ_ORION_UART1,
91 .flags = IORESOURCE_IRQ,
95 static struct plat_serial8250_port orion_uart_data[] = {
97 .mapbase = UART0_PHYS_BASE,
98 .membase = (char *)UART0_VIRT_BASE,
99 .irq = IRQ_ORION_UART0,
100 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
101 .iotype = UPIO_MEM,
102 .regshift = 2,
103 .uartclk = ORION_TCLK,
106 .mapbase = UART1_PHYS_BASE,
107 .membase = (char *)UART1_VIRT_BASE,
108 .irq = IRQ_ORION_UART1,
109 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
110 .iotype = UPIO_MEM,
111 .regshift = 2,
112 .uartclk = ORION_TCLK,
114 { },
117 static struct platform_device orion_uart = {
118 .name = "serial8250",
119 .id = PLAT8250_DEV_PLATFORM,
120 .dev = {
121 .platform_data = orion_uart_data,
123 .resource = orion_uart_resources,
124 .num_resources = ARRAY_SIZE(orion_uart_resources),
127 /*******************************************************************************
128 * USB Controller - 2 interfaces
129 ******************************************************************************/
131 static struct resource orion_ehci0_resources[] = {
133 .start = ORION_USB0_PHYS_BASE,
134 .end = ORION_USB0_PHYS_BASE + SZ_4K,
135 .flags = IORESOURCE_MEM,
138 .start = IRQ_ORION_USB0_CTRL,
139 .end = IRQ_ORION_USB0_CTRL,
140 .flags = IORESOURCE_IRQ,
144 static struct resource orion_ehci1_resources[] = {
146 .start = ORION_USB1_PHYS_BASE,
147 .end = ORION_USB1_PHYS_BASE + SZ_4K,
148 .flags = IORESOURCE_MEM,
151 .start = IRQ_ORION_USB1_CTRL,
152 .end = IRQ_ORION_USB1_CTRL,
153 .flags = IORESOURCE_IRQ,
157 static u64 ehci_dmamask = 0xffffffffUL;
159 static struct platform_device orion_ehci0 = {
160 .name = "orion-ehci",
161 .id = 0,
162 .dev = {
163 .dma_mask = &ehci_dmamask,
164 .coherent_dma_mask = 0xffffffff,
166 .resource = orion_ehci0_resources,
167 .num_resources = ARRAY_SIZE(orion_ehci0_resources),
170 static struct platform_device orion_ehci1 = {
171 .name = "orion-ehci",
172 .id = 1,
173 .dev = {
174 .dma_mask = &ehci_dmamask,
175 .coherent_dma_mask = 0xffffffff,
177 .resource = orion_ehci1_resources,
178 .num_resources = ARRAY_SIZE(orion_ehci1_resources),
181 /*****************************************************************************
182 * Gigabit Ethernet port
183 * (The Orion and Discovery (MV643xx) families use the same Ethernet driver)
184 ****************************************************************************/
186 static struct resource orion_eth_shared_resources[] = {
188 <<<<<<< HEAD:arch/arm/mach-orion/common.c
189 .start = ORION_ETH_PHYS_BASE,
190 .end = ORION_ETH_PHYS_BASE + 0xffff,
191 =======
192 .start = ORION_ETH_PHYS_BASE + 0x2000,
193 .end = ORION_ETH_PHYS_BASE + 0x3fff,
194 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mach-orion/common.c
195 .flags = IORESOURCE_MEM,
199 static struct platform_device orion_eth_shared = {
200 .name = MV643XX_ETH_SHARED_NAME,
201 .id = 0,
202 .num_resources = 1,
203 .resource = orion_eth_shared_resources,
206 static struct resource orion_eth_resources[] = {
208 .name = "eth irq",
209 .start = IRQ_ORION_ETH_SUM,
210 .end = IRQ_ORION_ETH_SUM,
211 .flags = IORESOURCE_IRQ,
215 static struct platform_device orion_eth = {
216 .name = MV643XX_ETH_NAME,
217 .id = 0,
218 .num_resources = 1,
219 .resource = orion_eth_resources,
222 void __init orion_eth_init(struct mv643xx_eth_platform_data *eth_data)
224 orion_eth.dev.platform_data = eth_data;
225 platform_device_register(&orion_eth_shared);
226 platform_device_register(&orion_eth);
229 /*****************************************************************************
230 * I2C controller
231 * (The Orion and Discovery (MV643xx) families share the same I2C controller)
232 ****************************************************************************/
234 static struct mv64xxx_i2c_pdata orion_i2c_pdata = {
235 .freq_m = 8, /* assumes 166 MHz TCLK */
236 .freq_n = 3,
237 .timeout = 1000, /* Default timeout of 1 second */
240 static struct resource orion_i2c_resources[] = {
242 .name = "i2c base",
243 .start = I2C_PHYS_BASE,
244 .end = I2C_PHYS_BASE + 0x20 -1,
245 .flags = IORESOURCE_MEM,
248 .name = "i2c irq",
249 .start = IRQ_ORION_I2C,
250 .end = IRQ_ORION_I2C,
251 .flags = IORESOURCE_IRQ,
255 static struct platform_device orion_i2c = {
256 .name = MV64XXX_I2C_CTLR_NAME,
257 .id = 0,
258 .num_resources = ARRAY_SIZE(orion_i2c_resources),
259 .resource = orion_i2c_resources,
260 .dev = {
261 .platform_data = &orion_i2c_pdata,
265 /*****************************************************************************
266 * Sata port
267 ****************************************************************************/
268 static struct resource orion_sata_resources[] = {
270 .name = "sata base",
271 .start = ORION_SATA_PHYS_BASE,
272 .end = ORION_SATA_PHYS_BASE + 0x5000 - 1,
273 .flags = IORESOURCE_MEM,
276 .name = "sata irq",
277 .start = IRQ_ORION_SATA,
278 .end = IRQ_ORION_SATA,
279 .flags = IORESOURCE_IRQ,
283 static struct platform_device orion_sata = {
284 .name = "sata_mv",
285 .id = 0,
286 .dev = {
287 .coherent_dma_mask = 0xffffffff,
289 .num_resources = ARRAY_SIZE(orion_sata_resources),
290 .resource = orion_sata_resources,
293 void __init orion_sata_init(struct mv_sata_platform_data *sata_data)
295 orion_sata.dev.platform_data = sata_data;
296 platform_device_register(&orion_sata);
299 /*****************************************************************************
300 * General
301 ****************************************************************************/
304 * Identify device ID and rev from PCIE configuration header space '0'.
306 static void orion_id(u32 *dev, u32 *rev, char **dev_name)
308 orion_pcie_id(dev, rev);
310 if (*dev == MV88F5281_DEV_ID) {
311 if (*rev == MV88F5281_REV_D2) {
312 *dev_name = "MV88F5281-D2";
313 } else if (*rev == MV88F5281_REV_D1) {
314 *dev_name = "MV88F5281-D1";
315 } else {
316 *dev_name = "MV88F5281-Rev-Unsupported";
318 } else if (*dev == MV88F5182_DEV_ID) {
319 if (*rev == MV88F5182_REV_A2) {
320 *dev_name = "MV88F5182-A2";
321 } else {
322 *dev_name = "MV88F5182-Rev-Unsupported";
324 } else if (*dev == MV88F5181_DEV_ID) {
325 if (*rev == MV88F5181_REV_B1) {
326 *dev_name = "MV88F5181-Rev-B1";
327 } else {
328 *dev_name = "MV88F5181-Rev-Unsupported";
330 } else {
331 *dev_name = "Device-Unknown";
335 void __init orion_init(void)
337 char *dev_name;
338 u32 dev, rev;
340 orion_id(&dev, &rev, &dev_name);
341 printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, ORION_TCLK);
344 * Setup Orion address map
346 orion_setup_cpu_wins();
347 orion_setup_usb_wins();
348 orion_setup_eth_wins();
349 orion_setup_pci_wins();
350 orion_setup_pcie_wins();
351 if (dev == MV88F5182_DEV_ID)
352 orion_setup_sata_wins();
355 * REgister devices
357 platform_device_register(&orion_uart);
358 platform_device_register(&orion_ehci0);
359 if (dev == MV88F5182_DEV_ID)
360 platform_device_register(&orion_ehci1);
361 platform_device_register(&orion_i2c);
363 <<<<<<< HEAD:arch/arm/mach-orion/common.c
364 =======
367 * Many orion-based systems have buggy bootloader implementations.
368 * This is a common fixup for bogus memory tags.
370 void __init tag_fixup_mem32(struct machine_desc *mdesc, struct tag *t,
371 char **from, struct meminfo *meminfo)
373 for (; t->hdr.size; t = tag_next(t))
374 if (t->hdr.tag == ATAG_MEM &&
375 (!t->u.mem.size || t->u.mem.size & ~PAGE_MASK ||
376 t->u.mem.start & ~PAGE_MASK)) {
377 printk(KERN_WARNING
378 "Clearing invalid memory bank %dKB@0x%08x\n",
379 t->u.mem.size / 1024, t->u.mem.start);
380 t->hdr.tag = 0;
383 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mach-orion/common.c