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