Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-dove/common.c |
| 3 | * |
| 4 | * Core functions for Marvell Dove 88AP510 System On Chip |
| 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/delay.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/pci.h> |
| 16 | #include <linux/serial_8250.h> |
| 17 | #include <linux/clk.h> |
| 18 | #include <linux/mbus.h> |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 19 | #include <linux/ata_platform.h> |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 20 | #include <linux/serial_8250.h> |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 21 | #include <linux/gpio.h> |
| 22 | #include <asm/page.h> |
| 23 | #include <asm/setup.h> |
| 24 | #include <asm/timex.h> |
Lennert Buytenhek | 573a652 | 2009-11-24 19:33:52 +0200 | [diff] [blame] | 25 | #include <asm/hardware/cache-tauros2.h> |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 26 | #include <asm/mach/map.h> |
| 27 | #include <asm/mach/time.h> |
| 28 | #include <asm/mach/pci.h> |
| 29 | #include <mach/dove.h> |
| 30 | #include <mach/bridge-regs.h> |
| 31 | #include <asm/mach/arch.h> |
| 32 | #include <linux/irq.h> |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 33 | #include <plat/ehci-orion.h> |
| 34 | #include <plat/time.h> |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 35 | #include <plat/common.h> |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 36 | #include "common.h" |
| 37 | |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 38 | static int get_tclk(void); |
| 39 | |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 40 | /***************************************************************************** |
| 41 | * I/O Address Mapping |
| 42 | ****************************************************************************/ |
| 43 | static struct map_desc dove_io_desc[] __initdata = { |
| 44 | { |
| 45 | .virtual = DOVE_SB_REGS_VIRT_BASE, |
| 46 | .pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE), |
| 47 | .length = DOVE_SB_REGS_SIZE, |
| 48 | .type = MT_DEVICE, |
| 49 | }, { |
| 50 | .virtual = DOVE_NB_REGS_VIRT_BASE, |
| 51 | .pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE), |
| 52 | .length = DOVE_NB_REGS_SIZE, |
| 53 | .type = MT_DEVICE, |
| 54 | }, { |
| 55 | .virtual = DOVE_PCIE0_IO_VIRT_BASE, |
| 56 | .pfn = __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE), |
| 57 | .length = DOVE_PCIE0_IO_SIZE, |
| 58 | .type = MT_DEVICE, |
| 59 | }, { |
| 60 | .virtual = DOVE_PCIE1_IO_VIRT_BASE, |
| 61 | .pfn = __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE), |
| 62 | .length = DOVE_PCIE1_IO_SIZE, |
| 63 | .type = MT_DEVICE, |
| 64 | }, |
| 65 | }; |
| 66 | |
| 67 | void __init dove_map_io(void) |
| 68 | { |
| 69 | iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc)); |
| 70 | } |
| 71 | |
| 72 | /***************************************************************************** |
| 73 | * EHCI |
| 74 | ****************************************************************************/ |
| 75 | static struct orion_ehci_data dove_ehci_data = { |
| 76 | .dram = &dove_mbus_dram_info, |
| 77 | .phy_version = EHCI_PHY_NA, |
| 78 | }; |
| 79 | |
| 80 | static u64 ehci_dmamask = DMA_BIT_MASK(32); |
| 81 | |
| 82 | /***************************************************************************** |
| 83 | * EHCI0 |
| 84 | ****************************************************************************/ |
| 85 | static struct resource dove_ehci0_resources[] = { |
| 86 | { |
| 87 | .start = DOVE_USB0_PHYS_BASE, |
| 88 | .end = DOVE_USB0_PHYS_BASE + SZ_4K - 1, |
| 89 | .flags = IORESOURCE_MEM, |
| 90 | }, { |
| 91 | .start = IRQ_DOVE_USB0, |
| 92 | .end = IRQ_DOVE_USB0, |
| 93 | .flags = IORESOURCE_IRQ, |
| 94 | }, |
| 95 | }; |
| 96 | |
| 97 | static struct platform_device dove_ehci0 = { |
| 98 | .name = "orion-ehci", |
| 99 | .id = 0, |
| 100 | .dev = { |
| 101 | .dma_mask = &ehci_dmamask, |
| 102 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 103 | .platform_data = &dove_ehci_data, |
| 104 | }, |
| 105 | .resource = dove_ehci0_resources, |
| 106 | .num_resources = ARRAY_SIZE(dove_ehci0_resources), |
| 107 | }; |
| 108 | |
| 109 | void __init dove_ehci0_init(void) |
| 110 | { |
| 111 | platform_device_register(&dove_ehci0); |
| 112 | } |
| 113 | |
| 114 | /***************************************************************************** |
| 115 | * EHCI1 |
| 116 | ****************************************************************************/ |
| 117 | static struct resource dove_ehci1_resources[] = { |
| 118 | { |
| 119 | .start = DOVE_USB1_PHYS_BASE, |
| 120 | .end = DOVE_USB1_PHYS_BASE + SZ_4K - 1, |
| 121 | .flags = IORESOURCE_MEM, |
| 122 | }, { |
| 123 | .start = IRQ_DOVE_USB1, |
| 124 | .end = IRQ_DOVE_USB1, |
| 125 | .flags = IORESOURCE_IRQ, |
| 126 | }, |
| 127 | }; |
| 128 | |
| 129 | static struct platform_device dove_ehci1 = { |
| 130 | .name = "orion-ehci", |
| 131 | .id = 1, |
| 132 | .dev = { |
| 133 | .dma_mask = &ehci_dmamask, |
| 134 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 135 | .platform_data = &dove_ehci_data, |
| 136 | }, |
| 137 | .resource = dove_ehci1_resources, |
| 138 | .num_resources = ARRAY_SIZE(dove_ehci1_resources), |
| 139 | }; |
| 140 | |
| 141 | void __init dove_ehci1_init(void) |
| 142 | { |
| 143 | platform_device_register(&dove_ehci1); |
| 144 | } |
| 145 | |
| 146 | /***************************************************************************** |
| 147 | * GE00 |
| 148 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 149 | void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data) |
| 150 | { |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 151 | orion_ge00_init(eth_data, &dove_mbus_dram_info, |
| 152 | DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM, |
| 153 | 0, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | /***************************************************************************** |
| 157 | * SoC RTC |
| 158 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 159 | void __init dove_rtc_init(void) |
| 160 | { |
Andrew Lunn | f6eaccb | 2011-05-15 13:32:42 +0200 | [diff] [blame] | 161 | orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | /***************************************************************************** |
| 165 | * SATA |
| 166 | ****************************************************************************/ |
| 167 | static struct resource dove_sata_resources[] = { |
| 168 | { |
| 169 | .name = "sata base", |
| 170 | .start = DOVE_SATA_PHYS_BASE, |
| 171 | .end = DOVE_SATA_PHYS_BASE + 0x5000 - 1, |
| 172 | .flags = IORESOURCE_MEM, |
| 173 | }, { |
| 174 | .name = "sata irq", |
| 175 | .start = IRQ_DOVE_SATA, |
| 176 | .end = IRQ_DOVE_SATA, |
| 177 | .flags = IORESOURCE_IRQ, |
| 178 | }, |
| 179 | }; |
| 180 | |
| 181 | static struct platform_device dove_sata = { |
| 182 | .name = "sata_mv", |
| 183 | .id = 0, |
| 184 | .dev = { |
| 185 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 186 | }, |
| 187 | .num_resources = ARRAY_SIZE(dove_sata_resources), |
| 188 | .resource = dove_sata_resources, |
| 189 | }; |
| 190 | |
| 191 | void __init dove_sata_init(struct mv_sata_platform_data *sata_data) |
| 192 | { |
| 193 | sata_data->dram = &dove_mbus_dram_info; |
| 194 | dove_sata.dev.platform_data = sata_data; |
| 195 | platform_device_register(&dove_sata); |
| 196 | } |
| 197 | |
| 198 | /***************************************************************************** |
| 199 | * UART0 |
| 200 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 201 | void __init dove_uart0_init(void) |
| 202 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 203 | orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE, |
| 204 | IRQ_DOVE_UART_0, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | /***************************************************************************** |
| 208 | * UART1 |
| 209 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 210 | void __init dove_uart1_init(void) |
| 211 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 212 | orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE, |
| 213 | IRQ_DOVE_UART_1, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | /***************************************************************************** |
| 217 | * UART2 |
| 218 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 219 | void __init dove_uart2_init(void) |
| 220 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 221 | orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE, |
| 222 | IRQ_DOVE_UART_2, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | /***************************************************************************** |
| 226 | * UART3 |
| 227 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 228 | void __init dove_uart3_init(void) |
| 229 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 230 | orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE, |
| 231 | IRQ_DOVE_UART_3, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | /***************************************************************************** |
Andrew Lunn | 980f9f6 | 2011-05-15 13:32:46 +0200 | [diff] [blame] | 235 | * SPI |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 236 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 237 | void __init dove_spi0_init(void) |
| 238 | { |
Andrew Lunn | 980f9f6 | 2011-05-15 13:32:46 +0200 | [diff] [blame] | 239 | orion_spi_init(DOVE_SPI0_PHYS_BASE, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 240 | } |
| 241 | |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 242 | void __init dove_spi1_init(void) |
| 243 | { |
Andrew Lunn | 980f9f6 | 2011-05-15 13:32:46 +0200 | [diff] [blame] | 244 | orion_spi_init(DOVE_SPI1_PHYS_BASE, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | /***************************************************************************** |
| 248 | * I2C |
| 249 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 250 | void __init dove_i2c_init(void) |
| 251 | { |
Andrew Lunn | aac7ffa | 2011-05-15 13:32:45 +0200 | [diff] [blame] | 252 | orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | /***************************************************************************** |
| 256 | * Time handling |
| 257 | ****************************************************************************/ |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 258 | void __init dove_init_early(void) |
| 259 | { |
| 260 | orion_time_set_base(TIMER_VIRT_BASE); |
| 261 | } |
| 262 | |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 263 | static int get_tclk(void) |
| 264 | { |
| 265 | /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */ |
| 266 | return 166666667; |
| 267 | } |
| 268 | |
| 269 | static void dove_timer_init(void) |
| 270 | { |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 271 | orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR, |
| 272 | IRQ_DOVE_BRIDGE, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | struct sys_timer dove_timer = { |
| 276 | .init = dove_timer_init, |
| 277 | }; |
| 278 | |
| 279 | /***************************************************************************** |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 280 | * XOR 0 |
| 281 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 282 | void __init dove_xor0_init(void) |
| 283 | { |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame^] | 284 | orion_xor0_init(&dove_mbus_dram_info, |
| 285 | DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE, |
| 286 | IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | /***************************************************************************** |
| 290 | * XOR 1 |
| 291 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 292 | void __init dove_xor1_init(void) |
| 293 | { |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame^] | 294 | orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE, |
| 295 | IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 296 | } |
| 297 | |
Saeed Bishara | 16bc90a | 2010-05-06 16:12:06 +0300 | [diff] [blame] | 298 | /***************************************************************************** |
| 299 | * SDIO |
| 300 | ****************************************************************************/ |
| 301 | static u64 sdio_dmamask = DMA_BIT_MASK(32); |
| 302 | |
| 303 | static struct resource dove_sdio0_resources[] = { |
| 304 | { |
| 305 | .start = DOVE_SDIO0_PHYS_BASE, |
| 306 | .end = DOVE_SDIO0_PHYS_BASE + 0xff, |
| 307 | .flags = IORESOURCE_MEM, |
| 308 | }, { |
| 309 | .start = IRQ_DOVE_SDIO0, |
| 310 | .end = IRQ_DOVE_SDIO0, |
| 311 | .flags = IORESOURCE_IRQ, |
| 312 | }, |
| 313 | }; |
| 314 | |
| 315 | static struct platform_device dove_sdio0 = { |
Mike Rapoport | 930e2fe | 2010-10-28 21:23:53 +0200 | [diff] [blame] | 316 | .name = "sdhci-dove", |
Saeed Bishara | 16bc90a | 2010-05-06 16:12:06 +0300 | [diff] [blame] | 317 | .id = 0, |
| 318 | .dev = { |
| 319 | .dma_mask = &sdio_dmamask, |
| 320 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 321 | }, |
| 322 | .resource = dove_sdio0_resources, |
| 323 | .num_resources = ARRAY_SIZE(dove_sdio0_resources), |
| 324 | }; |
| 325 | |
| 326 | void __init dove_sdio0_init(void) |
| 327 | { |
| 328 | platform_device_register(&dove_sdio0); |
| 329 | } |
| 330 | |
| 331 | static struct resource dove_sdio1_resources[] = { |
| 332 | { |
| 333 | .start = DOVE_SDIO1_PHYS_BASE, |
| 334 | .end = DOVE_SDIO1_PHYS_BASE + 0xff, |
| 335 | .flags = IORESOURCE_MEM, |
| 336 | }, { |
| 337 | .start = IRQ_DOVE_SDIO1, |
| 338 | .end = IRQ_DOVE_SDIO1, |
| 339 | .flags = IORESOURCE_IRQ, |
| 340 | }, |
| 341 | }; |
| 342 | |
| 343 | static struct platform_device dove_sdio1 = { |
Mike Rapoport | 930e2fe | 2010-10-28 21:23:53 +0200 | [diff] [blame] | 344 | .name = "sdhci-dove", |
Saeed Bishara | 16bc90a | 2010-05-06 16:12:06 +0300 | [diff] [blame] | 345 | .id = 1, |
| 346 | .dev = { |
| 347 | .dma_mask = &sdio_dmamask, |
| 348 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 349 | }, |
| 350 | .resource = dove_sdio1_resources, |
| 351 | .num_resources = ARRAY_SIZE(dove_sdio1_resources), |
| 352 | }; |
| 353 | |
| 354 | void __init dove_sdio1_init(void) |
| 355 | { |
| 356 | platform_device_register(&dove_sdio1); |
| 357 | } |
| 358 | |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 359 | void __init dove_init(void) |
| 360 | { |
| 361 | int tclk; |
| 362 | |
| 363 | tclk = get_tclk(); |
| 364 | |
| 365 | printk(KERN_INFO "Dove 88AP510 SoC, "); |
| 366 | printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000); |
| 367 | |
Lennert Buytenhek | 573a652 | 2009-11-24 19:33:52 +0200 | [diff] [blame] | 368 | #ifdef CONFIG_CACHE_TAUROS2 |
| 369 | tauros2_init(); |
| 370 | #endif |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 371 | dove_setup_cpu_mbus(); |
| 372 | |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 373 | /* internal devices that every board has */ |
| 374 | dove_rtc_init(); |
| 375 | dove_xor0_init(); |
| 376 | dove_xor1_init(); |
| 377 | } |