blob: cf7e5985eebff2bdaf56af9070674d2e81437927 [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/time.h>
Andrew Lunn28a2b452011-05-15 13:32:41 +020034#include <plat/common.h>
Saeed Bisharaedabd382009-08-06 15:12:43 +030035#include "common.h"
36
Andrew Lunn28a2b452011-05-15 13:32:41 +020037static int get_tclk(void);
38
Saeed Bisharaedabd382009-08-06 15:12:43 +030039/*****************************************************************************
40 * I/O Address Mapping
41 ****************************************************************************/
42static struct map_desc dove_io_desc[] __initdata = {
43 {
44 .virtual = DOVE_SB_REGS_VIRT_BASE,
45 .pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE),
46 .length = DOVE_SB_REGS_SIZE,
47 .type = MT_DEVICE,
48 }, {
49 .virtual = DOVE_NB_REGS_VIRT_BASE,
50 .pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE),
51 .length = DOVE_NB_REGS_SIZE,
52 .type = MT_DEVICE,
53 }, {
54 .virtual = DOVE_PCIE0_IO_VIRT_BASE,
55 .pfn = __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE),
56 .length = DOVE_PCIE0_IO_SIZE,
57 .type = MT_DEVICE,
58 }, {
59 .virtual = DOVE_PCIE1_IO_VIRT_BASE,
60 .pfn = __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE),
61 .length = DOVE_PCIE1_IO_SIZE,
62 .type = MT_DEVICE,
63 },
64};
65
66void __init dove_map_io(void)
67{
68 iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
69}
70
71/*****************************************************************************
Saeed Bisharaedabd382009-08-06 15:12:43 +030072 * EHCI0
73 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +030074void __init dove_ehci0_init(void)
75{
Andrew Lunn4fcd3f32011-05-15 13:32:49 +020076 orion_ehci_init(&dove_mbus_dram_info,
77 DOVE_USB0_PHYS_BASE, IRQ_DOVE_USB0);
Saeed Bisharaedabd382009-08-06 15:12:43 +030078}
79
80/*****************************************************************************
81 * EHCI1
82 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +030083void __init dove_ehci1_init(void)
84{
Andrew Lunn4fcd3f32011-05-15 13:32:49 +020085 orion_ehci_1_init(&dove_mbus_dram_info,
86 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{
Andrew Lunn7e3819d2011-05-15 13:32:44 +020094 orion_ge00_init(eth_data, &dove_mbus_dram_info,
95 DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM,
96 0, get_tclk());
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 Lunn9e613f82011-05-15 13:32:50 +0200112 orion_sata_init(sata_data, &dove_mbus_dram_info,
113 DOVE_SATA_PHYS_BASE, IRQ_DOVE_SATA);
114
Saeed Bisharaedabd382009-08-06 15:12:43 +0300115}
116
117/*****************************************************************************
118 * UART0
119 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300120void __init dove_uart0_init(void)
121{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200122 orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
123 IRQ_DOVE_UART_0, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300124}
125
126/*****************************************************************************
127 * UART1
128 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300129void __init dove_uart1_init(void)
130{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200131 orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
132 IRQ_DOVE_UART_1, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300133}
134
135/*****************************************************************************
136 * UART2
137 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300138void __init dove_uart2_init(void)
139{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200140 orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
141 IRQ_DOVE_UART_2, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300142}
143
144/*****************************************************************************
145 * UART3
146 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300147void __init dove_uart3_init(void)
148{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200149 orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
150 IRQ_DOVE_UART_3, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300151}
152
153/*****************************************************************************
Andrew Lunn980f9f62011-05-15 13:32:46 +0200154 * SPI
Saeed Bisharaedabd382009-08-06 15:12:43 +0300155 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300156void __init dove_spi0_init(void)
157{
Andrew Lunn980f9f62011-05-15 13:32:46 +0200158 orion_spi_init(DOVE_SPI0_PHYS_BASE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300159}
160
Saeed Bisharaedabd382009-08-06 15:12:43 +0300161void __init dove_spi1_init(void)
162{
Nicolas Pitreb7290a22011-09-14 01:22:05 -0400163 orion_spi_1_init(DOVE_SPI1_PHYS_BASE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300164}
165
166/*****************************************************************************
167 * I2C
168 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300169void __init dove_i2c_init(void)
170{
Andrew Lunnaac7ffa2011-05-15 13:32:45 +0200171 orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300172}
173
174/*****************************************************************************
175 * Time handling
176 ****************************************************************************/
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200177void __init dove_init_early(void)
178{
179 orion_time_set_base(TIMER_VIRT_BASE);
180}
181
Saeed Bisharaedabd382009-08-06 15:12:43 +0300182static int get_tclk(void)
183{
184 /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
185 return 166666667;
186}
187
188static void dove_timer_init(void)
189{
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200190 orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
191 IRQ_DOVE_BRIDGE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300192}
193
194struct sys_timer dove_timer = {
195 .init = dove_timer_init,
196};
197
198/*****************************************************************************
Saeed Bisharaedabd382009-08-06 15:12:43 +0300199 * XOR 0
200 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300201void __init dove_xor0_init(void)
202{
Andrew Lunnee962722011-05-15 13:32:48 +0200203 orion_xor0_init(&dove_mbus_dram_info,
204 DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE,
205 IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300206}
207
208/*****************************************************************************
209 * XOR 1
210 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300211void __init dove_xor1_init(void)
212{
Andrew Lunnee962722011-05-15 13:32:48 +0200213 orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE,
214 IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300215}
216
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300217/*****************************************************************************
218 * SDIO
219 ****************************************************************************/
220static u64 sdio_dmamask = DMA_BIT_MASK(32);
221
222static struct resource dove_sdio0_resources[] = {
223 {
224 .start = DOVE_SDIO0_PHYS_BASE,
225 .end = DOVE_SDIO0_PHYS_BASE + 0xff,
226 .flags = IORESOURCE_MEM,
227 }, {
228 .start = IRQ_DOVE_SDIO0,
229 .end = IRQ_DOVE_SDIO0,
230 .flags = IORESOURCE_IRQ,
231 },
232};
233
234static struct platform_device dove_sdio0 = {
Mike Rapoport930e2fe2010-10-28 21:23:53 +0200235 .name = "sdhci-dove",
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300236 .id = 0,
237 .dev = {
238 .dma_mask = &sdio_dmamask,
239 .coherent_dma_mask = DMA_BIT_MASK(32),
240 },
241 .resource = dove_sdio0_resources,
242 .num_resources = ARRAY_SIZE(dove_sdio0_resources),
243};
244
245void __init dove_sdio0_init(void)
246{
247 platform_device_register(&dove_sdio0);
248}
249
250static struct resource dove_sdio1_resources[] = {
251 {
252 .start = DOVE_SDIO1_PHYS_BASE,
253 .end = DOVE_SDIO1_PHYS_BASE + 0xff,
254 .flags = IORESOURCE_MEM,
255 }, {
256 .start = IRQ_DOVE_SDIO1,
257 .end = IRQ_DOVE_SDIO1,
258 .flags = IORESOURCE_IRQ,
259 },
260};
261
262static struct platform_device dove_sdio1 = {
Mike Rapoport930e2fe2010-10-28 21:23:53 +0200263 .name = "sdhci-dove",
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300264 .id = 1,
265 .dev = {
266 .dma_mask = &sdio_dmamask,
267 .coherent_dma_mask = DMA_BIT_MASK(32),
268 },
269 .resource = dove_sdio1_resources,
270 .num_resources = ARRAY_SIZE(dove_sdio1_resources),
271};
272
273void __init dove_sdio1_init(void)
274{
275 platform_device_register(&dove_sdio1);
276}
277
Saeed Bisharaedabd382009-08-06 15:12:43 +0300278void __init dove_init(void)
279{
280 int tclk;
281
282 tclk = get_tclk();
283
284 printk(KERN_INFO "Dove 88AP510 SoC, ");
285 printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000);
286
Lennert Buytenhek573a6522009-11-24 19:33:52 +0200287#ifdef CONFIG_CACHE_TAUROS2
288 tauros2_init();
289#endif
Saeed Bisharaedabd382009-08-06 15:12:43 +0300290 dove_setup_cpu_mbus();
291
Saeed Bisharaedabd382009-08-06 15:12:43 +0300292 /* internal devices that every board has */
293 dove_rtc_init();
294 dove_xor0_init();
295 dove_xor1_init();
296}