blob: dd1429ae6405e3e3c7f48280df66b6992d916b31 [file] [log] [blame]
Saeed Bisharaedabd382009-08-06 15:12:43 +03001/*
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 Bisharaedabd382009-08-06 15:12:43 +030016#include <linux/clk.h>
Saeed Bisharaedabd382009-08-06 15:12:43 +030017#include <linux/ata_platform.h>
Saeed Bisharaedabd382009-08-06 15:12:43 +030018#include <linux/gpio.h>
19#include <asm/page.h>
20#include <asm/setup.h>
21#include <asm/timex.h>
Lennert Buytenhek573a6522009-11-24 19:33:52 +020022#include <asm/hardware/cache-tauros2.h>
Saeed Bisharaedabd382009-08-06 15:12:43 +030023#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 Bisharaedabd382009-08-06 15:12:43 +030030#include <plat/time.h>
Andrew Lunn28a2b452011-05-15 13:32:41 +020031#include <plat/common.h>
Andrew Lunn45173d52011-12-07 21:48:06 +010032#include <plat/addr-map.h>
Saeed Bisharaedabd382009-08-06 15:12:43 +030033#include "common.h"
34
Andrew Lunn28a2b452011-05-15 13:32:41 +020035static int get_tclk(void);
36
Saeed Bisharaedabd382009-08-06 15:12:43 +030037/*****************************************************************************
38 * I/O Address Mapping
39 ****************************************************************************/
40static 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
64void __init dove_map_io(void)
65{
66 iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
67}
68
69/*****************************************************************************
Saeed Bisharaedabd382009-08-06 15:12:43 +030070 * EHCI0
71 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +030072void __init dove_ehci0_init(void)
73{
Andrew Lunndb33f4d2011-12-07 21:48:08 +010074 orion_ehci_init(DOVE_USB0_PHYS_BASE, IRQ_DOVE_USB0);
Saeed Bisharaedabd382009-08-06 15:12:43 +030075}
76
77/*****************************************************************************
78 * EHCI1
79 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +030080void __init dove_ehci1_init(void)
81{
Andrew Lunndb33f4d2011-12-07 21:48:08 +010082 orion_ehci_1_init(DOVE_USB1_PHYS_BASE, IRQ_DOVE_USB1);
Saeed Bisharaedabd382009-08-06 15:12:43 +030083}
84
85/*****************************************************************************
86 * GE00
87 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +030088void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
89{
Andrew Lunndb33f4d2011-12-07 21:48:08 +010090 orion_ge00_init(eth_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +020091 DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM,
92 0, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +030093}
94
95/*****************************************************************************
96 * SoC RTC
97 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +030098void __init dove_rtc_init(void)
99{
Andrew Lunnf6eaccb2011-05-15 13:32:42 +0200100 orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300101}
102
103/*****************************************************************************
104 * SATA
105 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300106void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
107{
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100108 orion_sata_init(sata_data, DOVE_SATA_PHYS_BASE, IRQ_DOVE_SATA);
Andrew Lunn9e613f82011-05-15 13:32:50 +0200109
Saeed Bisharaedabd382009-08-06 15:12:43 +0300110}
111
112/*****************************************************************************
113 * UART0
114 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300115void __init dove_uart0_init(void)
116{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200117 orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
118 IRQ_DOVE_UART_0, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300119}
120
121/*****************************************************************************
122 * UART1
123 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300124void __init dove_uart1_init(void)
125{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200126 orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
127 IRQ_DOVE_UART_1, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300128}
129
130/*****************************************************************************
131 * UART2
132 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300133void __init dove_uart2_init(void)
134{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200135 orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
136 IRQ_DOVE_UART_2, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300137}
138
139/*****************************************************************************
140 * UART3
141 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300142void __init dove_uart3_init(void)
143{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200144 orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
145 IRQ_DOVE_UART_3, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300146}
147
148/*****************************************************************************
Andrew Lunn980f9f62011-05-15 13:32:46 +0200149 * SPI
Saeed Bisharaedabd382009-08-06 15:12:43 +0300150 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300151void __init dove_spi0_init(void)
152{
Andrew Lunn980f9f62011-05-15 13:32:46 +0200153 orion_spi_init(DOVE_SPI0_PHYS_BASE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300154}
155
Saeed Bisharaedabd382009-08-06 15:12:43 +0300156void __init dove_spi1_init(void)
157{
Nicolas Pitre72cc2052011-09-14 01:22:05 -0400158 orion_spi_1_init(DOVE_SPI1_PHYS_BASE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300159}
160
161/*****************************************************************************
162 * I2C
163 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300164void __init dove_i2c_init(void)
165{
Andrew Lunnaac7ffa2011-05-15 13:32:45 +0200166 orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300167}
168
169/*****************************************************************************
170 * Time handling
171 ****************************************************************************/
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200172void __init dove_init_early(void)
173{
174 orion_time_set_base(TIMER_VIRT_BASE);
175}
176
Saeed Bisharaedabd382009-08-06 15:12:43 +0300177static int get_tclk(void)
178{
179 /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
180 return 166666667;
181}
182
183static void dove_timer_init(void)
184{
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200185 orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
186 IRQ_DOVE_BRIDGE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300187}
188
189struct sys_timer dove_timer = {
190 .init = dove_timer_init,
191};
192
193/*****************************************************************************
Saeed Bisharaedabd382009-08-06 15:12:43 +0300194 * XOR 0
195 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300196void __init dove_xor0_init(void)
197{
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100198 orion_xor0_init(DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE,
Andrew Lunnee962722011-05-15 13:32:48 +0200199 IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300200}
201
202/*****************************************************************************
203 * XOR 1
204 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300205void __init dove_xor1_init(void)
206{
Andrew Lunnee962722011-05-15 13:32:48 +0200207 orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE,
208 IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300209}
210
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300211/*****************************************************************************
212 * SDIO
213 ****************************************************************************/
214static u64 sdio_dmamask = DMA_BIT_MASK(32);
215
216static struct resource dove_sdio0_resources[] = {
217 {
218 .start = DOVE_SDIO0_PHYS_BASE,
219 .end = DOVE_SDIO0_PHYS_BASE + 0xff,
220 .flags = IORESOURCE_MEM,
221 }, {
222 .start = IRQ_DOVE_SDIO0,
223 .end = IRQ_DOVE_SDIO0,
224 .flags = IORESOURCE_IRQ,
225 },
226};
227
228static struct platform_device dove_sdio0 = {
Mike Rapoport930e2fe2010-10-28 21:23:53 +0200229 .name = "sdhci-dove",
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300230 .id = 0,
231 .dev = {
232 .dma_mask = &sdio_dmamask,
233 .coherent_dma_mask = DMA_BIT_MASK(32),
234 },
235 .resource = dove_sdio0_resources,
236 .num_resources = ARRAY_SIZE(dove_sdio0_resources),
237};
238
239void __init dove_sdio0_init(void)
240{
241 platform_device_register(&dove_sdio0);
242}
243
244static struct resource dove_sdio1_resources[] = {
245 {
246 .start = DOVE_SDIO1_PHYS_BASE,
247 .end = DOVE_SDIO1_PHYS_BASE + 0xff,
248 .flags = IORESOURCE_MEM,
249 }, {
250 .start = IRQ_DOVE_SDIO1,
251 .end = IRQ_DOVE_SDIO1,
252 .flags = IORESOURCE_IRQ,
253 },
254};
255
256static struct platform_device dove_sdio1 = {
Mike Rapoport930e2fe2010-10-28 21:23:53 +0200257 .name = "sdhci-dove",
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300258 .id = 1,
259 .dev = {
260 .dma_mask = &sdio_dmamask,
261 .coherent_dma_mask = DMA_BIT_MASK(32),
262 },
263 .resource = dove_sdio1_resources,
264 .num_resources = ARRAY_SIZE(dove_sdio1_resources),
265};
266
267void __init dove_sdio1_init(void)
268{
269 platform_device_register(&dove_sdio1);
270}
271
Saeed Bisharaedabd382009-08-06 15:12:43 +0300272void __init dove_init(void)
273{
274 int tclk;
275
276 tclk = get_tclk();
277
278 printk(KERN_INFO "Dove 88AP510 SoC, ");
279 printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000);
280
Lennert Buytenhek573a6522009-11-24 19:33:52 +0200281#ifdef CONFIG_CACHE_TAUROS2
282 tauros2_init();
283#endif
Saeed Bisharaedabd382009-08-06 15:12:43 +0300284 dove_setup_cpu_mbus();
285
Saeed Bisharaedabd382009-08-06 15:12:43 +0300286 /* internal devices that every board has */
287 dove_rtc_init();
288 dove_xor0_init();
289 dove_xor1_init();
290}
Russell King6ca6ff92011-11-05 09:48:52 +0000291
292void dove_restart(char mode, const char *cmd)
293{
294 /*
295 * Enable soft reset to assert RSTOUTn.
296 */
297 writel(SOFT_RESET_OUT_EN, RSTOUTn_MASK);
298
299 /*
300 * Assert soft reset.
301 */
302 writel(SOFT_RESET, SYSTEM_SOFT_RESET);
303
304 while (1)
305 ;
306}