blob: 1412592fdca13a6d0ca7e10c24dd2f604a557b86 [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 ****************************************************************************/
110static struct resource dove_sata_resources[] = {
111 {
112 .name = "sata base",
113 .start = DOVE_SATA_PHYS_BASE,
114 .end = DOVE_SATA_PHYS_BASE + 0x5000 - 1,
115 .flags = IORESOURCE_MEM,
116 }, {
117 .name = "sata irq",
118 .start = IRQ_DOVE_SATA,
119 .end = IRQ_DOVE_SATA,
120 .flags = IORESOURCE_IRQ,
121 },
122};
123
124static struct platform_device dove_sata = {
125 .name = "sata_mv",
126 .id = 0,
127 .dev = {
128 .coherent_dma_mask = DMA_BIT_MASK(32),
129 },
130 .num_resources = ARRAY_SIZE(dove_sata_resources),
131 .resource = dove_sata_resources,
132};
133
134void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
135{
136 sata_data->dram = &dove_mbus_dram_info;
137 dove_sata.dev.platform_data = sata_data;
138 platform_device_register(&dove_sata);
139}
140
141/*****************************************************************************
142 * UART0
143 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300144void __init dove_uart0_init(void)
145{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200146 orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
147 IRQ_DOVE_UART_0, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300148}
149
150/*****************************************************************************
151 * UART1
152 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300153void __init dove_uart1_init(void)
154{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200155 orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
156 IRQ_DOVE_UART_1, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300157}
158
159/*****************************************************************************
160 * UART2
161 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300162void __init dove_uart2_init(void)
163{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200164 orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
165 IRQ_DOVE_UART_2, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300166}
167
168/*****************************************************************************
169 * UART3
170 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300171void __init dove_uart3_init(void)
172{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200173 orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
174 IRQ_DOVE_UART_3, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300175}
176
177/*****************************************************************************
Andrew Lunn980f9f62011-05-15 13:32:46 +0200178 * SPI
Saeed Bisharaedabd382009-08-06 15:12:43 +0300179 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300180void __init dove_spi0_init(void)
181{
Andrew Lunn980f9f62011-05-15 13:32:46 +0200182 orion_spi_init(DOVE_SPI0_PHYS_BASE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300183}
184
Saeed Bisharaedabd382009-08-06 15:12:43 +0300185void __init dove_spi1_init(void)
186{
Andrew Lunn980f9f62011-05-15 13:32:46 +0200187 orion_spi_init(DOVE_SPI1_PHYS_BASE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300188}
189
190/*****************************************************************************
191 * I2C
192 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300193void __init dove_i2c_init(void)
194{
Andrew Lunnaac7ffa2011-05-15 13:32:45 +0200195 orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300196}
197
198/*****************************************************************************
199 * Time handling
200 ****************************************************************************/
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200201void __init dove_init_early(void)
202{
203 orion_time_set_base(TIMER_VIRT_BASE);
204}
205
Saeed Bisharaedabd382009-08-06 15:12:43 +0300206static int get_tclk(void)
207{
208 /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
209 return 166666667;
210}
211
212static void dove_timer_init(void)
213{
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200214 orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
215 IRQ_DOVE_BRIDGE, get_tclk());
Saeed Bisharaedabd382009-08-06 15:12:43 +0300216}
217
218struct sys_timer dove_timer = {
219 .init = dove_timer_init,
220};
221
222/*****************************************************************************
Saeed Bisharaedabd382009-08-06 15:12:43 +0300223 * XOR 0
224 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300225void __init dove_xor0_init(void)
226{
Andrew Lunnee962722011-05-15 13:32:48 +0200227 orion_xor0_init(&dove_mbus_dram_info,
228 DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE,
229 IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300230}
231
232/*****************************************************************************
233 * XOR 1
234 ****************************************************************************/
Saeed Bisharaedabd382009-08-06 15:12:43 +0300235void __init dove_xor1_init(void)
236{
Andrew Lunnee962722011-05-15 13:32:48 +0200237 orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE,
238 IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300239}
240
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300241/*****************************************************************************
242 * SDIO
243 ****************************************************************************/
244static u64 sdio_dmamask = DMA_BIT_MASK(32);
245
246static struct resource dove_sdio0_resources[] = {
247 {
248 .start = DOVE_SDIO0_PHYS_BASE,
249 .end = DOVE_SDIO0_PHYS_BASE + 0xff,
250 .flags = IORESOURCE_MEM,
251 }, {
252 .start = IRQ_DOVE_SDIO0,
253 .end = IRQ_DOVE_SDIO0,
254 .flags = IORESOURCE_IRQ,
255 },
256};
257
258static struct platform_device dove_sdio0 = {
Mike Rapoport930e2fe2010-10-28 21:23:53 +0200259 .name = "sdhci-dove",
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300260 .id = 0,
261 .dev = {
262 .dma_mask = &sdio_dmamask,
263 .coherent_dma_mask = DMA_BIT_MASK(32),
264 },
265 .resource = dove_sdio0_resources,
266 .num_resources = ARRAY_SIZE(dove_sdio0_resources),
267};
268
269void __init dove_sdio0_init(void)
270{
271 platform_device_register(&dove_sdio0);
272}
273
274static struct resource dove_sdio1_resources[] = {
275 {
276 .start = DOVE_SDIO1_PHYS_BASE,
277 .end = DOVE_SDIO1_PHYS_BASE + 0xff,
278 .flags = IORESOURCE_MEM,
279 }, {
280 .start = IRQ_DOVE_SDIO1,
281 .end = IRQ_DOVE_SDIO1,
282 .flags = IORESOURCE_IRQ,
283 },
284};
285
286static struct platform_device dove_sdio1 = {
Mike Rapoport930e2fe2010-10-28 21:23:53 +0200287 .name = "sdhci-dove",
Saeed Bishara16bc90a2010-05-06 16:12:06 +0300288 .id = 1,
289 .dev = {
290 .dma_mask = &sdio_dmamask,
291 .coherent_dma_mask = DMA_BIT_MASK(32),
292 },
293 .resource = dove_sdio1_resources,
294 .num_resources = ARRAY_SIZE(dove_sdio1_resources),
295};
296
297void __init dove_sdio1_init(void)
298{
299 platform_device_register(&dove_sdio1);
300}
301
Saeed Bisharaedabd382009-08-06 15:12:43 +0300302void __init dove_init(void)
303{
304 int tclk;
305
306 tclk = get_tclk();
307
308 printk(KERN_INFO "Dove 88AP510 SoC, ");
309 printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000);
310
Lennert Buytenhek573a6522009-11-24 19:33:52 +0200311#ifdef CONFIG_CACHE_TAUROS2
312 tauros2_init();
313#endif
Saeed Bisharaedabd382009-08-06 15:12:43 +0300314 dove_setup_cpu_mbus();
315
Saeed Bisharaedabd382009-08-06 15:12:43 +0300316 /* internal devices that every board has */
317 dove_rtc_init();
318 dove_xor0_init();
319 dove_xor1_init();
320}