blob: ba55f631cccc91bf0098f30492f82465fdf15db3 [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 {
Thomas Petazzonic3c5a282012-09-11 14:27:18 +020043 .virtual = (unsigned long) DOVE_SB_REGS_VIRT_BASE,
Saeed Bisharaedabd382009-08-06 15:12:43 +030044 .pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE),
45 .length = DOVE_SB_REGS_SIZE,
46 .type = MT_DEVICE,
47 }, {
Thomas Petazzonic3c5a282012-09-11 14:27:18 +020048 .virtual = (unsigned long) DOVE_NB_REGS_VIRT_BASE,
Saeed Bisharaedabd382009-08-06 15:12:43 +030049 .pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE),
50 .length = DOVE_NB_REGS_SIZE,
51 .type = MT_DEVICE,
52 }, {
Thomas Petazzonic3c5a282012-09-11 14:27:18 +020053 .virtual = (unsigned long) DOVE_PCIE0_IO_VIRT_BASE,
Saeed Bisharaedabd382009-08-06 15:12:43 +030054 .pfn = __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE),
55 .length = DOVE_PCIE0_IO_SIZE,
56 .type = MT_DEVICE,
57 }, {
Thomas Petazzonic3c5a282012-09-11 14:27:18 +020058 .virtual = (unsigned long) DOVE_PCIE1_IO_VIRT_BASE,
Saeed Bisharaedabd382009-08-06 15:12:43 +030059 .pfn = __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE),
60 .length = DOVE_PCIE1_IO_SIZE,
61 .type = MT_DEVICE,
62 },
63};
64
65void __init dove_map_io(void)
66{
67 iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
68}
69
70/*****************************************************************************
Andrew Lunn2f129bf2011-12-15 08:15:07 +010071 * CLK tree
72 ****************************************************************************/
73static struct clk *tclk;
74
75static void __init clk_init(void)
76{
77 tclk = clk_register_fixed_rate(NULL, "tclk", NULL, CLK_IS_ROOT,
78 get_tclk());
Andrew Lunn4574b882012-04-06 17:17:26 +020079
80 orion_clkdev_init(tclk);
Andrew Lunn2f129bf2011-12-15 08:15:07 +010081}
82
83/*****************************************************************************
Saeed Bisharaedabd382009-08-06 15:12:43 +030084 * EHCI0
85 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +030086void __init dove_ehci0_init(void)
87{
Andrew Lunn72053352012-02-08 15:52:47 +010088 orion_ehci_init(DOVE_USB0_PHYS_BASE, IRQ_DOVE_USB0, EHCI_PHY_NA);
Saeed Bisharaedabd382009-08-06 15:12:43 +030089}
90
91/*****************************************************************************
92 * EHCI1
93 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +030094void __init dove_ehci1_init(void)
95{
Andrew Lunndb33f4d2011-12-07 21:48:08 +010096 orion_ehci_1_init(DOVE_USB1_PHYS_BASE, IRQ_DOVE_USB1);
Saeed Bisharaedabd382009-08-06 15:12:43 +030097}
98
99/*****************************************************************************
100 * GE00
101 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300102void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
103{
Hannes Reinecke30e0f582012-06-12 15:59:45 +0200104 orion_ge00_init(eth_data, DOVE_GE00_PHYS_BASE,
Arnaud Patard (Rtp)58569ae2012-07-26 12:15:46 +0200105 IRQ_DOVE_GE00_SUM, IRQ_DOVE_GE00_ERR,
106 1600);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300107}
108
109/*****************************************************************************
110 * SoC RTC
111 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300112void __init dove_rtc_init(void)
113{
Andrew Lunnf6eaccb2011-05-15 13:32:42 +0200114 orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300115}
116
117/*****************************************************************************
118 * SATA
119 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300120void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
121{
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100122 orion_sata_init(sata_data, DOVE_SATA_PHYS_BASE, IRQ_DOVE_SATA);
Andrew Lunn9e613f82011-05-15 13:32:50 +0200123
Saeed Bisharaedabd382009-08-06 15:12:43 +0300124}
125
126/*****************************************************************************
127 * UART0
128 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300129void __init dove_uart0_init(void)
130{
Thomas Petazzonid19beac2012-09-11 14:27:23 +0200131 orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
Andrew Lunn74c33572011-12-24 03:06:34 +0100132 IRQ_DOVE_UART_0, tclk);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300133}
134
135/*****************************************************************************
136 * UART1
137 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300138void __init dove_uart1_init(void)
139{
Thomas Petazzonid19beac2012-09-11 14:27:23 +0200140 orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
Andrew Lunn74c33572011-12-24 03:06:34 +0100141 IRQ_DOVE_UART_1, tclk);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300142}
143
144/*****************************************************************************
145 * UART2
146 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300147void __init dove_uart2_init(void)
148{
Thomas Petazzonid19beac2012-09-11 14:27:23 +0200149 orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
Andrew Lunn74c33572011-12-24 03:06:34 +0100150 IRQ_DOVE_UART_2, tclk);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300151}
152
153/*****************************************************************************
154 * UART3
155 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300156void __init dove_uart3_init(void)
157{
Thomas Petazzonid19beac2012-09-11 14:27:23 +0200158 orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
Andrew Lunn74c33572011-12-24 03:06:34 +0100159 IRQ_DOVE_UART_3, tclk);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300160}
161
162/*****************************************************************************
Andrew Lunn980f9f62011-05-15 13:32:46 +0200163 * SPI
Saeed Bisharaedabd382009-08-06 15:12:43 +0300164 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300165void __init dove_spi0_init(void)
166{
Andrew Lunn4574b882012-04-06 17:17:26 +0200167 orion_spi_init(DOVE_SPI0_PHYS_BASE);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300168}
169
Saeed Bisharaedabd382009-08-06 15:12:43 +0300170void __init dove_spi1_init(void)
171{
Andrew Lunn4574b882012-04-06 17:17:26 +0200172 orion_spi_1_init(DOVE_SPI1_PHYS_BASE);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300173}
174
175/*****************************************************************************
176 * I2C
177 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300178void __init dove_i2c_init(void)
179{
Andrew Lunnaac7ffa2011-05-15 13:32:45 +0200180 orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300181}
182
183/*****************************************************************************
184 * Time handling
185 ****************************************************************************/
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200186void __init dove_init_early(void)
187{
Thomas Petazzonic3c5a282012-09-11 14:27:18 +0200188 orion_time_set_base((unsigned long) TIMER_VIRT_BASE);
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200189}
190
Saeed Bisharaedabd382009-08-06 15:12:43 +0300191static int get_tclk(void)
192{
193 /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
194 return 166666667;
195}
196
Andrew Lunnca2ac5c2012-05-14 11:28:43 +0200197static void __init dove_timer_init(void)
Saeed Bisharaedabd382009-08-06 15:12:43 +0300198{
Thomas Petazzonic3c5a282012-09-11 14:27:18 +0200199 orion_time_init((unsigned long) BRIDGE_VIRT_BASE,
200 BRIDGE_INT_TIMER1_CLR,
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200201 IRQ_DOVE_BRIDGE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300202}
203
204struct sys_timer dove_timer = {
205 .init = dove_timer_init,
206};
207
208/*****************************************************************************
Saeed Bisharaedabd382009-08-06 15:12:43 +0300209 * XOR 0
210 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300211void __init dove_xor0_init(void)
212{
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100213 orion_xor0_init(DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE,
Andrew Lunnee962722011-05-15 13:32:48 +0200214 IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300215}
216
217/*****************************************************************************
218 * XOR 1
219 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300220void __init dove_xor1_init(void)
221{
Andrew Lunnee962722011-05-15 13:32:48 +0200222 orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE,
223 IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300224}
225
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300226/*****************************************************************************
227 * SDIO
228 ****************************************************************************/
229static u64 sdio_dmamask = DMA_BIT_MASK(32);
230
231static struct resource dove_sdio0_resources[] = {
232 {
233 .start = DOVE_SDIO0_PHYS_BASE,
234 .end = DOVE_SDIO0_PHYS_BASE + 0xff,
235 .flags = IORESOURCE_MEM,
236 }, {
237 .start = IRQ_DOVE_SDIO0,
238 .end = IRQ_DOVE_SDIO0,
239 .flags = IORESOURCE_IRQ,
240 },
241};
242
243static struct platform_device dove_sdio0 = {
Mike Rapoport930e2fe2010-10-28 21:23:53 +0200244 .name = "sdhci-dove",
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300245 .id = 0,
246 .dev = {
247 .dma_mask = &sdio_dmamask,
248 .coherent_dma_mask = DMA_BIT_MASK(32),
249 },
250 .resource = dove_sdio0_resources,
251 .num_resources = ARRAY_SIZE(dove_sdio0_resources),
252};
253
254void __init dove_sdio0_init(void)
255{
256 platform_device_register(&dove_sdio0);
257}
258
259static struct resource dove_sdio1_resources[] = {
260 {
261 .start = DOVE_SDIO1_PHYS_BASE,
262 .end = DOVE_SDIO1_PHYS_BASE + 0xff,
263 .flags = IORESOURCE_MEM,
264 }, {
265 .start = IRQ_DOVE_SDIO1,
266 .end = IRQ_DOVE_SDIO1,
267 .flags = IORESOURCE_IRQ,
268 },
269};
270
271static struct platform_device dove_sdio1 = {
Mike Rapoport930e2fe2010-10-28 21:23:53 +0200272 .name = "sdhci-dove",
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300273 .id = 1,
274 .dev = {
275 .dma_mask = &sdio_dmamask,
276 .coherent_dma_mask = DMA_BIT_MASK(32),
277 },
278 .resource = dove_sdio1_resources,
279 .num_resources = ARRAY_SIZE(dove_sdio1_resources),
280};
281
282void __init dove_sdio1_init(void)
283{
284 platform_device_register(&dove_sdio1);
285}
286
Saeed Bisharaedabd382009-08-06 15:12:43 +0300287void __init dove_init(void)
288{
Saeed Bisharaedabd382009-08-06 15:12:43 +0300289 printk(KERN_INFO "Dove 88AP510 SoC, ");
Andrew Lunn2f129bf2011-12-15 08:15:07 +0100290 printk(KERN_INFO "TCLK = %dMHz\n", (get_tclk() + 499999) / 1000000);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300291
Lennert Buytenhek573a6522009-11-24 19:33:52 +0200292#ifdef CONFIG_CACHE_TAUROS2
293 tauros2_init();
294#endif
Saeed Bisharaedabd382009-08-06 15:12:43 +0300295 dove_setup_cpu_mbus();
296
Andrew Lunn2f129bf2011-12-15 08:15:07 +0100297 /* Setup root of clk tree */
298 clk_init();
299
Saeed Bisharaedabd382009-08-06 15:12:43 +0300300 /* internal devices that every board has */
301 dove_rtc_init();
302 dove_xor0_init();
303 dove_xor1_init();
304}
Russell King6ca6ff92011-11-05 09:48:52 +0000305
306void dove_restart(char mode, const char *cmd)
307{
308 /*
309 * Enable soft reset to assert RSTOUTn.
310 */
311 writel(SOFT_RESET_OUT_EN, RSTOUTn_MASK);
312
313 /*
314 * Assert soft reset.
315 */
316 writel(SOFT_RESET, SYSTEM_SOFT_RESET);
317
318 while (1)
319 ;
320}