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