Tzachi Perelstein | 585cf17 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-orion/common.c |
| 3 | * |
| 4 | * Core functions for Marvell Orion System On Chip |
| 5 | * |
| 6 | * Maintainer: Tzachi Perelstein <tzachi@marvell.com> |
| 7 | * |
| 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. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/init.h> |
Tzachi Perelstein | ca26f7d | 2007-10-23 15:14:42 -0400 | [diff] [blame^] | 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/serial_8250.h> |
Tzachi Perelstein | 585cf17 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 17 | #include <asm/page.h> |
Tzachi Perelstein | c67de5b | 2007-10-23 15:14:42 -0400 | [diff] [blame] | 18 | #include <asm/timex.h> |
Tzachi Perelstein | 585cf17 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 19 | #include <asm/mach/map.h> |
| 20 | #include <asm/arch/orion.h> |
| 21 | #include "common.h" |
| 22 | |
| 23 | /***************************************************************************** |
| 24 | * I/O Address Mapping |
| 25 | ****************************************************************************/ |
| 26 | static struct map_desc orion_io_desc[] __initdata = { |
| 27 | { |
| 28 | .virtual = ORION_REGS_BASE, |
| 29 | .pfn = __phys_to_pfn(ORION_REGS_BASE), |
| 30 | .length = ORION_REGS_SIZE, |
| 31 | .type = MT_DEVICE |
| 32 | }, |
| 33 | { |
| 34 | .virtual = ORION_PCIE_IO_BASE, |
| 35 | .pfn = __phys_to_pfn(ORION_PCIE_IO_BASE), |
| 36 | .length = ORION_PCIE_IO_SIZE, |
| 37 | .type = MT_DEVICE |
| 38 | }, |
| 39 | { |
| 40 | .virtual = ORION_PCI_IO_BASE, |
| 41 | .pfn = __phys_to_pfn(ORION_PCI_IO_BASE), |
| 42 | .length = ORION_PCI_IO_SIZE, |
| 43 | .type = MT_DEVICE |
| 44 | }, |
| 45 | { |
| 46 | .virtual = ORION_PCIE_WA_BASE, |
| 47 | .pfn = __phys_to_pfn(ORION_PCIE_WA_BASE), |
| 48 | .length = ORION_PCIE_WA_SIZE, |
| 49 | .type = MT_DEVICE |
| 50 | }, |
| 51 | }; |
| 52 | |
| 53 | void __init orion_map_io(void) |
| 54 | { |
| 55 | iotable_init(orion_io_desc, ARRAY_SIZE(orion_io_desc)); |
| 56 | } |
Tzachi Perelstein | c67de5b | 2007-10-23 15:14:42 -0400 | [diff] [blame] | 57 | |
| 58 | /***************************************************************************** |
Tzachi Perelstein | ca26f7d | 2007-10-23 15:14:42 -0400 | [diff] [blame^] | 59 | * UART |
| 60 | ****************************************************************************/ |
| 61 | |
| 62 | static struct resource orion_uart_resources[] = { |
| 63 | { |
| 64 | .start = UART0_BASE, |
| 65 | .end = UART0_BASE + 0xff, |
| 66 | .flags = IORESOURCE_MEM, |
| 67 | }, |
| 68 | { |
| 69 | .start = IRQ_ORION_UART0, |
| 70 | .end = IRQ_ORION_UART0, |
| 71 | .flags = IORESOURCE_IRQ, |
| 72 | }, |
| 73 | { |
| 74 | .start = UART1_BASE, |
| 75 | .end = UART1_BASE + 0xff, |
| 76 | .flags = IORESOURCE_MEM, |
| 77 | }, |
| 78 | { |
| 79 | .start = IRQ_ORION_UART1, |
| 80 | .end = IRQ_ORION_UART1, |
| 81 | .flags = IORESOURCE_IRQ, |
| 82 | }, |
| 83 | }; |
| 84 | |
| 85 | static struct plat_serial8250_port orion_uart_data[] = { |
| 86 | { |
| 87 | .mapbase = UART0_BASE, |
| 88 | .membase = (char *)UART0_BASE, |
| 89 | .irq = IRQ_ORION_UART0, |
| 90 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, |
| 91 | .iotype = UPIO_MEM, |
| 92 | .regshift = 2, |
| 93 | .uartclk = ORION_TCLK, |
| 94 | }, |
| 95 | { |
| 96 | .mapbase = UART1_BASE, |
| 97 | .membase = (char *)UART1_BASE, |
| 98 | .irq = IRQ_ORION_UART1, |
| 99 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, |
| 100 | .iotype = UPIO_MEM, |
| 101 | .regshift = 2, |
| 102 | .uartclk = ORION_TCLK, |
| 103 | }, |
| 104 | { }, |
| 105 | }; |
| 106 | |
| 107 | static struct platform_device orion_uart = { |
| 108 | .name = "serial8250", |
| 109 | .id = PLAT8250_DEV_PLATFORM, |
| 110 | .dev = { |
| 111 | .platform_data = orion_uart_data, |
| 112 | }, |
| 113 | .resource = orion_uart_resources, |
| 114 | .num_resources = ARRAY_SIZE(orion_uart_resources), |
| 115 | }; |
| 116 | |
| 117 | /******************************************************************************* |
| 118 | * USB Controller - 2 interfaces |
| 119 | ******************************************************************************/ |
| 120 | |
| 121 | static struct resource orion_ehci0_resources[] = { |
| 122 | { |
| 123 | .start = ORION_USB0_REG_BASE, |
| 124 | .end = ORION_USB0_REG_BASE + SZ_4K, |
| 125 | .flags = IORESOURCE_MEM, |
| 126 | }, |
| 127 | { |
| 128 | .start = IRQ_ORION_USB0_CTRL, |
| 129 | .end = IRQ_ORION_USB0_CTRL, |
| 130 | .flags = IORESOURCE_IRQ, |
| 131 | }, |
| 132 | }; |
| 133 | |
| 134 | static struct resource orion_ehci1_resources[] = { |
| 135 | { |
| 136 | .start = ORION_USB1_REG_BASE, |
| 137 | .end = ORION_USB1_REG_BASE + SZ_4K, |
| 138 | .flags = IORESOURCE_MEM, |
| 139 | }, |
| 140 | { |
| 141 | .start = IRQ_ORION_USB1_CTRL, |
| 142 | .end = IRQ_ORION_USB1_CTRL, |
| 143 | .flags = IORESOURCE_IRQ, |
| 144 | }, |
| 145 | }; |
| 146 | |
| 147 | static u64 ehci_dmamask = 0xffffffffUL; |
| 148 | |
| 149 | static struct platform_device orion_ehci0 = { |
| 150 | .name = "orion-ehci", |
| 151 | .id = 0, |
| 152 | .dev = { |
| 153 | .dma_mask = &ehci_dmamask, |
| 154 | .coherent_dma_mask = 0xffffffff, |
| 155 | }, |
| 156 | .resource = orion_ehci0_resources, |
| 157 | .num_resources = ARRAY_SIZE(orion_ehci0_resources), |
| 158 | }; |
| 159 | |
| 160 | static struct platform_device orion_ehci1 = { |
| 161 | .name = "orion-ehci", |
| 162 | .id = 1, |
| 163 | .dev = { |
| 164 | .dma_mask = &ehci_dmamask, |
| 165 | .coherent_dma_mask = 0xffffffff, |
| 166 | }, |
| 167 | .resource = orion_ehci1_resources, |
| 168 | .num_resources = ARRAY_SIZE(orion_ehci1_resources), |
| 169 | }; |
| 170 | |
| 171 | /***************************************************************************** |
Tzachi Perelstein | c67de5b | 2007-10-23 15:14:42 -0400 | [diff] [blame] | 172 | * General |
| 173 | ****************************************************************************/ |
| 174 | |
| 175 | /* |
| 176 | * Identify device ID and rev from PCIE configuration header space '0'. |
| 177 | */ |
| 178 | static void orion_id(u32 *dev, u32 *rev, char **dev_name) |
| 179 | { |
| 180 | orion_pcie_id(dev, rev); |
| 181 | |
| 182 | if (*dev == MV88F5281_DEV_ID) { |
| 183 | if (*rev == MV88F5281_REV_D2) { |
| 184 | *dev_name = "MV88F5281-D2"; |
| 185 | } else if (*rev == MV88F5281_REV_D1) { |
| 186 | *dev_name = "MV88F5281-D1"; |
| 187 | } else { |
| 188 | *dev_name = "MV88F5281-Rev-Unsupported"; |
| 189 | } |
| 190 | } else if (*dev == MV88F5182_DEV_ID) { |
| 191 | if (*rev == MV88F5182_REV_A2) { |
| 192 | *dev_name = "MV88F5182-A2"; |
| 193 | } else { |
| 194 | *dev_name = "MV88F5182-Rev-Unsupported"; |
| 195 | } |
| 196 | } else { |
| 197 | *dev_name = "Device-Unknown"; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | void __init orion_init(void) |
| 202 | { |
| 203 | char *dev_name; |
| 204 | u32 dev, rev; |
| 205 | |
| 206 | orion_id(&dev, &rev, &dev_name); |
| 207 | printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, ORION_TCLK); |
| 208 | |
| 209 | /* |
| 210 | * Setup Orion address map |
| 211 | */ |
| 212 | orion_setup_cpu_wins(); |
| 213 | orion_setup_usb_wins(); |
| 214 | orion_setup_eth_wins(); |
| 215 | orion_setup_pci_wins(); |
| 216 | orion_setup_pcie_wins(); |
| 217 | if (dev == MV88F5182_DEV_ID) |
| 218 | orion_setup_sata_wins(); |
Tzachi Perelstein | ca26f7d | 2007-10-23 15:14:42 -0400 | [diff] [blame^] | 219 | |
| 220 | /* |
| 221 | * REgister devices |
| 222 | */ |
| 223 | platform_device_register(&orion_uart); |
| 224 | platform_device_register(&orion_ehci0); |
| 225 | if (dev == MV88F5182_DEV_ID) |
| 226 | platform_device_register(&orion_ehci1); |
Tzachi Perelstein | c67de5b | 2007-10-23 15:14:42 -0400 | [diff] [blame] | 227 | } |