blob: 6703bf3120b685b30063e7d9ce31261f719a6dac [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>
16#include <linux/serial_8250.h>
17#include <linux/clk.h>
18#include <linux/mbus.h>
Saeed Bisharaedabd382009-08-06 15:12:43 +030019#include <linux/ata_platform.h>
Andrew Lunn5c602552011-05-15 13:32:40 +020020#include <linux/serial_8250.h>
Saeed Bisharaedabd382009-08-06 15:12:43 +030021#include <linux/gpio.h>
22#include <asm/page.h>
23#include <asm/setup.h>
24#include <asm/timex.h>
Lennert Buytenhek573a6522009-11-24 19:33:52 +020025#include <asm/hardware/cache-tauros2.h>
Saeed Bisharaedabd382009-08-06 15:12:43 +030026#include <asm/mach/map.h>
27#include <asm/mach/time.h>
28#include <asm/mach/pci.h>
29#include <mach/dove.h>
30#include <mach/bridge-regs.h>
31#include <asm/mach/arch.h>
32#include <linux/irq.h>
Saeed Bisharaedabd382009-08-06 15:12:43 +030033#include <plat/ehci-orion.h>
34#include <plat/time.h>
Andrew Lunn28a2b452011-05-15 13:32:41 +020035#include <plat/common.h>
Saeed Bisharaedabd382009-08-06 15:12:43 +030036#include "common.h"
37
Andrew Lunn28a2b452011-05-15 13:32:41 +020038static int get_tclk(void);
39
Saeed Bisharaedabd382009-08-06 15:12:43 +030040/*****************************************************************************
41 * I/O Address Mapping
42 ****************************************************************************/
43static struct map_desc dove_io_desc[] __initdata = {
44 {
45 .virtual = DOVE_SB_REGS_VIRT_BASE,
46 .pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE),
47 .length = DOVE_SB_REGS_SIZE,
48 .type = MT_DEVICE,
49 }, {
50 .virtual = DOVE_NB_REGS_VIRT_BASE,
51 .pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE),
52 .length = DOVE_NB_REGS_SIZE,
53 .type = MT_DEVICE,
54 }, {
55 .virtual = DOVE_PCIE0_IO_VIRT_BASE,
56 .pfn = __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE),
57 .length = DOVE_PCIE0_IO_SIZE,
58 .type = MT_DEVICE,
59 }, {
60 .virtual = DOVE_PCIE1_IO_VIRT_BASE,
61 .pfn = __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE),
62 .length = DOVE_PCIE1_IO_SIZE,
63 .type = MT_DEVICE,
64 },
65};
66
67void __init dove_map_io(void)
68{
69 iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
70}
71
72/*****************************************************************************
73 * EHCI
74 ****************************************************************************/
75static struct orion_ehci_data dove_ehci_data = {
76 .dram = &dove_mbus_dram_info,
77 .phy_version = EHCI_PHY_NA,
78};
79
80static u64 ehci_dmamask = DMA_BIT_MASK(32);
81
82/*****************************************************************************
83 * EHCI0
84 ****************************************************************************/
85static struct resource dove_ehci0_resources[] = {
86 {
87 .start = DOVE_USB0_PHYS_BASE,
88 .end = DOVE_USB0_PHYS_BASE + SZ_4K - 1,
89 .flags = IORESOURCE_MEM,
90 }, {
91 .start = IRQ_DOVE_USB0,
92 .end = IRQ_DOVE_USB0,
93 .flags = IORESOURCE_IRQ,
94 },
95};
96
97static struct platform_device dove_ehci0 = {
98 .name = "orion-ehci",
99 .id = 0,
100 .dev = {
101 .dma_mask = &ehci_dmamask,
102 .coherent_dma_mask = DMA_BIT_MASK(32),
103 .platform_data = &dove_ehci_data,
104 },
105 .resource = dove_ehci0_resources,
106 .num_resources = ARRAY_SIZE(dove_ehci0_resources),
107};
108
109void __init dove_ehci0_init(void)
110{
111 platform_device_register(&dove_ehci0);
112}
113
114/*****************************************************************************
115 * EHCI1
116 ****************************************************************************/
117static struct resource dove_ehci1_resources[] = {
118 {
119 .start = DOVE_USB1_PHYS_BASE,
120 .end = DOVE_USB1_PHYS_BASE + SZ_4K - 1,
121 .flags = IORESOURCE_MEM,
122 }, {
123 .start = IRQ_DOVE_USB1,
124 .end = IRQ_DOVE_USB1,
125 .flags = IORESOURCE_IRQ,
126 },
127};
128
129static struct platform_device dove_ehci1 = {
130 .name = "orion-ehci",
131 .id = 1,
132 .dev = {
133 .dma_mask = &ehci_dmamask,
134 .coherent_dma_mask = DMA_BIT_MASK(32),
135 .platform_data = &dove_ehci_data,
136 },
137 .resource = dove_ehci1_resources,
138 .num_resources = ARRAY_SIZE(dove_ehci1_resources),
139};
140
141void __init dove_ehci1_init(void)
142{
143 platform_device_register(&dove_ehci1);
144}
145
146/*****************************************************************************
147 * GE00
148 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300149void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
150{
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200151 orion_ge00_init(eth_data, &dove_mbus_dram_info,
152 DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM,
153 0, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300154}
155
156/*****************************************************************************
157 * SoC RTC
158 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300159void __init dove_rtc_init(void)
160{
Andrew Lunnf6eaccb2011-05-15 13:32:42 +0200161 orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300162}
163
164/*****************************************************************************
165 * SATA
166 ****************************************************************************/
167static struct resource dove_sata_resources[] = {
168 {
169 .name = "sata base",
170 .start = DOVE_SATA_PHYS_BASE,
171 .end = DOVE_SATA_PHYS_BASE + 0x5000 - 1,
172 .flags = IORESOURCE_MEM,
173 }, {
174 .name = "sata irq",
175 .start = IRQ_DOVE_SATA,
176 .end = IRQ_DOVE_SATA,
177 .flags = IORESOURCE_IRQ,
178 },
179};
180
181static struct platform_device dove_sata = {
182 .name = "sata_mv",
183 .id = 0,
184 .dev = {
185 .coherent_dma_mask = DMA_BIT_MASK(32),
186 },
187 .num_resources = ARRAY_SIZE(dove_sata_resources),
188 .resource = dove_sata_resources,
189};
190
191void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
192{
193 sata_data->dram = &dove_mbus_dram_info;
194 dove_sata.dev.platform_data = sata_data;
195 platform_device_register(&dove_sata);
196}
197
198/*****************************************************************************
199 * UART0
200 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300201void __init dove_uart0_init(void)
202{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200203 orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
204 IRQ_DOVE_UART_0, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300205}
206
207/*****************************************************************************
208 * UART1
209 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300210void __init dove_uart1_init(void)
211{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200212 orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
213 IRQ_DOVE_UART_1, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300214}
215
216/*****************************************************************************
217 * UART2
218 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300219void __init dove_uart2_init(void)
220{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200221 orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
222 IRQ_DOVE_UART_2, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300223}
224
225/*****************************************************************************
226 * UART3
227 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300228void __init dove_uart3_init(void)
229{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200230 orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
231 IRQ_DOVE_UART_3, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300232}
233
234/*****************************************************************************
Andrew Lunn980f9f62011-05-15 13:32:46 +0200235 * SPI
Saeed Bisharaedabd382009-08-06 15:12:43 +0300236 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300237void __init dove_spi0_init(void)
238{
Andrew Lunn980f9f62011-05-15 13:32:46 +0200239 orion_spi_init(DOVE_SPI0_PHYS_BASE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300240}
241
Saeed Bisharaedabd382009-08-06 15:12:43 +0300242void __init dove_spi1_init(void)
243{
Andrew Lunn980f9f62011-05-15 13:32:46 +0200244 orion_spi_init(DOVE_SPI1_PHYS_BASE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300245}
246
247/*****************************************************************************
248 * I2C
249 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300250void __init dove_i2c_init(void)
251{
Andrew Lunnaac7ffa2011-05-15 13:32:45 +0200252 orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300253}
254
255/*****************************************************************************
256 * Time handling
257 ****************************************************************************/
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200258void __init dove_init_early(void)
259{
260 orion_time_set_base(TIMER_VIRT_BASE);
261}
262
Saeed Bisharaedabd382009-08-06 15:12:43 +0300263static int get_tclk(void)
264{
265 /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
266 return 166666667;
267}
268
269static void dove_timer_init(void)
270{
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200271 orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
272 IRQ_DOVE_BRIDGE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300273}
274
275struct sys_timer dove_timer = {
276 .init = dove_timer_init,
277};
278
279/*****************************************************************************
Saeed Bisharaedabd382009-08-06 15:12:43 +0300280 * XOR 0
281 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300282void __init dove_xor0_init(void)
283{
Andrew Lunnee962722011-05-15 13:32:48 +0200284 orion_xor0_init(&dove_mbus_dram_info,
285 DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE,
286 IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300287}
288
289/*****************************************************************************
290 * XOR 1
291 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300292void __init dove_xor1_init(void)
293{
Andrew Lunnee962722011-05-15 13:32:48 +0200294 orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE,
295 IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300296}
297
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300298/*****************************************************************************
299 * SDIO
300 ****************************************************************************/
301static u64 sdio_dmamask = DMA_BIT_MASK(32);
302
303static struct resource dove_sdio0_resources[] = {
304 {
305 .start = DOVE_SDIO0_PHYS_BASE,
306 .end = DOVE_SDIO0_PHYS_BASE + 0xff,
307 .flags = IORESOURCE_MEM,
308 }, {
309 .start = IRQ_DOVE_SDIO0,
310 .end = IRQ_DOVE_SDIO0,
311 .flags = IORESOURCE_IRQ,
312 },
313};
314
315static struct platform_device dove_sdio0 = {
Mike Rapoport930e2fe2010-10-28 21:23:53 +0200316 .name = "sdhci-dove",
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300317 .id = 0,
318 .dev = {
319 .dma_mask = &sdio_dmamask,
320 .coherent_dma_mask = DMA_BIT_MASK(32),
321 },
322 .resource = dove_sdio0_resources,
323 .num_resources = ARRAY_SIZE(dove_sdio0_resources),
324};
325
326void __init dove_sdio0_init(void)
327{
328 platform_device_register(&dove_sdio0);
329}
330
331static struct resource dove_sdio1_resources[] = {
332 {
333 .start = DOVE_SDIO1_PHYS_BASE,
334 .end = DOVE_SDIO1_PHYS_BASE + 0xff,
335 .flags = IORESOURCE_MEM,
336 }, {
337 .start = IRQ_DOVE_SDIO1,
338 .end = IRQ_DOVE_SDIO1,
339 .flags = IORESOURCE_IRQ,
340 },
341};
342
343static struct platform_device dove_sdio1 = {
Mike Rapoport930e2fe2010-10-28 21:23:53 +0200344 .name = "sdhci-dove",
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300345 .id = 1,
346 .dev = {
347 .dma_mask = &sdio_dmamask,
348 .coherent_dma_mask = DMA_BIT_MASK(32),
349 },
350 .resource = dove_sdio1_resources,
351 .num_resources = ARRAY_SIZE(dove_sdio1_resources),
352};
353
354void __init dove_sdio1_init(void)
355{
356 platform_device_register(&dove_sdio1);
357}
358
Saeed Bisharaedabd382009-08-06 15:12:43 +0300359void __init dove_init(void)
360{
361 int tclk;
362
363 tclk = get_tclk();
364
365 printk(KERN_INFO "Dove 88AP510 SoC, ");
366 printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000);
367
Lennert Buytenhek573a6522009-11-24 19:33:52 +0200368#ifdef CONFIG_CACHE_TAUROS2
369 tauros2_init();
370#endif
Saeed Bisharaedabd382009-08-06 15:12:43 +0300371 dove_setup_cpu_mbus();
372
Saeed Bisharaedabd382009-08-06 15:12:43 +0300373 /* internal devices that every board has */
374 dove_rtc_init();
375 dove_xor0_init();
376 dove_xor1_init();
377}