18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * TI DaVinci DM355 chip specific setup
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Author: Kevin Hilman, Deep Root Systems, LLC
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * 2007 (c) Deep Root Systems, LLC. This file is licensed under
78c2ecf20Sopenharmony_ci * the terms of the GNU General Public License version 2. This program
88c2ecf20Sopenharmony_ci * is licensed "as is" without any warranty of any kind, whether express
98c2ecf20Sopenharmony_ci * or implied.
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
138c2ecf20Sopenharmony_ci#include <linux/clk/davinci.h>
148c2ecf20Sopenharmony_ci#include <linux/clkdev.h>
158c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h>
168c2ecf20Sopenharmony_ci#include <linux/dmaengine.h>
178c2ecf20Sopenharmony_ci#include <linux/init.h>
188c2ecf20Sopenharmony_ci#include <linux/io.h>
198c2ecf20Sopenharmony_ci#include <linux/irqchip/irq-davinci-aintc.h>
208c2ecf20Sopenharmony_ci#include <linux/platform_data/edma.h>
218c2ecf20Sopenharmony_ci#include <linux/platform_data/gpio-davinci.h>
228c2ecf20Sopenharmony_ci#include <linux/platform_data/spi-davinci.h>
238c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
248c2ecf20Sopenharmony_ci#include <linux/serial_8250.h>
258c2ecf20Sopenharmony_ci#include <linux/spi/spi.h>
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#include <asm/mach/map.h>
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#include <mach/common.h>
308c2ecf20Sopenharmony_ci#include <mach/cputype.h>
318c2ecf20Sopenharmony_ci#include <mach/mux.h>
328c2ecf20Sopenharmony_ci#include <mach/serial.h>
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#include <clocksource/timer-davinci.h>
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#include "asp.h"
378c2ecf20Sopenharmony_ci#include "davinci.h"
388c2ecf20Sopenharmony_ci#include "irqs.h"
398c2ecf20Sopenharmony_ci#include "mux.h"
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define DM355_UART2_BASE	(IO_PHYS + 0x206000)
428c2ecf20Sopenharmony_ci#define DM355_OSD_BASE		(IO_PHYS + 0x70200)
438c2ecf20Sopenharmony_ci#define DM355_VENC_BASE		(IO_PHYS + 0x70400)
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/*
468c2ecf20Sopenharmony_ci * Device specific clocks
478c2ecf20Sopenharmony_ci */
488c2ecf20Sopenharmony_ci#define DM355_REF_FREQ		24000000	/* 24 or 36 MHz */
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_cistatic u64 dm355_spi0_dma_mask = DMA_BIT_MASK(32);
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistatic struct resource dm355_spi0_resources[] = {
538c2ecf20Sopenharmony_ci	{
548c2ecf20Sopenharmony_ci		.start = 0x01c66000,
558c2ecf20Sopenharmony_ci		.end   = 0x01c667ff,
568c2ecf20Sopenharmony_ci		.flags = IORESOURCE_MEM,
578c2ecf20Sopenharmony_ci	},
588c2ecf20Sopenharmony_ci	{
598c2ecf20Sopenharmony_ci		.start = DAVINCI_INTC_IRQ(IRQ_DM355_SPINT0_0),
608c2ecf20Sopenharmony_ci		.flags = IORESOURCE_IRQ,
618c2ecf20Sopenharmony_ci	},
628c2ecf20Sopenharmony_ci};
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistatic struct davinci_spi_platform_data dm355_spi0_pdata = {
658c2ecf20Sopenharmony_ci	.version 	= SPI_VERSION_1,
668c2ecf20Sopenharmony_ci	.num_chipselect = 2,
678c2ecf20Sopenharmony_ci	.cshold_bug	= true,
688c2ecf20Sopenharmony_ci	.dma_event_q	= EVENTQ_1,
698c2ecf20Sopenharmony_ci	.prescaler_limit = 1,
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_cistatic struct platform_device dm355_spi0_device = {
728c2ecf20Sopenharmony_ci	.name = "spi_davinci",
738c2ecf20Sopenharmony_ci	.id = 0,
748c2ecf20Sopenharmony_ci	.dev = {
758c2ecf20Sopenharmony_ci		.dma_mask = &dm355_spi0_dma_mask,
768c2ecf20Sopenharmony_ci		.coherent_dma_mask = DMA_BIT_MASK(32),
778c2ecf20Sopenharmony_ci		.platform_data = &dm355_spi0_pdata,
788c2ecf20Sopenharmony_ci	},
798c2ecf20Sopenharmony_ci	.num_resources = ARRAY_SIZE(dm355_spi0_resources),
808c2ecf20Sopenharmony_ci	.resource = dm355_spi0_resources,
818c2ecf20Sopenharmony_ci};
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_civoid __init dm355_init_spi0(unsigned chipselect_mask,
848c2ecf20Sopenharmony_ci		const struct spi_board_info *info, unsigned len)
858c2ecf20Sopenharmony_ci{
868c2ecf20Sopenharmony_ci	/* for now, assume we need MISO */
878c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM355_SPI0_SDI);
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	/* not all slaves will be wired up */
908c2ecf20Sopenharmony_ci	if (chipselect_mask & BIT(0))
918c2ecf20Sopenharmony_ci		davinci_cfg_reg(DM355_SPI0_SDENA0);
928c2ecf20Sopenharmony_ci	if (chipselect_mask & BIT(1))
938c2ecf20Sopenharmony_ci		davinci_cfg_reg(DM355_SPI0_SDENA1);
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	spi_register_board_info(info, len);
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	platform_device_register(&dm355_spi0_device);
988c2ecf20Sopenharmony_ci}
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define INTMUX		0x18
1038c2ecf20Sopenharmony_ci#define EVTMUX		0x1c
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci/*
1068c2ecf20Sopenharmony_ci * Device specific mux setup
1078c2ecf20Sopenharmony_ci *
1088c2ecf20Sopenharmony_ci *	soc	description	mux  mode   mode  mux	 dbg
1098c2ecf20Sopenharmony_ci *				reg  offset mask  mode
1108c2ecf20Sopenharmony_ci */
1118c2ecf20Sopenharmony_cistatic const struct mux_config dm355_pins[] = {
1128c2ecf20Sopenharmony_ci#ifdef CONFIG_DAVINCI_MUX
1138c2ecf20Sopenharmony_ciMUX_CFG(DM355,	MMCSD0,		4,   2,     1,	  0,	 false)
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ciMUX_CFG(DM355,	SD1_CLK,	3,   6,     1,	  1,	 false)
1168c2ecf20Sopenharmony_ciMUX_CFG(DM355,	SD1_CMD,	3,   7,     1,	  1,	 false)
1178c2ecf20Sopenharmony_ciMUX_CFG(DM355,	SD1_DATA3,	3,   8,     3,	  1,	 false)
1188c2ecf20Sopenharmony_ciMUX_CFG(DM355,	SD1_DATA2,	3,   10,    3,	  1,	 false)
1198c2ecf20Sopenharmony_ciMUX_CFG(DM355,	SD1_DATA1,	3,   12,    3,	  1,	 false)
1208c2ecf20Sopenharmony_ciMUX_CFG(DM355,	SD1_DATA0,	3,   14,    3,	  1,	 false)
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ciMUX_CFG(DM355,	I2C_SDA,	3,   19,    1,	  1,	 false)
1238c2ecf20Sopenharmony_ciMUX_CFG(DM355,	I2C_SCL,	3,   20,    1,	  1,	 false)
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ciMUX_CFG(DM355,	MCBSP0_BDX,	3,   0,     1,	  1,	 false)
1268c2ecf20Sopenharmony_ciMUX_CFG(DM355,	MCBSP0_X,	3,   1,     1,	  1,	 false)
1278c2ecf20Sopenharmony_ciMUX_CFG(DM355,	MCBSP0_BFSX,	3,   2,     1,	  1,	 false)
1288c2ecf20Sopenharmony_ciMUX_CFG(DM355,	MCBSP0_BDR,	3,   3,     1,	  1,	 false)
1298c2ecf20Sopenharmony_ciMUX_CFG(DM355,	MCBSP0_R,	3,   4,     1,	  1,	 false)
1308c2ecf20Sopenharmony_ciMUX_CFG(DM355,	MCBSP0_BFSR,	3,   5,     1,	  1,	 false)
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ciMUX_CFG(DM355,	SPI0_SDI,	4,   1,     1,    0,	 false)
1338c2ecf20Sopenharmony_ciMUX_CFG(DM355,	SPI0_SDENA0,	4,   0,     1,    0,	 false)
1348c2ecf20Sopenharmony_ciMUX_CFG(DM355,	SPI0_SDENA1,	3,   28,    1,    1,	 false)
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ciINT_CFG(DM355,  INT_EDMA_CC,	      2,    1,    1,     false)
1378c2ecf20Sopenharmony_ciINT_CFG(DM355,  INT_EDMA_TC0_ERR,     3,    1,    1,     false)
1388c2ecf20Sopenharmony_ciINT_CFG(DM355,  INT_EDMA_TC1_ERR,     4,    1,    1,     false)
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ciEVT_CFG(DM355,  EVT8_ASP1_TX,	      0,    1,    0,     false)
1418c2ecf20Sopenharmony_ciEVT_CFG(DM355,  EVT9_ASP1_RX,	      1,    1,    0,     false)
1428c2ecf20Sopenharmony_ciEVT_CFG(DM355,  EVT26_MMC0_RX,	      2,    1,    0,     false)
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ciMUX_CFG(DM355,	VOUT_FIELD,	1,   18,    3,	  1,	 false)
1458c2ecf20Sopenharmony_ciMUX_CFG(DM355,	VOUT_FIELD_G70,	1,   18,    3,	  0,	 false)
1468c2ecf20Sopenharmony_ciMUX_CFG(DM355,	VOUT_HVSYNC,	1,   16,    1,	  0,	 false)
1478c2ecf20Sopenharmony_ciMUX_CFG(DM355,	VOUT_COUTL_EN,	1,   0,     0xff, 0x55,  false)
1488c2ecf20Sopenharmony_ciMUX_CFG(DM355,	VOUT_COUTH_EN,	1,   8,     0xff, 0x55,  false)
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ciMUX_CFG(DM355,	VIN_PCLK,	0,   14,    1,    1,	 false)
1518c2ecf20Sopenharmony_ciMUX_CFG(DM355,	VIN_CAM_WEN,	0,   13,    1,    1,	 false)
1528c2ecf20Sopenharmony_ciMUX_CFG(DM355,	VIN_CAM_VD,	0,   12,    1,    1,	 false)
1538c2ecf20Sopenharmony_ciMUX_CFG(DM355,	VIN_CAM_HD,	0,   11,    1,    1,	 false)
1548c2ecf20Sopenharmony_ciMUX_CFG(DM355,	VIN_YIN_EN,	0,   10,    1,    1,	 false)
1558c2ecf20Sopenharmony_ciMUX_CFG(DM355,	VIN_CINL_EN,	0,   0,   0xff, 0x55,	 false)
1568c2ecf20Sopenharmony_ciMUX_CFG(DM355,	VIN_CINH_EN,	0,   8,     3,    3,	 false)
1578c2ecf20Sopenharmony_ci#endif
1588c2ecf20Sopenharmony_ci};
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_cistatic u8 dm355_default_priorities[DAVINCI_N_AINTC_IRQ] = {
1618c2ecf20Sopenharmony_ci	[IRQ_DM355_CCDC_VDINT0]		= 2,
1628c2ecf20Sopenharmony_ci	[IRQ_DM355_CCDC_VDINT1]		= 6,
1638c2ecf20Sopenharmony_ci	[IRQ_DM355_CCDC_VDINT2]		= 6,
1648c2ecf20Sopenharmony_ci	[IRQ_DM355_IPIPE_HST]		= 6,
1658c2ecf20Sopenharmony_ci	[IRQ_DM355_H3AINT]		= 6,
1668c2ecf20Sopenharmony_ci	[IRQ_DM355_IPIPE_SDR]		= 6,
1678c2ecf20Sopenharmony_ci	[IRQ_DM355_IPIPEIFINT]		= 6,
1688c2ecf20Sopenharmony_ci	[IRQ_DM355_OSDINT]		= 7,
1698c2ecf20Sopenharmony_ci	[IRQ_DM355_VENCINT]		= 6,
1708c2ecf20Sopenharmony_ci	[IRQ_ASQINT]			= 6,
1718c2ecf20Sopenharmony_ci	[IRQ_IMXINT]			= 6,
1728c2ecf20Sopenharmony_ci	[IRQ_USBINT]			= 4,
1738c2ecf20Sopenharmony_ci	[IRQ_DM355_RTOINT]		= 4,
1748c2ecf20Sopenharmony_ci	[IRQ_DM355_UARTINT2]		= 7,
1758c2ecf20Sopenharmony_ci	[IRQ_DM355_TINT6]		= 7,
1768c2ecf20Sopenharmony_ci	[IRQ_CCINT0]			= 5,	/* dma */
1778c2ecf20Sopenharmony_ci	[IRQ_CCERRINT]			= 5,	/* dma */
1788c2ecf20Sopenharmony_ci	[IRQ_TCERRINT0]			= 5,	/* dma */
1798c2ecf20Sopenharmony_ci	[IRQ_TCERRINT]			= 5,	/* dma */
1808c2ecf20Sopenharmony_ci	[IRQ_DM355_SPINT2_1]		= 7,
1818c2ecf20Sopenharmony_ci	[IRQ_DM355_TINT7]		= 4,
1828c2ecf20Sopenharmony_ci	[IRQ_DM355_SDIOINT0]		= 7,
1838c2ecf20Sopenharmony_ci	[IRQ_MBXINT]			= 7,
1848c2ecf20Sopenharmony_ci	[IRQ_MBRINT]			= 7,
1858c2ecf20Sopenharmony_ci	[IRQ_MMCINT]			= 7,
1868c2ecf20Sopenharmony_ci	[IRQ_DM355_MMCINT1]		= 7,
1878c2ecf20Sopenharmony_ci	[IRQ_DM355_PWMINT3]		= 7,
1888c2ecf20Sopenharmony_ci	[IRQ_DDRINT]			= 7,
1898c2ecf20Sopenharmony_ci	[IRQ_AEMIFINT]			= 7,
1908c2ecf20Sopenharmony_ci	[IRQ_DM355_SDIOINT1]		= 4,
1918c2ecf20Sopenharmony_ci	[IRQ_TINT0_TINT12]		= 2,	/* clockevent */
1928c2ecf20Sopenharmony_ci	[IRQ_TINT0_TINT34]		= 2,	/* clocksource */
1938c2ecf20Sopenharmony_ci	[IRQ_TINT1_TINT12]		= 7,	/* DSP timer */
1948c2ecf20Sopenharmony_ci	[IRQ_TINT1_TINT34]		= 7,	/* system tick */
1958c2ecf20Sopenharmony_ci	[IRQ_PWMINT0]			= 7,
1968c2ecf20Sopenharmony_ci	[IRQ_PWMINT1]			= 7,
1978c2ecf20Sopenharmony_ci	[IRQ_PWMINT2]			= 7,
1988c2ecf20Sopenharmony_ci	[IRQ_I2C]			= 3,
1998c2ecf20Sopenharmony_ci	[IRQ_UARTINT0]			= 3,
2008c2ecf20Sopenharmony_ci	[IRQ_UARTINT1]			= 3,
2018c2ecf20Sopenharmony_ci	[IRQ_DM355_SPINT0_0]		= 3,
2028c2ecf20Sopenharmony_ci	[IRQ_DM355_SPINT0_1]		= 3,
2038c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIO0]		= 3,
2048c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIO1]		= 7,
2058c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIO2]		= 4,
2068c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIO3]		= 4,
2078c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIO4]		= 7,
2088c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIO5]		= 7,
2098c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIO6]		= 7,
2108c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIO7]		= 7,
2118c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIO8]		= 7,
2128c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIO9]		= 7,
2138c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIOBNK0]		= 7,
2148c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIOBNK1]		= 7,
2158c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIOBNK2]		= 7,
2168c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIOBNK3]		= 7,
2178c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIOBNK4]		= 7,
2188c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIOBNK5]		= 7,
2198c2ecf20Sopenharmony_ci	[IRQ_DM355_GPIOBNK6]		= 7,
2208c2ecf20Sopenharmony_ci	[IRQ_COMMTX]			= 7,
2218c2ecf20Sopenharmony_ci	[IRQ_COMMRX]			= 7,
2228c2ecf20Sopenharmony_ci	[IRQ_EMUINT]			= 7,
2238c2ecf20Sopenharmony_ci};
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cistatic s8 queue_priority_mapping[][2] = {
2288c2ecf20Sopenharmony_ci	/* {event queue no, Priority} */
2298c2ecf20Sopenharmony_ci	{0, 3},
2308c2ecf20Sopenharmony_ci	{1, 7},
2318c2ecf20Sopenharmony_ci	{-1, -1},
2328c2ecf20Sopenharmony_ci};
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_cistatic const struct dma_slave_map dm355_edma_map[] = {
2358c2ecf20Sopenharmony_ci	{ "davinci-mcbsp.0", "tx", EDMA_FILTER_PARAM(0, 2) },
2368c2ecf20Sopenharmony_ci	{ "davinci-mcbsp.0", "rx", EDMA_FILTER_PARAM(0, 3) },
2378c2ecf20Sopenharmony_ci	{ "davinci-mcbsp.1", "tx", EDMA_FILTER_PARAM(0, 8) },
2388c2ecf20Sopenharmony_ci	{ "davinci-mcbsp.1", "rx", EDMA_FILTER_PARAM(0, 9) },
2398c2ecf20Sopenharmony_ci	{ "spi_davinci.2", "tx", EDMA_FILTER_PARAM(0, 10) },
2408c2ecf20Sopenharmony_ci	{ "spi_davinci.2", "rx", EDMA_FILTER_PARAM(0, 11) },
2418c2ecf20Sopenharmony_ci	{ "spi_davinci.1", "tx", EDMA_FILTER_PARAM(0, 14) },
2428c2ecf20Sopenharmony_ci	{ "spi_davinci.1", "rx", EDMA_FILTER_PARAM(0, 15) },
2438c2ecf20Sopenharmony_ci	{ "spi_davinci.0", "tx", EDMA_FILTER_PARAM(0, 16) },
2448c2ecf20Sopenharmony_ci	{ "spi_davinci.0", "rx", EDMA_FILTER_PARAM(0, 17) },
2458c2ecf20Sopenharmony_ci	{ "dm6441-mmc.0", "rx", EDMA_FILTER_PARAM(0, 26) },
2468c2ecf20Sopenharmony_ci	{ "dm6441-mmc.0", "tx", EDMA_FILTER_PARAM(0, 27) },
2478c2ecf20Sopenharmony_ci	{ "dm6441-mmc.1", "rx", EDMA_FILTER_PARAM(0, 30) },
2488c2ecf20Sopenharmony_ci	{ "dm6441-mmc.1", "tx", EDMA_FILTER_PARAM(0, 31) },
2498c2ecf20Sopenharmony_ci};
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_cistatic struct edma_soc_info dm355_edma_pdata = {
2528c2ecf20Sopenharmony_ci	.queue_priority_mapping	= queue_priority_mapping,
2538c2ecf20Sopenharmony_ci	.default_queue		= EVENTQ_1,
2548c2ecf20Sopenharmony_ci	.slave_map		= dm355_edma_map,
2558c2ecf20Sopenharmony_ci	.slavecnt		= ARRAY_SIZE(dm355_edma_map),
2568c2ecf20Sopenharmony_ci};
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_cistatic struct resource edma_resources[] = {
2598c2ecf20Sopenharmony_ci	{
2608c2ecf20Sopenharmony_ci		.name	= "edma3_cc",
2618c2ecf20Sopenharmony_ci		.start	= 0x01c00000,
2628c2ecf20Sopenharmony_ci		.end	= 0x01c00000 + SZ_64K - 1,
2638c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
2648c2ecf20Sopenharmony_ci	},
2658c2ecf20Sopenharmony_ci	{
2668c2ecf20Sopenharmony_ci		.name	= "edma3_tc0",
2678c2ecf20Sopenharmony_ci		.start	= 0x01c10000,
2688c2ecf20Sopenharmony_ci		.end	= 0x01c10000 + SZ_1K - 1,
2698c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
2708c2ecf20Sopenharmony_ci	},
2718c2ecf20Sopenharmony_ci	{
2728c2ecf20Sopenharmony_ci		.name	= "edma3_tc1",
2738c2ecf20Sopenharmony_ci		.start	= 0x01c10400,
2748c2ecf20Sopenharmony_ci		.end	= 0x01c10400 + SZ_1K - 1,
2758c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
2768c2ecf20Sopenharmony_ci	},
2778c2ecf20Sopenharmony_ci	{
2788c2ecf20Sopenharmony_ci		.name	= "edma3_ccint",
2798c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_CCINT0),
2808c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
2818c2ecf20Sopenharmony_ci	},
2828c2ecf20Sopenharmony_ci	{
2838c2ecf20Sopenharmony_ci		.name	= "edma3_ccerrint",
2848c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_CCERRINT),
2858c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
2868c2ecf20Sopenharmony_ci	},
2878c2ecf20Sopenharmony_ci	/* not using (or muxing) TC*_ERR */
2888c2ecf20Sopenharmony_ci};
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_cistatic const struct platform_device_info dm355_edma_device __initconst = {
2918c2ecf20Sopenharmony_ci	.name		= "edma",
2928c2ecf20Sopenharmony_ci	.id		= 0,
2938c2ecf20Sopenharmony_ci	.dma_mask	= DMA_BIT_MASK(32),
2948c2ecf20Sopenharmony_ci	.res		= edma_resources,
2958c2ecf20Sopenharmony_ci	.num_res	= ARRAY_SIZE(edma_resources),
2968c2ecf20Sopenharmony_ci	.data		= &dm355_edma_pdata,
2978c2ecf20Sopenharmony_ci	.size_data	= sizeof(dm355_edma_pdata),
2988c2ecf20Sopenharmony_ci};
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_cistatic struct resource dm355_asp1_resources[] = {
3018c2ecf20Sopenharmony_ci	{
3028c2ecf20Sopenharmony_ci		.name	= "mpu",
3038c2ecf20Sopenharmony_ci		.start	= DAVINCI_ASP1_BASE,
3048c2ecf20Sopenharmony_ci		.end	= DAVINCI_ASP1_BASE + SZ_8K - 1,
3058c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
3068c2ecf20Sopenharmony_ci	},
3078c2ecf20Sopenharmony_ci	{
3088c2ecf20Sopenharmony_ci		.start	= DAVINCI_DMA_ASP1_TX,
3098c2ecf20Sopenharmony_ci		.end	= DAVINCI_DMA_ASP1_TX,
3108c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
3118c2ecf20Sopenharmony_ci	},
3128c2ecf20Sopenharmony_ci	{
3138c2ecf20Sopenharmony_ci		.start	= DAVINCI_DMA_ASP1_RX,
3148c2ecf20Sopenharmony_ci		.end	= DAVINCI_DMA_ASP1_RX,
3158c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
3168c2ecf20Sopenharmony_ci	},
3178c2ecf20Sopenharmony_ci};
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_cistatic struct platform_device dm355_asp1_device = {
3208c2ecf20Sopenharmony_ci	.name		= "davinci-mcbsp",
3218c2ecf20Sopenharmony_ci	.id		= 1,
3228c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dm355_asp1_resources),
3238c2ecf20Sopenharmony_ci	.resource	= dm355_asp1_resources,
3248c2ecf20Sopenharmony_ci};
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_cistatic void dm355_ccdc_setup_pinmux(void)
3278c2ecf20Sopenharmony_ci{
3288c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM355_VIN_PCLK);
3298c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM355_VIN_CAM_WEN);
3308c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM355_VIN_CAM_VD);
3318c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM355_VIN_CAM_HD);
3328c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM355_VIN_YIN_EN);
3338c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM355_VIN_CINL_EN);
3348c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM355_VIN_CINH_EN);
3358c2ecf20Sopenharmony_ci}
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_cistatic struct resource dm355_vpss_resources[] = {
3388c2ecf20Sopenharmony_ci	{
3398c2ecf20Sopenharmony_ci		/* VPSS BL Base address */
3408c2ecf20Sopenharmony_ci		.name		= "vpss",
3418c2ecf20Sopenharmony_ci		.start          = 0x01c70800,
3428c2ecf20Sopenharmony_ci		.end            = 0x01c70800 + 0xff,
3438c2ecf20Sopenharmony_ci		.flags          = IORESOURCE_MEM,
3448c2ecf20Sopenharmony_ci	},
3458c2ecf20Sopenharmony_ci	{
3468c2ecf20Sopenharmony_ci		/* VPSS CLK Base address */
3478c2ecf20Sopenharmony_ci		.name		= "vpss",
3488c2ecf20Sopenharmony_ci		.start          = 0x01c70000,
3498c2ecf20Sopenharmony_ci		.end            = 0x01c70000 + 0xf,
3508c2ecf20Sopenharmony_ci		.flags          = IORESOURCE_MEM,
3518c2ecf20Sopenharmony_ci	},
3528c2ecf20Sopenharmony_ci};
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_cistatic struct platform_device dm355_vpss_device = {
3558c2ecf20Sopenharmony_ci	.name			= "vpss",
3568c2ecf20Sopenharmony_ci	.id			= -1,
3578c2ecf20Sopenharmony_ci	.dev.platform_data	= "dm355_vpss",
3588c2ecf20Sopenharmony_ci	.num_resources		= ARRAY_SIZE(dm355_vpss_resources),
3598c2ecf20Sopenharmony_ci	.resource		= dm355_vpss_resources,
3608c2ecf20Sopenharmony_ci};
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_cistatic struct resource vpfe_resources[] = {
3638c2ecf20Sopenharmony_ci	{
3648c2ecf20Sopenharmony_ci		.start          = DAVINCI_INTC_IRQ(IRQ_VDINT0),
3658c2ecf20Sopenharmony_ci		.end            = DAVINCI_INTC_IRQ(IRQ_VDINT0),
3668c2ecf20Sopenharmony_ci		.flags          = IORESOURCE_IRQ,
3678c2ecf20Sopenharmony_ci	},
3688c2ecf20Sopenharmony_ci	{
3698c2ecf20Sopenharmony_ci		.start          = DAVINCI_INTC_IRQ(IRQ_VDINT1),
3708c2ecf20Sopenharmony_ci		.end            = DAVINCI_INTC_IRQ(IRQ_VDINT1),
3718c2ecf20Sopenharmony_ci		.flags          = IORESOURCE_IRQ,
3728c2ecf20Sopenharmony_ci	},
3738c2ecf20Sopenharmony_ci};
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_cistatic u64 vpfe_capture_dma_mask = DMA_BIT_MASK(32);
3768c2ecf20Sopenharmony_cistatic struct resource dm355_ccdc_resource[] = {
3778c2ecf20Sopenharmony_ci	/* CCDC Base address */
3788c2ecf20Sopenharmony_ci	{
3798c2ecf20Sopenharmony_ci		.flags          = IORESOURCE_MEM,
3808c2ecf20Sopenharmony_ci		.start          = 0x01c70600,
3818c2ecf20Sopenharmony_ci		.end            = 0x01c70600 + 0x1ff,
3828c2ecf20Sopenharmony_ci	},
3838c2ecf20Sopenharmony_ci};
3848c2ecf20Sopenharmony_cistatic struct platform_device dm355_ccdc_dev = {
3858c2ecf20Sopenharmony_ci	.name           = "dm355_ccdc",
3868c2ecf20Sopenharmony_ci	.id             = -1,
3878c2ecf20Sopenharmony_ci	.num_resources  = ARRAY_SIZE(dm355_ccdc_resource),
3888c2ecf20Sopenharmony_ci	.resource       = dm355_ccdc_resource,
3898c2ecf20Sopenharmony_ci	.dev = {
3908c2ecf20Sopenharmony_ci		.dma_mask               = &vpfe_capture_dma_mask,
3918c2ecf20Sopenharmony_ci		.coherent_dma_mask      = DMA_BIT_MASK(32),
3928c2ecf20Sopenharmony_ci		.platform_data		= dm355_ccdc_setup_pinmux,
3938c2ecf20Sopenharmony_ci	},
3948c2ecf20Sopenharmony_ci};
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_cistatic struct platform_device vpfe_capture_dev = {
3978c2ecf20Sopenharmony_ci	.name		= CAPTURE_DRV_NAME,
3988c2ecf20Sopenharmony_ci	.id		= -1,
3998c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(vpfe_resources),
4008c2ecf20Sopenharmony_ci	.resource	= vpfe_resources,
4018c2ecf20Sopenharmony_ci	.dev = {
4028c2ecf20Sopenharmony_ci		.dma_mask		= &vpfe_capture_dma_mask,
4038c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
4048c2ecf20Sopenharmony_ci	},
4058c2ecf20Sopenharmony_ci};
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_cistatic struct resource dm355_osd_resources[] = {
4088c2ecf20Sopenharmony_ci	{
4098c2ecf20Sopenharmony_ci		.start	= DM355_OSD_BASE,
4108c2ecf20Sopenharmony_ci		.end	= DM355_OSD_BASE + 0x17f,
4118c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
4128c2ecf20Sopenharmony_ci	},
4138c2ecf20Sopenharmony_ci};
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_cistatic struct platform_device dm355_osd_dev = {
4168c2ecf20Sopenharmony_ci	.name		= DM355_VPBE_OSD_SUBDEV_NAME,
4178c2ecf20Sopenharmony_ci	.id		= -1,
4188c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dm355_osd_resources),
4198c2ecf20Sopenharmony_ci	.resource	= dm355_osd_resources,
4208c2ecf20Sopenharmony_ci	.dev		= {
4218c2ecf20Sopenharmony_ci		.dma_mask		= &vpfe_capture_dma_mask,
4228c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
4238c2ecf20Sopenharmony_ci	},
4248c2ecf20Sopenharmony_ci};
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_cistatic struct resource dm355_venc_resources[] = {
4278c2ecf20Sopenharmony_ci	{
4288c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_VENCINT),
4298c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_VENCINT),
4308c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
4318c2ecf20Sopenharmony_ci	},
4328c2ecf20Sopenharmony_ci	/* venc registers io space */
4338c2ecf20Sopenharmony_ci	{
4348c2ecf20Sopenharmony_ci		.start	= DM355_VENC_BASE,
4358c2ecf20Sopenharmony_ci		.end	= DM355_VENC_BASE + 0x17f,
4368c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
4378c2ecf20Sopenharmony_ci	},
4388c2ecf20Sopenharmony_ci	/* VDAC config register io space */
4398c2ecf20Sopenharmony_ci	{
4408c2ecf20Sopenharmony_ci		.start	= DAVINCI_SYSTEM_MODULE_BASE + SYSMOD_VDAC_CONFIG,
4418c2ecf20Sopenharmony_ci		.end	= DAVINCI_SYSTEM_MODULE_BASE + SYSMOD_VDAC_CONFIG + 3,
4428c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
4438c2ecf20Sopenharmony_ci	},
4448c2ecf20Sopenharmony_ci};
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_cistatic struct resource dm355_v4l2_disp_resources[] = {
4478c2ecf20Sopenharmony_ci	{
4488c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_VENCINT),
4498c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_VENCINT),
4508c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
4518c2ecf20Sopenharmony_ci	},
4528c2ecf20Sopenharmony_ci	/* venc registers io space */
4538c2ecf20Sopenharmony_ci	{
4548c2ecf20Sopenharmony_ci		.start	= DM355_VENC_BASE,
4558c2ecf20Sopenharmony_ci		.end	= DM355_VENC_BASE + 0x17f,
4568c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
4578c2ecf20Sopenharmony_ci	},
4588c2ecf20Sopenharmony_ci};
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_cistatic int dm355_vpbe_setup_pinmux(u32 if_type, int field)
4618c2ecf20Sopenharmony_ci{
4628c2ecf20Sopenharmony_ci	switch (if_type) {
4638c2ecf20Sopenharmony_ci	case MEDIA_BUS_FMT_SGRBG8_1X8:
4648c2ecf20Sopenharmony_ci		davinci_cfg_reg(DM355_VOUT_FIELD_G70);
4658c2ecf20Sopenharmony_ci		break;
4668c2ecf20Sopenharmony_ci	case MEDIA_BUS_FMT_YUYV10_1X20:
4678c2ecf20Sopenharmony_ci		if (field)
4688c2ecf20Sopenharmony_ci			davinci_cfg_reg(DM355_VOUT_FIELD);
4698c2ecf20Sopenharmony_ci		else
4708c2ecf20Sopenharmony_ci			davinci_cfg_reg(DM355_VOUT_FIELD_G70);
4718c2ecf20Sopenharmony_ci		break;
4728c2ecf20Sopenharmony_ci	default:
4738c2ecf20Sopenharmony_ci		return -EINVAL;
4748c2ecf20Sopenharmony_ci	}
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM355_VOUT_COUTL_EN);
4778c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM355_VOUT_COUTH_EN);
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_ci	return 0;
4808c2ecf20Sopenharmony_ci}
4818c2ecf20Sopenharmony_ci
4828c2ecf20Sopenharmony_cistatic int dm355_venc_setup_clock(enum vpbe_enc_timings_type type,
4838c2ecf20Sopenharmony_ci				   unsigned int pclock)
4848c2ecf20Sopenharmony_ci{
4858c2ecf20Sopenharmony_ci	void __iomem *vpss_clk_ctrl_reg;
4868c2ecf20Sopenharmony_ci
4878c2ecf20Sopenharmony_ci	vpss_clk_ctrl_reg = DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL);
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_ci	switch (type) {
4908c2ecf20Sopenharmony_ci	case VPBE_ENC_STD:
4918c2ecf20Sopenharmony_ci		writel(VPSS_DACCLKEN_ENABLE | VPSS_VENCCLKEN_ENABLE,
4928c2ecf20Sopenharmony_ci		       vpss_clk_ctrl_reg);
4938c2ecf20Sopenharmony_ci		break;
4948c2ecf20Sopenharmony_ci	case VPBE_ENC_DV_TIMINGS:
4958c2ecf20Sopenharmony_ci		if (pclock > 27000000)
4968c2ecf20Sopenharmony_ci			/*
4978c2ecf20Sopenharmony_ci			 * For HD, use external clock source since we cannot
4988c2ecf20Sopenharmony_ci			 * support HD mode with internal clocks.
4998c2ecf20Sopenharmony_ci			 */
5008c2ecf20Sopenharmony_ci			writel(VPSS_MUXSEL_EXTCLK_ENABLE, vpss_clk_ctrl_reg);
5018c2ecf20Sopenharmony_ci		break;
5028c2ecf20Sopenharmony_ci	default:
5038c2ecf20Sopenharmony_ci		return -EINVAL;
5048c2ecf20Sopenharmony_ci	}
5058c2ecf20Sopenharmony_ci
5068c2ecf20Sopenharmony_ci	return 0;
5078c2ecf20Sopenharmony_ci}
5088c2ecf20Sopenharmony_ci
5098c2ecf20Sopenharmony_cistatic struct platform_device dm355_vpbe_display = {
5108c2ecf20Sopenharmony_ci	.name		= "vpbe-v4l2",
5118c2ecf20Sopenharmony_ci	.id		= -1,
5128c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dm355_v4l2_disp_resources),
5138c2ecf20Sopenharmony_ci	.resource	= dm355_v4l2_disp_resources,
5148c2ecf20Sopenharmony_ci	.dev		= {
5158c2ecf20Sopenharmony_ci		.dma_mask		= &vpfe_capture_dma_mask,
5168c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
5178c2ecf20Sopenharmony_ci	},
5188c2ecf20Sopenharmony_ci};
5198c2ecf20Sopenharmony_ci
5208c2ecf20Sopenharmony_cistatic struct venc_platform_data dm355_venc_pdata = {
5218c2ecf20Sopenharmony_ci	.setup_pinmux	= dm355_vpbe_setup_pinmux,
5228c2ecf20Sopenharmony_ci	.setup_clock	= dm355_venc_setup_clock,
5238c2ecf20Sopenharmony_ci};
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_cistatic struct platform_device dm355_venc_dev = {
5268c2ecf20Sopenharmony_ci	.name		= DM355_VPBE_VENC_SUBDEV_NAME,
5278c2ecf20Sopenharmony_ci	.id		= -1,
5288c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dm355_venc_resources),
5298c2ecf20Sopenharmony_ci	.resource	= dm355_venc_resources,
5308c2ecf20Sopenharmony_ci	.dev		= {
5318c2ecf20Sopenharmony_ci		.dma_mask		= &vpfe_capture_dma_mask,
5328c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
5338c2ecf20Sopenharmony_ci		.platform_data		= (void *)&dm355_venc_pdata,
5348c2ecf20Sopenharmony_ci	},
5358c2ecf20Sopenharmony_ci};
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_cistatic struct platform_device dm355_vpbe_dev = {
5388c2ecf20Sopenharmony_ci	.name		= "vpbe_controller",
5398c2ecf20Sopenharmony_ci	.id		= -1,
5408c2ecf20Sopenharmony_ci	.dev		= {
5418c2ecf20Sopenharmony_ci		.dma_mask		= &vpfe_capture_dma_mask,
5428c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
5438c2ecf20Sopenharmony_ci	},
5448c2ecf20Sopenharmony_ci};
5458c2ecf20Sopenharmony_ci
5468c2ecf20Sopenharmony_cistatic struct resource dm355_gpio_resources[] = {
5478c2ecf20Sopenharmony_ci	{	/* registers */
5488c2ecf20Sopenharmony_ci		.start	= DAVINCI_GPIO_BASE,
5498c2ecf20Sopenharmony_ci		.end	= DAVINCI_GPIO_BASE + SZ_4K - 1,
5508c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
5518c2ecf20Sopenharmony_ci	},
5528c2ecf20Sopenharmony_ci	{	/* interrupt */
5538c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK0),
5548c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK0),
5558c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
5568c2ecf20Sopenharmony_ci	},
5578c2ecf20Sopenharmony_ci	{
5588c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK1),
5598c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK1),
5608c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
5618c2ecf20Sopenharmony_ci	},
5628c2ecf20Sopenharmony_ci	{
5638c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK2),
5648c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK2),
5658c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
5668c2ecf20Sopenharmony_ci	},
5678c2ecf20Sopenharmony_ci	{
5688c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK3),
5698c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK3),
5708c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
5718c2ecf20Sopenharmony_ci	},
5728c2ecf20Sopenharmony_ci	{
5738c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK4),
5748c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK4),
5758c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
5768c2ecf20Sopenharmony_ci	},
5778c2ecf20Sopenharmony_ci	{
5788c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK5),
5798c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK5),
5808c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
5818c2ecf20Sopenharmony_ci	},
5828c2ecf20Sopenharmony_ci	{
5838c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK6),
5848c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM355_GPIOBNK6),
5858c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
5868c2ecf20Sopenharmony_ci	},
5878c2ecf20Sopenharmony_ci};
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_cistatic struct davinci_gpio_platform_data dm355_gpio_platform_data = {
5908c2ecf20Sopenharmony_ci	.no_auto_base	= true,
5918c2ecf20Sopenharmony_ci	.base		= 0,
5928c2ecf20Sopenharmony_ci	.ngpio		= 104,
5938c2ecf20Sopenharmony_ci};
5948c2ecf20Sopenharmony_ci
5958c2ecf20Sopenharmony_ciint __init dm355_gpio_register(void)
5968c2ecf20Sopenharmony_ci{
5978c2ecf20Sopenharmony_ci	return davinci_gpio_register(dm355_gpio_resources,
5988c2ecf20Sopenharmony_ci				     ARRAY_SIZE(dm355_gpio_resources),
5998c2ecf20Sopenharmony_ci				     &dm355_gpio_platform_data);
6008c2ecf20Sopenharmony_ci}
6018c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_cistatic struct map_desc dm355_io_desc[] = {
6048c2ecf20Sopenharmony_ci	{
6058c2ecf20Sopenharmony_ci		.virtual	= IO_VIRT,
6068c2ecf20Sopenharmony_ci		.pfn		= __phys_to_pfn(IO_PHYS),
6078c2ecf20Sopenharmony_ci		.length		= IO_SIZE,
6088c2ecf20Sopenharmony_ci		.type		= MT_DEVICE
6098c2ecf20Sopenharmony_ci	},
6108c2ecf20Sopenharmony_ci};
6118c2ecf20Sopenharmony_ci
6128c2ecf20Sopenharmony_ci/* Contents of JTAG ID register used to identify exact cpu type */
6138c2ecf20Sopenharmony_cistatic struct davinci_id dm355_ids[] = {
6148c2ecf20Sopenharmony_ci	{
6158c2ecf20Sopenharmony_ci		.variant	= 0x0,
6168c2ecf20Sopenharmony_ci		.part_no	= 0xb73b,
6178c2ecf20Sopenharmony_ci		.manufacturer	= 0x00f,
6188c2ecf20Sopenharmony_ci		.cpu_id		= DAVINCI_CPU_ID_DM355,
6198c2ecf20Sopenharmony_ci		.name		= "dm355",
6208c2ecf20Sopenharmony_ci	},
6218c2ecf20Sopenharmony_ci};
6228c2ecf20Sopenharmony_ci
6238c2ecf20Sopenharmony_ci/*
6248c2ecf20Sopenharmony_ci * Bottom half of timer0 is used for clockevent, top half is used for
6258c2ecf20Sopenharmony_ci * clocksource.
6268c2ecf20Sopenharmony_ci */
6278c2ecf20Sopenharmony_cistatic const struct davinci_timer_cfg dm355_timer_cfg = {
6288c2ecf20Sopenharmony_ci	.reg = DEFINE_RES_IO(DAVINCI_TIMER0_BASE, SZ_4K),
6298c2ecf20Sopenharmony_ci	.irq = {
6308c2ecf20Sopenharmony_ci		DEFINE_RES_IRQ(DAVINCI_INTC_IRQ(IRQ_TINT0_TINT12)),
6318c2ecf20Sopenharmony_ci		DEFINE_RES_IRQ(DAVINCI_INTC_IRQ(IRQ_TINT0_TINT34)),
6328c2ecf20Sopenharmony_ci	},
6338c2ecf20Sopenharmony_ci};
6348c2ecf20Sopenharmony_ci
6358c2ecf20Sopenharmony_cistatic struct plat_serial8250_port dm355_serial0_platform_data[] = {
6368c2ecf20Sopenharmony_ci	{
6378c2ecf20Sopenharmony_ci		.mapbase	= DAVINCI_UART0_BASE,
6388c2ecf20Sopenharmony_ci		.irq		= DAVINCI_INTC_IRQ(IRQ_UARTINT0),
6398c2ecf20Sopenharmony_ci		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
6408c2ecf20Sopenharmony_ci				  UPF_IOREMAP,
6418c2ecf20Sopenharmony_ci		.iotype		= UPIO_MEM,
6428c2ecf20Sopenharmony_ci		.regshift	= 2,
6438c2ecf20Sopenharmony_ci	},
6448c2ecf20Sopenharmony_ci	{
6458c2ecf20Sopenharmony_ci		.flags	= 0,
6468c2ecf20Sopenharmony_ci	}
6478c2ecf20Sopenharmony_ci};
6488c2ecf20Sopenharmony_cistatic struct plat_serial8250_port dm355_serial1_platform_data[] = {
6498c2ecf20Sopenharmony_ci	{
6508c2ecf20Sopenharmony_ci		.mapbase	= DAVINCI_UART1_BASE,
6518c2ecf20Sopenharmony_ci		.irq		= DAVINCI_INTC_IRQ(IRQ_UARTINT1),
6528c2ecf20Sopenharmony_ci		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
6538c2ecf20Sopenharmony_ci				  UPF_IOREMAP,
6548c2ecf20Sopenharmony_ci		.iotype		= UPIO_MEM,
6558c2ecf20Sopenharmony_ci		.regshift	= 2,
6568c2ecf20Sopenharmony_ci	},
6578c2ecf20Sopenharmony_ci	{
6588c2ecf20Sopenharmony_ci		.flags	= 0,
6598c2ecf20Sopenharmony_ci	}
6608c2ecf20Sopenharmony_ci};
6618c2ecf20Sopenharmony_cistatic struct plat_serial8250_port dm355_serial2_platform_data[] = {
6628c2ecf20Sopenharmony_ci	{
6638c2ecf20Sopenharmony_ci		.mapbase	= DM355_UART2_BASE,
6648c2ecf20Sopenharmony_ci		.irq		= DAVINCI_INTC_IRQ(IRQ_DM355_UARTINT2),
6658c2ecf20Sopenharmony_ci		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
6668c2ecf20Sopenharmony_ci				  UPF_IOREMAP,
6678c2ecf20Sopenharmony_ci		.iotype		= UPIO_MEM,
6688c2ecf20Sopenharmony_ci		.regshift	= 2,
6698c2ecf20Sopenharmony_ci	},
6708c2ecf20Sopenharmony_ci	{
6718c2ecf20Sopenharmony_ci		.flags	= 0,
6728c2ecf20Sopenharmony_ci	}
6738c2ecf20Sopenharmony_ci};
6748c2ecf20Sopenharmony_ci
6758c2ecf20Sopenharmony_cistruct platform_device dm355_serial_device[] = {
6768c2ecf20Sopenharmony_ci	{
6778c2ecf20Sopenharmony_ci		.name			= "serial8250",
6788c2ecf20Sopenharmony_ci		.id			= PLAT8250_DEV_PLATFORM,
6798c2ecf20Sopenharmony_ci		.dev			= {
6808c2ecf20Sopenharmony_ci			.platform_data	= dm355_serial0_platform_data,
6818c2ecf20Sopenharmony_ci		}
6828c2ecf20Sopenharmony_ci	},
6838c2ecf20Sopenharmony_ci	{
6848c2ecf20Sopenharmony_ci		.name			= "serial8250",
6858c2ecf20Sopenharmony_ci		.id			= PLAT8250_DEV_PLATFORM1,
6868c2ecf20Sopenharmony_ci		.dev			= {
6878c2ecf20Sopenharmony_ci			.platform_data	= dm355_serial1_platform_data,
6888c2ecf20Sopenharmony_ci		}
6898c2ecf20Sopenharmony_ci	},
6908c2ecf20Sopenharmony_ci	{
6918c2ecf20Sopenharmony_ci		.name			= "serial8250",
6928c2ecf20Sopenharmony_ci		.id			= PLAT8250_DEV_PLATFORM2,
6938c2ecf20Sopenharmony_ci		.dev			= {
6948c2ecf20Sopenharmony_ci			.platform_data	= dm355_serial2_platform_data,
6958c2ecf20Sopenharmony_ci		}
6968c2ecf20Sopenharmony_ci	},
6978c2ecf20Sopenharmony_ci	{
6988c2ecf20Sopenharmony_ci	}
6998c2ecf20Sopenharmony_ci};
7008c2ecf20Sopenharmony_ci
7018c2ecf20Sopenharmony_cistatic const struct davinci_soc_info davinci_soc_info_dm355 = {
7028c2ecf20Sopenharmony_ci	.io_desc		= dm355_io_desc,
7038c2ecf20Sopenharmony_ci	.io_desc_num		= ARRAY_SIZE(dm355_io_desc),
7048c2ecf20Sopenharmony_ci	.jtag_id_reg		= 0x01c40028,
7058c2ecf20Sopenharmony_ci	.ids			= dm355_ids,
7068c2ecf20Sopenharmony_ci	.ids_num		= ARRAY_SIZE(dm355_ids),
7078c2ecf20Sopenharmony_ci	.pinmux_base		= DAVINCI_SYSTEM_MODULE_BASE,
7088c2ecf20Sopenharmony_ci	.pinmux_pins		= dm355_pins,
7098c2ecf20Sopenharmony_ci	.pinmux_pins_num	= ARRAY_SIZE(dm355_pins),
7108c2ecf20Sopenharmony_ci	.sram_dma		= 0x00010000,
7118c2ecf20Sopenharmony_ci	.sram_len		= SZ_32K,
7128c2ecf20Sopenharmony_ci};
7138c2ecf20Sopenharmony_ci
7148c2ecf20Sopenharmony_civoid __init dm355_init_asp1(u32 evt_enable)
7158c2ecf20Sopenharmony_ci{
7168c2ecf20Sopenharmony_ci	/* we don't use ASP1 IRQs, or we'd need to mux them ... */
7178c2ecf20Sopenharmony_ci	if (evt_enable & ASP1_TX_EVT_EN)
7188c2ecf20Sopenharmony_ci		davinci_cfg_reg(DM355_EVT8_ASP1_TX);
7198c2ecf20Sopenharmony_ci
7208c2ecf20Sopenharmony_ci	if (evt_enable & ASP1_RX_EVT_EN)
7218c2ecf20Sopenharmony_ci		davinci_cfg_reg(DM355_EVT9_ASP1_RX);
7228c2ecf20Sopenharmony_ci
7238c2ecf20Sopenharmony_ci	platform_device_register(&dm355_asp1_device);
7248c2ecf20Sopenharmony_ci}
7258c2ecf20Sopenharmony_ci
7268c2ecf20Sopenharmony_civoid __init dm355_init(void)
7278c2ecf20Sopenharmony_ci{
7288c2ecf20Sopenharmony_ci	davinci_common_init(&davinci_soc_info_dm355);
7298c2ecf20Sopenharmony_ci	davinci_map_sysmod();
7308c2ecf20Sopenharmony_ci}
7318c2ecf20Sopenharmony_ci
7328c2ecf20Sopenharmony_civoid __init dm355_init_time(void)
7338c2ecf20Sopenharmony_ci{
7348c2ecf20Sopenharmony_ci	void __iomem *pll1, *psc;
7358c2ecf20Sopenharmony_ci	struct clk *clk;
7368c2ecf20Sopenharmony_ci	int rv;
7378c2ecf20Sopenharmony_ci
7388c2ecf20Sopenharmony_ci	clk_register_fixed_rate(NULL, "ref_clk", NULL, 0, DM355_REF_FREQ);
7398c2ecf20Sopenharmony_ci
7408c2ecf20Sopenharmony_ci	pll1 = ioremap(DAVINCI_PLL1_BASE, SZ_1K);
7418c2ecf20Sopenharmony_ci	dm355_pll1_init(NULL, pll1, NULL);
7428c2ecf20Sopenharmony_ci
7438c2ecf20Sopenharmony_ci	psc = ioremap(DAVINCI_PWR_SLEEP_CNTRL_BASE, SZ_4K);
7448c2ecf20Sopenharmony_ci	dm355_psc_init(NULL, psc);
7458c2ecf20Sopenharmony_ci
7468c2ecf20Sopenharmony_ci	clk = clk_get(NULL, "timer0");
7478c2ecf20Sopenharmony_ci	if (WARN_ON(IS_ERR(clk))) {
7488c2ecf20Sopenharmony_ci		pr_err("Unable to get the timer clock\n");
7498c2ecf20Sopenharmony_ci		return;
7508c2ecf20Sopenharmony_ci	}
7518c2ecf20Sopenharmony_ci
7528c2ecf20Sopenharmony_ci	rv = davinci_timer_register(clk, &dm355_timer_cfg);
7538c2ecf20Sopenharmony_ci	WARN(rv, "Unable to register the timer: %d\n", rv);
7548c2ecf20Sopenharmony_ci}
7558c2ecf20Sopenharmony_ci
7568c2ecf20Sopenharmony_cistatic struct resource dm355_pll2_resources[] = {
7578c2ecf20Sopenharmony_ci	{
7588c2ecf20Sopenharmony_ci		.start	= DAVINCI_PLL2_BASE,
7598c2ecf20Sopenharmony_ci		.end	= DAVINCI_PLL2_BASE + SZ_1K - 1,
7608c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
7618c2ecf20Sopenharmony_ci	},
7628c2ecf20Sopenharmony_ci};
7638c2ecf20Sopenharmony_ci
7648c2ecf20Sopenharmony_cistatic struct platform_device dm355_pll2_device = {
7658c2ecf20Sopenharmony_ci	.name		= "dm355-pll2",
7668c2ecf20Sopenharmony_ci	.id		= -1,
7678c2ecf20Sopenharmony_ci	.resource	= dm355_pll2_resources,
7688c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dm355_pll2_resources),
7698c2ecf20Sopenharmony_ci};
7708c2ecf20Sopenharmony_ci
7718c2ecf20Sopenharmony_civoid __init dm355_register_clocks(void)
7728c2ecf20Sopenharmony_ci{
7738c2ecf20Sopenharmony_ci	/* PLL1 and PSC are registered in dm355_init_time() */
7748c2ecf20Sopenharmony_ci	platform_device_register(&dm355_pll2_device);
7758c2ecf20Sopenharmony_ci}
7768c2ecf20Sopenharmony_ci
7778c2ecf20Sopenharmony_ciint __init dm355_init_video(struct vpfe_config *vpfe_cfg,
7788c2ecf20Sopenharmony_ci				struct vpbe_config *vpbe_cfg)
7798c2ecf20Sopenharmony_ci{
7808c2ecf20Sopenharmony_ci	if (vpfe_cfg || vpbe_cfg)
7818c2ecf20Sopenharmony_ci		platform_device_register(&dm355_vpss_device);
7828c2ecf20Sopenharmony_ci
7838c2ecf20Sopenharmony_ci	if (vpfe_cfg) {
7848c2ecf20Sopenharmony_ci		vpfe_capture_dev.dev.platform_data = vpfe_cfg;
7858c2ecf20Sopenharmony_ci		platform_device_register(&dm355_ccdc_dev);
7868c2ecf20Sopenharmony_ci		platform_device_register(&vpfe_capture_dev);
7878c2ecf20Sopenharmony_ci	}
7888c2ecf20Sopenharmony_ci
7898c2ecf20Sopenharmony_ci	if (vpbe_cfg) {
7908c2ecf20Sopenharmony_ci		dm355_vpbe_dev.dev.platform_data = vpbe_cfg;
7918c2ecf20Sopenharmony_ci		platform_device_register(&dm355_osd_dev);
7928c2ecf20Sopenharmony_ci		platform_device_register(&dm355_venc_dev);
7938c2ecf20Sopenharmony_ci		platform_device_register(&dm355_vpbe_dev);
7948c2ecf20Sopenharmony_ci		platform_device_register(&dm355_vpbe_display);
7958c2ecf20Sopenharmony_ci	}
7968c2ecf20Sopenharmony_ci
7978c2ecf20Sopenharmony_ci	return 0;
7988c2ecf20Sopenharmony_ci}
7998c2ecf20Sopenharmony_ci
8008c2ecf20Sopenharmony_cistatic const struct davinci_aintc_config dm355_aintc_config = {
8018c2ecf20Sopenharmony_ci	.reg = {
8028c2ecf20Sopenharmony_ci		.start		= DAVINCI_ARM_INTC_BASE,
8038c2ecf20Sopenharmony_ci		.end		= DAVINCI_ARM_INTC_BASE + SZ_4K - 1,
8048c2ecf20Sopenharmony_ci		.flags		= IORESOURCE_MEM,
8058c2ecf20Sopenharmony_ci	},
8068c2ecf20Sopenharmony_ci	.num_irqs		= 64,
8078c2ecf20Sopenharmony_ci	.prios			= dm355_default_priorities,
8088c2ecf20Sopenharmony_ci};
8098c2ecf20Sopenharmony_ci
8108c2ecf20Sopenharmony_civoid __init dm355_init_irq(void)
8118c2ecf20Sopenharmony_ci{
8128c2ecf20Sopenharmony_ci	davinci_aintc_init(&dm355_aintc_config);
8138c2ecf20Sopenharmony_ci}
8148c2ecf20Sopenharmony_ci
8158c2ecf20Sopenharmony_cistatic int __init dm355_init_devices(void)
8168c2ecf20Sopenharmony_ci{
8178c2ecf20Sopenharmony_ci	struct platform_device *edma_pdev;
8188c2ecf20Sopenharmony_ci	int ret = 0;
8198c2ecf20Sopenharmony_ci
8208c2ecf20Sopenharmony_ci	if (!cpu_is_davinci_dm355())
8218c2ecf20Sopenharmony_ci		return 0;
8228c2ecf20Sopenharmony_ci
8238c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM355_INT_EDMA_CC);
8248c2ecf20Sopenharmony_ci	edma_pdev = platform_device_register_full(&dm355_edma_device);
8258c2ecf20Sopenharmony_ci	if (IS_ERR(edma_pdev)) {
8268c2ecf20Sopenharmony_ci		pr_warn("%s: Failed to register eDMA\n", __func__);
8278c2ecf20Sopenharmony_ci		return PTR_ERR(edma_pdev);
8288c2ecf20Sopenharmony_ci	}
8298c2ecf20Sopenharmony_ci
8308c2ecf20Sopenharmony_ci	ret = davinci_init_wdt();
8318c2ecf20Sopenharmony_ci	if (ret)
8328c2ecf20Sopenharmony_ci		pr_warn("%s: watchdog init failed: %d\n", __func__, ret);
8338c2ecf20Sopenharmony_ci
8348c2ecf20Sopenharmony_ci	return ret;
8358c2ecf20Sopenharmony_ci}
8368c2ecf20Sopenharmony_cipostcore_initcall(dm355_init_devices);
837