blob: bd54d7b7ef8513bba6d937c40c8da022add81eb5 [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>
Andrew Lunn2f129bf2011-12-15 08:15:07 +010016#include <linux/clk-provider.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 Lunn72053352012-02-08 15:52:47 +010031#include <plat/ehci-orion.h>
Andrew Lunn28a2b452011-05-15 13:32:41 +020032#include <plat/common.h>
Andrew Lunn45173d52011-12-07 21:48:06 +010033#include <plat/addr-map.h>
Saeed Bisharaedabd382009-08-06 15:12:43 +030034#include "common.h"
35
Andrew Lunn28a2b452011-05-15 13:32:41 +020036static int get_tclk(void);
37
Saeed Bisharaedabd382009-08-06 15:12:43 +030038/*****************************************************************************
39 * I/O Address Mapping
40 ****************************************************************************/
41static struct map_desc dove_io_desc[] __initdata = {
42 {
43 .virtual = DOVE_SB_REGS_VIRT_BASE,
44 .pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE),
45 .length = DOVE_SB_REGS_SIZE,
46 .type = MT_DEVICE,
47 }, {
48 .virtual = DOVE_NB_REGS_VIRT_BASE,
49 .pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE),
50 .length = DOVE_NB_REGS_SIZE,
51 .type = MT_DEVICE,
Saeed Bisharaedabd382009-08-06 15:12:43 +030052 },
53};
54
55void __init dove_map_io(void)
56{
57 iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
58}
59
60/*****************************************************************************
Andrew Lunn2f129bf2011-12-15 08:15:07 +010061 * CLK tree
62 ****************************************************************************/
63static struct clk *tclk;
64
65static void __init clk_init(void)
66{
67 tclk = clk_register_fixed_rate(NULL, "tclk", NULL, CLK_IS_ROOT,
68 get_tclk());
Andrew Lunn4574b882012-04-06 17:17:26 +020069
70 orion_clkdev_init(tclk);
Andrew Lunn2f129bf2011-12-15 08:15:07 +010071}
72
73/*****************************************************************************
Saeed Bisharaedabd382009-08-06 15:12:43 +030074 * EHCI0
75 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +030076void __init dove_ehci0_init(void)
77{
Andrew Lunn72053352012-02-08 15:52:47 +010078 orion_ehci_init(DOVE_USB0_PHYS_BASE, IRQ_DOVE_USB0, EHCI_PHY_NA);
Saeed Bisharaedabd382009-08-06 15:12:43 +030079}
80
81/*****************************************************************************
82 * EHCI1
83 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +030084void __init dove_ehci1_init(void)
85{
Andrew Lunndb33f4d2011-12-07 21:48:08 +010086 orion_ehci_1_init(DOVE_USB1_PHYS_BASE, IRQ_DOVE_USB1);
Saeed Bisharaedabd382009-08-06 15:12:43 +030087}
88
89/*****************************************************************************
90 * GE00
91 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +030092void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
93{
Hannes Reinecke30e0f582012-06-12 15:59:45 +020094 orion_ge00_init(eth_data, DOVE_GE00_PHYS_BASE,
Arnaud Patard (Rtp)58569ae2012-07-26 12:15:46 +020095 IRQ_DOVE_GE00_SUM, IRQ_DOVE_GE00_ERR,
96 1600);
Saeed Bisharaedabd382009-08-06 15:12:43 +030097}
98
99/*****************************************************************************
100 * SoC RTC
101 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300102void __init dove_rtc_init(void)
103{
Andrew Lunnf6eaccb2011-05-15 13:32:42 +0200104 orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300105}
106
107/*****************************************************************************
108 * SATA
109 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300110void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
111{
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100112 orion_sata_init(sata_data, DOVE_SATA_PHYS_BASE, IRQ_DOVE_SATA);
Andrew Lunn9e613f82011-05-15 13:32:50 +0200113
Saeed Bisharaedabd382009-08-06 15:12:43 +0300114}
115
116/*****************************************************************************
117 * UART0
118 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300119void __init dove_uart0_init(void)
120{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200121 orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
Andrew Lunn74c33572011-12-24 03:06:34 +0100122 IRQ_DOVE_UART_0, tclk);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300123}
124
125/*****************************************************************************
126 * UART1
127 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300128void __init dove_uart1_init(void)
129{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200130 orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
Andrew Lunn74c33572011-12-24 03:06:34 +0100131 IRQ_DOVE_UART_1, tclk);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300132}
133
134/*****************************************************************************
135 * UART2
136 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300137void __init dove_uart2_init(void)
138{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200139 orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
Andrew Lunn74c33572011-12-24 03:06:34 +0100140 IRQ_DOVE_UART_2, tclk);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300141}
142
143/*****************************************************************************
144 * UART3
145 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300146void __init dove_uart3_init(void)
147{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200148 orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
Andrew Lunn74c33572011-12-24 03:06:34 +0100149 IRQ_DOVE_UART_3, tclk);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300150}
151
152/*****************************************************************************
Andrew Lunn980f9f62011-05-15 13:32:46 +0200153 * SPI
Saeed Bisharaedabd382009-08-06 15:12:43 +0300154 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300155void __init dove_spi0_init(void)
156{
Andrew Lunn4574b882012-04-06 17:17:26 +0200157 orion_spi_init(DOVE_SPI0_PHYS_BASE);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300158}
159
Saeed Bisharaedabd382009-08-06 15:12:43 +0300160void __init dove_spi1_init(void)
161{
Andrew Lunn4574b882012-04-06 17:17:26 +0200162 orion_spi_1_init(DOVE_SPI1_PHYS_BASE);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300163}
164
165/*****************************************************************************
166 * I2C
167 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300168void __init dove_i2c_init(void)
169{
Andrew Lunnaac7ffa2011-05-15 13:32:45 +0200170 orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300171}
172
173/*****************************************************************************
174 * Time handling
175 ****************************************************************************/
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200176void __init dove_init_early(void)
177{
178 orion_time_set_base(TIMER_VIRT_BASE);
179}
180
Saeed Bisharaedabd382009-08-06 15:12:43 +0300181static int get_tclk(void)
182{
183 /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
184 return 166666667;
185}
186
Andrew Lunnca2ac5c2012-05-14 11:28:43 +0200187static void __init dove_timer_init(void)
Saeed Bisharaedabd382009-08-06 15:12:43 +0300188{
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200189 orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
190 IRQ_DOVE_BRIDGE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300191}
192
193struct sys_timer dove_timer = {
194 .init = dove_timer_init,
195};
196
197/*****************************************************************************
Saeed Bisharaedabd382009-08-06 15:12:43 +0300198 * XOR 0
199 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300200void __init dove_xor0_init(void)
201{
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100202 orion_xor0_init(DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE,
Andrew Lunnee962722011-05-15 13:32:48 +0200203 IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300204}
205
206/*****************************************************************************
207 * XOR 1
208 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300209void __init dove_xor1_init(void)
210{
Andrew Lunnee962722011-05-15 13:32:48 +0200211 orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE,
212 IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300213}
214
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300215/*****************************************************************************
216 * SDIO
217 ****************************************************************************/
218static u64 sdio_dmamask = DMA_BIT_MASK(32);
219
220static 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
232static struct platform_device dove_sdio0 = {
Mike Rapoport930e2fe2010-10-28 21:23:53 +0200233 .name = "sdhci-dove",
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300234 .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
243void __init dove_sdio0_init(void)
244{
245 platform_device_register(&dove_sdio0);
246}
247
248static 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
260static struct platform_device dove_sdio1 = {
Mike Rapoport930e2fe2010-10-28 21:23:53 +0200261 .name = "sdhci-dove",
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300262 .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
271void __init dove_sdio1_init(void)
272{
273 platform_device_register(&dove_sdio1);
274}
275
Saeed Bisharaedabd382009-08-06 15:12:43 +0300276void __init dove_init(void)
277{
Saeed Bisharaedabd382009-08-06 15:12:43 +0300278 printk(KERN_INFO "Dove 88AP510 SoC, ");
Andrew Lunn2f129bf2011-12-15 08:15:07 +0100279 printk(KERN_INFO "TCLK = %dMHz\n", (get_tclk() + 499999) / 1000000);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300280
Lennert Buytenhek573a6522009-11-24 19:33:52 +0200281#ifdef CONFIG_CACHE_TAUROS2
Chao Xie5cc58152012-07-31 14:13:13 +0800282 tauros2_init(0);
Lennert Buytenhek573a6522009-11-24 19:33:52 +0200283#endif
Saeed Bisharaedabd382009-08-06 15:12:43 +0300284 dove_setup_cpu_mbus();
285
Andrew Lunn2f129bf2011-12-15 08:15:07 +0100286 /* Setup root of clk tree */
287 clk_init();
288
Saeed Bisharaedabd382009-08-06 15:12:43 +0300289 /* internal devices that every board has */
290 dove_rtc_init();
291 dove_xor0_init();
292 dove_xor1_init();
293}
Russell King6ca6ff92011-11-05 09:48:52 +0000294
295void dove_restart(char mode, const char *cmd)
296{
297 /*
298 * Enable soft reset to assert RSTOUTn.
299 */
300 writel(SOFT_RESET_OUT_EN, RSTOUTn_MASK);
301
302 /*
303 * Assert soft reset.
304 */
305 writel(SOFT_RESET, SYSTEM_SOFT_RESET);
306
307 while (1)
308 ;
309}