Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-loki/common.c |
| 3 | * |
| 4 | * Core functions for Marvell Loki (88RC8480) SoCs |
| 5 | * |
| 6 | * This file is licensed under the terms of the GNU General Public |
| 7 | * License version 2. This program is licensed "as is" without any |
| 8 | * warranty of any kind, whether express or implied. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/serial_8250.h> |
| 15 | #include <linux/mbus.h> |
| 16 | #include <linux/mv643xx_eth.h> |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame^] | 17 | #include <linux/dma-mapping.h> |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 18 | #include <asm/page.h> |
| 19 | #include <asm/timex.h> |
| 20 | #include <asm/mach/map.h> |
| 21 | #include <asm/mach/time.h> |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 22 | #include <mach/bridge-regs.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 23 | #include <mach/loki.h> |
Lennert Buytenhek | 6f088f1 | 2008-08-09 13:44:58 +0200 | [diff] [blame] | 24 | #include <plat/orion_nand.h> |
| 25 | #include <plat/time.h> |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 26 | #include "common.h" |
| 27 | |
| 28 | /***************************************************************************** |
| 29 | * I/O Address Mapping |
| 30 | ****************************************************************************/ |
| 31 | static struct map_desc loki_io_desc[] __initdata = { |
| 32 | { |
| 33 | .virtual = LOKI_REGS_VIRT_BASE, |
| 34 | .pfn = __phys_to_pfn(LOKI_REGS_PHYS_BASE), |
| 35 | .length = LOKI_REGS_SIZE, |
| 36 | .type = MT_DEVICE, |
| 37 | }, |
| 38 | }; |
| 39 | |
| 40 | void __init loki_map_io(void) |
| 41 | { |
| 42 | iotable_init(loki_io_desc, ARRAY_SIZE(loki_io_desc)); |
| 43 | } |
| 44 | |
| 45 | |
| 46 | /***************************************************************************** |
| 47 | * GE0 |
| 48 | ****************************************************************************/ |
| 49 | struct mv643xx_eth_shared_platform_data loki_ge0_shared_data = { |
| 50 | .t_clk = LOKI_TCLK, |
| 51 | .dram = &loki_mbus_dram_info, |
| 52 | }; |
| 53 | |
| 54 | static struct resource loki_ge0_shared_resources[] = { |
| 55 | { |
| 56 | .name = "ge0 base", |
| 57 | .start = GE0_PHYS_BASE + 0x2000, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame^] | 58 | .end = GE0_PHYS_BASE + SZ_16K - 1, |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 59 | .flags = IORESOURCE_MEM, |
| 60 | }, |
| 61 | }; |
| 62 | |
| 63 | static struct platform_device loki_ge0_shared = { |
| 64 | .name = MV643XX_ETH_SHARED_NAME, |
| 65 | .id = 0, |
| 66 | .dev = { |
| 67 | .platform_data = &loki_ge0_shared_data, |
| 68 | }, |
| 69 | .num_resources = 1, |
| 70 | .resource = loki_ge0_shared_resources, |
| 71 | }; |
| 72 | |
| 73 | static struct resource loki_ge0_resources[] = { |
| 74 | { |
| 75 | .name = "ge0 irq", |
| 76 | .start = IRQ_LOKI_GBE_A_INT, |
| 77 | .end = IRQ_LOKI_GBE_A_INT, |
| 78 | .flags = IORESOURCE_IRQ, |
| 79 | }, |
| 80 | }; |
| 81 | |
| 82 | static struct platform_device loki_ge0 = { |
| 83 | .name = MV643XX_ETH_NAME, |
| 84 | .id = 0, |
| 85 | .num_resources = 1, |
| 86 | .resource = loki_ge0_resources, |
Nicolas Pitre | a49a018 | 2009-05-22 16:53:40 -0400 | [diff] [blame] | 87 | .dev = { |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame^] | 88 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Nicolas Pitre | a49a018 | 2009-05-22 16:53:40 -0400 | [diff] [blame] | 89 | }, |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | void __init loki_ge0_init(struct mv643xx_eth_platform_data *eth_data) |
| 93 | { |
| 94 | eth_data->shared = &loki_ge0_shared; |
| 95 | loki_ge0.dev.platform_data = eth_data; |
| 96 | |
| 97 | writel(0x00079220, GE0_VIRT_BASE + 0x20b0); |
| 98 | platform_device_register(&loki_ge0_shared); |
| 99 | platform_device_register(&loki_ge0); |
| 100 | } |
| 101 | |
| 102 | |
| 103 | /***************************************************************************** |
| 104 | * GE1 |
| 105 | ****************************************************************************/ |
| 106 | struct mv643xx_eth_shared_platform_data loki_ge1_shared_data = { |
| 107 | .t_clk = LOKI_TCLK, |
| 108 | .dram = &loki_mbus_dram_info, |
| 109 | }; |
| 110 | |
| 111 | static struct resource loki_ge1_shared_resources[] = { |
| 112 | { |
| 113 | .name = "ge1 base", |
| 114 | .start = GE1_PHYS_BASE + 0x2000, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame^] | 115 | .end = GE1_PHYS_BASE + SZ_16K - 1, |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 116 | .flags = IORESOURCE_MEM, |
| 117 | }, |
| 118 | }; |
| 119 | |
| 120 | static struct platform_device loki_ge1_shared = { |
| 121 | .name = MV643XX_ETH_SHARED_NAME, |
| 122 | .id = 1, |
| 123 | .dev = { |
| 124 | .platform_data = &loki_ge1_shared_data, |
| 125 | }, |
| 126 | .num_resources = 1, |
| 127 | .resource = loki_ge1_shared_resources, |
| 128 | }; |
| 129 | |
| 130 | static struct resource loki_ge1_resources[] = { |
| 131 | { |
| 132 | .name = "ge1 irq", |
| 133 | .start = IRQ_LOKI_GBE_B_INT, |
| 134 | .end = IRQ_LOKI_GBE_B_INT, |
| 135 | .flags = IORESOURCE_IRQ, |
| 136 | }, |
| 137 | }; |
| 138 | |
| 139 | static struct platform_device loki_ge1 = { |
| 140 | .name = MV643XX_ETH_NAME, |
| 141 | .id = 1, |
| 142 | .num_resources = 1, |
| 143 | .resource = loki_ge1_resources, |
Nicolas Pitre | a49a018 | 2009-05-22 16:53:40 -0400 | [diff] [blame] | 144 | .dev = { |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame^] | 145 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Nicolas Pitre | a49a018 | 2009-05-22 16:53:40 -0400 | [diff] [blame] | 146 | }, |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | void __init loki_ge1_init(struct mv643xx_eth_platform_data *eth_data) |
| 150 | { |
| 151 | eth_data->shared = &loki_ge1_shared; |
| 152 | loki_ge1.dev.platform_data = eth_data; |
| 153 | |
| 154 | writel(0x00079220, GE1_VIRT_BASE + 0x20b0); |
| 155 | platform_device_register(&loki_ge1_shared); |
| 156 | platform_device_register(&loki_ge1); |
| 157 | } |
| 158 | |
| 159 | |
| 160 | /***************************************************************************** |
| 161 | * SAS/SATA |
| 162 | ****************************************************************************/ |
| 163 | static struct resource loki_sas_resources[] = { |
| 164 | { |
| 165 | .name = "mvsas0 mem", |
| 166 | .start = SAS0_PHYS_BASE, |
| 167 | .end = SAS0_PHYS_BASE + 0x01ff, |
| 168 | .flags = IORESOURCE_MEM, |
| 169 | }, { |
| 170 | .name = "mvsas0 irq", |
| 171 | .start = IRQ_LOKI_SAS_A, |
| 172 | .end = IRQ_LOKI_SAS_A, |
| 173 | .flags = IORESOURCE_IRQ, |
| 174 | }, { |
| 175 | .name = "mvsas1 mem", |
| 176 | .start = SAS1_PHYS_BASE, |
| 177 | .end = SAS1_PHYS_BASE + 0x01ff, |
| 178 | .flags = IORESOURCE_MEM, |
| 179 | }, { |
| 180 | .name = "mvsas1 irq", |
| 181 | .start = IRQ_LOKI_SAS_B, |
| 182 | .end = IRQ_LOKI_SAS_B, |
| 183 | .flags = IORESOURCE_IRQ, |
| 184 | }, |
| 185 | }; |
| 186 | |
| 187 | static struct platform_device loki_sas = { |
| 188 | .name = "mvsas", |
| 189 | .id = 0, |
| 190 | .dev = { |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame^] | 191 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 192 | }, |
| 193 | .num_resources = ARRAY_SIZE(loki_sas_resources), |
| 194 | .resource = loki_sas_resources, |
| 195 | }; |
| 196 | |
| 197 | void __init loki_sas_init(void) |
| 198 | { |
| 199 | writel(0x8300f707, DDR_REG(0x1424)); |
| 200 | platform_device_register(&loki_sas); |
| 201 | } |
| 202 | |
| 203 | |
| 204 | /***************************************************************************** |
| 205 | * UART0 |
| 206 | ****************************************************************************/ |
| 207 | static struct plat_serial8250_port loki_uart0_data[] = { |
| 208 | { |
| 209 | .mapbase = UART0_PHYS_BASE, |
| 210 | .membase = (char *)UART0_VIRT_BASE, |
| 211 | .irq = IRQ_LOKI_UART0, |
| 212 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, |
| 213 | .iotype = UPIO_MEM, |
| 214 | .regshift = 2, |
| 215 | .uartclk = LOKI_TCLK, |
| 216 | }, { |
| 217 | }, |
| 218 | }; |
| 219 | |
| 220 | static struct resource loki_uart0_resources[] = { |
| 221 | { |
| 222 | .start = UART0_PHYS_BASE, |
| 223 | .end = UART0_PHYS_BASE + 0xff, |
| 224 | .flags = IORESOURCE_MEM, |
| 225 | }, { |
| 226 | .start = IRQ_LOKI_UART0, |
| 227 | .end = IRQ_LOKI_UART0, |
| 228 | .flags = IORESOURCE_IRQ, |
| 229 | }, |
| 230 | }; |
| 231 | |
| 232 | static struct platform_device loki_uart0 = { |
| 233 | .name = "serial8250", |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame^] | 234 | .id = PLAT8250_DEV_PLATFORM, |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 235 | .dev = { |
| 236 | .platform_data = loki_uart0_data, |
| 237 | }, |
| 238 | .resource = loki_uart0_resources, |
| 239 | .num_resources = ARRAY_SIZE(loki_uart0_resources), |
| 240 | }; |
| 241 | |
| 242 | void __init loki_uart0_init(void) |
| 243 | { |
| 244 | platform_device_register(&loki_uart0); |
| 245 | } |
| 246 | |
| 247 | |
| 248 | /***************************************************************************** |
| 249 | * UART1 |
| 250 | ****************************************************************************/ |
| 251 | static struct plat_serial8250_port loki_uart1_data[] = { |
| 252 | { |
| 253 | .mapbase = UART1_PHYS_BASE, |
| 254 | .membase = (char *)UART1_VIRT_BASE, |
| 255 | .irq = IRQ_LOKI_UART1, |
| 256 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, |
| 257 | .iotype = UPIO_MEM, |
| 258 | .regshift = 2, |
| 259 | .uartclk = LOKI_TCLK, |
| 260 | }, { |
| 261 | }, |
| 262 | }; |
| 263 | |
| 264 | static struct resource loki_uart1_resources[] = { |
| 265 | { |
| 266 | .start = UART1_PHYS_BASE, |
| 267 | .end = UART1_PHYS_BASE + 0xff, |
| 268 | .flags = IORESOURCE_MEM, |
| 269 | }, { |
| 270 | .start = IRQ_LOKI_UART1, |
| 271 | .end = IRQ_LOKI_UART1, |
| 272 | .flags = IORESOURCE_IRQ, |
| 273 | }, |
| 274 | }; |
| 275 | |
| 276 | static struct platform_device loki_uart1 = { |
| 277 | .name = "serial8250", |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame^] | 278 | .id = PLAT8250_DEV_PLATFORM1, |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 279 | .dev = { |
| 280 | .platform_data = loki_uart1_data, |
| 281 | }, |
| 282 | .resource = loki_uart1_resources, |
| 283 | .num_resources = ARRAY_SIZE(loki_uart1_resources), |
| 284 | }; |
| 285 | |
| 286 | void __init loki_uart1_init(void) |
| 287 | { |
| 288 | platform_device_register(&loki_uart1); |
| 289 | } |
| 290 | |
| 291 | |
| 292 | /***************************************************************************** |
| 293 | * Time handling |
| 294 | ****************************************************************************/ |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 295 | void __init loki_init_early(void) |
| 296 | { |
| 297 | orion_time_set_base(TIMER_VIRT_BASE); |
| 298 | } |
| 299 | |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 300 | static void loki_timer_init(void) |
| 301 | { |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 302 | orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR, |
| 303 | IRQ_LOKI_BRIDGE, LOKI_TCLK); |
Lennert Buytenhek | 777f9be | 2008-06-22 22:45:02 +0200 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | struct sys_timer loki_timer = { |
| 307 | .init = loki_timer_init, |
| 308 | }; |
| 309 | |
| 310 | |
| 311 | /***************************************************************************** |
| 312 | * General |
| 313 | ****************************************************************************/ |
| 314 | void __init loki_init(void) |
| 315 | { |
| 316 | printk(KERN_INFO "Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK); |
| 317 | |
| 318 | loki_setup_cpu_mbus(); |
| 319 | } |