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/time.h> |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 34 | #include <plat/common.h> |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 35 | #include "common.h" |
| 36 | |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 37 | static int get_tclk(void); |
| 38 | |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 39 | /***************************************************************************** |
| 40 | * I/O Address Mapping |
| 41 | ****************************************************************************/ |
| 42 | static struct map_desc dove_io_desc[] __initdata = { |
| 43 | { |
| 44 | .virtual = DOVE_SB_REGS_VIRT_BASE, |
| 45 | .pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE), |
| 46 | .length = DOVE_SB_REGS_SIZE, |
| 47 | .type = MT_DEVICE, |
| 48 | }, { |
| 49 | .virtual = DOVE_NB_REGS_VIRT_BASE, |
| 50 | .pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE), |
| 51 | .length = DOVE_NB_REGS_SIZE, |
| 52 | .type = MT_DEVICE, |
| 53 | }, { |
| 54 | .virtual = DOVE_PCIE0_IO_VIRT_BASE, |
| 55 | .pfn = __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE), |
| 56 | .length = DOVE_PCIE0_IO_SIZE, |
| 57 | .type = MT_DEVICE, |
| 58 | }, { |
| 59 | .virtual = DOVE_PCIE1_IO_VIRT_BASE, |
| 60 | .pfn = __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE), |
| 61 | .length = DOVE_PCIE1_IO_SIZE, |
| 62 | .type = MT_DEVICE, |
| 63 | }, |
| 64 | }; |
| 65 | |
| 66 | void __init dove_map_io(void) |
| 67 | { |
| 68 | iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc)); |
| 69 | } |
| 70 | |
| 71 | /***************************************************************************** |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 72 | * EHCI0 |
| 73 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 74 | void __init dove_ehci0_init(void) |
| 75 | { |
Andrew Lunn | 4fcd3f3 | 2011-05-15 13:32:49 +0200 | [diff] [blame] | 76 | orion_ehci_init(&dove_mbus_dram_info, |
| 77 | DOVE_USB0_PHYS_BASE, IRQ_DOVE_USB0); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | /***************************************************************************** |
| 81 | * EHCI1 |
| 82 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 83 | void __init dove_ehci1_init(void) |
| 84 | { |
Andrew Lunn | 4fcd3f3 | 2011-05-15 13:32:49 +0200 | [diff] [blame] | 85 | orion_ehci_1_init(&dove_mbus_dram_info, |
| 86 | DOVE_USB1_PHYS_BASE, IRQ_DOVE_USB1); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | /***************************************************************************** |
| 90 | * GE00 |
| 91 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 92 | void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data) |
| 93 | { |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 94 | orion_ge00_init(eth_data, &dove_mbus_dram_info, |
| 95 | DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM, |
| 96 | 0, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | /***************************************************************************** |
| 100 | * SoC RTC |
| 101 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 102 | void __init dove_rtc_init(void) |
| 103 | { |
Andrew Lunn | f6eaccb | 2011-05-15 13:32:42 +0200 | [diff] [blame] | 104 | orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | /***************************************************************************** |
| 108 | * SATA |
| 109 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 110 | void __init dove_sata_init(struct mv_sata_platform_data *sata_data) |
| 111 | { |
Andrew Lunn | 9e613f8 | 2011-05-15 13:32:50 +0200 | [diff] [blame] | 112 | orion_sata_init(sata_data, &dove_mbus_dram_info, |
| 113 | DOVE_SATA_PHYS_BASE, IRQ_DOVE_SATA); |
| 114 | |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | /***************************************************************************** |
| 118 | * UART0 |
| 119 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 120 | void __init dove_uart0_init(void) |
| 121 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 122 | orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE, |
| 123 | IRQ_DOVE_UART_0, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | /***************************************************************************** |
| 127 | * UART1 |
| 128 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 129 | void __init dove_uart1_init(void) |
| 130 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 131 | orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE, |
| 132 | IRQ_DOVE_UART_1, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | /***************************************************************************** |
| 136 | * UART2 |
| 137 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 138 | void __init dove_uart2_init(void) |
| 139 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 140 | orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE, |
| 141 | IRQ_DOVE_UART_2, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | /***************************************************************************** |
| 145 | * UART3 |
| 146 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 147 | void __init dove_uart3_init(void) |
| 148 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 149 | orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE, |
| 150 | IRQ_DOVE_UART_3, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | /***************************************************************************** |
Andrew Lunn | 980f9f6 | 2011-05-15 13:32:46 +0200 | [diff] [blame] | 154 | * SPI |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 155 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 156 | void __init dove_spi0_init(void) |
| 157 | { |
Andrew Lunn | 980f9f6 | 2011-05-15 13:32:46 +0200 | [diff] [blame] | 158 | orion_spi_init(DOVE_SPI0_PHYS_BASE, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 159 | } |
| 160 | |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 161 | void __init dove_spi1_init(void) |
| 162 | { |
Nicolas Pitre | b7290a2 | 2011-09-14 01:22:05 -0400 | [diff] [blame] | 163 | orion_spi_1_init(DOVE_SPI1_PHYS_BASE, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | /***************************************************************************** |
| 167 | * I2C |
| 168 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 169 | void __init dove_i2c_init(void) |
| 170 | { |
Andrew Lunn | aac7ffa | 2011-05-15 13:32:45 +0200 | [diff] [blame] | 171 | orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | /***************************************************************************** |
| 175 | * Time handling |
| 176 | ****************************************************************************/ |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 177 | void __init dove_init_early(void) |
| 178 | { |
| 179 | orion_time_set_base(TIMER_VIRT_BASE); |
| 180 | } |
| 181 | |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 182 | static int get_tclk(void) |
| 183 | { |
| 184 | /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */ |
| 185 | return 166666667; |
| 186 | } |
| 187 | |
| 188 | static void dove_timer_init(void) |
| 189 | { |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 190 | orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR, |
| 191 | IRQ_DOVE_BRIDGE, get_tclk()); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | struct sys_timer dove_timer = { |
| 195 | .init = dove_timer_init, |
| 196 | }; |
| 197 | |
| 198 | /***************************************************************************** |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 199 | * XOR 0 |
| 200 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 201 | void __init dove_xor0_init(void) |
| 202 | { |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame] | 203 | orion_xor0_init(&dove_mbus_dram_info, |
| 204 | DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE, |
| 205 | IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | /***************************************************************************** |
| 209 | * XOR 1 |
| 210 | ****************************************************************************/ |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 211 | void __init dove_xor1_init(void) |
| 212 | { |
Andrew Lunn | ee96272 | 2011-05-15 13:32:48 +0200 | [diff] [blame] | 213 | orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE, |
| 214 | IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11); |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 215 | } |
| 216 | |
Saeed Bishara | 16bc90a | 2010-05-06 16:12:06 +0300 | [diff] [blame] | 217 | /***************************************************************************** |
| 218 | * SDIO |
| 219 | ****************************************************************************/ |
| 220 | static u64 sdio_dmamask = DMA_BIT_MASK(32); |
| 221 | |
| 222 | static struct resource dove_sdio0_resources[] = { |
| 223 | { |
| 224 | .start = DOVE_SDIO0_PHYS_BASE, |
| 225 | .end = DOVE_SDIO0_PHYS_BASE + 0xff, |
| 226 | .flags = IORESOURCE_MEM, |
| 227 | }, { |
| 228 | .start = IRQ_DOVE_SDIO0, |
| 229 | .end = IRQ_DOVE_SDIO0, |
| 230 | .flags = IORESOURCE_IRQ, |
| 231 | }, |
| 232 | }; |
| 233 | |
| 234 | static struct platform_device dove_sdio0 = { |
Mike Rapoport | 930e2fe | 2010-10-28 21:23:53 +0200 | [diff] [blame] | 235 | .name = "sdhci-dove", |
Saeed Bishara | 16bc90a | 2010-05-06 16:12:06 +0300 | [diff] [blame] | 236 | .id = 0, |
| 237 | .dev = { |
| 238 | .dma_mask = &sdio_dmamask, |
| 239 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 240 | }, |
| 241 | .resource = dove_sdio0_resources, |
| 242 | .num_resources = ARRAY_SIZE(dove_sdio0_resources), |
| 243 | }; |
| 244 | |
| 245 | void __init dove_sdio0_init(void) |
| 246 | { |
| 247 | platform_device_register(&dove_sdio0); |
| 248 | } |
| 249 | |
| 250 | static struct resource dove_sdio1_resources[] = { |
| 251 | { |
| 252 | .start = DOVE_SDIO1_PHYS_BASE, |
| 253 | .end = DOVE_SDIO1_PHYS_BASE + 0xff, |
| 254 | .flags = IORESOURCE_MEM, |
| 255 | }, { |
| 256 | .start = IRQ_DOVE_SDIO1, |
| 257 | .end = IRQ_DOVE_SDIO1, |
| 258 | .flags = IORESOURCE_IRQ, |
| 259 | }, |
| 260 | }; |
| 261 | |
| 262 | static struct platform_device dove_sdio1 = { |
Mike Rapoport | 930e2fe | 2010-10-28 21:23:53 +0200 | [diff] [blame] | 263 | .name = "sdhci-dove", |
Saeed Bishara | 16bc90a | 2010-05-06 16:12:06 +0300 | [diff] [blame] | 264 | .id = 1, |
| 265 | .dev = { |
| 266 | .dma_mask = &sdio_dmamask, |
| 267 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 268 | }, |
| 269 | .resource = dove_sdio1_resources, |
| 270 | .num_resources = ARRAY_SIZE(dove_sdio1_resources), |
| 271 | }; |
| 272 | |
| 273 | void __init dove_sdio1_init(void) |
| 274 | { |
| 275 | platform_device_register(&dove_sdio1); |
| 276 | } |
| 277 | |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 278 | void __init dove_init(void) |
| 279 | { |
| 280 | int tclk; |
| 281 | |
| 282 | tclk = get_tclk(); |
| 283 | |
| 284 | printk(KERN_INFO "Dove 88AP510 SoC, "); |
| 285 | printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000); |
| 286 | |
Lennert Buytenhek | 573a652 | 2009-11-24 19:33:52 +0200 | [diff] [blame] | 287 | #ifdef CONFIG_CACHE_TAUROS2 |
| 288 | tauros2_init(); |
| 289 | #endif |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 290 | dove_setup_cpu_mbus(); |
| 291 | |
Saeed Bishara | edabd38 | 2009-08-06 15:12:43 +0300 | [diff] [blame] | 292 | /* internal devices that every board has */ |
| 293 | dove_rtc_init(); |
| 294 | dove_xor0_init(); |
| 295 | dove_xor1_init(); |
| 296 | } |