18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * arch/arm/mach-dove/common.c
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Core functions for Marvell Dove 88AP510 System On Chip
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public
78c2ecf20Sopenharmony_ci * License version 2.  This program is licensed "as is" without any
88c2ecf20Sopenharmony_ci * warranty of any kind, whether express or implied.
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
128c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h>
138c2ecf20Sopenharmony_ci#include <linux/init.h>
148c2ecf20Sopenharmony_ci#include <linux/io.h>
158c2ecf20Sopenharmony_ci#include <linux/of.h>
168c2ecf20Sopenharmony_ci#include <linux/of_platform.h>
178c2ecf20Sopenharmony_ci#include <linux/platform_data/dma-mv_xor.h>
188c2ecf20Sopenharmony_ci#include <linux/platform_data/usb-ehci-orion.h>
198c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
208c2ecf20Sopenharmony_ci#include <linux/soc/dove/pmu.h>
218c2ecf20Sopenharmony_ci#include <asm/hardware/cache-tauros2.h>
228c2ecf20Sopenharmony_ci#include <asm/mach/arch.h>
238c2ecf20Sopenharmony_ci#include <asm/mach/map.h>
248c2ecf20Sopenharmony_ci#include <asm/mach/time.h>
258c2ecf20Sopenharmony_ci#include <plat/common.h>
268c2ecf20Sopenharmony_ci#include <plat/irq.h>
278c2ecf20Sopenharmony_ci#include <plat/time.h>
288c2ecf20Sopenharmony_ci#include "bridge-regs.h"
298c2ecf20Sopenharmony_ci#include "pm.h"
308c2ecf20Sopenharmony_ci#include "common.h"
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* These can go away once Dove uses the mvebu-mbus DT binding */
338c2ecf20Sopenharmony_ci#define DOVE_MBUS_PCIE0_MEM_TARGET    0x4
348c2ecf20Sopenharmony_ci#define DOVE_MBUS_PCIE0_MEM_ATTR      0xe8
358c2ecf20Sopenharmony_ci#define DOVE_MBUS_PCIE0_IO_TARGET     0x4
368c2ecf20Sopenharmony_ci#define DOVE_MBUS_PCIE0_IO_ATTR       0xe0
378c2ecf20Sopenharmony_ci#define DOVE_MBUS_PCIE1_MEM_TARGET    0x8
388c2ecf20Sopenharmony_ci#define DOVE_MBUS_PCIE1_MEM_ATTR      0xe8
398c2ecf20Sopenharmony_ci#define DOVE_MBUS_PCIE1_IO_TARGET     0x8
408c2ecf20Sopenharmony_ci#define DOVE_MBUS_PCIE1_IO_ATTR       0xe0
418c2ecf20Sopenharmony_ci#define DOVE_MBUS_CESA_TARGET         0x3
428c2ecf20Sopenharmony_ci#define DOVE_MBUS_CESA_ATTR           0x1
438c2ecf20Sopenharmony_ci#define DOVE_MBUS_BOOTROM_TARGET      0x1
448c2ecf20Sopenharmony_ci#define DOVE_MBUS_BOOTROM_ATTR        0xfd
458c2ecf20Sopenharmony_ci#define DOVE_MBUS_SCRATCHPAD_TARGET   0xd
468c2ecf20Sopenharmony_ci#define DOVE_MBUS_SCRATCHPAD_ATTR     0x0
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/*****************************************************************************
498c2ecf20Sopenharmony_ci * I/O Address Mapping
508c2ecf20Sopenharmony_ci ****************************************************************************/
518c2ecf20Sopenharmony_cistatic struct map_desc __maybe_unused dove_io_desc[] __initdata = {
528c2ecf20Sopenharmony_ci	{
538c2ecf20Sopenharmony_ci		.virtual	= (unsigned long) DOVE_SB_REGS_VIRT_BASE,
548c2ecf20Sopenharmony_ci		.pfn		= __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE),
558c2ecf20Sopenharmony_ci		.length		= DOVE_SB_REGS_SIZE,
568c2ecf20Sopenharmony_ci		.type		= MT_DEVICE,
578c2ecf20Sopenharmony_ci	}, {
588c2ecf20Sopenharmony_ci		.virtual	= (unsigned long) DOVE_NB_REGS_VIRT_BASE,
598c2ecf20Sopenharmony_ci		.pfn		= __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE),
608c2ecf20Sopenharmony_ci		.length		= DOVE_NB_REGS_SIZE,
618c2ecf20Sopenharmony_ci		.type		= MT_DEVICE,
628c2ecf20Sopenharmony_ci	},
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_civoid __init dove_map_io(void)
668c2ecf20Sopenharmony_ci{
678c2ecf20Sopenharmony_ci	iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
688c2ecf20Sopenharmony_ci}
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/*****************************************************************************
718c2ecf20Sopenharmony_ci * CLK tree
728c2ecf20Sopenharmony_ci ****************************************************************************/
738c2ecf20Sopenharmony_cistatic int dove_tclk;
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(gating_lock);
768c2ecf20Sopenharmony_cistatic struct clk *tclk;
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cistatic struct clk __init *dove_register_gate(const char *name,
798c2ecf20Sopenharmony_ci					     const char *parent, u8 bit_idx)
808c2ecf20Sopenharmony_ci{
818c2ecf20Sopenharmony_ci	return clk_register_gate(NULL, name, parent, 0,
828c2ecf20Sopenharmony_ci				 (void __iomem *)CLOCK_GATING_CONTROL,
838c2ecf20Sopenharmony_ci				 bit_idx, 0, &gating_lock);
848c2ecf20Sopenharmony_ci}
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_cistatic void __init dove_clk_init(void)
878c2ecf20Sopenharmony_ci{
888c2ecf20Sopenharmony_ci	struct clk *usb0, *usb1, *sata, *pex0, *pex1, *sdio0, *sdio1;
898c2ecf20Sopenharmony_ci	struct clk *nand, *camera, *i2s0, *i2s1, *crypto, *ac97, *pdma;
908c2ecf20Sopenharmony_ci	struct clk *xor0, *xor1, *ge, *gephy;
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci	tclk = clk_register_fixed_rate(NULL, "tclk", NULL, 0, dove_tclk);
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	usb0 = dove_register_gate("usb0", "tclk", CLOCK_GATING_BIT_USB0);
958c2ecf20Sopenharmony_ci	usb1 = dove_register_gate("usb1", "tclk", CLOCK_GATING_BIT_USB1);
968c2ecf20Sopenharmony_ci	sata = dove_register_gate("sata", "tclk", CLOCK_GATING_BIT_SATA);
978c2ecf20Sopenharmony_ci	pex0 = dove_register_gate("pex0", "tclk", CLOCK_GATING_BIT_PCIE0);
988c2ecf20Sopenharmony_ci	pex1 = dove_register_gate("pex1", "tclk", CLOCK_GATING_BIT_PCIE1);
998c2ecf20Sopenharmony_ci	sdio0 = dove_register_gate("sdio0", "tclk", CLOCK_GATING_BIT_SDIO0);
1008c2ecf20Sopenharmony_ci	sdio1 = dove_register_gate("sdio1", "tclk", CLOCK_GATING_BIT_SDIO1);
1018c2ecf20Sopenharmony_ci	nand = dove_register_gate("nand", "tclk", CLOCK_GATING_BIT_NAND);
1028c2ecf20Sopenharmony_ci	camera = dove_register_gate("camera", "tclk", CLOCK_GATING_BIT_CAMERA);
1038c2ecf20Sopenharmony_ci	i2s0 = dove_register_gate("i2s0", "tclk", CLOCK_GATING_BIT_I2S0);
1048c2ecf20Sopenharmony_ci	i2s1 = dove_register_gate("i2s1", "tclk", CLOCK_GATING_BIT_I2S1);
1058c2ecf20Sopenharmony_ci	crypto = dove_register_gate("crypto", "tclk", CLOCK_GATING_BIT_CRYPTO);
1068c2ecf20Sopenharmony_ci	ac97 = dove_register_gate("ac97", "tclk", CLOCK_GATING_BIT_AC97);
1078c2ecf20Sopenharmony_ci	pdma = dove_register_gate("pdma", "tclk", CLOCK_GATING_BIT_PDMA);
1088c2ecf20Sopenharmony_ci	xor0 = dove_register_gate("xor0", "tclk", CLOCK_GATING_BIT_XOR0);
1098c2ecf20Sopenharmony_ci	xor1 = dove_register_gate("xor1", "tclk", CLOCK_GATING_BIT_XOR1);
1108c2ecf20Sopenharmony_ci	gephy = dove_register_gate("gephy", "tclk", CLOCK_GATING_BIT_GIGA_PHY);
1118c2ecf20Sopenharmony_ci	ge = dove_register_gate("ge", "gephy", CLOCK_GATING_BIT_GBE);
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "orion_spi.0", tclk);
1148c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "orion_spi.1", tclk);
1158c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "orion_wdt", tclk);
1168c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "mv64xxx_i2c.0", tclk);
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "orion-ehci.0", usb0);
1198c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "orion-ehci.1", usb1);
1208c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "mv643xx_eth_port.0", ge);
1218c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "sata_mv.0", sata);
1228c2ecf20Sopenharmony_ci	orion_clkdev_add("0", "pcie", pex0);
1238c2ecf20Sopenharmony_ci	orion_clkdev_add("1", "pcie", pex1);
1248c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "sdhci-dove.0", sdio0);
1258c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "sdhci-dove.1", sdio1);
1268c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "orion_nand", nand);
1278c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "cafe1000-ccic.0", camera);
1288c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "mvebu-audio.0", i2s0);
1298c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "mvebu-audio.1", i2s1);
1308c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "mv_crypto", crypto);
1318c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "dove-ac97", ac97);
1328c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, "dove-pdma", pdma);
1338c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, MV_XOR_NAME ".0", xor0);
1348c2ecf20Sopenharmony_ci	orion_clkdev_add(NULL, MV_XOR_NAME ".1", xor1);
1358c2ecf20Sopenharmony_ci}
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci/*****************************************************************************
1388c2ecf20Sopenharmony_ci * EHCI0
1398c2ecf20Sopenharmony_ci ****************************************************************************/
1408c2ecf20Sopenharmony_civoid __init dove_ehci0_init(void)
1418c2ecf20Sopenharmony_ci{
1428c2ecf20Sopenharmony_ci	orion_ehci_init(DOVE_USB0_PHYS_BASE, IRQ_DOVE_USB0, EHCI_PHY_NA);
1438c2ecf20Sopenharmony_ci}
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci/*****************************************************************************
1468c2ecf20Sopenharmony_ci * EHCI1
1478c2ecf20Sopenharmony_ci ****************************************************************************/
1488c2ecf20Sopenharmony_civoid __init dove_ehci1_init(void)
1498c2ecf20Sopenharmony_ci{
1508c2ecf20Sopenharmony_ci	orion_ehci_1_init(DOVE_USB1_PHYS_BASE, IRQ_DOVE_USB1);
1518c2ecf20Sopenharmony_ci}
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci/*****************************************************************************
1548c2ecf20Sopenharmony_ci * GE00
1558c2ecf20Sopenharmony_ci ****************************************************************************/
1568c2ecf20Sopenharmony_civoid __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
1578c2ecf20Sopenharmony_ci{
1588c2ecf20Sopenharmony_ci	orion_ge00_init(eth_data, DOVE_GE00_PHYS_BASE,
1598c2ecf20Sopenharmony_ci			IRQ_DOVE_GE00_SUM, IRQ_DOVE_GE00_ERR,
1608c2ecf20Sopenharmony_ci			1600);
1618c2ecf20Sopenharmony_ci}
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci/*****************************************************************************
1648c2ecf20Sopenharmony_ci * SoC RTC
1658c2ecf20Sopenharmony_ci ****************************************************************************/
1668c2ecf20Sopenharmony_cistatic void __init dove_rtc_init(void)
1678c2ecf20Sopenharmony_ci{
1688c2ecf20Sopenharmony_ci	orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC);
1698c2ecf20Sopenharmony_ci}
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci/*****************************************************************************
1728c2ecf20Sopenharmony_ci * SATA
1738c2ecf20Sopenharmony_ci ****************************************************************************/
1748c2ecf20Sopenharmony_civoid __init dove_sata_init(struct mv_sata_platform_data *sata_data)
1758c2ecf20Sopenharmony_ci{
1768c2ecf20Sopenharmony_ci	orion_sata_init(sata_data, DOVE_SATA_PHYS_BASE, IRQ_DOVE_SATA);
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci}
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci/*****************************************************************************
1818c2ecf20Sopenharmony_ci * UART0
1828c2ecf20Sopenharmony_ci ****************************************************************************/
1838c2ecf20Sopenharmony_civoid __init dove_uart0_init(void)
1848c2ecf20Sopenharmony_ci{
1858c2ecf20Sopenharmony_ci	orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
1868c2ecf20Sopenharmony_ci			 IRQ_DOVE_UART_0, tclk);
1878c2ecf20Sopenharmony_ci}
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci/*****************************************************************************
1908c2ecf20Sopenharmony_ci * UART1
1918c2ecf20Sopenharmony_ci ****************************************************************************/
1928c2ecf20Sopenharmony_civoid __init dove_uart1_init(void)
1938c2ecf20Sopenharmony_ci{
1948c2ecf20Sopenharmony_ci	orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
1958c2ecf20Sopenharmony_ci			 IRQ_DOVE_UART_1, tclk);
1968c2ecf20Sopenharmony_ci}
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci/*****************************************************************************
1998c2ecf20Sopenharmony_ci * UART2
2008c2ecf20Sopenharmony_ci ****************************************************************************/
2018c2ecf20Sopenharmony_civoid __init dove_uart2_init(void)
2028c2ecf20Sopenharmony_ci{
2038c2ecf20Sopenharmony_ci	orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
2048c2ecf20Sopenharmony_ci			 IRQ_DOVE_UART_2, tclk);
2058c2ecf20Sopenharmony_ci}
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci/*****************************************************************************
2088c2ecf20Sopenharmony_ci * UART3
2098c2ecf20Sopenharmony_ci ****************************************************************************/
2108c2ecf20Sopenharmony_civoid __init dove_uart3_init(void)
2118c2ecf20Sopenharmony_ci{
2128c2ecf20Sopenharmony_ci	orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
2138c2ecf20Sopenharmony_ci			 IRQ_DOVE_UART_3, tclk);
2148c2ecf20Sopenharmony_ci}
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci/*****************************************************************************
2178c2ecf20Sopenharmony_ci * SPI
2188c2ecf20Sopenharmony_ci ****************************************************************************/
2198c2ecf20Sopenharmony_civoid __init dove_spi0_init(void)
2208c2ecf20Sopenharmony_ci{
2218c2ecf20Sopenharmony_ci	orion_spi_init(DOVE_SPI0_PHYS_BASE);
2228c2ecf20Sopenharmony_ci}
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_civoid __init dove_spi1_init(void)
2258c2ecf20Sopenharmony_ci{
2268c2ecf20Sopenharmony_ci	orion_spi_1_init(DOVE_SPI1_PHYS_BASE);
2278c2ecf20Sopenharmony_ci}
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci/*****************************************************************************
2308c2ecf20Sopenharmony_ci * I2C
2318c2ecf20Sopenharmony_ci ****************************************************************************/
2328c2ecf20Sopenharmony_civoid __init dove_i2c_init(void)
2338c2ecf20Sopenharmony_ci{
2348c2ecf20Sopenharmony_ci	orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10);
2358c2ecf20Sopenharmony_ci}
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci/*****************************************************************************
2388c2ecf20Sopenharmony_ci * Time handling
2398c2ecf20Sopenharmony_ci ****************************************************************************/
2408c2ecf20Sopenharmony_civoid __init dove_init_early(void)
2418c2ecf20Sopenharmony_ci{
2428c2ecf20Sopenharmony_ci	orion_time_set_base(TIMER_VIRT_BASE);
2438c2ecf20Sopenharmony_ci	mvebu_mbus_init("marvell,dove-mbus",
2448c2ecf20Sopenharmony_ci			BRIDGE_WINS_BASE, BRIDGE_WINS_SZ,
2458c2ecf20Sopenharmony_ci			DOVE_MC_WINS_BASE, DOVE_MC_WINS_SZ);
2468c2ecf20Sopenharmony_ci}
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_cistatic int __init dove_find_tclk(void)
2498c2ecf20Sopenharmony_ci{
2508c2ecf20Sopenharmony_ci	return 166666667;
2518c2ecf20Sopenharmony_ci}
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_civoid __init dove_timer_init(void)
2548c2ecf20Sopenharmony_ci{
2558c2ecf20Sopenharmony_ci	dove_tclk = dove_find_tclk();
2568c2ecf20Sopenharmony_ci	orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
2578c2ecf20Sopenharmony_ci			IRQ_DOVE_BRIDGE, dove_tclk);
2588c2ecf20Sopenharmony_ci}
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci/*****************************************************************************
2618c2ecf20Sopenharmony_ci * XOR 0
2628c2ecf20Sopenharmony_ci ****************************************************************************/
2638c2ecf20Sopenharmony_cistatic void __init dove_xor0_init(void)
2648c2ecf20Sopenharmony_ci{
2658c2ecf20Sopenharmony_ci	orion_xor0_init(DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE,
2668c2ecf20Sopenharmony_ci			IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01);
2678c2ecf20Sopenharmony_ci}
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ci/*****************************************************************************
2708c2ecf20Sopenharmony_ci * XOR 1
2718c2ecf20Sopenharmony_ci ****************************************************************************/
2728c2ecf20Sopenharmony_cistatic void __init dove_xor1_init(void)
2738c2ecf20Sopenharmony_ci{
2748c2ecf20Sopenharmony_ci	orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE,
2758c2ecf20Sopenharmony_ci			IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11);
2768c2ecf20Sopenharmony_ci}
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci/*****************************************************************************
2798c2ecf20Sopenharmony_ci * SDIO
2808c2ecf20Sopenharmony_ci ****************************************************************************/
2818c2ecf20Sopenharmony_cistatic u64 sdio_dmamask = DMA_BIT_MASK(32);
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_cistatic struct resource dove_sdio0_resources[] = {
2848c2ecf20Sopenharmony_ci	{
2858c2ecf20Sopenharmony_ci		.start	= DOVE_SDIO0_PHYS_BASE,
2868c2ecf20Sopenharmony_ci		.end	= DOVE_SDIO0_PHYS_BASE + 0xff,
2878c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
2888c2ecf20Sopenharmony_ci	}, {
2898c2ecf20Sopenharmony_ci		.start	= IRQ_DOVE_SDIO0,
2908c2ecf20Sopenharmony_ci		.end	= IRQ_DOVE_SDIO0,
2918c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
2928c2ecf20Sopenharmony_ci	},
2938c2ecf20Sopenharmony_ci};
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_cistatic struct platform_device dove_sdio0 = {
2968c2ecf20Sopenharmony_ci	.name		= "sdhci-dove",
2978c2ecf20Sopenharmony_ci	.id		= 0,
2988c2ecf20Sopenharmony_ci	.dev		= {
2998c2ecf20Sopenharmony_ci		.dma_mask		= &sdio_dmamask,
3008c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
3018c2ecf20Sopenharmony_ci	},
3028c2ecf20Sopenharmony_ci	.resource	= dove_sdio0_resources,
3038c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dove_sdio0_resources),
3048c2ecf20Sopenharmony_ci};
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_civoid __init dove_sdio0_init(void)
3078c2ecf20Sopenharmony_ci{
3088c2ecf20Sopenharmony_ci	platform_device_register(&dove_sdio0);
3098c2ecf20Sopenharmony_ci}
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_cistatic struct resource dove_sdio1_resources[] = {
3128c2ecf20Sopenharmony_ci	{
3138c2ecf20Sopenharmony_ci		.start	= DOVE_SDIO1_PHYS_BASE,
3148c2ecf20Sopenharmony_ci		.end	= DOVE_SDIO1_PHYS_BASE + 0xff,
3158c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
3168c2ecf20Sopenharmony_ci	}, {
3178c2ecf20Sopenharmony_ci		.start	= IRQ_DOVE_SDIO1,
3188c2ecf20Sopenharmony_ci		.end	= IRQ_DOVE_SDIO1,
3198c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
3208c2ecf20Sopenharmony_ci	},
3218c2ecf20Sopenharmony_ci};
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_cistatic struct platform_device dove_sdio1 = {
3248c2ecf20Sopenharmony_ci	.name		= "sdhci-dove",
3258c2ecf20Sopenharmony_ci	.id		= 1,
3268c2ecf20Sopenharmony_ci	.dev		= {
3278c2ecf20Sopenharmony_ci		.dma_mask		= &sdio_dmamask,
3288c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
3298c2ecf20Sopenharmony_ci	},
3308c2ecf20Sopenharmony_ci	.resource	= dove_sdio1_resources,
3318c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dove_sdio1_resources),
3328c2ecf20Sopenharmony_ci};
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_civoid __init dove_sdio1_init(void)
3358c2ecf20Sopenharmony_ci{
3368c2ecf20Sopenharmony_ci	platform_device_register(&dove_sdio1);
3378c2ecf20Sopenharmony_ci}
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_civoid __init dove_setup_cpu_wins(void)
3408c2ecf20Sopenharmony_ci{
3418c2ecf20Sopenharmony_ci	/*
3428c2ecf20Sopenharmony_ci	 * The PCIe windows will no longer be statically allocated
3438c2ecf20Sopenharmony_ci	 * here once Dove is migrated to the pci-mvebu driver. The
3448c2ecf20Sopenharmony_ci	 * non-PCIe windows will no longer be created here once Dove
3458c2ecf20Sopenharmony_ci	 * fully moves to DT.
3468c2ecf20Sopenharmony_ci	 */
3478c2ecf20Sopenharmony_ci	mvebu_mbus_add_window_remap_by_id(DOVE_MBUS_PCIE0_IO_TARGET,
3488c2ecf20Sopenharmony_ci					  DOVE_MBUS_PCIE0_IO_ATTR,
3498c2ecf20Sopenharmony_ci					  DOVE_PCIE0_IO_PHYS_BASE,
3508c2ecf20Sopenharmony_ci					  DOVE_PCIE0_IO_SIZE,
3518c2ecf20Sopenharmony_ci					  DOVE_PCIE0_IO_BUS_BASE);
3528c2ecf20Sopenharmony_ci	mvebu_mbus_add_window_remap_by_id(DOVE_MBUS_PCIE1_IO_TARGET,
3538c2ecf20Sopenharmony_ci					  DOVE_MBUS_PCIE1_IO_ATTR,
3548c2ecf20Sopenharmony_ci					  DOVE_PCIE1_IO_PHYS_BASE,
3558c2ecf20Sopenharmony_ci					  DOVE_PCIE1_IO_SIZE,
3568c2ecf20Sopenharmony_ci					  DOVE_PCIE1_IO_BUS_BASE);
3578c2ecf20Sopenharmony_ci	mvebu_mbus_add_window_by_id(DOVE_MBUS_PCIE0_MEM_TARGET,
3588c2ecf20Sopenharmony_ci				    DOVE_MBUS_PCIE0_MEM_ATTR,
3598c2ecf20Sopenharmony_ci				    DOVE_PCIE0_MEM_PHYS_BASE,
3608c2ecf20Sopenharmony_ci				    DOVE_PCIE0_MEM_SIZE);
3618c2ecf20Sopenharmony_ci	mvebu_mbus_add_window_by_id(DOVE_MBUS_PCIE1_MEM_TARGET,
3628c2ecf20Sopenharmony_ci				    DOVE_MBUS_PCIE1_MEM_ATTR,
3638c2ecf20Sopenharmony_ci				    DOVE_PCIE1_MEM_PHYS_BASE,
3648c2ecf20Sopenharmony_ci				    DOVE_PCIE1_MEM_SIZE);
3658c2ecf20Sopenharmony_ci	mvebu_mbus_add_window_by_id(DOVE_MBUS_CESA_TARGET,
3668c2ecf20Sopenharmony_ci				    DOVE_MBUS_CESA_ATTR,
3678c2ecf20Sopenharmony_ci				    DOVE_CESA_PHYS_BASE,
3688c2ecf20Sopenharmony_ci				    DOVE_CESA_SIZE);
3698c2ecf20Sopenharmony_ci	mvebu_mbus_add_window_by_id(DOVE_MBUS_BOOTROM_TARGET,
3708c2ecf20Sopenharmony_ci				    DOVE_MBUS_BOOTROM_ATTR,
3718c2ecf20Sopenharmony_ci				    DOVE_BOOTROM_PHYS_BASE,
3728c2ecf20Sopenharmony_ci				    DOVE_BOOTROM_SIZE);
3738c2ecf20Sopenharmony_ci	mvebu_mbus_add_window_by_id(DOVE_MBUS_SCRATCHPAD_TARGET,
3748c2ecf20Sopenharmony_ci				    DOVE_MBUS_SCRATCHPAD_ATTR,
3758c2ecf20Sopenharmony_ci				    DOVE_SCRATCHPAD_PHYS_BASE,
3768c2ecf20Sopenharmony_ci				    DOVE_SCRATCHPAD_SIZE);
3778c2ecf20Sopenharmony_ci}
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_cistatic struct resource orion_wdt_resource[] = {
3808c2ecf20Sopenharmony_ci		DEFINE_RES_MEM(TIMER_PHYS_BASE, 0x04),
3818c2ecf20Sopenharmony_ci		DEFINE_RES_MEM(RSTOUTn_MASK_PHYS, 0x04),
3828c2ecf20Sopenharmony_ci};
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_cistatic struct platform_device orion_wdt_device = {
3858c2ecf20Sopenharmony_ci	.name		= "orion_wdt",
3868c2ecf20Sopenharmony_ci	.id		= -1,
3878c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(orion_wdt_resource),
3888c2ecf20Sopenharmony_ci	.resource	= orion_wdt_resource,
3898c2ecf20Sopenharmony_ci};
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_cistatic void __init __maybe_unused orion_wdt_init(void)
3928c2ecf20Sopenharmony_ci{
3938c2ecf20Sopenharmony_ci	platform_device_register(&orion_wdt_device);
3948c2ecf20Sopenharmony_ci}
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_cistatic const struct dove_pmu_domain_initdata pmu_domains[] __initconst = {
3978c2ecf20Sopenharmony_ci	{
3988c2ecf20Sopenharmony_ci		.pwr_mask = PMU_PWR_VPU_PWR_DWN_MASK,
3998c2ecf20Sopenharmony_ci		.rst_mask = PMU_SW_RST_VIDEO_MASK,
4008c2ecf20Sopenharmony_ci		.iso_mask = PMU_ISO_VIDEO_MASK,
4018c2ecf20Sopenharmony_ci		.name = "vpu-domain",
4028c2ecf20Sopenharmony_ci	}, {
4038c2ecf20Sopenharmony_ci		.pwr_mask = PMU_PWR_GPU_PWR_DWN_MASK,
4048c2ecf20Sopenharmony_ci		.rst_mask = PMU_SW_RST_GPU_MASK,
4058c2ecf20Sopenharmony_ci		.iso_mask = PMU_ISO_GPU_MASK,
4068c2ecf20Sopenharmony_ci		.name = "gpu-domain",
4078c2ecf20Sopenharmony_ci	}, {
4088c2ecf20Sopenharmony_ci		/* sentinel */
4098c2ecf20Sopenharmony_ci	},
4108c2ecf20Sopenharmony_ci};
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_cistatic const struct dove_pmu_initdata pmu_data __initconst = {
4138c2ecf20Sopenharmony_ci	.pmc_base = DOVE_PMU_VIRT_BASE,
4148c2ecf20Sopenharmony_ci	.pmu_base = DOVE_PMU_VIRT_BASE + 0x8000,
4158c2ecf20Sopenharmony_ci	.irq = IRQ_DOVE_PMU,
4168c2ecf20Sopenharmony_ci	.irq_domain_start = IRQ_DOVE_PMU_START,
4178c2ecf20Sopenharmony_ci	.domains = pmu_domains,
4188c2ecf20Sopenharmony_ci};
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_civoid __init dove_init(void)
4218c2ecf20Sopenharmony_ci{
4228c2ecf20Sopenharmony_ci	pr_info("Dove 88AP510 SoC, TCLK = %d MHz.\n",
4238c2ecf20Sopenharmony_ci		(dove_tclk + 499999) / 1000000);
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_ci#ifdef CONFIG_CACHE_TAUROS2
4268c2ecf20Sopenharmony_ci	tauros2_init(0);
4278c2ecf20Sopenharmony_ci#endif
4288c2ecf20Sopenharmony_ci	dove_setup_cpu_wins();
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_ci	/* Setup root of clk tree */
4318c2ecf20Sopenharmony_ci	dove_clk_init();
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ci	/* internal devices that every board has */
4348c2ecf20Sopenharmony_ci	dove_init_pmu_legacy(&pmu_data);
4358c2ecf20Sopenharmony_ci	dove_rtc_init();
4368c2ecf20Sopenharmony_ci	dove_xor0_init();
4378c2ecf20Sopenharmony_ci	dove_xor1_init();
4388c2ecf20Sopenharmony_ci}
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_civoid dove_restart(enum reboot_mode mode, const char *cmd)
4418c2ecf20Sopenharmony_ci{
4428c2ecf20Sopenharmony_ci	/*
4438c2ecf20Sopenharmony_ci	 * Enable soft reset to assert RSTOUTn.
4448c2ecf20Sopenharmony_ci	 */
4458c2ecf20Sopenharmony_ci	writel(SOFT_RESET_OUT_EN, RSTOUTn_MASK);
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_ci	/*
4488c2ecf20Sopenharmony_ci	 * Assert soft reset.
4498c2ecf20Sopenharmony_ci	 */
4508c2ecf20Sopenharmony_ci	writel(SOFT_RESET, SYSTEM_SOFT_RESET);
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_ci	while (1)
4538c2ecf20Sopenharmony_ci		;
4548c2ecf20Sopenharmony_ci}
455