18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * TI DaVinci DM365 chip specific setup
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2009 Texas Instruments
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or
78c2ecf20Sopenharmony_ci * modify it under the terms of the GNU General Public License as
88c2ecf20Sopenharmony_ci * published by the Free Software Foundation version 2.
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * This program is distributed "as is" WITHOUT ANY WARRANTY of any
118c2ecf20Sopenharmony_ci * kind, whether express or implied; without even the implied warranty
128c2ecf20Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
138c2ecf20Sopenharmony_ci * GNU General Public License for more details.
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
178c2ecf20Sopenharmony_ci#include <linux/clk/davinci.h>
188c2ecf20Sopenharmony_ci#include <linux/clkdev.h>
198c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h>
208c2ecf20Sopenharmony_ci#include <linux/dmaengine.h>
218c2ecf20Sopenharmony_ci#include <linux/init.h>
228c2ecf20Sopenharmony_ci#include <linux/io.h>
238c2ecf20Sopenharmony_ci#include <linux/irqchip/irq-davinci-aintc.h>
248c2ecf20Sopenharmony_ci#include <linux/platform_data/edma.h>
258c2ecf20Sopenharmony_ci#include <linux/platform_data/gpio-davinci.h>
268c2ecf20Sopenharmony_ci#include <linux/platform_data/keyscan-davinci.h>
278c2ecf20Sopenharmony_ci#include <linux/platform_data/spi-davinci.h>
288c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
298c2ecf20Sopenharmony_ci#include <linux/serial_8250.h>
308c2ecf20Sopenharmony_ci#include <linux/spi/spi.h>
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#include <asm/mach/map.h>
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#include <mach/common.h>
358c2ecf20Sopenharmony_ci#include <mach/cputype.h>
368c2ecf20Sopenharmony_ci#include <mach/mux.h>
378c2ecf20Sopenharmony_ci#include <mach/serial.h>
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#include <clocksource/timer-davinci.h>
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#include "asp.h"
428c2ecf20Sopenharmony_ci#include "davinci.h"
438c2ecf20Sopenharmony_ci#include "irqs.h"
448c2ecf20Sopenharmony_ci#include "mux.h"
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define DM365_REF_FREQ		24000000	/* 24 MHz on the DM365 EVM */
478c2ecf20Sopenharmony_ci#define DM365_RTC_BASE			0x01c69000
488c2ecf20Sopenharmony_ci#define DM365_KEYSCAN_BASE		0x01c69400
498c2ecf20Sopenharmony_ci#define DM365_OSD_BASE			0x01c71c00
508c2ecf20Sopenharmony_ci#define DM365_VENC_BASE			0x01c71e00
518c2ecf20Sopenharmony_ci#define DAVINCI_DM365_VC_BASE		0x01d0c000
528c2ecf20Sopenharmony_ci#define DAVINCI_DMA_VC_TX		2
538c2ecf20Sopenharmony_ci#define DAVINCI_DMA_VC_RX		3
548c2ecf20Sopenharmony_ci#define DM365_EMAC_BASE			0x01d07000
558c2ecf20Sopenharmony_ci#define DM365_EMAC_MDIO_BASE		(DM365_EMAC_BASE + 0x4000)
568c2ecf20Sopenharmony_ci#define DM365_EMAC_CNTRL_OFFSET		0x0000
578c2ecf20Sopenharmony_ci#define DM365_EMAC_CNTRL_MOD_OFFSET	0x3000
588c2ecf20Sopenharmony_ci#define DM365_EMAC_CNTRL_RAM_OFFSET	0x1000
598c2ecf20Sopenharmony_ci#define DM365_EMAC_CNTRL_RAM_SIZE	0x2000
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define INTMUX		0x18
628c2ecf20Sopenharmony_ci#define EVTMUX		0x1c
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_cistatic const struct mux_config dm365_pins[] = {
668c2ecf20Sopenharmony_ci#ifdef CONFIG_DAVINCI_MUX
678c2ecf20Sopenharmony_ciMUX_CFG(DM365,	MMCSD0,		0,   24,     1,	  0,	 false)
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SD1_CLK,	0,   16,    3,	  1,	 false)
708c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SD1_CMD,	4,   30,    3,	  1,	 false)
718c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SD1_DATA3,	4,   28,    3,	  1,	 false)
728c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SD1_DATA2,	4,   26,    3,	  1,	 false)
738c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SD1_DATA1,	4,   24,    3,	  1,	 false)
748c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SD1_DATA0,	4,   22,    3,	  1,	 false)
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ciMUX_CFG(DM365,	I2C_SDA,	3,   23,    3,	  2,	 false)
778c2ecf20Sopenharmony_ciMUX_CFG(DM365,	I2C_SCL,	3,   21,    3,	  2,	 false)
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ciMUX_CFG(DM365,	AEMIF_AR_A14,	2,   0,     3,	  1,	 false)
808c2ecf20Sopenharmony_ciMUX_CFG(DM365,	AEMIF_AR_BA0,	2,   0,     3,	  2,	 false)
818c2ecf20Sopenharmony_ciMUX_CFG(DM365,	AEMIF_A3,	2,   2,     3,	  1,	 false)
828c2ecf20Sopenharmony_ciMUX_CFG(DM365,	AEMIF_A7,	2,   4,     3,	  1,	 false)
838c2ecf20Sopenharmony_ciMUX_CFG(DM365,	AEMIF_D15_8,	2,   6,     1,	  1,	 false)
848c2ecf20Sopenharmony_ciMUX_CFG(DM365,	AEMIF_CE0,	2,   7,     1,	  0,	 false)
858c2ecf20Sopenharmony_ciMUX_CFG(DM365,	AEMIF_CE1,	2,   8,     1,    0,     false)
868c2ecf20Sopenharmony_ciMUX_CFG(DM365,	AEMIF_WE_OE,	2,   9,     1,    0,     false)
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ciMUX_CFG(DM365,	MCBSP0_BDX,	0,   23,    1,	  1,	 false)
898c2ecf20Sopenharmony_ciMUX_CFG(DM365,	MCBSP0_X,	0,   22,    1,	  1,	 false)
908c2ecf20Sopenharmony_ciMUX_CFG(DM365,	MCBSP0_BFSX,	0,   21,    1,	  1,	 false)
918c2ecf20Sopenharmony_ciMUX_CFG(DM365,	MCBSP0_BDR,	0,   20,    1,	  1,	 false)
928c2ecf20Sopenharmony_ciMUX_CFG(DM365,	MCBSP0_R,	0,   19,    1,	  1,	 false)
938c2ecf20Sopenharmony_ciMUX_CFG(DM365,	MCBSP0_BFSR,	0,   18,    1,	  1,	 false)
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI0_SCLK,	3,   28,    1,    1,	 false)
968c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI0_SDI,	3,   26,    3,    1,	 false)
978c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI0_SDO,	3,   25,    1,    1,	 false)
988c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI0_SDENA0,	3,   29,    3,    1,	 false)
998c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI0_SDENA1,	3,   26,    3,    2,	 false)
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ciMUX_CFG(DM365,	UART0_RXD,	3,   20,    1,    1,	 false)
1028c2ecf20Sopenharmony_ciMUX_CFG(DM365,	UART0_TXD,	3,   19,    1,    1,	 false)
1038c2ecf20Sopenharmony_ciMUX_CFG(DM365,	UART1_RXD,	3,   17,    3,    2,	 false)
1048c2ecf20Sopenharmony_ciMUX_CFG(DM365,	UART1_TXD,	3,   15,    3,    2,	 false)
1058c2ecf20Sopenharmony_ciMUX_CFG(DM365,	UART1_RTS,	3,   23,    3,    1,	 false)
1068c2ecf20Sopenharmony_ciMUX_CFG(DM365,	UART1_CTS,	3,   21,    3,    1,	 false)
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_TX_EN,	3,   17,    3,    1,     false)
1098c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_TX_CLK,	3,   15,    3,    1,     false)
1108c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_COL,	3,   14,    1,    1,     false)
1118c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_TXD3,	3,   13,    1,    1,     false)
1128c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_TXD2,	3,   12,    1,    1,     false)
1138c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_TXD1,	3,   11,    1,    1,     false)
1148c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_TXD0,	3,   10,    1,    1,     false)
1158c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_RXD3,	3,   9,     1,    1,     false)
1168c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_RXD2,	3,   8,     1,    1,     false)
1178c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_RXD1,	3,   7,     1,    1,     false)
1188c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_RXD0,	3,   6,     1,    1,     false)
1198c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_RX_CLK,	3,   5,     1,    1,     false)
1208c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_RX_DV,	3,   4,     1,    1,     false)
1218c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_RX_ER,	3,   3,     1,    1,     false)
1228c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_CRS,	3,   2,     1,    1,     false)
1238c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_MDIO,	3,   1,     1,    1,     false)
1248c2ecf20Sopenharmony_ciMUX_CFG(DM365,  EMAC_MDCLK,	3,   0,     1,    1,     false)
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ciMUX_CFG(DM365,	KEYSCAN,	2,   0,     0x3f, 0x3f,  false)
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ciMUX_CFG(DM365,	PWM0,		1,   0,     3,    2,     false)
1298c2ecf20Sopenharmony_ciMUX_CFG(DM365,	PWM0_G23,	3,   26,    3,    3,     false)
1308c2ecf20Sopenharmony_ciMUX_CFG(DM365,	PWM1,		1,   2,     3,    2,     false)
1318c2ecf20Sopenharmony_ciMUX_CFG(DM365,	PWM1_G25,	3,   29,    3,    2,     false)
1328c2ecf20Sopenharmony_ciMUX_CFG(DM365,	PWM2_G87,	1,   10,    3,    2,     false)
1338c2ecf20Sopenharmony_ciMUX_CFG(DM365,	PWM2_G88,	1,   8,     3,    2,     false)
1348c2ecf20Sopenharmony_ciMUX_CFG(DM365,	PWM2_G89,	1,   6,     3,    2,     false)
1358c2ecf20Sopenharmony_ciMUX_CFG(DM365,	PWM2_G90,	1,   4,     3,    2,     false)
1368c2ecf20Sopenharmony_ciMUX_CFG(DM365,	PWM3_G80,	1,   20,    3,    3,     false)
1378c2ecf20Sopenharmony_ciMUX_CFG(DM365,	PWM3_G81,	1,   18,    3,    3,     false)
1388c2ecf20Sopenharmony_ciMUX_CFG(DM365,	PWM3_G85,	1,   14,    3,    2,     false)
1398c2ecf20Sopenharmony_ciMUX_CFG(DM365,	PWM3_G86,	1,   12,    3,    2,     false)
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI1_SCLK,	4,   2,     3,    1,	 false)
1428c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI1_SDI,	3,   31,    1,    1,	 false)
1438c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI1_SDO,	4,   0,     3,    1,	 false)
1448c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI1_SDENA0,	4,   4,     3,    1,	 false)
1458c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI1_SDENA1,	4,   0,     3,    2,	 false)
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI2_SCLK,	4,   10,    3,    1,	 false)
1488c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI2_SDI,	4,   6,     3,    1,	 false)
1498c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI2_SDO,	4,   8,     3,    1,	 false)
1508c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI2_SDENA0,	4,   12,    3,    1,	 false)
1518c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI2_SDENA1,	4,   8,     3,    2,	 false)
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI3_SCLK,	0,   0,	    3,    2,	 false)
1548c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI3_SDI,	0,   2,     3,    2,	 false)
1558c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI3_SDO,	0,   6,     3,    2,	 false)
1568c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI3_SDENA0,	0,   4,     3,    2,	 false)
1578c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI3_SDENA1,	0,   6,     3,    3,	 false)
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI4_SCLK,	4,   18,    3,    1,	 false)
1608c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI4_SDI,	4,   14,    3,    1,	 false)
1618c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI4_SDO,	4,   16,    3,    1,	 false)
1628c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI4_SDENA0,	4,   20,    3,    1,	 false)
1638c2ecf20Sopenharmony_ciMUX_CFG(DM365,	SPI4_SDENA1,	4,   16,    3,    2,	 false)
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ciMUX_CFG(DM365,	CLKOUT0,	4,   20,    3,    3,     false)
1668c2ecf20Sopenharmony_ciMUX_CFG(DM365,	CLKOUT1,	4,   16,    3,    3,     false)
1678c2ecf20Sopenharmony_ciMUX_CFG(DM365,	CLKOUT2,	4,   8,     3,    3,     false)
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ciMUX_CFG(DM365,	GPIO20,		3,   21,    3,    0,	 false)
1708c2ecf20Sopenharmony_ciMUX_CFG(DM365,	GPIO30,		4,   6,     3,	  0,	 false)
1718c2ecf20Sopenharmony_ciMUX_CFG(DM365,	GPIO31,		4,   8,     3,	  0,	 false)
1728c2ecf20Sopenharmony_ciMUX_CFG(DM365,	GPIO32,		4,   10,    3,	  0,	 false)
1738c2ecf20Sopenharmony_ciMUX_CFG(DM365,	GPIO33,		4,   12,    3,	  0,	 false)
1748c2ecf20Sopenharmony_ciMUX_CFG(DM365,	GPIO40,		4,   26,    3,	  0,	 false)
1758c2ecf20Sopenharmony_ciMUX_CFG(DM365,	GPIO64_57,	2,   6,     1,	  0,	 false)
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ciMUX_CFG(DM365,	VOUT_FIELD,	1,   18,    3,	  1,	 false)
1788c2ecf20Sopenharmony_ciMUX_CFG(DM365,	VOUT_FIELD_G81,	1,   18,    3,	  0,	 false)
1798c2ecf20Sopenharmony_ciMUX_CFG(DM365,	VOUT_HVSYNC,	1,   16,    1,	  0,	 false)
1808c2ecf20Sopenharmony_ciMUX_CFG(DM365,	VOUT_COUTL_EN,	1,   0,     0xff, 0x55,  false)
1818c2ecf20Sopenharmony_ciMUX_CFG(DM365,	VOUT_COUTH_EN,	1,   8,     0xff, 0x55,  false)
1828c2ecf20Sopenharmony_ciMUX_CFG(DM365,	VIN_CAM_WEN,	0,   14,    3,	  0,	 false)
1838c2ecf20Sopenharmony_ciMUX_CFG(DM365,	VIN_CAM_VD,	0,   13,    1,	  0,	 false)
1848c2ecf20Sopenharmony_ciMUX_CFG(DM365,	VIN_CAM_HD,	0,   12,    1,	  0,	 false)
1858c2ecf20Sopenharmony_ciMUX_CFG(DM365,	VIN_YIN4_7_EN,	0,   0,     0xff, 0,	 false)
1868c2ecf20Sopenharmony_ciMUX_CFG(DM365,	VIN_YIN0_3_EN,	0,   8,     0xf,  0,	 false)
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_EDMA_CC,         2,     1,    1,     false)
1898c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_EDMA_TC0_ERR,    3,     1,    1,     false)
1908c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_EDMA_TC1_ERR,    4,     1,    1,     false)
1918c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_EDMA_TC2_ERR,    22,    1,    1,     false)
1928c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_EDMA_TC3_ERR,    23,    1,    1,     false)
1938c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_PRTCSS,          10,    1,    1,     false)
1948c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_EMAC_RXTHRESH,   14,    1,    1,     false)
1958c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_EMAC_RXPULSE,    15,    1,    1,     false)
1968c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_EMAC_TXPULSE,    16,    1,    1,     false)
1978c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_EMAC_MISCPULSE,  17,    1,    1,     false)
1988c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_IMX0_ENABLE,     0,     1,    0,     false)
1998c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_IMX0_DISABLE,    0,     1,    1,     false)
2008c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_HDVICP_ENABLE,   0,     1,    1,     false)
2018c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_HDVICP_DISABLE,  0,     1,    0,     false)
2028c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_IMX1_ENABLE,     24,    1,    1,     false)
2038c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_IMX1_DISABLE,    24,    1,    0,     false)
2048c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_NSF_ENABLE,      25,    1,    1,     false)
2058c2ecf20Sopenharmony_ciINT_CFG(DM365,  INT_NSF_DISABLE,     25,    1,    0,     false)
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ciEVT_CFG(DM365,	EVT2_ASP_TX,         0,     1,    0,     false)
2088c2ecf20Sopenharmony_ciEVT_CFG(DM365,	EVT3_ASP_RX,         1,     1,    0,     false)
2098c2ecf20Sopenharmony_ciEVT_CFG(DM365,	EVT2_VC_TX,          0,     1,    1,     false)
2108c2ecf20Sopenharmony_ciEVT_CFG(DM365,	EVT3_VC_RX,          1,     1,    1,     false)
2118c2ecf20Sopenharmony_ci#endif
2128c2ecf20Sopenharmony_ci};
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_cistatic u64 dm365_spi0_dma_mask = DMA_BIT_MASK(32);
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_cistatic struct davinci_spi_platform_data dm365_spi0_pdata = {
2178c2ecf20Sopenharmony_ci	.version 	= SPI_VERSION_1,
2188c2ecf20Sopenharmony_ci	.num_chipselect = 2,
2198c2ecf20Sopenharmony_ci	.dma_event_q	= EVENTQ_3,
2208c2ecf20Sopenharmony_ci	.prescaler_limit = 1,
2218c2ecf20Sopenharmony_ci};
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_cistatic struct resource dm365_spi0_resources[] = {
2248c2ecf20Sopenharmony_ci	{
2258c2ecf20Sopenharmony_ci		.start = 0x01c66000,
2268c2ecf20Sopenharmony_ci		.end   = 0x01c667ff,
2278c2ecf20Sopenharmony_ci		.flags = IORESOURCE_MEM,
2288c2ecf20Sopenharmony_ci	},
2298c2ecf20Sopenharmony_ci	{
2308c2ecf20Sopenharmony_ci		.start = DAVINCI_INTC_IRQ(IRQ_DM365_SPIINT0_0),
2318c2ecf20Sopenharmony_ci		.flags = IORESOURCE_IRQ,
2328c2ecf20Sopenharmony_ci	},
2338c2ecf20Sopenharmony_ci};
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_cistatic struct platform_device dm365_spi0_device = {
2368c2ecf20Sopenharmony_ci	.name = "spi_davinci",
2378c2ecf20Sopenharmony_ci	.id = 0,
2388c2ecf20Sopenharmony_ci	.dev = {
2398c2ecf20Sopenharmony_ci		.dma_mask = &dm365_spi0_dma_mask,
2408c2ecf20Sopenharmony_ci		.coherent_dma_mask = DMA_BIT_MASK(32),
2418c2ecf20Sopenharmony_ci		.platform_data = &dm365_spi0_pdata,
2428c2ecf20Sopenharmony_ci	},
2438c2ecf20Sopenharmony_ci	.num_resources = ARRAY_SIZE(dm365_spi0_resources),
2448c2ecf20Sopenharmony_ci	.resource = dm365_spi0_resources,
2458c2ecf20Sopenharmony_ci};
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_civoid __init dm365_init_spi0(unsigned chipselect_mask,
2488c2ecf20Sopenharmony_ci		const struct spi_board_info *info, unsigned len)
2498c2ecf20Sopenharmony_ci{
2508c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_SPI0_SCLK);
2518c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_SPI0_SDI);
2528c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_SPI0_SDO);
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci	/* not all slaves will be wired up */
2558c2ecf20Sopenharmony_ci	if (chipselect_mask & BIT(0))
2568c2ecf20Sopenharmony_ci		davinci_cfg_reg(DM365_SPI0_SDENA0);
2578c2ecf20Sopenharmony_ci	if (chipselect_mask & BIT(1))
2588c2ecf20Sopenharmony_ci		davinci_cfg_reg(DM365_SPI0_SDENA1);
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci	spi_register_board_info(info, len);
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci	platform_device_register(&dm365_spi0_device);
2638c2ecf20Sopenharmony_ci}
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_cistatic struct resource dm365_gpio_resources[] = {
2668c2ecf20Sopenharmony_ci	{	/* registers */
2678c2ecf20Sopenharmony_ci		.start	= DAVINCI_GPIO_BASE,
2688c2ecf20Sopenharmony_ci		.end	= DAVINCI_GPIO_BASE + SZ_4K - 1,
2698c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
2708c2ecf20Sopenharmony_ci	},
2718c2ecf20Sopenharmony_ci	{	/* interrupt */
2728c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO0),
2738c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO0),
2748c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
2758c2ecf20Sopenharmony_ci	},
2768c2ecf20Sopenharmony_ci	{
2778c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO1),
2788c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO1),
2798c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
2808c2ecf20Sopenharmony_ci	},
2818c2ecf20Sopenharmony_ci	{
2828c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO2),
2838c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO2),
2848c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
2858c2ecf20Sopenharmony_ci	},
2868c2ecf20Sopenharmony_ci	{
2878c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO3),
2888c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO3),
2898c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
2908c2ecf20Sopenharmony_ci	},
2918c2ecf20Sopenharmony_ci	{
2928c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO4),
2938c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO4),
2948c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
2958c2ecf20Sopenharmony_ci	},
2968c2ecf20Sopenharmony_ci	{
2978c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO5),
2988c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO5),
2998c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
3008c2ecf20Sopenharmony_ci	},
3018c2ecf20Sopenharmony_ci	{
3028c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO6),
3038c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO6),
3048c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
3058c2ecf20Sopenharmony_ci	},
3068c2ecf20Sopenharmony_ci	{
3078c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO7),
3088c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM365_GPIO7),
3098c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
3108c2ecf20Sopenharmony_ci	},
3118c2ecf20Sopenharmony_ci};
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_cistatic struct davinci_gpio_platform_data dm365_gpio_platform_data = {
3148c2ecf20Sopenharmony_ci	.no_auto_base	= true,
3158c2ecf20Sopenharmony_ci	.base		= 0,
3168c2ecf20Sopenharmony_ci	.ngpio		= 104,
3178c2ecf20Sopenharmony_ci	.gpio_unbanked	= 8,
3188c2ecf20Sopenharmony_ci};
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ciint __init dm365_gpio_register(void)
3218c2ecf20Sopenharmony_ci{
3228c2ecf20Sopenharmony_ci	return davinci_gpio_register(dm365_gpio_resources,
3238c2ecf20Sopenharmony_ci				     ARRAY_SIZE(dm365_gpio_resources),
3248c2ecf20Sopenharmony_ci				     &dm365_gpio_platform_data);
3258c2ecf20Sopenharmony_ci}
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_cistatic struct emac_platform_data dm365_emac_pdata = {
3288c2ecf20Sopenharmony_ci	.ctrl_reg_offset	= DM365_EMAC_CNTRL_OFFSET,
3298c2ecf20Sopenharmony_ci	.ctrl_mod_reg_offset	= DM365_EMAC_CNTRL_MOD_OFFSET,
3308c2ecf20Sopenharmony_ci	.ctrl_ram_offset	= DM365_EMAC_CNTRL_RAM_OFFSET,
3318c2ecf20Sopenharmony_ci	.ctrl_ram_size		= DM365_EMAC_CNTRL_RAM_SIZE,
3328c2ecf20Sopenharmony_ci	.version		= EMAC_VERSION_2,
3338c2ecf20Sopenharmony_ci};
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_cistatic struct resource dm365_emac_resources[] = {
3368c2ecf20Sopenharmony_ci	{
3378c2ecf20Sopenharmony_ci		.start	= DM365_EMAC_BASE,
3388c2ecf20Sopenharmony_ci		.end	= DM365_EMAC_BASE + SZ_16K - 1,
3398c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
3408c2ecf20Sopenharmony_ci	},
3418c2ecf20Sopenharmony_ci	{
3428c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM365_EMAC_RXTHRESH),
3438c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM365_EMAC_RXTHRESH),
3448c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
3458c2ecf20Sopenharmony_ci	},
3468c2ecf20Sopenharmony_ci	{
3478c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM365_EMAC_RXPULSE),
3488c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM365_EMAC_RXPULSE),
3498c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
3508c2ecf20Sopenharmony_ci	},
3518c2ecf20Sopenharmony_ci	{
3528c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM365_EMAC_TXPULSE),
3538c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM365_EMAC_TXPULSE),
3548c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
3558c2ecf20Sopenharmony_ci	},
3568c2ecf20Sopenharmony_ci	{
3578c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_DM365_EMAC_MISCPULSE),
3588c2ecf20Sopenharmony_ci		.end	= DAVINCI_INTC_IRQ(IRQ_DM365_EMAC_MISCPULSE),
3598c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
3608c2ecf20Sopenharmony_ci	},
3618c2ecf20Sopenharmony_ci};
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_cistatic struct platform_device dm365_emac_device = {
3648c2ecf20Sopenharmony_ci	.name		= "davinci_emac",
3658c2ecf20Sopenharmony_ci	.id		= 1,
3668c2ecf20Sopenharmony_ci	.dev = {
3678c2ecf20Sopenharmony_ci		.platform_data	= &dm365_emac_pdata,
3688c2ecf20Sopenharmony_ci	},
3698c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dm365_emac_resources),
3708c2ecf20Sopenharmony_ci	.resource	= dm365_emac_resources,
3718c2ecf20Sopenharmony_ci};
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_cistatic struct resource dm365_mdio_resources[] = {
3748c2ecf20Sopenharmony_ci	{
3758c2ecf20Sopenharmony_ci		.start	= DM365_EMAC_MDIO_BASE,
3768c2ecf20Sopenharmony_ci		.end	= DM365_EMAC_MDIO_BASE + SZ_4K - 1,
3778c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
3788c2ecf20Sopenharmony_ci	},
3798c2ecf20Sopenharmony_ci};
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_cistatic struct platform_device dm365_mdio_device = {
3828c2ecf20Sopenharmony_ci	.name		= "davinci_mdio",
3838c2ecf20Sopenharmony_ci	.id		= 0,
3848c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dm365_mdio_resources),
3858c2ecf20Sopenharmony_ci	.resource	= dm365_mdio_resources,
3868c2ecf20Sopenharmony_ci};
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_cistatic u8 dm365_default_priorities[DAVINCI_N_AINTC_IRQ] = {
3898c2ecf20Sopenharmony_ci	[IRQ_VDINT0]			= 2,
3908c2ecf20Sopenharmony_ci	[IRQ_VDINT1]			= 6,
3918c2ecf20Sopenharmony_ci	[IRQ_VDINT2]			= 6,
3928c2ecf20Sopenharmony_ci	[IRQ_HISTINT]			= 6,
3938c2ecf20Sopenharmony_ci	[IRQ_H3AINT]			= 6,
3948c2ecf20Sopenharmony_ci	[IRQ_PRVUINT]			= 6,
3958c2ecf20Sopenharmony_ci	[IRQ_RSZINT]			= 6,
3968c2ecf20Sopenharmony_ci	[IRQ_DM365_INSFINT]		= 7,
3978c2ecf20Sopenharmony_ci	[IRQ_VENCINT]			= 6,
3988c2ecf20Sopenharmony_ci	[IRQ_ASQINT]			= 6,
3998c2ecf20Sopenharmony_ci	[IRQ_IMXINT]			= 6,
4008c2ecf20Sopenharmony_ci	[IRQ_DM365_IMCOPINT]		= 4,
4018c2ecf20Sopenharmony_ci	[IRQ_USBINT]			= 4,
4028c2ecf20Sopenharmony_ci	[IRQ_DM365_RTOINT]		= 7,
4038c2ecf20Sopenharmony_ci	[IRQ_DM365_TINT5]		= 7,
4048c2ecf20Sopenharmony_ci	[IRQ_DM365_TINT6]		= 5,
4058c2ecf20Sopenharmony_ci	[IRQ_CCINT0]			= 5,
4068c2ecf20Sopenharmony_ci	[IRQ_CCERRINT]			= 5,
4078c2ecf20Sopenharmony_ci	[IRQ_TCERRINT0]			= 5,
4088c2ecf20Sopenharmony_ci	[IRQ_TCERRINT]			= 7,
4098c2ecf20Sopenharmony_ci	[IRQ_PSCIN]			= 4,
4108c2ecf20Sopenharmony_ci	[IRQ_DM365_SPINT2_1]		= 7,
4118c2ecf20Sopenharmony_ci	[IRQ_DM365_TINT7]		= 7,
4128c2ecf20Sopenharmony_ci	[IRQ_DM365_SDIOINT0]		= 7,
4138c2ecf20Sopenharmony_ci	[IRQ_MBXINT]			= 7,
4148c2ecf20Sopenharmony_ci	[IRQ_MBRINT]			= 7,
4158c2ecf20Sopenharmony_ci	[IRQ_MMCINT]			= 7,
4168c2ecf20Sopenharmony_ci	[IRQ_DM365_MMCINT1]		= 7,
4178c2ecf20Sopenharmony_ci	[IRQ_DM365_PWMINT3]		= 7,
4188c2ecf20Sopenharmony_ci	[IRQ_AEMIFINT]			= 2,
4198c2ecf20Sopenharmony_ci	[IRQ_DM365_SDIOINT1]		= 2,
4208c2ecf20Sopenharmony_ci	[IRQ_TINT0_TINT12]		= 7,
4218c2ecf20Sopenharmony_ci	[IRQ_TINT0_TINT34]		= 7,
4228c2ecf20Sopenharmony_ci	[IRQ_TINT1_TINT12]		= 7,
4238c2ecf20Sopenharmony_ci	[IRQ_TINT1_TINT34]		= 7,
4248c2ecf20Sopenharmony_ci	[IRQ_PWMINT0]			= 7,
4258c2ecf20Sopenharmony_ci	[IRQ_PWMINT1]			= 3,
4268c2ecf20Sopenharmony_ci	[IRQ_PWMINT2]			= 3,
4278c2ecf20Sopenharmony_ci	[IRQ_I2C]			= 3,
4288c2ecf20Sopenharmony_ci	[IRQ_UARTINT0]			= 3,
4298c2ecf20Sopenharmony_ci	[IRQ_UARTINT1]			= 3,
4308c2ecf20Sopenharmony_ci	[IRQ_DM365_RTCINT]		= 3,
4318c2ecf20Sopenharmony_ci	[IRQ_DM365_SPIINT0_0]		= 3,
4328c2ecf20Sopenharmony_ci	[IRQ_DM365_SPIINT3_0]		= 3,
4338c2ecf20Sopenharmony_ci	[IRQ_DM365_GPIO0]		= 3,
4348c2ecf20Sopenharmony_ci	[IRQ_DM365_GPIO1]		= 7,
4358c2ecf20Sopenharmony_ci	[IRQ_DM365_GPIO2]		= 4,
4368c2ecf20Sopenharmony_ci	[IRQ_DM365_GPIO3]		= 4,
4378c2ecf20Sopenharmony_ci	[IRQ_DM365_GPIO4]		= 7,
4388c2ecf20Sopenharmony_ci	[IRQ_DM365_GPIO5]		= 7,
4398c2ecf20Sopenharmony_ci	[IRQ_DM365_GPIO6]		= 7,
4408c2ecf20Sopenharmony_ci	[IRQ_DM365_GPIO7]		= 7,
4418c2ecf20Sopenharmony_ci	[IRQ_DM365_EMAC_RXTHRESH]	= 7,
4428c2ecf20Sopenharmony_ci	[IRQ_DM365_EMAC_RXPULSE]	= 7,
4438c2ecf20Sopenharmony_ci	[IRQ_DM365_EMAC_TXPULSE]	= 7,
4448c2ecf20Sopenharmony_ci	[IRQ_DM365_EMAC_MISCPULSE]	= 7,
4458c2ecf20Sopenharmony_ci	[IRQ_DM365_GPIO12]		= 7,
4468c2ecf20Sopenharmony_ci	[IRQ_DM365_GPIO13]		= 7,
4478c2ecf20Sopenharmony_ci	[IRQ_DM365_GPIO14]		= 7,
4488c2ecf20Sopenharmony_ci	[IRQ_DM365_GPIO15]		= 7,
4498c2ecf20Sopenharmony_ci	[IRQ_DM365_KEYINT]		= 7,
4508c2ecf20Sopenharmony_ci	[IRQ_DM365_TCERRINT2]		= 7,
4518c2ecf20Sopenharmony_ci	[IRQ_DM365_TCERRINT3]		= 7,
4528c2ecf20Sopenharmony_ci	[IRQ_DM365_EMUINT]		= 7,
4538c2ecf20Sopenharmony_ci};
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ci/* Four Transfer Controllers on DM365 */
4568c2ecf20Sopenharmony_cistatic s8 dm365_queue_priority_mapping[][2] = {
4578c2ecf20Sopenharmony_ci	/* {event queue no, Priority} */
4588c2ecf20Sopenharmony_ci	{0, 7},
4598c2ecf20Sopenharmony_ci	{1, 7},
4608c2ecf20Sopenharmony_ci	{2, 7},
4618c2ecf20Sopenharmony_ci	{3, 0},
4628c2ecf20Sopenharmony_ci	{-1, -1},
4638c2ecf20Sopenharmony_ci};
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_cistatic const struct dma_slave_map dm365_edma_map[] = {
4668c2ecf20Sopenharmony_ci	{ "davinci-mcbsp", "tx", EDMA_FILTER_PARAM(0, 2) },
4678c2ecf20Sopenharmony_ci	{ "davinci-mcbsp", "rx", EDMA_FILTER_PARAM(0, 3) },
4688c2ecf20Sopenharmony_ci	{ "davinci_voicecodec", "tx", EDMA_FILTER_PARAM(0, 2) },
4698c2ecf20Sopenharmony_ci	{ "davinci_voicecodec", "rx", EDMA_FILTER_PARAM(0, 3) },
4708c2ecf20Sopenharmony_ci	{ "spi_davinci.2", "tx", EDMA_FILTER_PARAM(0, 10) },
4718c2ecf20Sopenharmony_ci	{ "spi_davinci.2", "rx", EDMA_FILTER_PARAM(0, 11) },
4728c2ecf20Sopenharmony_ci	{ "spi_davinci.1", "tx", EDMA_FILTER_PARAM(0, 14) },
4738c2ecf20Sopenharmony_ci	{ "spi_davinci.1", "rx", EDMA_FILTER_PARAM(0, 15) },
4748c2ecf20Sopenharmony_ci	{ "spi_davinci.0", "tx", EDMA_FILTER_PARAM(0, 16) },
4758c2ecf20Sopenharmony_ci	{ "spi_davinci.0", "rx", EDMA_FILTER_PARAM(0, 17) },
4768c2ecf20Sopenharmony_ci	{ "spi_davinci.3", "tx", EDMA_FILTER_PARAM(0, 18) },
4778c2ecf20Sopenharmony_ci	{ "spi_davinci.3", "rx", EDMA_FILTER_PARAM(0, 19) },
4788c2ecf20Sopenharmony_ci	{ "da830-mmc.0", "rx", EDMA_FILTER_PARAM(0, 26) },
4798c2ecf20Sopenharmony_ci	{ "da830-mmc.0", "tx", EDMA_FILTER_PARAM(0, 27) },
4808c2ecf20Sopenharmony_ci	{ "da830-mmc.1", "rx", EDMA_FILTER_PARAM(0, 30) },
4818c2ecf20Sopenharmony_ci	{ "da830-mmc.1", "tx", EDMA_FILTER_PARAM(0, 31) },
4828c2ecf20Sopenharmony_ci};
4838c2ecf20Sopenharmony_ci
4848c2ecf20Sopenharmony_cistatic struct edma_soc_info dm365_edma_pdata = {
4858c2ecf20Sopenharmony_ci	.queue_priority_mapping	= dm365_queue_priority_mapping,
4868c2ecf20Sopenharmony_ci	.default_queue		= EVENTQ_3,
4878c2ecf20Sopenharmony_ci	.slave_map		= dm365_edma_map,
4888c2ecf20Sopenharmony_ci	.slavecnt		= ARRAY_SIZE(dm365_edma_map),
4898c2ecf20Sopenharmony_ci};
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_cistatic struct resource edma_resources[] = {
4928c2ecf20Sopenharmony_ci	{
4938c2ecf20Sopenharmony_ci		.name	= "edma3_cc",
4948c2ecf20Sopenharmony_ci		.start	= 0x01c00000,
4958c2ecf20Sopenharmony_ci		.end	= 0x01c00000 + SZ_64K - 1,
4968c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
4978c2ecf20Sopenharmony_ci	},
4988c2ecf20Sopenharmony_ci	{
4998c2ecf20Sopenharmony_ci		.name	= "edma3_tc0",
5008c2ecf20Sopenharmony_ci		.start	= 0x01c10000,
5018c2ecf20Sopenharmony_ci		.end	= 0x01c10000 + SZ_1K - 1,
5028c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
5038c2ecf20Sopenharmony_ci	},
5048c2ecf20Sopenharmony_ci	{
5058c2ecf20Sopenharmony_ci		.name	= "edma3_tc1",
5068c2ecf20Sopenharmony_ci		.start	= 0x01c10400,
5078c2ecf20Sopenharmony_ci		.end	= 0x01c10400 + SZ_1K - 1,
5088c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
5098c2ecf20Sopenharmony_ci	},
5108c2ecf20Sopenharmony_ci	{
5118c2ecf20Sopenharmony_ci		.name	= "edma3_tc2",
5128c2ecf20Sopenharmony_ci		.start	= 0x01c10800,
5138c2ecf20Sopenharmony_ci		.end	= 0x01c10800 + SZ_1K - 1,
5148c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
5158c2ecf20Sopenharmony_ci	},
5168c2ecf20Sopenharmony_ci	{
5178c2ecf20Sopenharmony_ci		.name	= "edma3_tc3",
5188c2ecf20Sopenharmony_ci		.start	= 0x01c10c00,
5198c2ecf20Sopenharmony_ci		.end	= 0x01c10c00 + SZ_1K - 1,
5208c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
5218c2ecf20Sopenharmony_ci	},
5228c2ecf20Sopenharmony_ci	{
5238c2ecf20Sopenharmony_ci		.name	= "edma3_ccint",
5248c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_CCINT0),
5258c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
5268c2ecf20Sopenharmony_ci	},
5278c2ecf20Sopenharmony_ci	{
5288c2ecf20Sopenharmony_ci		.name	= "edma3_ccerrint",
5298c2ecf20Sopenharmony_ci		.start	= DAVINCI_INTC_IRQ(IRQ_CCERRINT),
5308c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
5318c2ecf20Sopenharmony_ci	},
5328c2ecf20Sopenharmony_ci	/* not using TC*_ERR */
5338c2ecf20Sopenharmony_ci};
5348c2ecf20Sopenharmony_ci
5358c2ecf20Sopenharmony_cistatic const struct platform_device_info dm365_edma_device __initconst = {
5368c2ecf20Sopenharmony_ci	.name		= "edma",
5378c2ecf20Sopenharmony_ci	.id		= 0,
5388c2ecf20Sopenharmony_ci	.dma_mask	= DMA_BIT_MASK(32),
5398c2ecf20Sopenharmony_ci	.res		= edma_resources,
5408c2ecf20Sopenharmony_ci	.num_res	= ARRAY_SIZE(edma_resources),
5418c2ecf20Sopenharmony_ci	.data		= &dm365_edma_pdata,
5428c2ecf20Sopenharmony_ci	.size_data	= sizeof(dm365_edma_pdata),
5438c2ecf20Sopenharmony_ci};
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_cistatic struct resource dm365_asp_resources[] = {
5468c2ecf20Sopenharmony_ci	{
5478c2ecf20Sopenharmony_ci		.name	= "mpu",
5488c2ecf20Sopenharmony_ci		.start	= DAVINCI_DM365_ASP0_BASE,
5498c2ecf20Sopenharmony_ci		.end	= DAVINCI_DM365_ASP0_BASE + SZ_8K - 1,
5508c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
5518c2ecf20Sopenharmony_ci	},
5528c2ecf20Sopenharmony_ci	{
5538c2ecf20Sopenharmony_ci		.start	= DAVINCI_DMA_ASP0_TX,
5548c2ecf20Sopenharmony_ci		.end	= DAVINCI_DMA_ASP0_TX,
5558c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
5568c2ecf20Sopenharmony_ci	},
5578c2ecf20Sopenharmony_ci	{
5588c2ecf20Sopenharmony_ci		.start	= DAVINCI_DMA_ASP0_RX,
5598c2ecf20Sopenharmony_ci		.end	= DAVINCI_DMA_ASP0_RX,
5608c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
5618c2ecf20Sopenharmony_ci	},
5628c2ecf20Sopenharmony_ci};
5638c2ecf20Sopenharmony_ci
5648c2ecf20Sopenharmony_cistatic struct platform_device dm365_asp_device = {
5658c2ecf20Sopenharmony_ci	.name		= "davinci-mcbsp",
5668c2ecf20Sopenharmony_ci	.id		= -1,
5678c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dm365_asp_resources),
5688c2ecf20Sopenharmony_ci	.resource	= dm365_asp_resources,
5698c2ecf20Sopenharmony_ci};
5708c2ecf20Sopenharmony_ci
5718c2ecf20Sopenharmony_cistatic struct resource dm365_vc_resources[] = {
5728c2ecf20Sopenharmony_ci	{
5738c2ecf20Sopenharmony_ci		.start	= DAVINCI_DM365_VC_BASE,
5748c2ecf20Sopenharmony_ci		.end	= DAVINCI_DM365_VC_BASE + SZ_1K - 1,
5758c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
5768c2ecf20Sopenharmony_ci	},
5778c2ecf20Sopenharmony_ci	{
5788c2ecf20Sopenharmony_ci		.start	= DAVINCI_DMA_VC_TX,
5798c2ecf20Sopenharmony_ci		.end	= DAVINCI_DMA_VC_TX,
5808c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
5818c2ecf20Sopenharmony_ci	},
5828c2ecf20Sopenharmony_ci	{
5838c2ecf20Sopenharmony_ci		.start	= DAVINCI_DMA_VC_RX,
5848c2ecf20Sopenharmony_ci		.end	= DAVINCI_DMA_VC_RX,
5858c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_DMA,
5868c2ecf20Sopenharmony_ci	},
5878c2ecf20Sopenharmony_ci};
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_cistatic struct platform_device dm365_vc_device = {
5908c2ecf20Sopenharmony_ci	.name		= "davinci_voicecodec",
5918c2ecf20Sopenharmony_ci	.id		= -1,
5928c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dm365_vc_resources),
5938c2ecf20Sopenharmony_ci	.resource	= dm365_vc_resources,
5948c2ecf20Sopenharmony_ci};
5958c2ecf20Sopenharmony_ci
5968c2ecf20Sopenharmony_cistatic struct resource dm365_rtc_resources[] = {
5978c2ecf20Sopenharmony_ci	{
5988c2ecf20Sopenharmony_ci		.start = DM365_RTC_BASE,
5998c2ecf20Sopenharmony_ci		.end = DM365_RTC_BASE + SZ_1K - 1,
6008c2ecf20Sopenharmony_ci		.flags = IORESOURCE_MEM,
6018c2ecf20Sopenharmony_ci	},
6028c2ecf20Sopenharmony_ci	{
6038c2ecf20Sopenharmony_ci		.start = DAVINCI_INTC_IRQ(IRQ_DM365_RTCINT),
6048c2ecf20Sopenharmony_ci		.flags = IORESOURCE_IRQ,
6058c2ecf20Sopenharmony_ci	},
6068c2ecf20Sopenharmony_ci};
6078c2ecf20Sopenharmony_ci
6088c2ecf20Sopenharmony_cistatic struct platform_device dm365_rtc_device = {
6098c2ecf20Sopenharmony_ci	.name = "rtc_davinci",
6108c2ecf20Sopenharmony_ci	.id = 0,
6118c2ecf20Sopenharmony_ci	.num_resources = ARRAY_SIZE(dm365_rtc_resources),
6128c2ecf20Sopenharmony_ci	.resource = dm365_rtc_resources,
6138c2ecf20Sopenharmony_ci};
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_cistatic struct map_desc dm365_io_desc[] = {
6168c2ecf20Sopenharmony_ci	{
6178c2ecf20Sopenharmony_ci		.virtual	= IO_VIRT,
6188c2ecf20Sopenharmony_ci		.pfn		= __phys_to_pfn(IO_PHYS),
6198c2ecf20Sopenharmony_ci		.length		= IO_SIZE,
6208c2ecf20Sopenharmony_ci		.type		= MT_DEVICE
6218c2ecf20Sopenharmony_ci	},
6228c2ecf20Sopenharmony_ci};
6238c2ecf20Sopenharmony_ci
6248c2ecf20Sopenharmony_cistatic struct resource dm365_ks_resources[] = {
6258c2ecf20Sopenharmony_ci	{
6268c2ecf20Sopenharmony_ci		/* registers */
6278c2ecf20Sopenharmony_ci		.start = DM365_KEYSCAN_BASE,
6288c2ecf20Sopenharmony_ci		.end = DM365_KEYSCAN_BASE + SZ_1K - 1,
6298c2ecf20Sopenharmony_ci		.flags = IORESOURCE_MEM,
6308c2ecf20Sopenharmony_ci	},
6318c2ecf20Sopenharmony_ci	{
6328c2ecf20Sopenharmony_ci		/* interrupt */
6338c2ecf20Sopenharmony_ci		.start = DAVINCI_INTC_IRQ(IRQ_DM365_KEYINT),
6348c2ecf20Sopenharmony_ci		.end = DAVINCI_INTC_IRQ(IRQ_DM365_KEYINT),
6358c2ecf20Sopenharmony_ci		.flags = IORESOURCE_IRQ,
6368c2ecf20Sopenharmony_ci	},
6378c2ecf20Sopenharmony_ci};
6388c2ecf20Sopenharmony_ci
6398c2ecf20Sopenharmony_cistatic struct platform_device dm365_ks_device = {
6408c2ecf20Sopenharmony_ci	.name		= "davinci_keyscan",
6418c2ecf20Sopenharmony_ci	.id		= 0,
6428c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dm365_ks_resources),
6438c2ecf20Sopenharmony_ci	.resource	= dm365_ks_resources,
6448c2ecf20Sopenharmony_ci};
6458c2ecf20Sopenharmony_ci
6468c2ecf20Sopenharmony_ci/* Contents of JTAG ID register used to identify exact cpu type */
6478c2ecf20Sopenharmony_cistatic struct davinci_id dm365_ids[] = {
6488c2ecf20Sopenharmony_ci	{
6498c2ecf20Sopenharmony_ci		.variant	= 0x0,
6508c2ecf20Sopenharmony_ci		.part_no	= 0xb83e,
6518c2ecf20Sopenharmony_ci		.manufacturer	= 0x017,
6528c2ecf20Sopenharmony_ci		.cpu_id		= DAVINCI_CPU_ID_DM365,
6538c2ecf20Sopenharmony_ci		.name		= "dm365_rev1.1",
6548c2ecf20Sopenharmony_ci	},
6558c2ecf20Sopenharmony_ci	{
6568c2ecf20Sopenharmony_ci		.variant	= 0x8,
6578c2ecf20Sopenharmony_ci		.part_no	= 0xb83e,
6588c2ecf20Sopenharmony_ci		.manufacturer	= 0x017,
6598c2ecf20Sopenharmony_ci		.cpu_id		= DAVINCI_CPU_ID_DM365,
6608c2ecf20Sopenharmony_ci		.name		= "dm365_rev1.2",
6618c2ecf20Sopenharmony_ci	},
6628c2ecf20Sopenharmony_ci};
6638c2ecf20Sopenharmony_ci
6648c2ecf20Sopenharmony_ci/*
6658c2ecf20Sopenharmony_ci * Bottom half of timer0 is used for clockevent, top half is used for
6668c2ecf20Sopenharmony_ci * clocksource.
6678c2ecf20Sopenharmony_ci */
6688c2ecf20Sopenharmony_cistatic const struct davinci_timer_cfg dm365_timer_cfg = {
6698c2ecf20Sopenharmony_ci	.reg = DEFINE_RES_IO(DAVINCI_TIMER0_BASE, SZ_128),
6708c2ecf20Sopenharmony_ci	.irq = {
6718c2ecf20Sopenharmony_ci		DEFINE_RES_IRQ(DAVINCI_INTC_IRQ(IRQ_TINT0_TINT12)),
6728c2ecf20Sopenharmony_ci		DEFINE_RES_IRQ(DAVINCI_INTC_IRQ(IRQ_TINT0_TINT34)),
6738c2ecf20Sopenharmony_ci	},
6748c2ecf20Sopenharmony_ci};
6758c2ecf20Sopenharmony_ci
6768c2ecf20Sopenharmony_ci#define DM365_UART1_BASE	(IO_PHYS + 0x106000)
6778c2ecf20Sopenharmony_ci
6788c2ecf20Sopenharmony_cistatic struct plat_serial8250_port dm365_serial0_platform_data[] = {
6798c2ecf20Sopenharmony_ci	{
6808c2ecf20Sopenharmony_ci		.mapbase	= DAVINCI_UART0_BASE,
6818c2ecf20Sopenharmony_ci		.irq		= DAVINCI_INTC_IRQ(IRQ_UARTINT0),
6828c2ecf20Sopenharmony_ci		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
6838c2ecf20Sopenharmony_ci				  UPF_IOREMAP,
6848c2ecf20Sopenharmony_ci		.iotype		= UPIO_MEM,
6858c2ecf20Sopenharmony_ci		.regshift	= 2,
6868c2ecf20Sopenharmony_ci	},
6878c2ecf20Sopenharmony_ci	{
6888c2ecf20Sopenharmony_ci		.flags	= 0,
6898c2ecf20Sopenharmony_ci	}
6908c2ecf20Sopenharmony_ci};
6918c2ecf20Sopenharmony_cistatic struct plat_serial8250_port dm365_serial1_platform_data[] = {
6928c2ecf20Sopenharmony_ci	{
6938c2ecf20Sopenharmony_ci		.mapbase	= DM365_UART1_BASE,
6948c2ecf20Sopenharmony_ci		.irq		= DAVINCI_INTC_IRQ(IRQ_UARTINT1),
6958c2ecf20Sopenharmony_ci		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
6968c2ecf20Sopenharmony_ci				  UPF_IOREMAP,
6978c2ecf20Sopenharmony_ci		.iotype		= UPIO_MEM,
6988c2ecf20Sopenharmony_ci		.regshift	= 2,
6998c2ecf20Sopenharmony_ci	},
7008c2ecf20Sopenharmony_ci	{
7018c2ecf20Sopenharmony_ci		.flags	= 0,
7028c2ecf20Sopenharmony_ci	}
7038c2ecf20Sopenharmony_ci};
7048c2ecf20Sopenharmony_ci
7058c2ecf20Sopenharmony_cistruct platform_device dm365_serial_device[] = {
7068c2ecf20Sopenharmony_ci	{
7078c2ecf20Sopenharmony_ci		.name			= "serial8250",
7088c2ecf20Sopenharmony_ci		.id			= PLAT8250_DEV_PLATFORM,
7098c2ecf20Sopenharmony_ci		.dev			= {
7108c2ecf20Sopenharmony_ci			.platform_data	= dm365_serial0_platform_data,
7118c2ecf20Sopenharmony_ci		}
7128c2ecf20Sopenharmony_ci	},
7138c2ecf20Sopenharmony_ci	{
7148c2ecf20Sopenharmony_ci		.name			= "serial8250",
7158c2ecf20Sopenharmony_ci		.id			= PLAT8250_DEV_PLATFORM1,
7168c2ecf20Sopenharmony_ci		.dev			= {
7178c2ecf20Sopenharmony_ci			.platform_data	= dm365_serial1_platform_data,
7188c2ecf20Sopenharmony_ci		}
7198c2ecf20Sopenharmony_ci	},
7208c2ecf20Sopenharmony_ci	{
7218c2ecf20Sopenharmony_ci	}
7228c2ecf20Sopenharmony_ci};
7238c2ecf20Sopenharmony_ci
7248c2ecf20Sopenharmony_cistatic const struct davinci_soc_info davinci_soc_info_dm365 = {
7258c2ecf20Sopenharmony_ci	.io_desc		= dm365_io_desc,
7268c2ecf20Sopenharmony_ci	.io_desc_num		= ARRAY_SIZE(dm365_io_desc),
7278c2ecf20Sopenharmony_ci	.jtag_id_reg		= 0x01c40028,
7288c2ecf20Sopenharmony_ci	.ids			= dm365_ids,
7298c2ecf20Sopenharmony_ci	.ids_num		= ARRAY_SIZE(dm365_ids),
7308c2ecf20Sopenharmony_ci	.pinmux_base		= DAVINCI_SYSTEM_MODULE_BASE,
7318c2ecf20Sopenharmony_ci	.pinmux_pins		= dm365_pins,
7328c2ecf20Sopenharmony_ci	.pinmux_pins_num	= ARRAY_SIZE(dm365_pins),
7338c2ecf20Sopenharmony_ci	.emac_pdata		= &dm365_emac_pdata,
7348c2ecf20Sopenharmony_ci	.sram_dma		= 0x00010000,
7358c2ecf20Sopenharmony_ci	.sram_len		= SZ_32K,
7368c2ecf20Sopenharmony_ci};
7378c2ecf20Sopenharmony_ci
7388c2ecf20Sopenharmony_civoid __init dm365_init_asp(void)
7398c2ecf20Sopenharmony_ci{
7408c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_MCBSP0_BDX);
7418c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_MCBSP0_X);
7428c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_MCBSP0_BFSX);
7438c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_MCBSP0_BDR);
7448c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_MCBSP0_R);
7458c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_MCBSP0_BFSR);
7468c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_EVT2_ASP_TX);
7478c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_EVT3_ASP_RX);
7488c2ecf20Sopenharmony_ci	platform_device_register(&dm365_asp_device);
7498c2ecf20Sopenharmony_ci}
7508c2ecf20Sopenharmony_ci
7518c2ecf20Sopenharmony_civoid __init dm365_init_vc(void)
7528c2ecf20Sopenharmony_ci{
7538c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_EVT2_VC_TX);
7548c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_EVT3_VC_RX);
7558c2ecf20Sopenharmony_ci	platform_device_register(&dm365_vc_device);
7568c2ecf20Sopenharmony_ci}
7578c2ecf20Sopenharmony_ci
7588c2ecf20Sopenharmony_civoid __init dm365_init_ks(struct davinci_ks_platform_data *pdata)
7598c2ecf20Sopenharmony_ci{
7608c2ecf20Sopenharmony_ci	dm365_ks_device.dev.platform_data = pdata;
7618c2ecf20Sopenharmony_ci	platform_device_register(&dm365_ks_device);
7628c2ecf20Sopenharmony_ci}
7638c2ecf20Sopenharmony_ci
7648c2ecf20Sopenharmony_civoid __init dm365_init_rtc(void)
7658c2ecf20Sopenharmony_ci{
7668c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_INT_PRTCSS);
7678c2ecf20Sopenharmony_ci	platform_device_register(&dm365_rtc_device);
7688c2ecf20Sopenharmony_ci}
7698c2ecf20Sopenharmony_ci
7708c2ecf20Sopenharmony_civoid __init dm365_init(void)
7718c2ecf20Sopenharmony_ci{
7728c2ecf20Sopenharmony_ci	davinci_common_init(&davinci_soc_info_dm365);
7738c2ecf20Sopenharmony_ci	davinci_map_sysmod();
7748c2ecf20Sopenharmony_ci}
7758c2ecf20Sopenharmony_ci
7768c2ecf20Sopenharmony_civoid __init dm365_init_time(void)
7778c2ecf20Sopenharmony_ci{
7788c2ecf20Sopenharmony_ci	void __iomem *pll1, *pll2, *psc;
7798c2ecf20Sopenharmony_ci	struct clk *clk;
7808c2ecf20Sopenharmony_ci	int rv;
7818c2ecf20Sopenharmony_ci
7828c2ecf20Sopenharmony_ci	clk_register_fixed_rate(NULL, "ref_clk", NULL, 0, DM365_REF_FREQ);
7838c2ecf20Sopenharmony_ci
7848c2ecf20Sopenharmony_ci	pll1 = ioremap(DAVINCI_PLL1_BASE, SZ_1K);
7858c2ecf20Sopenharmony_ci	dm365_pll1_init(NULL, pll1, NULL);
7868c2ecf20Sopenharmony_ci
7878c2ecf20Sopenharmony_ci	pll2 = ioremap(DAVINCI_PLL2_BASE, SZ_1K);
7888c2ecf20Sopenharmony_ci	dm365_pll2_init(NULL, pll2, NULL);
7898c2ecf20Sopenharmony_ci
7908c2ecf20Sopenharmony_ci	psc = ioremap(DAVINCI_PWR_SLEEP_CNTRL_BASE, SZ_4K);
7918c2ecf20Sopenharmony_ci	dm365_psc_init(NULL, psc);
7928c2ecf20Sopenharmony_ci
7938c2ecf20Sopenharmony_ci	clk = clk_get(NULL, "timer0");
7948c2ecf20Sopenharmony_ci	if (WARN_ON(IS_ERR(clk))) {
7958c2ecf20Sopenharmony_ci		pr_err("Unable to get the timer clock\n");
7968c2ecf20Sopenharmony_ci		return;
7978c2ecf20Sopenharmony_ci	}
7988c2ecf20Sopenharmony_ci
7998c2ecf20Sopenharmony_ci	rv = davinci_timer_register(clk, &dm365_timer_cfg);
8008c2ecf20Sopenharmony_ci	WARN(rv, "Unable to register the timer: %d\n", rv);
8018c2ecf20Sopenharmony_ci}
8028c2ecf20Sopenharmony_ci
8038c2ecf20Sopenharmony_civoid __init dm365_register_clocks(void)
8048c2ecf20Sopenharmony_ci{
8058c2ecf20Sopenharmony_ci	/* all clocks are currently registered in dm365_init_time() */
8068c2ecf20Sopenharmony_ci}
8078c2ecf20Sopenharmony_ci
8088c2ecf20Sopenharmony_cistatic struct resource dm365_vpss_resources[] = {
8098c2ecf20Sopenharmony_ci	{
8108c2ecf20Sopenharmony_ci		/* VPSS ISP5 Base address */
8118c2ecf20Sopenharmony_ci		.name           = "isp5",
8128c2ecf20Sopenharmony_ci		.start          = 0x01c70000,
8138c2ecf20Sopenharmony_ci		.end            = 0x01c70000 + 0xff,
8148c2ecf20Sopenharmony_ci		.flags          = IORESOURCE_MEM,
8158c2ecf20Sopenharmony_ci	},
8168c2ecf20Sopenharmony_ci	{
8178c2ecf20Sopenharmony_ci		/* VPSS CLK Base address */
8188c2ecf20Sopenharmony_ci		.name           = "vpss",
8198c2ecf20Sopenharmony_ci		.start          = 0x01c70200,
8208c2ecf20Sopenharmony_ci		.end            = 0x01c70200 + 0xff,
8218c2ecf20Sopenharmony_ci		.flags          = IORESOURCE_MEM,
8228c2ecf20Sopenharmony_ci	},
8238c2ecf20Sopenharmony_ci};
8248c2ecf20Sopenharmony_ci
8258c2ecf20Sopenharmony_cistatic struct platform_device dm365_vpss_device = {
8268c2ecf20Sopenharmony_ci       .name                   = "vpss",
8278c2ecf20Sopenharmony_ci       .id                     = -1,
8288c2ecf20Sopenharmony_ci       .dev.platform_data      = "dm365_vpss",
8298c2ecf20Sopenharmony_ci       .num_resources          = ARRAY_SIZE(dm365_vpss_resources),
8308c2ecf20Sopenharmony_ci       .resource               = dm365_vpss_resources,
8318c2ecf20Sopenharmony_ci};
8328c2ecf20Sopenharmony_ci
8338c2ecf20Sopenharmony_cistatic struct resource vpfe_resources[] = {
8348c2ecf20Sopenharmony_ci	{
8358c2ecf20Sopenharmony_ci		.start          = DAVINCI_INTC_IRQ(IRQ_VDINT0),
8368c2ecf20Sopenharmony_ci		.end            = DAVINCI_INTC_IRQ(IRQ_VDINT0),
8378c2ecf20Sopenharmony_ci		.flags          = IORESOURCE_IRQ,
8388c2ecf20Sopenharmony_ci	},
8398c2ecf20Sopenharmony_ci	{
8408c2ecf20Sopenharmony_ci		.start          = DAVINCI_INTC_IRQ(IRQ_VDINT1),
8418c2ecf20Sopenharmony_ci		.end            = DAVINCI_INTC_IRQ(IRQ_VDINT1),
8428c2ecf20Sopenharmony_ci		.flags          = IORESOURCE_IRQ,
8438c2ecf20Sopenharmony_ci	},
8448c2ecf20Sopenharmony_ci};
8458c2ecf20Sopenharmony_ci
8468c2ecf20Sopenharmony_cistatic u64 vpfe_capture_dma_mask = DMA_BIT_MASK(32);
8478c2ecf20Sopenharmony_cistatic struct platform_device vpfe_capture_dev = {
8488c2ecf20Sopenharmony_ci	.name           = CAPTURE_DRV_NAME,
8498c2ecf20Sopenharmony_ci	.id             = -1,
8508c2ecf20Sopenharmony_ci	.num_resources  = ARRAY_SIZE(vpfe_resources),
8518c2ecf20Sopenharmony_ci	.resource       = vpfe_resources,
8528c2ecf20Sopenharmony_ci	.dev = {
8538c2ecf20Sopenharmony_ci		.dma_mask               = &vpfe_capture_dma_mask,
8548c2ecf20Sopenharmony_ci		.coherent_dma_mask      = DMA_BIT_MASK(32),
8558c2ecf20Sopenharmony_ci	},
8568c2ecf20Sopenharmony_ci};
8578c2ecf20Sopenharmony_ci
8588c2ecf20Sopenharmony_cistatic void dm365_isif_setup_pinmux(void)
8598c2ecf20Sopenharmony_ci{
8608c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_VIN_CAM_WEN);
8618c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_VIN_CAM_VD);
8628c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_VIN_CAM_HD);
8638c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_VIN_YIN4_7_EN);
8648c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_VIN_YIN0_3_EN);
8658c2ecf20Sopenharmony_ci}
8668c2ecf20Sopenharmony_ci
8678c2ecf20Sopenharmony_cistatic struct resource isif_resource[] = {
8688c2ecf20Sopenharmony_ci	/* ISIF Base address */
8698c2ecf20Sopenharmony_ci	{
8708c2ecf20Sopenharmony_ci		.start          = 0x01c71000,
8718c2ecf20Sopenharmony_ci		.end            = 0x01c71000 + 0x1ff,
8728c2ecf20Sopenharmony_ci		.flags          = IORESOURCE_MEM,
8738c2ecf20Sopenharmony_ci	},
8748c2ecf20Sopenharmony_ci	/* ISIF Linearization table 0 */
8758c2ecf20Sopenharmony_ci	{
8768c2ecf20Sopenharmony_ci		.start          = 0x1C7C000,
8778c2ecf20Sopenharmony_ci		.end            = 0x1C7C000 + 0x2ff,
8788c2ecf20Sopenharmony_ci		.flags          = IORESOURCE_MEM,
8798c2ecf20Sopenharmony_ci	},
8808c2ecf20Sopenharmony_ci	/* ISIF Linearization table 1 */
8818c2ecf20Sopenharmony_ci	{
8828c2ecf20Sopenharmony_ci		.start          = 0x1C7C400,
8838c2ecf20Sopenharmony_ci		.end            = 0x1C7C400 + 0x2ff,
8848c2ecf20Sopenharmony_ci		.flags          = IORESOURCE_MEM,
8858c2ecf20Sopenharmony_ci	},
8868c2ecf20Sopenharmony_ci};
8878c2ecf20Sopenharmony_cistatic struct platform_device dm365_isif_dev = {
8888c2ecf20Sopenharmony_ci	.name           = "isif",
8898c2ecf20Sopenharmony_ci	.id             = -1,
8908c2ecf20Sopenharmony_ci	.num_resources  = ARRAY_SIZE(isif_resource),
8918c2ecf20Sopenharmony_ci	.resource       = isif_resource,
8928c2ecf20Sopenharmony_ci	.dev = {
8938c2ecf20Sopenharmony_ci		.dma_mask               = &vpfe_capture_dma_mask,
8948c2ecf20Sopenharmony_ci		.coherent_dma_mask      = DMA_BIT_MASK(32),
8958c2ecf20Sopenharmony_ci		.platform_data		= dm365_isif_setup_pinmux,
8968c2ecf20Sopenharmony_ci	},
8978c2ecf20Sopenharmony_ci};
8988c2ecf20Sopenharmony_ci
8998c2ecf20Sopenharmony_cistatic struct resource dm365_osd_resources[] = {
9008c2ecf20Sopenharmony_ci	{
9018c2ecf20Sopenharmony_ci		.start = DM365_OSD_BASE,
9028c2ecf20Sopenharmony_ci		.end   = DM365_OSD_BASE + 0xff,
9038c2ecf20Sopenharmony_ci		.flags = IORESOURCE_MEM,
9048c2ecf20Sopenharmony_ci	},
9058c2ecf20Sopenharmony_ci};
9068c2ecf20Sopenharmony_ci
9078c2ecf20Sopenharmony_cistatic u64 dm365_video_dma_mask = DMA_BIT_MASK(32);
9088c2ecf20Sopenharmony_ci
9098c2ecf20Sopenharmony_cistatic struct platform_device dm365_osd_dev = {
9108c2ecf20Sopenharmony_ci	.name		= DM365_VPBE_OSD_SUBDEV_NAME,
9118c2ecf20Sopenharmony_ci	.id		= -1,
9128c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dm365_osd_resources),
9138c2ecf20Sopenharmony_ci	.resource	= dm365_osd_resources,
9148c2ecf20Sopenharmony_ci	.dev		= {
9158c2ecf20Sopenharmony_ci		.dma_mask		= &dm365_video_dma_mask,
9168c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
9178c2ecf20Sopenharmony_ci	},
9188c2ecf20Sopenharmony_ci};
9198c2ecf20Sopenharmony_ci
9208c2ecf20Sopenharmony_cistatic struct resource dm365_venc_resources[] = {
9218c2ecf20Sopenharmony_ci	{
9228c2ecf20Sopenharmony_ci		.start = DAVINCI_INTC_IRQ(IRQ_VENCINT),
9238c2ecf20Sopenharmony_ci		.end   = DAVINCI_INTC_IRQ(IRQ_VENCINT),
9248c2ecf20Sopenharmony_ci		.flags = IORESOURCE_IRQ,
9258c2ecf20Sopenharmony_ci	},
9268c2ecf20Sopenharmony_ci	/* venc registers io space */
9278c2ecf20Sopenharmony_ci	{
9288c2ecf20Sopenharmony_ci		.start = DM365_VENC_BASE,
9298c2ecf20Sopenharmony_ci		.end   = DM365_VENC_BASE + 0x177,
9308c2ecf20Sopenharmony_ci		.flags = IORESOURCE_MEM,
9318c2ecf20Sopenharmony_ci	},
9328c2ecf20Sopenharmony_ci	/* vdaccfg registers io space */
9338c2ecf20Sopenharmony_ci	{
9348c2ecf20Sopenharmony_ci		.start = DAVINCI_SYSTEM_MODULE_BASE + SYSMOD_VDAC_CONFIG,
9358c2ecf20Sopenharmony_ci		.end   = DAVINCI_SYSTEM_MODULE_BASE + SYSMOD_VDAC_CONFIG + 3,
9368c2ecf20Sopenharmony_ci		.flags = IORESOURCE_MEM,
9378c2ecf20Sopenharmony_ci	},
9388c2ecf20Sopenharmony_ci};
9398c2ecf20Sopenharmony_ci
9408c2ecf20Sopenharmony_cistatic struct resource dm365_v4l2_disp_resources[] = {
9418c2ecf20Sopenharmony_ci	{
9428c2ecf20Sopenharmony_ci		.start = DAVINCI_INTC_IRQ(IRQ_VENCINT),
9438c2ecf20Sopenharmony_ci		.end   = DAVINCI_INTC_IRQ(IRQ_VENCINT),
9448c2ecf20Sopenharmony_ci		.flags = IORESOURCE_IRQ,
9458c2ecf20Sopenharmony_ci	},
9468c2ecf20Sopenharmony_ci	/* venc registers io space */
9478c2ecf20Sopenharmony_ci	{
9488c2ecf20Sopenharmony_ci		.start = DM365_VENC_BASE,
9498c2ecf20Sopenharmony_ci		.end   = DM365_VENC_BASE + 0x177,
9508c2ecf20Sopenharmony_ci		.flags = IORESOURCE_MEM,
9518c2ecf20Sopenharmony_ci	},
9528c2ecf20Sopenharmony_ci};
9538c2ecf20Sopenharmony_ci
9548c2ecf20Sopenharmony_cistatic int dm365_vpbe_setup_pinmux(u32 if_type, int field)
9558c2ecf20Sopenharmony_ci{
9568c2ecf20Sopenharmony_ci	switch (if_type) {
9578c2ecf20Sopenharmony_ci	case MEDIA_BUS_FMT_SGRBG8_1X8:
9588c2ecf20Sopenharmony_ci		davinci_cfg_reg(DM365_VOUT_FIELD_G81);
9598c2ecf20Sopenharmony_ci		davinci_cfg_reg(DM365_VOUT_COUTL_EN);
9608c2ecf20Sopenharmony_ci		davinci_cfg_reg(DM365_VOUT_COUTH_EN);
9618c2ecf20Sopenharmony_ci		break;
9628c2ecf20Sopenharmony_ci	case MEDIA_BUS_FMT_YUYV10_1X20:
9638c2ecf20Sopenharmony_ci		if (field)
9648c2ecf20Sopenharmony_ci			davinci_cfg_reg(DM365_VOUT_FIELD);
9658c2ecf20Sopenharmony_ci		else
9668c2ecf20Sopenharmony_ci			davinci_cfg_reg(DM365_VOUT_FIELD_G81);
9678c2ecf20Sopenharmony_ci		davinci_cfg_reg(DM365_VOUT_COUTL_EN);
9688c2ecf20Sopenharmony_ci		davinci_cfg_reg(DM365_VOUT_COUTH_EN);
9698c2ecf20Sopenharmony_ci		break;
9708c2ecf20Sopenharmony_ci	default:
9718c2ecf20Sopenharmony_ci		return -EINVAL;
9728c2ecf20Sopenharmony_ci	}
9738c2ecf20Sopenharmony_ci
9748c2ecf20Sopenharmony_ci	return 0;
9758c2ecf20Sopenharmony_ci}
9768c2ecf20Sopenharmony_ci
9778c2ecf20Sopenharmony_cistatic int dm365_venc_setup_clock(enum vpbe_enc_timings_type type,
9788c2ecf20Sopenharmony_ci				  unsigned int pclock)
9798c2ecf20Sopenharmony_ci{
9808c2ecf20Sopenharmony_ci	void __iomem *vpss_clkctl_reg;
9818c2ecf20Sopenharmony_ci	u32 val;
9828c2ecf20Sopenharmony_ci
9838c2ecf20Sopenharmony_ci	vpss_clkctl_reg = DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL);
9848c2ecf20Sopenharmony_ci
9858c2ecf20Sopenharmony_ci	switch (type) {
9868c2ecf20Sopenharmony_ci	case VPBE_ENC_STD:
9878c2ecf20Sopenharmony_ci		val = VPSS_VENCCLKEN_ENABLE | VPSS_DACCLKEN_ENABLE;
9888c2ecf20Sopenharmony_ci		break;
9898c2ecf20Sopenharmony_ci	case VPBE_ENC_DV_TIMINGS:
9908c2ecf20Sopenharmony_ci		if (pclock <= 27000000) {
9918c2ecf20Sopenharmony_ci			val = VPSS_VENCCLKEN_ENABLE | VPSS_DACCLKEN_ENABLE;
9928c2ecf20Sopenharmony_ci		} else {
9938c2ecf20Sopenharmony_ci			/* set sysclk4 to output 74.25 MHz from pll1 */
9948c2ecf20Sopenharmony_ci			val = VPSS_PLLC2SYSCLK5_ENABLE | VPSS_DACCLKEN_ENABLE |
9958c2ecf20Sopenharmony_ci			      VPSS_VENCCLKEN_ENABLE;
9968c2ecf20Sopenharmony_ci		}
9978c2ecf20Sopenharmony_ci		break;
9988c2ecf20Sopenharmony_ci	default:
9998c2ecf20Sopenharmony_ci		return -EINVAL;
10008c2ecf20Sopenharmony_ci	}
10018c2ecf20Sopenharmony_ci	writel(val, vpss_clkctl_reg);
10028c2ecf20Sopenharmony_ci
10038c2ecf20Sopenharmony_ci	return 0;
10048c2ecf20Sopenharmony_ci}
10058c2ecf20Sopenharmony_ci
10068c2ecf20Sopenharmony_cistatic struct platform_device dm365_vpbe_display = {
10078c2ecf20Sopenharmony_ci	.name		= "vpbe-v4l2",
10088c2ecf20Sopenharmony_ci	.id		= -1,
10098c2ecf20Sopenharmony_ci	.num_resources  = ARRAY_SIZE(dm365_v4l2_disp_resources),
10108c2ecf20Sopenharmony_ci	.resource	= dm365_v4l2_disp_resources,
10118c2ecf20Sopenharmony_ci	.dev		= {
10128c2ecf20Sopenharmony_ci		.dma_mask		= &dm365_video_dma_mask,
10138c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
10148c2ecf20Sopenharmony_ci	},
10158c2ecf20Sopenharmony_ci};
10168c2ecf20Sopenharmony_ci
10178c2ecf20Sopenharmony_cistatic struct venc_platform_data dm365_venc_pdata = {
10188c2ecf20Sopenharmony_ci	.setup_pinmux	= dm365_vpbe_setup_pinmux,
10198c2ecf20Sopenharmony_ci	.setup_clock	= dm365_venc_setup_clock,
10208c2ecf20Sopenharmony_ci};
10218c2ecf20Sopenharmony_ci
10228c2ecf20Sopenharmony_cistatic struct platform_device dm365_venc_dev = {
10238c2ecf20Sopenharmony_ci	.name		= DM365_VPBE_VENC_SUBDEV_NAME,
10248c2ecf20Sopenharmony_ci	.id		= -1,
10258c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(dm365_venc_resources),
10268c2ecf20Sopenharmony_ci	.resource	= dm365_venc_resources,
10278c2ecf20Sopenharmony_ci	.dev		= {
10288c2ecf20Sopenharmony_ci		.dma_mask		= &dm365_video_dma_mask,
10298c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
10308c2ecf20Sopenharmony_ci		.platform_data		= (void *)&dm365_venc_pdata,
10318c2ecf20Sopenharmony_ci	},
10328c2ecf20Sopenharmony_ci};
10338c2ecf20Sopenharmony_ci
10348c2ecf20Sopenharmony_cistatic struct platform_device dm365_vpbe_dev = {
10358c2ecf20Sopenharmony_ci	.name		= "vpbe_controller",
10368c2ecf20Sopenharmony_ci	.id		= -1,
10378c2ecf20Sopenharmony_ci	.dev		= {
10388c2ecf20Sopenharmony_ci		.dma_mask		= &dm365_video_dma_mask,
10398c2ecf20Sopenharmony_ci		.coherent_dma_mask	= DMA_BIT_MASK(32),
10408c2ecf20Sopenharmony_ci	},
10418c2ecf20Sopenharmony_ci};
10428c2ecf20Sopenharmony_ci
10438c2ecf20Sopenharmony_ciint __init dm365_init_video(struct vpfe_config *vpfe_cfg,
10448c2ecf20Sopenharmony_ci				struct vpbe_config *vpbe_cfg)
10458c2ecf20Sopenharmony_ci{
10468c2ecf20Sopenharmony_ci	if (vpfe_cfg || vpbe_cfg)
10478c2ecf20Sopenharmony_ci		platform_device_register(&dm365_vpss_device);
10488c2ecf20Sopenharmony_ci
10498c2ecf20Sopenharmony_ci	if (vpfe_cfg) {
10508c2ecf20Sopenharmony_ci		vpfe_capture_dev.dev.platform_data = vpfe_cfg;
10518c2ecf20Sopenharmony_ci		platform_device_register(&dm365_isif_dev);
10528c2ecf20Sopenharmony_ci		platform_device_register(&vpfe_capture_dev);
10538c2ecf20Sopenharmony_ci	}
10548c2ecf20Sopenharmony_ci	if (vpbe_cfg) {
10558c2ecf20Sopenharmony_ci		dm365_vpbe_dev.dev.platform_data = vpbe_cfg;
10568c2ecf20Sopenharmony_ci		platform_device_register(&dm365_osd_dev);
10578c2ecf20Sopenharmony_ci		platform_device_register(&dm365_venc_dev);
10588c2ecf20Sopenharmony_ci		platform_device_register(&dm365_vpbe_dev);
10598c2ecf20Sopenharmony_ci		platform_device_register(&dm365_vpbe_display);
10608c2ecf20Sopenharmony_ci	}
10618c2ecf20Sopenharmony_ci
10628c2ecf20Sopenharmony_ci	return 0;
10638c2ecf20Sopenharmony_ci}
10648c2ecf20Sopenharmony_ci
10658c2ecf20Sopenharmony_cistatic const struct davinci_aintc_config dm365_aintc_config = {
10668c2ecf20Sopenharmony_ci	.reg = {
10678c2ecf20Sopenharmony_ci		.start		= DAVINCI_ARM_INTC_BASE,
10688c2ecf20Sopenharmony_ci		.end		= DAVINCI_ARM_INTC_BASE + SZ_4K - 1,
10698c2ecf20Sopenharmony_ci		.flags		= IORESOURCE_MEM,
10708c2ecf20Sopenharmony_ci	},
10718c2ecf20Sopenharmony_ci	.num_irqs		= 64,
10728c2ecf20Sopenharmony_ci	.prios			= dm365_default_priorities,
10738c2ecf20Sopenharmony_ci};
10748c2ecf20Sopenharmony_ci
10758c2ecf20Sopenharmony_civoid __init dm365_init_irq(void)
10768c2ecf20Sopenharmony_ci{
10778c2ecf20Sopenharmony_ci	davinci_aintc_init(&dm365_aintc_config);
10788c2ecf20Sopenharmony_ci}
10798c2ecf20Sopenharmony_ci
10808c2ecf20Sopenharmony_cistatic int __init dm365_init_devices(void)
10818c2ecf20Sopenharmony_ci{
10828c2ecf20Sopenharmony_ci	struct platform_device *edma_pdev;
10838c2ecf20Sopenharmony_ci	int ret = 0;
10848c2ecf20Sopenharmony_ci
10858c2ecf20Sopenharmony_ci	if (!cpu_is_davinci_dm365())
10868c2ecf20Sopenharmony_ci		return 0;
10878c2ecf20Sopenharmony_ci
10888c2ecf20Sopenharmony_ci	davinci_cfg_reg(DM365_INT_EDMA_CC);
10898c2ecf20Sopenharmony_ci	edma_pdev = platform_device_register_full(&dm365_edma_device);
10908c2ecf20Sopenharmony_ci	if (IS_ERR(edma_pdev)) {
10918c2ecf20Sopenharmony_ci		pr_warn("%s: Failed to register eDMA\n", __func__);
10928c2ecf20Sopenharmony_ci		return PTR_ERR(edma_pdev);
10938c2ecf20Sopenharmony_ci	}
10948c2ecf20Sopenharmony_ci
10958c2ecf20Sopenharmony_ci	platform_device_register(&dm365_mdio_device);
10968c2ecf20Sopenharmony_ci	platform_device_register(&dm365_emac_device);
10978c2ecf20Sopenharmony_ci
10988c2ecf20Sopenharmony_ci	ret = davinci_init_wdt();
10998c2ecf20Sopenharmony_ci	if (ret)
11008c2ecf20Sopenharmony_ci		pr_warn("%s: watchdog init failed: %d\n", __func__, ret);
11018c2ecf20Sopenharmony_ci
11028c2ecf20Sopenharmony_ci	return ret;
11038c2ecf20Sopenharmony_ci}
11048c2ecf20Sopenharmony_cipostcore_initcall(dm365_init_devices);
1105