dm355.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  1. /*
  2. * TI DaVinci DM355 chip specific setup
  3. *
  4. * Author: Kevin Hilman, Deep Root Systems, LLC
  5. *
  6. * 2007 (c) Deep Root Systems, LLC. This file is licensed under
  7. * the terms of the GNU General Public License version 2. This program
  8. * is licensed "as is" without any warranty of any kind, whether express
  9. * or implied.
  10. */
  11. #include <linux/clk-provider.h>
  12. #include <linux/clk/davinci.h>
  13. #include <linux/clkdev.h>
  14. #include <linux/dma-mapping.h>
  15. #include <linux/dmaengine.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_data/edma.h>
  18. #include <linux/platform_data/gpio-davinci.h>
  19. #include <linux/platform_data/spi-davinci.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/serial_8250.h>
  22. #include <linux/spi/spi.h>
  23. #include <asm/mach/map.h>
  24. #include <mach/common.h>
  25. #include <mach/cputype.h>
  26. #include <mach/irqs.h>
  27. #include <mach/mux.h>
  28. #include <mach/serial.h>
  29. #include <mach/time.h>
  30. #include "asp.h"
  31. #include "davinci.h"
  32. #include "mux.h"
  33. #define DM355_UART2_BASE (IO_PHYS + 0x206000)
  34. #define DM355_OSD_BASE (IO_PHYS + 0x70200)
  35. #define DM355_VENC_BASE (IO_PHYS + 0x70400)
  36. /*
  37. * Device specific clocks
  38. */
  39. #define DM355_REF_FREQ 24000000 /* 24 or 36 MHz */
  40. static u64 dm355_spi0_dma_mask = DMA_BIT_MASK(32);
  41. static struct resource dm355_spi0_resources[] = {
  42. {
  43. .start = 0x01c66000,
  44. .end = 0x01c667ff,
  45. .flags = IORESOURCE_MEM,
  46. },
  47. {
  48. .start = IRQ_DM355_SPINT0_0,
  49. .flags = IORESOURCE_IRQ,
  50. },
  51. };
  52. static struct davinci_spi_platform_data dm355_spi0_pdata = {
  53. .version = SPI_VERSION_1,
  54. .num_chipselect = 2,
  55. .cshold_bug = true,
  56. .dma_event_q = EVENTQ_1,
  57. .prescaler_limit = 1,
  58. };
  59. static struct platform_device dm355_spi0_device = {
  60. .name = "spi_davinci",
  61. .id = 0,
  62. .dev = {
  63. .dma_mask = &dm355_spi0_dma_mask,
  64. .coherent_dma_mask = DMA_BIT_MASK(32),
  65. .platform_data = &dm355_spi0_pdata,
  66. },
  67. .num_resources = ARRAY_SIZE(dm355_spi0_resources),
  68. .resource = dm355_spi0_resources,
  69. };
  70. void __init dm355_init_spi0(unsigned chipselect_mask,
  71. const struct spi_board_info *info, unsigned len)
  72. {
  73. /* for now, assume we need MISO */
  74. davinci_cfg_reg(DM355_SPI0_SDI);
  75. /* not all slaves will be wired up */
  76. if (chipselect_mask & BIT(0))
  77. davinci_cfg_reg(DM355_SPI0_SDENA0);
  78. if (chipselect_mask & BIT(1))
  79. davinci_cfg_reg(DM355_SPI0_SDENA1);
  80. spi_register_board_info(info, len);
  81. platform_device_register(&dm355_spi0_device);
  82. }
  83. /*----------------------------------------------------------------------*/
  84. #define INTMUX 0x18
  85. #define EVTMUX 0x1c
  86. /*
  87. * Device specific mux setup
  88. *
  89. * soc description mux mode mode mux dbg
  90. * reg offset mask mode
  91. */
  92. static const struct mux_config dm355_pins[] = {
  93. #ifdef CONFIG_DAVINCI_MUX
  94. MUX_CFG(DM355, MMCSD0, 4, 2, 1, 0, false)
  95. MUX_CFG(DM355, SD1_CLK, 3, 6, 1, 1, false)
  96. MUX_CFG(DM355, SD1_CMD, 3, 7, 1, 1, false)
  97. MUX_CFG(DM355, SD1_DATA3, 3, 8, 3, 1, false)
  98. MUX_CFG(DM355, SD1_DATA2, 3, 10, 3, 1, false)
  99. MUX_CFG(DM355, SD1_DATA1, 3, 12, 3, 1, false)
  100. MUX_CFG(DM355, SD1_DATA0, 3, 14, 3, 1, false)
  101. MUX_CFG(DM355, I2C_SDA, 3, 19, 1, 1, false)
  102. MUX_CFG(DM355, I2C_SCL, 3, 20, 1, 1, false)
  103. MUX_CFG(DM355, MCBSP0_BDX, 3, 0, 1, 1, false)
  104. MUX_CFG(DM355, MCBSP0_X, 3, 1, 1, 1, false)
  105. MUX_CFG(DM355, MCBSP0_BFSX, 3, 2, 1, 1, false)
  106. MUX_CFG(DM355, MCBSP0_BDR, 3, 3, 1, 1, false)
  107. MUX_CFG(DM355, MCBSP0_R, 3, 4, 1, 1, false)
  108. MUX_CFG(DM355, MCBSP0_BFSR, 3, 5, 1, 1, false)
  109. MUX_CFG(DM355, SPI0_SDI, 4, 1, 1, 0, false)
  110. MUX_CFG(DM355, SPI0_SDENA0, 4, 0, 1, 0, false)
  111. MUX_CFG(DM355, SPI0_SDENA1, 3, 28, 1, 1, false)
  112. INT_CFG(DM355, INT_EDMA_CC, 2, 1, 1, false)
  113. INT_CFG(DM355, INT_EDMA_TC0_ERR, 3, 1, 1, false)
  114. INT_CFG(DM355, INT_EDMA_TC1_ERR, 4, 1, 1, false)
  115. EVT_CFG(DM355, EVT8_ASP1_TX, 0, 1, 0, false)
  116. EVT_CFG(DM355, EVT9_ASP1_RX, 1, 1, 0, false)
  117. EVT_CFG(DM355, EVT26_MMC0_RX, 2, 1, 0, false)
  118. MUX_CFG(DM355, VOUT_FIELD, 1, 18, 3, 1, false)
  119. MUX_CFG(DM355, VOUT_FIELD_G70, 1, 18, 3, 0, false)
  120. MUX_CFG(DM355, VOUT_HVSYNC, 1, 16, 1, 0, false)
  121. MUX_CFG(DM355, VOUT_COUTL_EN, 1, 0, 0xff, 0x55, false)
  122. MUX_CFG(DM355, VOUT_COUTH_EN, 1, 8, 0xff, 0x55, false)
  123. MUX_CFG(DM355, VIN_PCLK, 0, 14, 1, 1, false)
  124. MUX_CFG(DM355, VIN_CAM_WEN, 0, 13, 1, 1, false)
  125. MUX_CFG(DM355, VIN_CAM_VD, 0, 12, 1, 1, false)
  126. MUX_CFG(DM355, VIN_CAM_HD, 0, 11, 1, 1, false)
  127. MUX_CFG(DM355, VIN_YIN_EN, 0, 10, 1, 1, false)
  128. MUX_CFG(DM355, VIN_CINL_EN, 0, 0, 0xff, 0x55, false)
  129. MUX_CFG(DM355, VIN_CINH_EN, 0, 8, 3, 3, false)
  130. #endif
  131. };
  132. static u8 dm355_default_priorities[DAVINCI_N_AINTC_IRQ] = {
  133. [IRQ_DM355_CCDC_VDINT0] = 2,
  134. [IRQ_DM355_CCDC_VDINT1] = 6,
  135. [IRQ_DM355_CCDC_VDINT2] = 6,
  136. [IRQ_DM355_IPIPE_HST] = 6,
  137. [IRQ_DM355_H3AINT] = 6,
  138. [IRQ_DM355_IPIPE_SDR] = 6,
  139. [IRQ_DM355_IPIPEIFINT] = 6,
  140. [IRQ_DM355_OSDINT] = 7,
  141. [IRQ_DM355_VENCINT] = 6,
  142. [IRQ_ASQINT] = 6,
  143. [IRQ_IMXINT] = 6,
  144. [IRQ_USBINT] = 4,
  145. [IRQ_DM355_RTOINT] = 4,
  146. [IRQ_DM355_UARTINT2] = 7,
  147. [IRQ_DM355_TINT6] = 7,
  148. [IRQ_CCINT0] = 5, /* dma */
  149. [IRQ_CCERRINT] = 5, /* dma */
  150. [IRQ_TCERRINT0] = 5, /* dma */
  151. [IRQ_TCERRINT] = 5, /* dma */
  152. [IRQ_DM355_SPINT2_1] = 7,
  153. [IRQ_DM355_TINT7] = 4,
  154. [IRQ_DM355_SDIOINT0] = 7,
  155. [IRQ_MBXINT] = 7,
  156. [IRQ_MBRINT] = 7,
  157. [IRQ_MMCINT] = 7,
  158. [IRQ_DM355_MMCINT1] = 7,
  159. [IRQ_DM355_PWMINT3] = 7,
  160. [IRQ_DDRINT] = 7,
  161. [IRQ_AEMIFINT] = 7,
  162. [IRQ_DM355_SDIOINT1] = 4,
  163. [IRQ_TINT0_TINT12] = 2, /* clockevent */
  164. [IRQ_TINT0_TINT34] = 2, /* clocksource */
  165. [IRQ_TINT1_TINT12] = 7, /* DSP timer */
  166. [IRQ_TINT1_TINT34] = 7, /* system tick */
  167. [IRQ_PWMINT0] = 7,
  168. [IRQ_PWMINT1] = 7,
  169. [IRQ_PWMINT2] = 7,
  170. [IRQ_I2C] = 3,
  171. [IRQ_UARTINT0] = 3,
  172. [IRQ_UARTINT1] = 3,
  173. [IRQ_DM355_SPINT0_0] = 3,
  174. [IRQ_DM355_SPINT0_1] = 3,
  175. [IRQ_DM355_GPIO0] = 3,
  176. [IRQ_DM355_GPIO1] = 7,
  177. [IRQ_DM355_GPIO2] = 4,
  178. [IRQ_DM355_GPIO3] = 4,
  179. [IRQ_DM355_GPIO4] = 7,
  180. [IRQ_DM355_GPIO5] = 7,
  181. [IRQ_DM355_GPIO6] = 7,
  182. [IRQ_DM355_GPIO7] = 7,
  183. [IRQ_DM355_GPIO8] = 7,
  184. [IRQ_DM355_GPIO9] = 7,
  185. [IRQ_DM355_GPIOBNK0] = 7,
  186. [IRQ_DM355_GPIOBNK1] = 7,
  187. [IRQ_DM355_GPIOBNK2] = 7,
  188. [IRQ_DM355_GPIOBNK3] = 7,
  189. [IRQ_DM355_GPIOBNK4] = 7,
  190. [IRQ_DM355_GPIOBNK5] = 7,
  191. [IRQ_DM355_GPIOBNK6] = 7,
  192. [IRQ_COMMTX] = 7,
  193. [IRQ_COMMRX] = 7,
  194. [IRQ_EMUINT] = 7,
  195. };
  196. /*----------------------------------------------------------------------*/
  197. static s8 queue_priority_mapping[][2] = {
  198. /* {event queue no, Priority} */
  199. {0, 3},
  200. {1, 7},
  201. {-1, -1},
  202. };
  203. static const struct dma_slave_map dm355_edma_map[] = {
  204. { "davinci-mcbsp.0", "tx", EDMA_FILTER_PARAM(0, 2) },
  205. { "davinci-mcbsp.0", "rx", EDMA_FILTER_PARAM(0, 3) },
  206. { "davinci-mcbsp.1", "tx", EDMA_FILTER_PARAM(0, 8) },
  207. { "davinci-mcbsp.1", "rx", EDMA_FILTER_PARAM(0, 9) },
  208. { "spi_davinci.2", "tx", EDMA_FILTER_PARAM(0, 10) },
  209. { "spi_davinci.2", "rx", EDMA_FILTER_PARAM(0, 11) },
  210. { "spi_davinci.1", "tx", EDMA_FILTER_PARAM(0, 14) },
  211. { "spi_davinci.1", "rx", EDMA_FILTER_PARAM(0, 15) },
  212. { "spi_davinci.0", "tx", EDMA_FILTER_PARAM(0, 16) },
  213. { "spi_davinci.0", "rx", EDMA_FILTER_PARAM(0, 17) },
  214. { "dm6441-mmc.0", "rx", EDMA_FILTER_PARAM(0, 26) },
  215. { "dm6441-mmc.0", "tx", EDMA_FILTER_PARAM(0, 27) },
  216. { "dm6441-mmc.1", "rx", EDMA_FILTER_PARAM(0, 30) },
  217. { "dm6441-mmc.1", "tx", EDMA_FILTER_PARAM(0, 31) },
  218. };
  219. static struct edma_soc_info dm355_edma_pdata = {
  220. .queue_priority_mapping = queue_priority_mapping,
  221. .default_queue = EVENTQ_1,
  222. .slave_map = dm355_edma_map,
  223. .slavecnt = ARRAY_SIZE(dm355_edma_map),
  224. };
  225. static struct resource edma_resources[] = {
  226. {
  227. .name = "edma3_cc",
  228. .start = 0x01c00000,
  229. .end = 0x01c00000 + SZ_64K - 1,
  230. .flags = IORESOURCE_MEM,
  231. },
  232. {
  233. .name = "edma3_tc0",
  234. .start = 0x01c10000,
  235. .end = 0x01c10000 + SZ_1K - 1,
  236. .flags = IORESOURCE_MEM,
  237. },
  238. {
  239. .name = "edma3_tc1",
  240. .start = 0x01c10400,
  241. .end = 0x01c10400 + SZ_1K - 1,
  242. .flags = IORESOURCE_MEM,
  243. },
  244. {
  245. .name = "edma3_ccint",
  246. .start = IRQ_CCINT0,
  247. .flags = IORESOURCE_IRQ,
  248. },
  249. {
  250. .name = "edma3_ccerrint",
  251. .start = IRQ_CCERRINT,
  252. .flags = IORESOURCE_IRQ,
  253. },
  254. /* not using (or muxing) TC*_ERR */
  255. };
  256. static const struct platform_device_info dm355_edma_device __initconst = {
  257. .name = "edma",
  258. .id = 0,
  259. .dma_mask = DMA_BIT_MASK(32),
  260. .res = edma_resources,
  261. .num_res = ARRAY_SIZE(edma_resources),
  262. .data = &dm355_edma_pdata,
  263. .size_data = sizeof(dm355_edma_pdata),
  264. };
  265. static struct resource dm355_asp1_resources[] = {
  266. {
  267. .name = "mpu",
  268. .start = DAVINCI_ASP1_BASE,
  269. .end = DAVINCI_ASP1_BASE + SZ_8K - 1,
  270. .flags = IORESOURCE_MEM,
  271. },
  272. {
  273. .start = DAVINCI_DMA_ASP1_TX,
  274. .end = DAVINCI_DMA_ASP1_TX,
  275. .flags = IORESOURCE_DMA,
  276. },
  277. {
  278. .start = DAVINCI_DMA_ASP1_RX,
  279. .end = DAVINCI_DMA_ASP1_RX,
  280. .flags = IORESOURCE_DMA,
  281. },
  282. };
  283. static struct platform_device dm355_asp1_device = {
  284. .name = "davinci-mcbsp",
  285. .id = 1,
  286. .num_resources = ARRAY_SIZE(dm355_asp1_resources),
  287. .resource = dm355_asp1_resources,
  288. };
  289. static void dm355_ccdc_setup_pinmux(void)
  290. {
  291. davinci_cfg_reg(DM355_VIN_PCLK);
  292. davinci_cfg_reg(DM355_VIN_CAM_WEN);
  293. davinci_cfg_reg(DM355_VIN_CAM_VD);
  294. davinci_cfg_reg(DM355_VIN_CAM_HD);
  295. davinci_cfg_reg(DM355_VIN_YIN_EN);
  296. davinci_cfg_reg(DM355_VIN_CINL_EN);
  297. davinci_cfg_reg(DM355_VIN_CINH_EN);
  298. }
  299. static struct resource dm355_vpss_resources[] = {
  300. {
  301. /* VPSS BL Base address */
  302. .name = "vpss",
  303. .start = 0x01c70800,
  304. .end = 0x01c70800 + 0xff,
  305. .flags = IORESOURCE_MEM,
  306. },
  307. {
  308. /* VPSS CLK Base address */
  309. .name = "vpss",
  310. .start = 0x01c70000,
  311. .end = 0x01c70000 + 0xf,
  312. .flags = IORESOURCE_MEM,
  313. },
  314. };
  315. static struct platform_device dm355_vpss_device = {
  316. .name = "vpss",
  317. .id = -1,
  318. .dev.platform_data = "dm355_vpss",
  319. .num_resources = ARRAY_SIZE(dm355_vpss_resources),
  320. .resource = dm355_vpss_resources,
  321. };
  322. static struct resource vpfe_resources[] = {
  323. {
  324. .start = IRQ_VDINT0,
  325. .end = IRQ_VDINT0,
  326. .flags = IORESOURCE_IRQ,
  327. },
  328. {
  329. .start = IRQ_VDINT1,
  330. .end = IRQ_VDINT1,
  331. .flags = IORESOURCE_IRQ,
  332. },
  333. };
  334. static u64 vpfe_capture_dma_mask = DMA_BIT_MASK(32);
  335. static struct resource dm355_ccdc_resource[] = {
  336. /* CCDC Base address */
  337. {
  338. .flags = IORESOURCE_MEM,
  339. .start = 0x01c70600,
  340. .end = 0x01c70600 + 0x1ff,
  341. },
  342. };
  343. static struct platform_device dm355_ccdc_dev = {
  344. .name = "dm355_ccdc",
  345. .id = -1,
  346. .num_resources = ARRAY_SIZE(dm355_ccdc_resource),
  347. .resource = dm355_ccdc_resource,
  348. .dev = {
  349. .dma_mask = &vpfe_capture_dma_mask,
  350. .coherent_dma_mask = DMA_BIT_MASK(32),
  351. .platform_data = dm355_ccdc_setup_pinmux,
  352. },
  353. };
  354. static struct platform_device vpfe_capture_dev = {
  355. .name = CAPTURE_DRV_NAME,
  356. .id = -1,
  357. .num_resources = ARRAY_SIZE(vpfe_resources),
  358. .resource = vpfe_resources,
  359. .dev = {
  360. .dma_mask = &vpfe_capture_dma_mask,
  361. .coherent_dma_mask = DMA_BIT_MASK(32),
  362. },
  363. };
  364. static struct resource dm355_osd_resources[] = {
  365. {
  366. .start = DM355_OSD_BASE,
  367. .end = DM355_OSD_BASE + 0x17f,
  368. .flags = IORESOURCE_MEM,
  369. },
  370. };
  371. static struct platform_device dm355_osd_dev = {
  372. .name = DM355_VPBE_OSD_SUBDEV_NAME,
  373. .id = -1,
  374. .num_resources = ARRAY_SIZE(dm355_osd_resources),
  375. .resource = dm355_osd_resources,
  376. .dev = {
  377. .dma_mask = &vpfe_capture_dma_mask,
  378. .coherent_dma_mask = DMA_BIT_MASK(32),
  379. },
  380. };
  381. static struct resource dm355_venc_resources[] = {
  382. {
  383. .start = IRQ_VENCINT,
  384. .end = IRQ_VENCINT,
  385. .flags = IORESOURCE_IRQ,
  386. },
  387. /* venc registers io space */
  388. {
  389. .start = DM355_VENC_BASE,
  390. .end = DM355_VENC_BASE + 0x17f,
  391. .flags = IORESOURCE_MEM,
  392. },
  393. /* VDAC config register io space */
  394. {
  395. .start = DAVINCI_SYSTEM_MODULE_BASE + SYSMOD_VDAC_CONFIG,
  396. .end = DAVINCI_SYSTEM_MODULE_BASE + SYSMOD_VDAC_CONFIG + 3,
  397. .flags = IORESOURCE_MEM,
  398. },
  399. };
  400. static struct resource dm355_v4l2_disp_resources[] = {
  401. {
  402. .start = IRQ_VENCINT,
  403. .end = IRQ_VENCINT,
  404. .flags = IORESOURCE_IRQ,
  405. },
  406. /* venc registers io space */
  407. {
  408. .start = DM355_VENC_BASE,
  409. .end = DM355_VENC_BASE + 0x17f,
  410. .flags = IORESOURCE_MEM,
  411. },
  412. };
  413. static int dm355_vpbe_setup_pinmux(u32 if_type, int field)
  414. {
  415. switch (if_type) {
  416. case MEDIA_BUS_FMT_SGRBG8_1X8:
  417. davinci_cfg_reg(DM355_VOUT_FIELD_G70);
  418. break;
  419. case MEDIA_BUS_FMT_YUYV10_1X20:
  420. if (field)
  421. davinci_cfg_reg(DM355_VOUT_FIELD);
  422. else
  423. davinci_cfg_reg(DM355_VOUT_FIELD_G70);
  424. break;
  425. default:
  426. return -EINVAL;
  427. }
  428. davinci_cfg_reg(DM355_VOUT_COUTL_EN);
  429. davinci_cfg_reg(DM355_VOUT_COUTH_EN);
  430. return 0;
  431. }
  432. static int dm355_venc_setup_clock(enum vpbe_enc_timings_type type,
  433. unsigned int pclock)
  434. {
  435. void __iomem *vpss_clk_ctrl_reg;
  436. vpss_clk_ctrl_reg = DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL);
  437. switch (type) {
  438. case VPBE_ENC_STD:
  439. writel(VPSS_DACCLKEN_ENABLE | VPSS_VENCCLKEN_ENABLE,
  440. vpss_clk_ctrl_reg);
  441. break;
  442. case VPBE_ENC_DV_TIMINGS:
  443. if (pclock > 27000000)
  444. /*
  445. * For HD, use external clock source since we cannot
  446. * support HD mode with internal clocks.
  447. */
  448. writel(VPSS_MUXSEL_EXTCLK_ENABLE, vpss_clk_ctrl_reg);
  449. break;
  450. default:
  451. return -EINVAL;
  452. }
  453. return 0;
  454. }
  455. static struct platform_device dm355_vpbe_display = {
  456. .name = "vpbe-v4l2",
  457. .id = -1,
  458. .num_resources = ARRAY_SIZE(dm355_v4l2_disp_resources),
  459. .resource = dm355_v4l2_disp_resources,
  460. .dev = {
  461. .dma_mask = &vpfe_capture_dma_mask,
  462. .coherent_dma_mask = DMA_BIT_MASK(32),
  463. },
  464. };
  465. static struct venc_platform_data dm355_venc_pdata = {
  466. .setup_pinmux = dm355_vpbe_setup_pinmux,
  467. .setup_clock = dm355_venc_setup_clock,
  468. };
  469. static struct platform_device dm355_venc_dev = {
  470. .name = DM355_VPBE_VENC_SUBDEV_NAME,
  471. .id = -1,
  472. .num_resources = ARRAY_SIZE(dm355_venc_resources),
  473. .resource = dm355_venc_resources,
  474. .dev = {
  475. .dma_mask = &vpfe_capture_dma_mask,
  476. .coherent_dma_mask = DMA_BIT_MASK(32),
  477. .platform_data = (void *)&dm355_venc_pdata,
  478. },
  479. };
  480. static struct platform_device dm355_vpbe_dev = {
  481. .name = "vpbe_controller",
  482. .id = -1,
  483. .dev = {
  484. .dma_mask = &vpfe_capture_dma_mask,
  485. .coherent_dma_mask = DMA_BIT_MASK(32),
  486. },
  487. };
  488. static struct resource dm355_gpio_resources[] = {
  489. { /* registers */
  490. .start = DAVINCI_GPIO_BASE,
  491. .end = DAVINCI_GPIO_BASE + SZ_4K - 1,
  492. .flags = IORESOURCE_MEM,
  493. },
  494. { /* interrupt */
  495. .start = IRQ_DM355_GPIOBNK0,
  496. .end = IRQ_DM355_GPIOBNK0,
  497. .flags = IORESOURCE_IRQ,
  498. },
  499. {
  500. .start = IRQ_DM355_GPIOBNK1,
  501. .end = IRQ_DM355_GPIOBNK1,
  502. .flags = IORESOURCE_IRQ,
  503. },
  504. {
  505. .start = IRQ_DM355_GPIOBNK2,
  506. .end = IRQ_DM355_GPIOBNK2,
  507. .flags = IORESOURCE_IRQ,
  508. },
  509. {
  510. .start = IRQ_DM355_GPIOBNK3,
  511. .end = IRQ_DM355_GPIOBNK3,
  512. .flags = IORESOURCE_IRQ,
  513. },
  514. {
  515. .start = IRQ_DM355_GPIOBNK4,
  516. .end = IRQ_DM355_GPIOBNK4,
  517. .flags = IORESOURCE_IRQ,
  518. },
  519. {
  520. .start = IRQ_DM355_GPIOBNK5,
  521. .end = IRQ_DM355_GPIOBNK5,
  522. .flags = IORESOURCE_IRQ,
  523. },
  524. {
  525. .start = IRQ_DM355_GPIOBNK6,
  526. .end = IRQ_DM355_GPIOBNK6,
  527. .flags = IORESOURCE_IRQ,
  528. },
  529. };
  530. static struct davinci_gpio_platform_data dm355_gpio_platform_data = {
  531. .ngpio = 104,
  532. };
  533. int __init dm355_gpio_register(void)
  534. {
  535. return davinci_gpio_register(dm355_gpio_resources,
  536. ARRAY_SIZE(dm355_gpio_resources),
  537. &dm355_gpio_platform_data);
  538. }
  539. /*----------------------------------------------------------------------*/
  540. static struct map_desc dm355_io_desc[] = {
  541. {
  542. .virtual = IO_VIRT,
  543. .pfn = __phys_to_pfn(IO_PHYS),
  544. .length = IO_SIZE,
  545. .type = MT_DEVICE
  546. },
  547. };
  548. /* Contents of JTAG ID register used to identify exact cpu type */
  549. static struct davinci_id dm355_ids[] = {
  550. {
  551. .variant = 0x0,
  552. .part_no = 0xb73b,
  553. .manufacturer = 0x00f,
  554. .cpu_id = DAVINCI_CPU_ID_DM355,
  555. .name = "dm355",
  556. },
  557. };
  558. /*
  559. * T0_BOT: Timer 0, bottom: clockevent source for hrtimers
  560. * T0_TOP: Timer 0, top : clocksource for generic timekeeping
  561. * T1_BOT: Timer 1, bottom: (used by DSP in TI DSPLink code)
  562. * T1_TOP: Timer 1, top : <unused>
  563. */
  564. static struct davinci_timer_info dm355_timer_info = {
  565. .timers = davinci_timer_instance,
  566. .clockevent_id = T0_BOT,
  567. .clocksource_id = T0_TOP,
  568. };
  569. static struct plat_serial8250_port dm355_serial0_platform_data[] = {
  570. {
  571. .mapbase = DAVINCI_UART0_BASE,
  572. .irq = IRQ_UARTINT0,
  573. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  574. UPF_IOREMAP,
  575. .iotype = UPIO_MEM,
  576. .regshift = 2,
  577. },
  578. {
  579. .flags = 0,
  580. }
  581. };
  582. static struct plat_serial8250_port dm355_serial1_platform_data[] = {
  583. {
  584. .mapbase = DAVINCI_UART1_BASE,
  585. .irq = IRQ_UARTINT1,
  586. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  587. UPF_IOREMAP,
  588. .iotype = UPIO_MEM,
  589. .regshift = 2,
  590. },
  591. {
  592. .flags = 0,
  593. }
  594. };
  595. static struct plat_serial8250_port dm355_serial2_platform_data[] = {
  596. {
  597. .mapbase = DM355_UART2_BASE,
  598. .irq = IRQ_DM355_UARTINT2,
  599. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  600. UPF_IOREMAP,
  601. .iotype = UPIO_MEM,
  602. .regshift = 2,
  603. },
  604. {
  605. .flags = 0,
  606. }
  607. };
  608. struct platform_device dm355_serial_device[] = {
  609. {
  610. .name = "serial8250",
  611. .id = PLAT8250_DEV_PLATFORM,
  612. .dev = {
  613. .platform_data = dm355_serial0_platform_data,
  614. }
  615. },
  616. {
  617. .name = "serial8250",
  618. .id = PLAT8250_DEV_PLATFORM1,
  619. .dev = {
  620. .platform_data = dm355_serial1_platform_data,
  621. }
  622. },
  623. {
  624. .name = "serial8250",
  625. .id = PLAT8250_DEV_PLATFORM2,
  626. .dev = {
  627. .platform_data = dm355_serial2_platform_data,
  628. }
  629. },
  630. {
  631. }
  632. };
  633. static const struct davinci_soc_info davinci_soc_info_dm355 = {
  634. .io_desc = dm355_io_desc,
  635. .io_desc_num = ARRAY_SIZE(dm355_io_desc),
  636. .jtag_id_reg = 0x01c40028,
  637. .ids = dm355_ids,
  638. .ids_num = ARRAY_SIZE(dm355_ids),
  639. .pinmux_base = DAVINCI_SYSTEM_MODULE_BASE,
  640. .pinmux_pins = dm355_pins,
  641. .pinmux_pins_num = ARRAY_SIZE(dm355_pins),
  642. .intc_base = DAVINCI_ARM_INTC_BASE,
  643. .intc_type = DAVINCI_INTC_TYPE_AINTC,
  644. .intc_irq_prios = dm355_default_priorities,
  645. .intc_irq_num = DAVINCI_N_AINTC_IRQ,
  646. .timer_info = &dm355_timer_info,
  647. .sram_dma = 0x00010000,
  648. .sram_len = SZ_32K,
  649. };
  650. void __init dm355_init_asp1(u32 evt_enable)
  651. {
  652. /* we don't use ASP1 IRQs, or we'd need to mux them ... */
  653. if (evt_enable & ASP1_TX_EVT_EN)
  654. davinci_cfg_reg(DM355_EVT8_ASP1_TX);
  655. if (evt_enable & ASP1_RX_EVT_EN)
  656. davinci_cfg_reg(DM355_EVT9_ASP1_RX);
  657. platform_device_register(&dm355_asp1_device);
  658. }
  659. void __init dm355_init(void)
  660. {
  661. davinci_common_init(&davinci_soc_info_dm355);
  662. davinci_map_sysmod();
  663. }
  664. void __init dm355_init_time(void)
  665. {
  666. void __iomem *pll1, *psc;
  667. struct clk *clk;
  668. clk_register_fixed_rate(NULL, "ref_clk", NULL, 0, DM355_REF_FREQ);
  669. pll1 = ioremap(DAVINCI_PLL1_BASE, SZ_1K);
  670. dm355_pll1_init(NULL, pll1, NULL);
  671. psc = ioremap(DAVINCI_PWR_SLEEP_CNTRL_BASE, SZ_4K);
  672. dm355_psc_init(NULL, psc);
  673. clk = clk_get(NULL, "timer0");
  674. davinci_timer_init(clk);
  675. }
  676. static struct resource dm355_pll2_resources[] = {
  677. {
  678. .start = DAVINCI_PLL2_BASE,
  679. .end = DAVINCI_PLL2_BASE + SZ_1K - 1,
  680. .flags = IORESOURCE_MEM,
  681. },
  682. };
  683. static struct platform_device dm355_pll2_device = {
  684. .name = "dm355-pll2",
  685. .id = -1,
  686. .resource = dm355_pll2_resources,
  687. .num_resources = ARRAY_SIZE(dm355_pll2_resources),
  688. };
  689. void __init dm355_register_clocks(void)
  690. {
  691. /* PLL1 and PSC are registered in dm355_init_time() */
  692. platform_device_register(&dm355_pll2_device);
  693. }
  694. int __init dm355_init_video(struct vpfe_config *vpfe_cfg,
  695. struct vpbe_config *vpbe_cfg)
  696. {
  697. if (vpfe_cfg || vpbe_cfg)
  698. platform_device_register(&dm355_vpss_device);
  699. if (vpfe_cfg) {
  700. vpfe_capture_dev.dev.platform_data = vpfe_cfg;
  701. platform_device_register(&dm355_ccdc_dev);
  702. platform_device_register(&vpfe_capture_dev);
  703. }
  704. if (vpbe_cfg) {
  705. dm355_vpbe_dev.dev.platform_data = vpbe_cfg;
  706. platform_device_register(&dm355_osd_dev);
  707. platform_device_register(&dm355_venc_dev);
  708. platform_device_register(&dm355_vpbe_dev);
  709. platform_device_register(&dm355_vpbe_display);
  710. }
  711. return 0;
  712. }
  713. static int __init dm355_init_devices(void)
  714. {
  715. struct platform_device *edma_pdev;
  716. int ret = 0;
  717. if (!cpu_is_davinci_dm355())
  718. return 0;
  719. davinci_cfg_reg(DM355_INT_EDMA_CC);
  720. edma_pdev = platform_device_register_full(&dm355_edma_device);
  721. if (IS_ERR(edma_pdev)) {
  722. pr_warn("%s: Failed to register eDMA\n", __func__);
  723. return PTR_ERR(edma_pdev);
  724. }
  725. ret = davinci_init_wdt();
  726. if (ret)
  727. pr_warn("%s: watchdog init failed: %d\n", __func__, ret);
  728. return ret;
  729. }
  730. postcore_initcall(dm355_init_devices);