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