2 * arch/arm/mach-dove/common.c
4 * Core functions for Marvell Dove 88AP510 System On Chip
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.
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/clk-provider.h>
17 #include <linux/ata_platform.h>
18 #include <linux/gpio.h>
20 #include <asm/setup.h>
21 #include <asm/timex.h>
22 #include <asm/hardware/cache-tauros2.h>
23 #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>
30 #include <plat/time.h>
31 #include <plat/ehci-orion.h>
32 #include <plat/common.h>
33 #include <plat/addr-map.h>
36 static int get_tclk(void);
38 /*****************************************************************************
40 ****************************************************************************/
41 static struct map_desc dove_io_desc
[] __initdata
= {
43 .virtual = DOVE_SB_REGS_VIRT_BASE
,
44 .pfn
= __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE
),
45 .length
= DOVE_SB_REGS_SIZE
,
48 .virtual = DOVE_NB_REGS_VIRT_BASE
,
49 .pfn
= __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE
),
50 .length
= DOVE_NB_REGS_SIZE
,
53 .virtual = DOVE_PCIE0_IO_VIRT_BASE
,
54 .pfn
= __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE
),
55 .length
= DOVE_PCIE0_IO_SIZE
,
58 .virtual = DOVE_PCIE1_IO_VIRT_BASE
,
59 .pfn
= __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE
),
60 .length
= DOVE_PCIE1_IO_SIZE
,
65 void __init
dove_map_io(void)
67 iotable_init(dove_io_desc
, ARRAY_SIZE(dove_io_desc
));
70 /*****************************************************************************
72 ****************************************************************************/
73 static struct clk
*tclk
;
75 static void __init
clk_init(void)
77 tclk
= clk_register_fixed_rate(NULL
, "tclk", NULL
, CLK_IS_ROOT
,
80 orion_clkdev_init(tclk
);
83 /*****************************************************************************
85 ****************************************************************************/
86 void __init
dove_ehci0_init(void)
88 orion_ehci_init(DOVE_USB0_PHYS_BASE
, IRQ_DOVE_USB0
, EHCI_PHY_NA
);
91 /*****************************************************************************
93 ****************************************************************************/
94 void __init
dove_ehci1_init(void)
96 orion_ehci_1_init(DOVE_USB1_PHYS_BASE
, IRQ_DOVE_USB1
);
99 /*****************************************************************************
101 ****************************************************************************/
102 void __init
dove_ge00_init(struct mv643xx_eth_platform_data
*eth_data
)
104 orion_ge00_init(eth_data
, DOVE_GE00_PHYS_BASE
,
105 IRQ_DOVE_GE00_SUM
, IRQ_DOVE_GE00_ERR
,
109 /*****************************************************************************
111 ****************************************************************************/
112 void __init
dove_rtc_init(void)
114 orion_rtc_init(DOVE_RTC_PHYS_BASE
, IRQ_DOVE_RTC
);
117 /*****************************************************************************
119 ****************************************************************************/
120 void __init
dove_sata_init(struct mv_sata_platform_data
*sata_data
)
122 orion_sata_init(sata_data
, DOVE_SATA_PHYS_BASE
, IRQ_DOVE_SATA
);
126 /*****************************************************************************
128 ****************************************************************************/
129 void __init
dove_uart0_init(void)
131 orion_uart0_init(DOVE_UART0_VIRT_BASE
, DOVE_UART0_PHYS_BASE
,
132 IRQ_DOVE_UART_0
, tclk
);
135 /*****************************************************************************
137 ****************************************************************************/
138 void __init
dove_uart1_init(void)
140 orion_uart1_init(DOVE_UART1_VIRT_BASE
, DOVE_UART1_PHYS_BASE
,
141 IRQ_DOVE_UART_1
, tclk
);
144 /*****************************************************************************
146 ****************************************************************************/
147 void __init
dove_uart2_init(void)
149 orion_uart2_init(DOVE_UART2_VIRT_BASE
, DOVE_UART2_PHYS_BASE
,
150 IRQ_DOVE_UART_2
, tclk
);
153 /*****************************************************************************
155 ****************************************************************************/
156 void __init
dove_uart3_init(void)
158 orion_uart3_init(DOVE_UART3_VIRT_BASE
, DOVE_UART3_PHYS_BASE
,
159 IRQ_DOVE_UART_3
, tclk
);
162 /*****************************************************************************
164 ****************************************************************************/
165 void __init
dove_spi0_init(void)
167 orion_spi_init(DOVE_SPI0_PHYS_BASE
);
170 void __init
dove_spi1_init(void)
172 orion_spi_1_init(DOVE_SPI1_PHYS_BASE
);
175 /*****************************************************************************
177 ****************************************************************************/
178 void __init
dove_i2c_init(void)
180 orion_i2c_init(DOVE_I2C_PHYS_BASE
, IRQ_DOVE_I2C
, 10);
183 /*****************************************************************************
185 ****************************************************************************/
186 void __init
dove_init_early(void)
188 orion_time_set_base(TIMER_VIRT_BASE
);
191 static int get_tclk(void)
193 /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
197 static void __init
dove_timer_init(void)
199 orion_time_init(BRIDGE_VIRT_BASE
, BRIDGE_INT_TIMER1_CLR
,
200 IRQ_DOVE_BRIDGE
, get_tclk());
203 struct sys_timer dove_timer
= {
204 .init
= dove_timer_init
,
207 /*****************************************************************************
209 ****************************************************************************/
210 void __init
dove_xor0_init(void)
212 orion_xor0_init(DOVE_XOR0_PHYS_BASE
, DOVE_XOR0_HIGH_PHYS_BASE
,
213 IRQ_DOVE_XOR_00
, IRQ_DOVE_XOR_01
);
216 /*****************************************************************************
218 ****************************************************************************/
219 void __init
dove_xor1_init(void)
221 orion_xor1_init(DOVE_XOR1_PHYS_BASE
, DOVE_XOR1_HIGH_PHYS_BASE
,
222 IRQ_DOVE_XOR_10
, IRQ_DOVE_XOR_11
);
225 /*****************************************************************************
227 ****************************************************************************/
228 static u64 sdio_dmamask
= DMA_BIT_MASK(32);
230 static struct resource dove_sdio0_resources
[] = {
232 .start
= DOVE_SDIO0_PHYS_BASE
,
233 .end
= DOVE_SDIO0_PHYS_BASE
+ 0xff,
234 .flags
= IORESOURCE_MEM
,
236 .start
= IRQ_DOVE_SDIO0
,
237 .end
= IRQ_DOVE_SDIO0
,
238 .flags
= IORESOURCE_IRQ
,
242 static struct platform_device dove_sdio0
= {
243 .name
= "sdhci-dove",
246 .dma_mask
= &sdio_dmamask
,
247 .coherent_dma_mask
= DMA_BIT_MASK(32),
249 .resource
= dove_sdio0_resources
,
250 .num_resources
= ARRAY_SIZE(dove_sdio0_resources
),
253 void __init
dove_sdio0_init(void)
255 platform_device_register(&dove_sdio0
);
258 static struct resource dove_sdio1_resources
[] = {
260 .start
= DOVE_SDIO1_PHYS_BASE
,
261 .end
= DOVE_SDIO1_PHYS_BASE
+ 0xff,
262 .flags
= IORESOURCE_MEM
,
264 .start
= IRQ_DOVE_SDIO1
,
265 .end
= IRQ_DOVE_SDIO1
,
266 .flags
= IORESOURCE_IRQ
,
270 static struct platform_device dove_sdio1
= {
271 .name
= "sdhci-dove",
274 .dma_mask
= &sdio_dmamask
,
275 .coherent_dma_mask
= DMA_BIT_MASK(32),
277 .resource
= dove_sdio1_resources
,
278 .num_resources
= ARRAY_SIZE(dove_sdio1_resources
),
281 void __init
dove_sdio1_init(void)
283 platform_device_register(&dove_sdio1
);
286 void __init
dove_init(void)
288 printk(KERN_INFO
"Dove 88AP510 SoC, ");
289 printk(KERN_INFO
"TCLK = %dMHz\n", (get_tclk() + 499999) / 1000000);
291 #ifdef CONFIG_CACHE_TAUROS2
294 dove_setup_cpu_mbus();
296 /* Setup root of clk tree */
299 /* internal devices that every board has */
305 void dove_restart(char mode
, const char *cmd
)
308 * Enable soft reset to assert RSTOUTn.
310 writel(SOFT_RESET_OUT_EN
, RSTOUTn_MASK
);
315 writel(SOFT_RESET
, SYSTEM_SOFT_RESET
);