xref: /linux/arch/arm/mach-dove/common.c (revision dea56c78)
10fdebc5eSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2edabd38eSSaeed Bishara /*
3edabd38eSSaeed Bishara  * arch/arm/mach-dove/common.c
4edabd38eSSaeed Bishara  *
5edabd38eSSaeed Bishara  * Core functions for Marvell Dove 88AP510 System On Chip
6edabd38eSSaeed Bishara  */
7edabd38eSSaeed Bishara 
82f129bf4SAndrew Lunn #include <linux/clk-provider.h>
9b3af7a1fSSebastian Hesselbarth #include <linux/dma-mapping.h>
10b3af7a1fSSebastian Hesselbarth #include <linux/init.h>
1162e59c4eSStephen Boyd #include <linux/io.h>
12b3af7a1fSSebastian Hesselbarth #include <linux/platform_data/dma-mv_xor.h>
13b3af7a1fSSebastian Hesselbarth #include <linux/platform_data/usb-ehci-orion.h>
14b3af7a1fSSebastian Hesselbarth #include <linux/platform_device.h>
15c5d431e8SRussell King #include <linux/soc/dove/pmu.h>
16573a652fSLennert Buytenhek #include <asm/hardware/cache-tauros2.h>
17b3af7a1fSSebastian Hesselbarth #include <asm/mach/arch.h>
18edabd38eSSaeed Bishara #include <asm/mach/map.h>
19edabd38eSSaeed Bishara #include <asm/mach/time.h>
2028a2b450SAndrew Lunn #include <plat/common.h>
21b3af7a1fSSebastian Hesselbarth #include <plat/irq.h>
22b3af7a1fSSebastian Hesselbarth #include <plat/time.h>
23ce78179eSArnd Bergmann #include "bridge-regs.h"
24ce78179eSArnd Bergmann #include "pm.h"
25edabd38eSSaeed Bishara #include "common.h"
26edabd38eSSaeed Bishara 
2789a7fbfbSThomas Petazzoni /* These can go away once Dove uses the mvebu-mbus DT binding */
2889a7fbfbSThomas Petazzoni #define DOVE_MBUS_PCIE0_MEM_TARGET    0x4
2989a7fbfbSThomas Petazzoni #define DOVE_MBUS_PCIE0_MEM_ATTR      0xe8
3089a7fbfbSThomas Petazzoni #define DOVE_MBUS_PCIE0_IO_TARGET     0x4
3189a7fbfbSThomas Petazzoni #define DOVE_MBUS_PCIE0_IO_ATTR       0xe0
3289a7fbfbSThomas Petazzoni #define DOVE_MBUS_PCIE1_MEM_TARGET    0x8
3389a7fbfbSThomas Petazzoni #define DOVE_MBUS_PCIE1_MEM_ATTR      0xe8
3489a7fbfbSThomas Petazzoni #define DOVE_MBUS_PCIE1_IO_TARGET     0x8
3589a7fbfbSThomas Petazzoni #define DOVE_MBUS_PCIE1_IO_ATTR       0xe0
3689a7fbfbSThomas Petazzoni #define DOVE_MBUS_CESA_TARGET         0x3
3789a7fbfbSThomas Petazzoni #define DOVE_MBUS_CESA_ATTR           0x1
3889a7fbfbSThomas Petazzoni #define DOVE_MBUS_BOOTROM_TARGET      0x1
3989a7fbfbSThomas Petazzoni #define DOVE_MBUS_BOOTROM_ATTR        0xfd
4089a7fbfbSThomas Petazzoni #define DOVE_MBUS_SCRATCHPAD_TARGET   0xd
4189a7fbfbSThomas Petazzoni #define DOVE_MBUS_SCRATCHPAD_ATTR     0x0
4289a7fbfbSThomas Petazzoni 
43edabd38eSSaeed Bishara /*****************************************************************************
44edabd38eSSaeed Bishara  * I/O Address Mapping
45edabd38eSSaeed Bishara  ****************************************************************************/
46afb80cf1SVincenzo Frascino static struct map_desc __maybe_unused dove_io_desc[] __initdata = {
47edabd38eSSaeed Bishara 	{
48c3c5a281SThomas Petazzoni 		.virtual	= (unsigned long) DOVE_SB_REGS_VIRT_BASE,
49edabd38eSSaeed Bishara 		.pfn		= __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE),
50edabd38eSSaeed Bishara 		.length		= DOVE_SB_REGS_SIZE,
51edabd38eSSaeed Bishara 		.type		= MT_DEVICE,
52edabd38eSSaeed Bishara 	}, {
53c3c5a281SThomas Petazzoni 		.virtual	= (unsigned long) DOVE_NB_REGS_VIRT_BASE,
54edabd38eSSaeed Bishara 		.pfn		= __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE),
55edabd38eSSaeed Bishara 		.length		= DOVE_NB_REGS_SIZE,
56edabd38eSSaeed Bishara 		.type		= MT_DEVICE,
57edabd38eSSaeed Bishara 	},
58edabd38eSSaeed Bishara };
59edabd38eSSaeed Bishara 
dove_map_io(void)60edabd38eSSaeed Bishara void __init dove_map_io(void)
61edabd38eSSaeed Bishara {
62edabd38eSSaeed Bishara 	iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
63edabd38eSSaeed Bishara }
64edabd38eSSaeed Bishara 
65edabd38eSSaeed Bishara /*****************************************************************************
662f129bf4SAndrew Lunn  * CLK tree
672f129bf4SAndrew Lunn  ****************************************************************************/
685817d10bSSebastian Hesselbarth static int dove_tclk;
6952167471SSebastian Hesselbarth 
7052167471SSebastian Hesselbarth static DEFINE_SPINLOCK(gating_lock);
712f129bf4SAndrew Lunn static struct clk *tclk;
722f129bf4SAndrew Lunn 
dove_register_gate(const char * name,const char * parent,u8 bit_idx)7352167471SSebastian Hesselbarth static struct clk __init *dove_register_gate(const char *name,
7452167471SSebastian Hesselbarth 					     const char *parent, u8 bit_idx)
752f129bf4SAndrew Lunn {
7652167471SSebastian Hesselbarth 	return clk_register_gate(NULL, name, parent, 0,
7752167471SSebastian Hesselbarth 				 (void __iomem *)CLOCK_GATING_CONTROL,
7852167471SSebastian Hesselbarth 				 bit_idx, 0, &gating_lock);
7952167471SSebastian Hesselbarth }
804574b886SAndrew Lunn 
dove_clk_init(void)815817d10bSSebastian Hesselbarth static void __init dove_clk_init(void)
822f129bf4SAndrew Lunn {
8352167471SSebastian Hesselbarth 	struct clk *usb0, *usb1, *sata, *pex0, *pex1, *sdio0, *sdio1;
8452167471SSebastian Hesselbarth 	struct clk *nand, *camera, *i2s0, *i2s1, *crypto, *ac97, *pdma;
85*dea56c78SUwe Kleine-König 	struct clk *xor0, *xor1, *ge;
8652167471SSebastian Hesselbarth 
873a1a4559SStephen Boyd 	tclk = clk_register_fixed_rate(NULL, "tclk", NULL, 0, dove_tclk);
884574b886SAndrew Lunn 
8952167471SSebastian Hesselbarth 	usb0 = dove_register_gate("usb0", "tclk", CLOCK_GATING_BIT_USB0);
9052167471SSebastian Hesselbarth 	usb1 = dove_register_gate("usb1", "tclk", CLOCK_GATING_BIT_USB1);
9152167471SSebastian Hesselbarth 	sata = dove_register_gate("sata", "tclk", CLOCK_GATING_BIT_SATA);
9252167471SSebastian Hesselbarth 	pex0 = dove_register_gate("pex0", "tclk", CLOCK_GATING_BIT_PCIE0);
9352167471SSebastian Hesselbarth 	pex1 = dove_register_gate("pex1", "tclk", CLOCK_GATING_BIT_PCIE1);
9452167471SSebastian Hesselbarth 	sdio0 = dove_register_gate("sdio0", "tclk", CLOCK_GATING_BIT_SDIO0);
9552167471SSebastian Hesselbarth 	sdio1 = dove_register_gate("sdio1", "tclk", CLOCK_GATING_BIT_SDIO1);
9652167471SSebastian Hesselbarth 	nand = dove_register_gate("nand", "tclk", CLOCK_GATING_BIT_NAND);
9752167471SSebastian Hesselbarth 	camera = dove_register_gate("camera", "tclk", CLOCK_GATING_BIT_CAMERA);
9852167471SSebastian Hesselbarth 	i2s0 = dove_register_gate("i2s0", "tclk", CLOCK_GATING_BIT_I2S0);
9952167471SSebastian Hesselbarth 	i2s1 = dove_register_gate("i2s1", "tclk", CLOCK_GATING_BIT_I2S1);
10052167471SSebastian Hesselbarth 	crypto = dove_register_gate("crypto", "tclk", CLOCK_GATING_BIT_CRYPTO);
10152167471SSebastian Hesselbarth 	ac97 = dove_register_gate("ac97", "tclk", CLOCK_GATING_BIT_AC97);
10252167471SSebastian Hesselbarth 	pdma = dove_register_gate("pdma", "tclk", CLOCK_GATING_BIT_PDMA);
10352167471SSebastian Hesselbarth 	xor0 = dove_register_gate("xor0", "tclk", CLOCK_GATING_BIT_XOR0);
10452167471SSebastian Hesselbarth 	xor1 = dove_register_gate("xor1", "tclk", CLOCK_GATING_BIT_XOR1);
105*dea56c78SUwe Kleine-König 	dove_register_gate("gephy", "tclk", CLOCK_GATING_BIT_GIGA_PHY);
10652167471SSebastian Hesselbarth 	ge = dove_register_gate("ge", "gephy", CLOCK_GATING_BIT_GBE);
10752167471SSebastian Hesselbarth 
10852167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "orion_spi.0", tclk);
10952167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "orion_spi.1", tclk);
11052167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "orion_wdt", tclk);
11152167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "mv64xxx_i2c.0", tclk);
11252167471SSebastian Hesselbarth 
11352167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "orion-ehci.0", usb0);
11452167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "orion-ehci.1", usb1);
1153fbcd3d0SSebastian Hesselbarth 	orion_clkdev_add(NULL, "mv643xx_eth_port.0", ge);
1163fbcd3d0SSebastian Hesselbarth 	orion_clkdev_add(NULL, "sata_mv.0", sata);
11752167471SSebastian Hesselbarth 	orion_clkdev_add("0", "pcie", pex0);
11852167471SSebastian Hesselbarth 	orion_clkdev_add("1", "pcie", pex1);
11952167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "sdhci-dove.0", sdio0);
12052167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "sdhci-dove.1", sdio1);
12152167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "orion_nand", nand);
12252167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "cafe1000-ccic.0", camera);
12364ddf1f8SRussell King 	orion_clkdev_add(NULL, "mvebu-audio.0", i2s0);
12464ddf1f8SRussell King 	orion_clkdev_add(NULL, "mvebu-audio.1", i2s1);
12552167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "mv_crypto", crypto);
12652167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "dove-ac97", ac97);
12752167471SSebastian Hesselbarth 	orion_clkdev_add(NULL, "dove-pdma", pdma);
1280dddee7aSThomas Petazzoni 	orion_clkdev_add(NULL, MV_XOR_NAME ".0", xor0);
1290dddee7aSThomas Petazzoni 	orion_clkdev_add(NULL, MV_XOR_NAME ".1", xor1);
1302f129bf4SAndrew Lunn }
1312f129bf4SAndrew Lunn 
1322f129bf4SAndrew Lunn /*****************************************************************************
133edabd38eSSaeed Bishara  * EHCI0
134edabd38eSSaeed Bishara  ****************************************************************************/
dove_ehci0_init(void)135edabd38eSSaeed Bishara void __init dove_ehci0_init(void)
136edabd38eSSaeed Bishara {
13772053353SAndrew Lunn 	orion_ehci_init(DOVE_USB0_PHYS_BASE, IRQ_DOVE_USB0, EHCI_PHY_NA);
138edabd38eSSaeed Bishara }
139edabd38eSSaeed Bishara 
140edabd38eSSaeed Bishara /*****************************************************************************
141edabd38eSSaeed Bishara  * EHCI1
142edabd38eSSaeed Bishara  ****************************************************************************/
dove_ehci1_init(void)143edabd38eSSaeed Bishara void __init dove_ehci1_init(void)
144edabd38eSSaeed Bishara {
145db33f4deSAndrew Lunn 	orion_ehci_1_init(DOVE_USB1_PHYS_BASE, IRQ_DOVE_USB1);
146edabd38eSSaeed Bishara }
147edabd38eSSaeed Bishara 
148edabd38eSSaeed Bishara /*****************************************************************************
149edabd38eSSaeed Bishara  * GE00
150edabd38eSSaeed Bishara  ****************************************************************************/
dove_ge00_init(struct mv643xx_eth_platform_data * eth_data)151edabd38eSSaeed Bishara void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
152edabd38eSSaeed Bishara {
15330e0f580SHannes Reinecke 	orion_ge00_init(eth_data, DOVE_GE00_PHYS_BASE,
15458569aeeSArnaud Patard (Rtp) 			IRQ_DOVE_GE00_SUM, IRQ_DOVE_GE00_ERR,
15558569aeeSArnaud Patard (Rtp) 			1600);
156edabd38eSSaeed Bishara }
157edabd38eSSaeed Bishara 
158edabd38eSSaeed Bishara /*****************************************************************************
159edabd38eSSaeed Bishara  * SoC RTC
160edabd38eSSaeed Bishara  ****************************************************************************/
dove_rtc_init(void)161887c206aSAndrew Lunn static void __init dove_rtc_init(void)
162edabd38eSSaeed Bishara {
163f6eaccb3SAndrew Lunn 	orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC);
164edabd38eSSaeed Bishara }
165edabd38eSSaeed Bishara 
166edabd38eSSaeed Bishara /*****************************************************************************
167edabd38eSSaeed Bishara  * SATA
168edabd38eSSaeed Bishara  ****************************************************************************/
dove_sata_init(struct mv_sata_platform_data * sata_data)169edabd38eSSaeed Bishara void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
170edabd38eSSaeed Bishara {
171db33f4deSAndrew Lunn 	orion_sata_init(sata_data, DOVE_SATA_PHYS_BASE, IRQ_DOVE_SATA);
1729e613f8aSAndrew Lunn 
173edabd38eSSaeed Bishara }
174edabd38eSSaeed Bishara 
175edabd38eSSaeed Bishara /*****************************************************************************
176edabd38eSSaeed Bishara  * UART0
177edabd38eSSaeed Bishara  ****************************************************************************/
dove_uart0_init(void)178edabd38eSSaeed Bishara void __init dove_uart0_init(void)
179edabd38eSSaeed Bishara {
18028a2b450SAndrew Lunn 	orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
18174c33576SAndrew Lunn 			 IRQ_DOVE_UART_0, tclk);
182edabd38eSSaeed Bishara }
183edabd38eSSaeed Bishara 
184edabd38eSSaeed Bishara /*****************************************************************************
185edabd38eSSaeed Bishara  * UART1
186edabd38eSSaeed Bishara  ****************************************************************************/
dove_uart1_init(void)187edabd38eSSaeed Bishara void __init dove_uart1_init(void)
188edabd38eSSaeed Bishara {
18928a2b450SAndrew Lunn 	orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
19074c33576SAndrew Lunn 			 IRQ_DOVE_UART_1, tclk);
191edabd38eSSaeed Bishara }
192edabd38eSSaeed Bishara 
193edabd38eSSaeed Bishara /*****************************************************************************
194edabd38eSSaeed Bishara  * UART2
195edabd38eSSaeed Bishara  ****************************************************************************/
dove_uart2_init(void)196edabd38eSSaeed Bishara void __init dove_uart2_init(void)
197edabd38eSSaeed Bishara {
19828a2b450SAndrew Lunn 	orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
19974c33576SAndrew Lunn 			 IRQ_DOVE_UART_2, tclk);
200edabd38eSSaeed Bishara }
201edabd38eSSaeed Bishara 
202edabd38eSSaeed Bishara /*****************************************************************************
203edabd38eSSaeed Bishara  * UART3
204edabd38eSSaeed Bishara  ****************************************************************************/
dove_uart3_init(void)205edabd38eSSaeed Bishara void __init dove_uart3_init(void)
206edabd38eSSaeed Bishara {
20728a2b450SAndrew Lunn 	orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
20874c33576SAndrew Lunn 			 IRQ_DOVE_UART_3, tclk);
209edabd38eSSaeed Bishara }
210edabd38eSSaeed Bishara 
211edabd38eSSaeed Bishara /*****************************************************************************
212980f9f60SAndrew Lunn  * SPI
213edabd38eSSaeed Bishara  ****************************************************************************/
dove_spi0_init(void)214edabd38eSSaeed Bishara void __init dove_spi0_init(void)
215edabd38eSSaeed Bishara {
2164574b886SAndrew Lunn 	orion_spi_init(DOVE_SPI0_PHYS_BASE);
217edabd38eSSaeed Bishara }
218edabd38eSSaeed Bishara 
dove_spi1_init(void)219edabd38eSSaeed Bishara void __init dove_spi1_init(void)
220edabd38eSSaeed Bishara {
2214574b886SAndrew Lunn 	orion_spi_1_init(DOVE_SPI1_PHYS_BASE);
222edabd38eSSaeed Bishara }
223edabd38eSSaeed Bishara 
224edabd38eSSaeed Bishara /*****************************************************************************
225edabd38eSSaeed Bishara  * I2C
226edabd38eSSaeed Bishara  ****************************************************************************/
dove_i2c_init(void)227edabd38eSSaeed Bishara void __init dove_i2c_init(void)
228edabd38eSSaeed Bishara {
229aac7ffa3SAndrew Lunn 	orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10);
230edabd38eSSaeed Bishara }
231edabd38eSSaeed Bishara 
232edabd38eSSaeed Bishara /*****************************************************************************
233edabd38eSSaeed Bishara  * Time handling
234edabd38eSSaeed Bishara  ****************************************************************************/
dove_init_early(void)2354ee1f6b5SLennert Buytenhek void __init dove_init_early(void)
2364ee1f6b5SLennert Buytenhek {
2374ee1f6b5SLennert Buytenhek 	orion_time_set_base(TIMER_VIRT_BASE);
2387d554902SThomas Petazzoni 	mvebu_mbus_init("marvell,dove-mbus",
2397d554902SThomas Petazzoni 			BRIDGE_WINS_BASE, BRIDGE_WINS_SZ,
2407d554902SThomas Petazzoni 			DOVE_MC_WINS_BASE, DOVE_MC_WINS_SZ);
2414ee1f6b5SLennert Buytenhek }
2424ee1f6b5SLennert Buytenhek 
dove_find_tclk(void)2435817d10bSSebastian Hesselbarth static int __init dove_find_tclk(void)
244edabd38eSSaeed Bishara {
245edabd38eSSaeed Bishara 	return 166666667;
246edabd38eSSaeed Bishara }
247edabd38eSSaeed Bishara 
dove_timer_init(void)2486bb27d73SStephen Warren void __init dove_timer_init(void)
249edabd38eSSaeed Bishara {
2505817d10bSSebastian Hesselbarth 	dove_tclk = dove_find_tclk();
2514ee1f6b5SLennert Buytenhek 	orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
2525817d10bSSebastian Hesselbarth 			IRQ_DOVE_BRIDGE, dove_tclk);
253edabd38eSSaeed Bishara }
254edabd38eSSaeed Bishara 
255edabd38eSSaeed Bishara /*****************************************************************************
256edabd38eSSaeed Bishara  * XOR 0
257edabd38eSSaeed Bishara  ****************************************************************************/
dove_xor0_init(void)258887c206aSAndrew Lunn static void __init dove_xor0_init(void)
259edabd38eSSaeed Bishara {
260db33f4deSAndrew Lunn 	orion_xor0_init(DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE,
261ee962723SAndrew Lunn 			IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01);
262edabd38eSSaeed Bishara }
263edabd38eSSaeed Bishara 
264edabd38eSSaeed Bishara /*****************************************************************************
265edabd38eSSaeed Bishara  * XOR 1
266edabd38eSSaeed Bishara  ****************************************************************************/
dove_xor1_init(void)267887c206aSAndrew Lunn static void __init dove_xor1_init(void)
268edabd38eSSaeed Bishara {
269ee962723SAndrew Lunn 	orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE,
270ee962723SAndrew Lunn 			IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11);
271edabd38eSSaeed Bishara }
272edabd38eSSaeed Bishara 
27316bc90afSSaeed Bishara /*****************************************************************************
27416bc90afSSaeed Bishara  * SDIO
27516bc90afSSaeed Bishara  ****************************************************************************/
27616bc90afSSaeed Bishara static u64 sdio_dmamask = DMA_BIT_MASK(32);
27716bc90afSSaeed Bishara 
27816bc90afSSaeed Bishara static struct resource dove_sdio0_resources[] = {
27916bc90afSSaeed Bishara 	{
28016bc90afSSaeed Bishara 		.start	= DOVE_SDIO0_PHYS_BASE,
28116bc90afSSaeed Bishara 		.end	= DOVE_SDIO0_PHYS_BASE + 0xff,
28216bc90afSSaeed Bishara 		.flags	= IORESOURCE_MEM,
28316bc90afSSaeed Bishara 	}, {
28416bc90afSSaeed Bishara 		.start	= IRQ_DOVE_SDIO0,
28516bc90afSSaeed Bishara 		.end	= IRQ_DOVE_SDIO0,
28616bc90afSSaeed Bishara 		.flags	= IORESOURCE_IRQ,
28716bc90afSSaeed Bishara 	},
28816bc90afSSaeed Bishara };
28916bc90afSSaeed Bishara 
29016bc90afSSaeed Bishara static struct platform_device dove_sdio0 = {
291930e2fe7SMike Rapoport 	.name		= "sdhci-dove",
29216bc90afSSaeed Bishara 	.id		= 0,
29316bc90afSSaeed Bishara 	.dev		= {
29416bc90afSSaeed Bishara 		.dma_mask		= &sdio_dmamask,
29516bc90afSSaeed Bishara 		.coherent_dma_mask	= DMA_BIT_MASK(32),
29616bc90afSSaeed Bishara 	},
29716bc90afSSaeed Bishara 	.resource	= dove_sdio0_resources,
29816bc90afSSaeed Bishara 	.num_resources	= ARRAY_SIZE(dove_sdio0_resources),
29916bc90afSSaeed Bishara };
30016bc90afSSaeed Bishara 
dove_sdio0_init(void)30116bc90afSSaeed Bishara void __init dove_sdio0_init(void)
30216bc90afSSaeed Bishara {
30316bc90afSSaeed Bishara 	platform_device_register(&dove_sdio0);
30416bc90afSSaeed Bishara }
30516bc90afSSaeed Bishara 
30616bc90afSSaeed Bishara static struct resource dove_sdio1_resources[] = {
30716bc90afSSaeed Bishara 	{
30816bc90afSSaeed Bishara 		.start	= DOVE_SDIO1_PHYS_BASE,
30916bc90afSSaeed Bishara 		.end	= DOVE_SDIO1_PHYS_BASE + 0xff,
31016bc90afSSaeed Bishara 		.flags	= IORESOURCE_MEM,
31116bc90afSSaeed Bishara 	}, {
31216bc90afSSaeed Bishara 		.start	= IRQ_DOVE_SDIO1,
31316bc90afSSaeed Bishara 		.end	= IRQ_DOVE_SDIO1,
31416bc90afSSaeed Bishara 		.flags	= IORESOURCE_IRQ,
31516bc90afSSaeed Bishara 	},
31616bc90afSSaeed Bishara };
31716bc90afSSaeed Bishara 
31816bc90afSSaeed Bishara static struct platform_device dove_sdio1 = {
319930e2fe7SMike Rapoport 	.name		= "sdhci-dove",
32016bc90afSSaeed Bishara 	.id		= 1,
32116bc90afSSaeed Bishara 	.dev		= {
32216bc90afSSaeed Bishara 		.dma_mask		= &sdio_dmamask,
32316bc90afSSaeed Bishara 		.coherent_dma_mask	= DMA_BIT_MASK(32),
32416bc90afSSaeed Bishara 	},
32516bc90afSSaeed Bishara 	.resource	= dove_sdio1_resources,
32616bc90afSSaeed Bishara 	.num_resources	= ARRAY_SIZE(dove_sdio1_resources),
32716bc90afSSaeed Bishara };
32816bc90afSSaeed Bishara 
dove_sdio1_init(void)32916bc90afSSaeed Bishara void __init dove_sdio1_init(void)
33016bc90afSSaeed Bishara {
33116bc90afSSaeed Bishara 	platform_device_register(&dove_sdio1);
33216bc90afSSaeed Bishara }
33316bc90afSSaeed Bishara 
dove_setup_cpu_wins(void)3347d554902SThomas Petazzoni void __init dove_setup_cpu_wins(void)
3357d554902SThomas Petazzoni {
3367d554902SThomas Petazzoni 	/*
3377d554902SThomas Petazzoni 	 * The PCIe windows will no longer be statically allocated
33889a7fbfbSThomas Petazzoni 	 * here once Dove is migrated to the pci-mvebu driver. The
33989a7fbfbSThomas Petazzoni 	 * non-PCIe windows will no longer be created here once Dove
34089a7fbfbSThomas Petazzoni 	 * fully moves to DT.
3417d554902SThomas Petazzoni 	 */
34289a7fbfbSThomas Petazzoni 	mvebu_mbus_add_window_remap_by_id(DOVE_MBUS_PCIE0_IO_TARGET,
34389a7fbfbSThomas Petazzoni 					  DOVE_MBUS_PCIE0_IO_ATTR,
3447d554902SThomas Petazzoni 					  DOVE_PCIE0_IO_PHYS_BASE,
3457d554902SThomas Petazzoni 					  DOVE_PCIE0_IO_SIZE,
34689a7fbfbSThomas Petazzoni 					  DOVE_PCIE0_IO_BUS_BASE);
34789a7fbfbSThomas Petazzoni 	mvebu_mbus_add_window_remap_by_id(DOVE_MBUS_PCIE1_IO_TARGET,
34889a7fbfbSThomas Petazzoni 					  DOVE_MBUS_PCIE1_IO_ATTR,
3497d554902SThomas Petazzoni 					  DOVE_PCIE1_IO_PHYS_BASE,
3507d554902SThomas Petazzoni 					  DOVE_PCIE1_IO_SIZE,
35189a7fbfbSThomas Petazzoni 					  DOVE_PCIE1_IO_BUS_BASE);
35289a7fbfbSThomas Petazzoni 	mvebu_mbus_add_window_by_id(DOVE_MBUS_PCIE0_MEM_TARGET,
35389a7fbfbSThomas Petazzoni 				    DOVE_MBUS_PCIE0_MEM_ATTR,
3547d554902SThomas Petazzoni 				    DOVE_PCIE0_MEM_PHYS_BASE,
35589a7fbfbSThomas Petazzoni 				    DOVE_PCIE0_MEM_SIZE);
35689a7fbfbSThomas Petazzoni 	mvebu_mbus_add_window_by_id(DOVE_MBUS_PCIE1_MEM_TARGET,
35789a7fbfbSThomas Petazzoni 				    DOVE_MBUS_PCIE1_MEM_ATTR,
3587d554902SThomas Petazzoni 				    DOVE_PCIE1_MEM_PHYS_BASE,
35989a7fbfbSThomas Petazzoni 				    DOVE_PCIE1_MEM_SIZE);
36089a7fbfbSThomas Petazzoni 	mvebu_mbus_add_window_by_id(DOVE_MBUS_CESA_TARGET,
36189a7fbfbSThomas Petazzoni 				    DOVE_MBUS_CESA_ATTR,
36289a7fbfbSThomas Petazzoni 				    DOVE_CESA_PHYS_BASE,
3637d554902SThomas Petazzoni 				    DOVE_CESA_SIZE);
36489a7fbfbSThomas Petazzoni 	mvebu_mbus_add_window_by_id(DOVE_MBUS_BOOTROM_TARGET,
36589a7fbfbSThomas Petazzoni 				    DOVE_MBUS_BOOTROM_ATTR,
36689a7fbfbSThomas Petazzoni 				    DOVE_BOOTROM_PHYS_BASE,
3677d554902SThomas Petazzoni 				    DOVE_BOOTROM_SIZE);
36889a7fbfbSThomas Petazzoni 	mvebu_mbus_add_window_by_id(DOVE_MBUS_SCRATCHPAD_TARGET,
36989a7fbfbSThomas Petazzoni 				    DOVE_MBUS_SCRATCHPAD_ATTR,
37089a7fbfbSThomas Petazzoni 				    DOVE_SCRATCHPAD_PHYS_BASE,
3717d554902SThomas Petazzoni 				    DOVE_SCRATCHPAD_SIZE);
3727d554902SThomas Petazzoni }
3737d554902SThomas Petazzoni 
37406f3008aSArnd Bergmann static struct resource orion_wdt_resource[] = {
37506f3008aSArnd Bergmann 		DEFINE_RES_MEM(TIMER_PHYS_BASE, 0x04),
37606f3008aSArnd Bergmann 		DEFINE_RES_MEM(RSTOUTn_MASK_PHYS, 0x04),
37706f3008aSArnd Bergmann };
37806f3008aSArnd Bergmann 
37906f3008aSArnd Bergmann static struct platform_device orion_wdt_device = {
38006f3008aSArnd Bergmann 	.name		= "orion_wdt",
38106f3008aSArnd Bergmann 	.id		= -1,
38206f3008aSArnd Bergmann 	.num_resources	= ARRAY_SIZE(orion_wdt_resource),
38306f3008aSArnd Bergmann 	.resource	= orion_wdt_resource,
38406f3008aSArnd Bergmann };
38506f3008aSArnd Bergmann 
orion_wdt_init(void)38606f3008aSArnd Bergmann static void __init __maybe_unused orion_wdt_init(void)
38706f3008aSArnd Bergmann {
38806f3008aSArnd Bergmann 	platform_device_register(&orion_wdt_device);
38906f3008aSArnd Bergmann }
39006f3008aSArnd Bergmann 
391c5d431e8SRussell King static const struct dove_pmu_domain_initdata pmu_domains[] __initconst = {
392c5d431e8SRussell King 	{
393c5d431e8SRussell King 		.pwr_mask = PMU_PWR_VPU_PWR_DWN_MASK,
394c5d431e8SRussell King 		.rst_mask = PMU_SW_RST_VIDEO_MASK,
395c5d431e8SRussell King 		.iso_mask = PMU_ISO_VIDEO_MASK,
396c5d431e8SRussell King 		.name = "vpu-domain",
397c5d431e8SRussell King 	}, {
398c5d431e8SRussell King 		.pwr_mask = PMU_PWR_GPU_PWR_DWN_MASK,
399c5d431e8SRussell King 		.rst_mask = PMU_SW_RST_GPU_MASK,
400c5d431e8SRussell King 		.iso_mask = PMU_ISO_GPU_MASK,
401c5d431e8SRussell King 		.name = "gpu-domain",
402c5d431e8SRussell King 	}, {
403c5d431e8SRussell King 		/* sentinel */
404c5d431e8SRussell King 	},
405c5d431e8SRussell King };
406c5d431e8SRussell King 
407c5d431e8SRussell King static const struct dove_pmu_initdata pmu_data __initconst = {
408c5d431e8SRussell King 	.pmc_base = DOVE_PMU_VIRT_BASE,
409c5d431e8SRussell King 	.pmu_base = DOVE_PMU_VIRT_BASE + 0x8000,
410c5d431e8SRussell King 	.irq = IRQ_DOVE_PMU,
411c5d431e8SRussell King 	.irq_domain_start = IRQ_DOVE_PMU_START,
412c5d431e8SRussell King 	.domains = pmu_domains,
413c5d431e8SRussell King };
414c5d431e8SRussell King 
dove_init(void)415edabd38eSSaeed Bishara void __init dove_init(void)
416edabd38eSSaeed Bishara {
4175817d10bSSebastian Hesselbarth 	pr_info("Dove 88AP510 SoC, TCLK = %d MHz.\n",
4185817d10bSSebastian Hesselbarth 		(dove_tclk + 499999) / 1000000);
419edabd38eSSaeed Bishara 
420573a652fSLennert Buytenhek #ifdef CONFIG_CACHE_TAUROS2
4215cc58157SChao Xie 	tauros2_init(0);
422573a652fSLennert Buytenhek #endif
4237d554902SThomas Petazzoni 	dove_setup_cpu_wins();
424edabd38eSSaeed Bishara 
4252f129bf4SAndrew Lunn 	/* Setup root of clk tree */
4265817d10bSSebastian Hesselbarth 	dove_clk_init();
4272f129bf4SAndrew Lunn 
428edabd38eSSaeed Bishara 	/* internal devices that every board has */
429c5d431e8SRussell King 	dove_init_pmu_legacy(&pmu_data);
430edabd38eSSaeed Bishara 	dove_rtc_init();
431edabd38eSSaeed Bishara 	dove_xor0_init();
432edabd38eSSaeed Bishara 	dove_xor1_init();
433edabd38eSSaeed Bishara }
4346ca6ff97SRussell King 
dove_restart(enum reboot_mode mode,const char * cmd)4357b6d864bSRobin Holt void dove_restart(enum reboot_mode mode, const char *cmd)
4366ca6ff97SRussell King {
4376ca6ff97SRussell King 	/*
4386ca6ff97SRussell King 	 * Enable soft reset to assert RSTOUTn.
4396ca6ff97SRussell King 	 */
4406ca6ff97SRussell King 	writel(SOFT_RESET_OUT_EN, RSTOUTn_MASK);
4416ca6ff97SRussell King 
4426ca6ff97SRussell King 	/*
4436ca6ff97SRussell King 	 * Assert soft reset.
4446ca6ff97SRussell King 	 */
4456ca6ff97SRussell King 	writel(SOFT_RESET, SYSTEM_SOFT_RESET);
4466ca6ff97SRussell King 
4476ca6ff97SRussell King 	while (1)
4486ca6ff97SRussell King 		;
4496ca6ff97SRussell King }
450