dm355.c 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  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/init.h>
  12. #include <linux/clk.h>
  13. #include <linux/serial_8250.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/dma-mapping.h>
  16. #include <linux/dmaengine.h>
  17. #include <linux/spi/spi.h>
  18. #include <linux/platform_data/edma.h>
  19. #include <linux/platform_data/gpio-davinci.h>
  20. #include <linux/platform_data/spi-davinci.h>
  21. #include <asm/mach/map.h>
  22. #include <mach/cputype.h>
  23. #include "psc.h"
  24. #include <mach/mux.h>
  25. #include <mach/irqs.h>
  26. #include <mach/time.h>
  27. #include <mach/serial.h>
  28. #include <mach/common.h>
  29. #include "davinci.h"
  30. #include "clock.h"
  31. #include "mux.h"
  32. #include "asp.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 struct pll_data pll1_data = {
  41. .num = 1,
  42. .phys_base = DAVINCI_PLL1_BASE,
  43. .flags = PLL_HAS_PREDIV | PLL_HAS_POSTDIV,
  44. };
  45. static struct pll_data pll2_data = {
  46. .num = 2,
  47. .phys_base = DAVINCI_PLL2_BASE,
  48. .flags = PLL_HAS_PREDIV,
  49. };
  50. static struct clk ref_clk = {
  51. .name = "ref_clk",
  52. /* FIXME -- crystal rate is board-specific */
  53. .rate = DM355_REF_FREQ,
  54. };
  55. static struct clk pll1_clk = {
  56. .name = "pll1",
  57. .parent = &ref_clk,
  58. .flags = CLK_PLL,
  59. .pll_data = &pll1_data,
  60. };
  61. static struct clk pll1_aux_clk = {
  62. .name = "pll1_aux_clk",
  63. .parent = &pll1_clk,
  64. .flags = CLK_PLL | PRE_PLL,
  65. };
  66. static struct clk pll1_sysclk1 = {
  67. .name = "pll1_sysclk1",
  68. .parent = &pll1_clk,
  69. .flags = CLK_PLL,
  70. .div_reg = PLLDIV1,
  71. };
  72. static struct clk pll1_sysclk2 = {
  73. .name = "pll1_sysclk2",
  74. .parent = &pll1_clk,
  75. .flags = CLK_PLL,
  76. .div_reg = PLLDIV2,
  77. };
  78. static struct clk pll1_sysclk3 = {
  79. .name = "pll1_sysclk3",
  80. .parent = &pll1_clk,
  81. .flags = CLK_PLL,
  82. .div_reg = PLLDIV3,
  83. };
  84. static struct clk pll1_sysclk4 = {
  85. .name = "pll1_sysclk4",
  86. .parent = &pll1_clk,
  87. .flags = CLK_PLL,
  88. .div_reg = PLLDIV4,
  89. };
  90. static struct clk pll1_sysclkbp = {
  91. .name = "pll1_sysclkbp",
  92. .parent = &pll1_clk,
  93. .flags = CLK_PLL | PRE_PLL,
  94. .div_reg = BPDIV
  95. };
  96. static struct clk vpss_dac_clk = {
  97. .name = "vpss_dac",
  98. .parent = &pll1_sysclk3,
  99. .lpsc = DM355_LPSC_VPSS_DAC,
  100. };
  101. static struct clk vpss_master_clk = {
  102. .name = "vpss_master",
  103. .parent = &pll1_sysclk4,
  104. .lpsc = DAVINCI_LPSC_VPSSMSTR,
  105. .flags = CLK_PSC,
  106. };
  107. static struct clk vpss_slave_clk = {
  108. .name = "vpss_slave",
  109. .parent = &pll1_sysclk4,
  110. .lpsc = DAVINCI_LPSC_VPSSSLV,
  111. };
  112. static struct clk clkout1_clk = {
  113. .name = "clkout1",
  114. .parent = &pll1_aux_clk,
  115. /* NOTE: clkout1 can be externally gated by muxing GPIO-18 */
  116. };
  117. static struct clk clkout2_clk = {
  118. .name = "clkout2",
  119. .parent = &pll1_sysclkbp,
  120. };
  121. static struct clk pll2_clk = {
  122. .name = "pll2",
  123. .parent = &ref_clk,
  124. .flags = CLK_PLL,
  125. .pll_data = &pll2_data,
  126. };
  127. static struct clk pll2_sysclk1 = {
  128. .name = "pll2_sysclk1",
  129. .parent = &pll2_clk,
  130. .flags = CLK_PLL,
  131. .div_reg = PLLDIV1,
  132. };
  133. static struct clk pll2_sysclkbp = {
  134. .name = "pll2_sysclkbp",
  135. .parent = &pll2_clk,
  136. .flags = CLK_PLL | PRE_PLL,
  137. .div_reg = BPDIV
  138. };
  139. static struct clk clkout3_clk = {
  140. .name = "clkout3",
  141. .parent = &pll2_sysclkbp,
  142. /* NOTE: clkout3 can be externally gated by muxing GPIO-16 */
  143. };
  144. static struct clk arm_clk = {
  145. .name = "arm_clk",
  146. .parent = &pll1_sysclk1,
  147. .lpsc = DAVINCI_LPSC_ARM,
  148. .flags = ALWAYS_ENABLED,
  149. };
  150. /*
  151. * NOT LISTED below, and not touched by Linux
  152. * - in SyncReset state by default
  153. * .lpsc = DAVINCI_LPSC_TPCC,
  154. * .lpsc = DAVINCI_LPSC_TPTC0,
  155. * .lpsc = DAVINCI_LPSC_TPTC1,
  156. * .lpsc = DAVINCI_LPSC_DDR_EMIF, .parent = &sysclk2_clk,
  157. * .lpsc = DAVINCI_LPSC_MEMSTICK,
  158. * - in Enabled state by default
  159. * .lpsc = DAVINCI_LPSC_SYSTEM_SUBSYS,
  160. * .lpsc = DAVINCI_LPSC_SCR2, // "bus"
  161. * .lpsc = DAVINCI_LPSC_SCR3, // "bus"
  162. * .lpsc = DAVINCI_LPSC_SCR4, // "bus"
  163. * .lpsc = DAVINCI_LPSC_CROSSBAR, // "emulation"
  164. * .lpsc = DAVINCI_LPSC_CFG27, // "test"
  165. * .lpsc = DAVINCI_LPSC_CFG3, // "test"
  166. * .lpsc = DAVINCI_LPSC_CFG5, // "test"
  167. */
  168. static struct clk mjcp_clk = {
  169. .name = "mjcp",
  170. .parent = &pll1_sysclk1,
  171. .lpsc = DAVINCI_LPSC_IMCOP,
  172. };
  173. static struct clk uart0_clk = {
  174. .name = "uart0",
  175. .parent = &pll1_aux_clk,
  176. .lpsc = DAVINCI_LPSC_UART0,
  177. };
  178. static struct clk uart1_clk = {
  179. .name = "uart1",
  180. .parent = &pll1_aux_clk,
  181. .lpsc = DAVINCI_LPSC_UART1,
  182. };
  183. static struct clk uart2_clk = {
  184. .name = "uart2",
  185. .parent = &pll1_sysclk2,
  186. .lpsc = DAVINCI_LPSC_UART2,
  187. };
  188. static struct clk i2c_clk = {
  189. .name = "i2c",
  190. .parent = &pll1_aux_clk,
  191. .lpsc = DAVINCI_LPSC_I2C,
  192. };
  193. static struct clk asp0_clk = {
  194. .name = "asp0",
  195. .parent = &pll1_sysclk2,
  196. .lpsc = DAVINCI_LPSC_McBSP,
  197. };
  198. static struct clk asp1_clk = {
  199. .name = "asp1",
  200. .parent = &pll1_sysclk2,
  201. .lpsc = DM355_LPSC_McBSP1,
  202. };
  203. static struct clk mmcsd0_clk = {
  204. .name = "mmcsd0",
  205. .parent = &pll1_sysclk2,
  206. .lpsc = DAVINCI_LPSC_MMC_SD,
  207. };
  208. static struct clk mmcsd1_clk = {
  209. .name = "mmcsd1",
  210. .parent = &pll1_sysclk2,
  211. .lpsc = DM355_LPSC_MMC_SD1,
  212. };
  213. static struct clk spi0_clk = {
  214. .name = "spi0",
  215. .parent = &pll1_sysclk2,
  216. .lpsc = DAVINCI_LPSC_SPI,
  217. };
  218. static struct clk spi1_clk = {
  219. .name = "spi1",
  220. .parent = &pll1_sysclk2,
  221. .lpsc = DM355_LPSC_SPI1,
  222. };
  223. static struct clk spi2_clk = {
  224. .name = "spi2",
  225. .parent = &pll1_sysclk2,
  226. .lpsc = DM355_LPSC_SPI2,
  227. };
  228. static struct clk gpio_clk = {
  229. .name = "gpio",
  230. .parent = &pll1_sysclk2,
  231. .lpsc = DAVINCI_LPSC_GPIO,
  232. };
  233. static struct clk aemif_clk = {
  234. .name = "aemif",
  235. .parent = &pll1_sysclk2,
  236. .lpsc = DAVINCI_LPSC_AEMIF,
  237. };
  238. static struct clk pwm0_clk = {
  239. .name = "pwm0",
  240. .parent = &pll1_aux_clk,
  241. .lpsc = DAVINCI_LPSC_PWM0,
  242. };
  243. static struct clk pwm1_clk = {
  244. .name = "pwm1",
  245. .parent = &pll1_aux_clk,
  246. .lpsc = DAVINCI_LPSC_PWM1,
  247. };
  248. static struct clk pwm2_clk = {
  249. .name = "pwm2",
  250. .parent = &pll1_aux_clk,
  251. .lpsc = DAVINCI_LPSC_PWM2,
  252. };
  253. static struct clk pwm3_clk = {
  254. .name = "pwm3",
  255. .parent = &pll1_aux_clk,
  256. .lpsc = DM355_LPSC_PWM3,
  257. };
  258. static struct clk timer0_clk = {
  259. .name = "timer0",
  260. .parent = &pll1_aux_clk,
  261. .lpsc = DAVINCI_LPSC_TIMER0,
  262. };
  263. static struct clk timer1_clk = {
  264. .name = "timer1",
  265. .parent = &pll1_aux_clk,
  266. .lpsc = DAVINCI_LPSC_TIMER1,
  267. };
  268. static struct clk timer2_clk = {
  269. .name = "timer2",
  270. .parent = &pll1_aux_clk,
  271. .lpsc = DAVINCI_LPSC_TIMER2,
  272. .usecount = 1, /* REVISIT: why can't this be disabled? */
  273. };
  274. static struct clk timer3_clk = {
  275. .name = "timer3",
  276. .parent = &pll1_aux_clk,
  277. .lpsc = DM355_LPSC_TIMER3,
  278. };
  279. static struct clk rto_clk = {
  280. .name = "rto",
  281. .parent = &pll1_aux_clk,
  282. .lpsc = DM355_LPSC_RTO,
  283. };
  284. static struct clk usb_clk = {
  285. .name = "usb",
  286. .parent = &pll1_sysclk2,
  287. .lpsc = DAVINCI_LPSC_USB,
  288. };
  289. static struct clk_lookup dm355_clks[] = {
  290. CLK(NULL, "ref", &ref_clk),
  291. CLK(NULL, "pll1", &pll1_clk),
  292. CLK(NULL, "pll1_sysclk1", &pll1_sysclk1),
  293. CLK(NULL, "pll1_sysclk2", &pll1_sysclk2),
  294. CLK(NULL, "pll1_sysclk3", &pll1_sysclk3),
  295. CLK(NULL, "pll1_sysclk4", &pll1_sysclk4),
  296. CLK(NULL, "pll1_aux", &pll1_aux_clk),
  297. CLK(NULL, "pll1_sysclkbp", &pll1_sysclkbp),
  298. CLK(NULL, "vpss_dac", &vpss_dac_clk),
  299. CLK("vpss", "master", &vpss_master_clk),
  300. CLK("vpss", "slave", &vpss_slave_clk),
  301. CLK(NULL, "clkout1", &clkout1_clk),
  302. CLK(NULL, "clkout2", &clkout2_clk),
  303. CLK(NULL, "pll2", &pll2_clk),
  304. CLK(NULL, "pll2_sysclk1", &pll2_sysclk1),
  305. CLK(NULL, "pll2_sysclkbp", &pll2_sysclkbp),
  306. CLK(NULL, "clkout3", &clkout3_clk),
  307. CLK(NULL, "arm", &arm_clk),
  308. CLK(NULL, "mjcp", &mjcp_clk),
  309. CLK("serial8250.0", NULL, &uart0_clk),
  310. CLK("serial8250.1", NULL, &uart1_clk),
  311. CLK("serial8250.2", NULL, &uart2_clk),
  312. CLK("i2c_davinci.1", NULL, &i2c_clk),
  313. CLK("davinci-mcbsp.0", NULL, &asp0_clk),
  314. CLK("davinci-mcbsp.1", NULL, &asp1_clk),
  315. CLK("dm6441-mmc.0", NULL, &mmcsd0_clk),
  316. CLK("dm6441-mmc.1", NULL, &mmcsd1_clk),
  317. CLK("spi_davinci.0", NULL, &spi0_clk),
  318. CLK("spi_davinci.1", NULL, &spi1_clk),
  319. CLK("spi_davinci.2", NULL, &spi2_clk),
  320. CLK(NULL, "gpio", &gpio_clk),
  321. CLK(NULL, "aemif", &aemif_clk),
  322. CLK(NULL, "pwm0", &pwm0_clk),
  323. CLK(NULL, "pwm1", &pwm1_clk),
  324. CLK(NULL, "pwm2", &pwm2_clk),
  325. CLK(NULL, "pwm3", &pwm3_clk),
  326. CLK(NULL, "timer0", &timer0_clk),
  327. CLK(NULL, "timer1", &timer1_clk),
  328. CLK("davinci-wdt", NULL, &timer2_clk),
  329. CLK(NULL, "timer3", &timer3_clk),
  330. CLK(NULL, "rto", &rto_clk),
  331. CLK(NULL, "usb", &usb_clk),
  332. CLK(NULL, NULL, NULL),
  333. };
  334. /*----------------------------------------------------------------------*/
  335. static u64 dm355_spi0_dma_mask = DMA_BIT_MASK(32);
  336. static struct resource dm355_spi0_resources[] = {
  337. {
  338. .start = 0x01c66000,
  339. .end = 0x01c667ff,
  340. .flags = IORESOURCE_MEM,
  341. },
  342. {
  343. .start = IRQ_DM355_SPINT0_0,
  344. .flags = IORESOURCE_IRQ,
  345. },
  346. {
  347. .start = 17,
  348. .flags = IORESOURCE_DMA,
  349. },
  350. {
  351. .start = 16,
  352. .flags = IORESOURCE_DMA,
  353. },
  354. };
  355. static struct davinci_spi_platform_data dm355_spi0_pdata = {
  356. .version = SPI_VERSION_1,
  357. .num_chipselect = 2,
  358. .cshold_bug = true,
  359. .dma_event_q = EVENTQ_1,
  360. .prescaler_limit = 1,
  361. };
  362. static struct platform_device dm355_spi0_device = {
  363. .name = "spi_davinci",
  364. .id = 0,
  365. .dev = {
  366. .dma_mask = &dm355_spi0_dma_mask,
  367. .coherent_dma_mask = DMA_BIT_MASK(32),
  368. .platform_data = &dm355_spi0_pdata,
  369. },
  370. .num_resources = ARRAY_SIZE(dm355_spi0_resources),
  371. .resource = dm355_spi0_resources,
  372. };
  373. void __init dm355_init_spi0(unsigned chipselect_mask,
  374. const struct spi_board_info *info, unsigned len)
  375. {
  376. /* for now, assume we need MISO */
  377. davinci_cfg_reg(DM355_SPI0_SDI);
  378. /* not all slaves will be wired up */
  379. if (chipselect_mask & BIT(0))
  380. davinci_cfg_reg(DM355_SPI0_SDENA0);
  381. if (chipselect_mask & BIT(1))
  382. davinci_cfg_reg(DM355_SPI0_SDENA1);
  383. spi_register_board_info(info, len);
  384. platform_device_register(&dm355_spi0_device);
  385. }
  386. /*----------------------------------------------------------------------*/
  387. #define INTMUX 0x18
  388. #define EVTMUX 0x1c
  389. /*
  390. * Device specific mux setup
  391. *
  392. * soc description mux mode mode mux dbg
  393. * reg offset mask mode
  394. */
  395. static const struct mux_config dm355_pins[] = {
  396. #ifdef CONFIG_DAVINCI_MUX
  397. MUX_CFG(DM355, MMCSD0, 4, 2, 1, 0, false)
  398. MUX_CFG(DM355, SD1_CLK, 3, 6, 1, 1, false)
  399. MUX_CFG(DM355, SD1_CMD, 3, 7, 1, 1, false)
  400. MUX_CFG(DM355, SD1_DATA3, 3, 8, 3, 1, false)
  401. MUX_CFG(DM355, SD1_DATA2, 3, 10, 3, 1, false)
  402. MUX_CFG(DM355, SD1_DATA1, 3, 12, 3, 1, false)
  403. MUX_CFG(DM355, SD1_DATA0, 3, 14, 3, 1, false)
  404. MUX_CFG(DM355, I2C_SDA, 3, 19, 1, 1, false)
  405. MUX_CFG(DM355, I2C_SCL, 3, 20, 1, 1, false)
  406. MUX_CFG(DM355, MCBSP0_BDX, 3, 0, 1, 1, false)
  407. MUX_CFG(DM355, MCBSP0_X, 3, 1, 1, 1, false)
  408. MUX_CFG(DM355, MCBSP0_BFSX, 3, 2, 1, 1, false)
  409. MUX_CFG(DM355, MCBSP0_BDR, 3, 3, 1, 1, false)
  410. MUX_CFG(DM355, MCBSP0_R, 3, 4, 1, 1, false)
  411. MUX_CFG(DM355, MCBSP0_BFSR, 3, 5, 1, 1, false)
  412. MUX_CFG(DM355, SPI0_SDI, 4, 1, 1, 0, false)
  413. MUX_CFG(DM355, SPI0_SDENA0, 4, 0, 1, 0, false)
  414. MUX_CFG(DM355, SPI0_SDENA1, 3, 28, 1, 1, false)
  415. INT_CFG(DM355, INT_EDMA_CC, 2, 1, 1, false)
  416. INT_CFG(DM355, INT_EDMA_TC0_ERR, 3, 1, 1, false)
  417. INT_CFG(DM355, INT_EDMA_TC1_ERR, 4, 1, 1, false)
  418. EVT_CFG(DM355, EVT8_ASP1_TX, 0, 1, 0, false)
  419. EVT_CFG(DM355, EVT9_ASP1_RX, 1, 1, 0, false)
  420. EVT_CFG(DM355, EVT26_MMC0_RX, 2, 1, 0, false)
  421. MUX_CFG(DM355, VOUT_FIELD, 1, 18, 3, 1, false)
  422. MUX_CFG(DM355, VOUT_FIELD_G70, 1, 18, 3, 0, false)
  423. MUX_CFG(DM355, VOUT_HVSYNC, 1, 16, 1, 0, false)
  424. MUX_CFG(DM355, VOUT_COUTL_EN, 1, 0, 0xff, 0x55, false)
  425. MUX_CFG(DM355, VOUT_COUTH_EN, 1, 8, 0xff, 0x55, false)
  426. MUX_CFG(DM355, VIN_PCLK, 0, 14, 1, 1, false)
  427. MUX_CFG(DM355, VIN_CAM_WEN, 0, 13, 1, 1, false)
  428. MUX_CFG(DM355, VIN_CAM_VD, 0, 12, 1, 1, false)
  429. MUX_CFG(DM355, VIN_CAM_HD, 0, 11, 1, 1, false)
  430. MUX_CFG(DM355, VIN_YIN_EN, 0, 10, 1, 1, false)
  431. MUX_CFG(DM355, VIN_CINL_EN, 0, 0, 0xff, 0x55, false)
  432. MUX_CFG(DM355, VIN_CINH_EN, 0, 8, 3, 3, false)
  433. #endif
  434. };
  435. static u8 dm355_default_priorities[DAVINCI_N_AINTC_IRQ] = {
  436. [IRQ_DM355_CCDC_VDINT0] = 2,
  437. [IRQ_DM355_CCDC_VDINT1] = 6,
  438. [IRQ_DM355_CCDC_VDINT2] = 6,
  439. [IRQ_DM355_IPIPE_HST] = 6,
  440. [IRQ_DM355_H3AINT] = 6,
  441. [IRQ_DM355_IPIPE_SDR] = 6,
  442. [IRQ_DM355_IPIPEIFINT] = 6,
  443. [IRQ_DM355_OSDINT] = 7,
  444. [IRQ_DM355_VENCINT] = 6,
  445. [IRQ_ASQINT] = 6,
  446. [IRQ_IMXINT] = 6,
  447. [IRQ_USBINT] = 4,
  448. [IRQ_DM355_RTOINT] = 4,
  449. [IRQ_DM355_UARTINT2] = 7,
  450. [IRQ_DM355_TINT6] = 7,
  451. [IRQ_CCINT0] = 5, /* dma */
  452. [IRQ_CCERRINT] = 5, /* dma */
  453. [IRQ_TCERRINT0] = 5, /* dma */
  454. [IRQ_TCERRINT] = 5, /* dma */
  455. [IRQ_DM355_SPINT2_1] = 7,
  456. [IRQ_DM355_TINT7] = 4,
  457. [IRQ_DM355_SDIOINT0] = 7,
  458. [IRQ_MBXINT] = 7,
  459. [IRQ_MBRINT] = 7,
  460. [IRQ_MMCINT] = 7,
  461. [IRQ_DM355_MMCINT1] = 7,
  462. [IRQ_DM355_PWMINT3] = 7,
  463. [IRQ_DDRINT] = 7,
  464. [IRQ_AEMIFINT] = 7,
  465. [IRQ_DM355_SDIOINT1] = 4,
  466. [IRQ_TINT0_TINT12] = 2, /* clockevent */
  467. [IRQ_TINT0_TINT34] = 2, /* clocksource */
  468. [IRQ_TINT1_TINT12] = 7, /* DSP timer */
  469. [IRQ_TINT1_TINT34] = 7, /* system tick */
  470. [IRQ_PWMINT0] = 7,
  471. [IRQ_PWMINT1] = 7,
  472. [IRQ_PWMINT2] = 7,
  473. [IRQ_I2C] = 3,
  474. [IRQ_UARTINT0] = 3,
  475. [IRQ_UARTINT1] = 3,
  476. [IRQ_DM355_SPINT0_0] = 3,
  477. [IRQ_DM355_SPINT0_1] = 3,
  478. [IRQ_DM355_GPIO0] = 3,
  479. [IRQ_DM355_GPIO1] = 7,
  480. [IRQ_DM355_GPIO2] = 4,
  481. [IRQ_DM355_GPIO3] = 4,
  482. [IRQ_DM355_GPIO4] = 7,
  483. [IRQ_DM355_GPIO5] = 7,
  484. [IRQ_DM355_GPIO6] = 7,
  485. [IRQ_DM355_GPIO7] = 7,
  486. [IRQ_DM355_GPIO8] = 7,
  487. [IRQ_DM355_GPIO9] = 7,
  488. [IRQ_DM355_GPIOBNK0] = 7,
  489. [IRQ_DM355_GPIOBNK1] = 7,
  490. [IRQ_DM355_GPIOBNK2] = 7,
  491. [IRQ_DM355_GPIOBNK3] = 7,
  492. [IRQ_DM355_GPIOBNK4] = 7,
  493. [IRQ_DM355_GPIOBNK5] = 7,
  494. [IRQ_DM355_GPIOBNK6] = 7,
  495. [IRQ_COMMTX] = 7,
  496. [IRQ_COMMRX] = 7,
  497. [IRQ_EMUINT] = 7,
  498. };
  499. /*----------------------------------------------------------------------*/
  500. static s8 queue_priority_mapping[][2] = {
  501. /* {event queue no, Priority} */
  502. {0, 3},
  503. {1, 7},
  504. {-1, -1},
  505. };
  506. static const struct dma_slave_map dm355_edma_map[] = {
  507. { "davinci-mcbsp.0", "tx", EDMA_FILTER_PARAM(0, 2) },
  508. { "davinci-mcbsp.0", "rx", EDMA_FILTER_PARAM(0, 3) },
  509. { "davinci-mcbsp.1", "tx", EDMA_FILTER_PARAM(0, 8) },
  510. { "davinci-mcbsp.1", "rx", EDMA_FILTER_PARAM(0, 9) },
  511. { "spi_davinci.2", "tx", EDMA_FILTER_PARAM(0, 10) },
  512. { "spi_davinci.2", "rx", EDMA_FILTER_PARAM(0, 11) },
  513. { "spi_davinci.1", "tx", EDMA_FILTER_PARAM(0, 14) },
  514. { "spi_davinci.1", "rx", EDMA_FILTER_PARAM(0, 15) },
  515. { "spi_davinci.0", "tx", EDMA_FILTER_PARAM(0, 16) },
  516. { "spi_davinci.0", "rx", EDMA_FILTER_PARAM(0, 17) },
  517. { "dm6441-mmc.0", "rx", EDMA_FILTER_PARAM(0, 26) },
  518. { "dm6441-mmc.0", "tx", EDMA_FILTER_PARAM(0, 27) },
  519. { "dm6441-mmc.1", "rx", EDMA_FILTER_PARAM(0, 30) },
  520. { "dm6441-mmc.1", "tx", EDMA_FILTER_PARAM(0, 31) },
  521. };
  522. static struct edma_soc_info dm355_edma_pdata = {
  523. .queue_priority_mapping = queue_priority_mapping,
  524. .default_queue = EVENTQ_1,
  525. .slave_map = dm355_edma_map,
  526. .slavecnt = ARRAY_SIZE(dm355_edma_map),
  527. };
  528. static struct resource edma_resources[] = {
  529. {
  530. .name = "edma3_cc",
  531. .start = 0x01c00000,
  532. .end = 0x01c00000 + SZ_64K - 1,
  533. .flags = IORESOURCE_MEM,
  534. },
  535. {
  536. .name = "edma3_tc0",
  537. .start = 0x01c10000,
  538. .end = 0x01c10000 + SZ_1K - 1,
  539. .flags = IORESOURCE_MEM,
  540. },
  541. {
  542. .name = "edma3_tc1",
  543. .start = 0x01c10400,
  544. .end = 0x01c10400 + SZ_1K - 1,
  545. .flags = IORESOURCE_MEM,
  546. },
  547. {
  548. .name = "edma3_ccint",
  549. .start = IRQ_CCINT0,
  550. .flags = IORESOURCE_IRQ,
  551. },
  552. {
  553. .name = "edma3_ccerrint",
  554. .start = IRQ_CCERRINT,
  555. .flags = IORESOURCE_IRQ,
  556. },
  557. /* not using (or muxing) TC*_ERR */
  558. };
  559. static const struct platform_device_info dm355_edma_device __initconst = {
  560. .name = "edma",
  561. .id = 0,
  562. .dma_mask = DMA_BIT_MASK(32),
  563. .res = edma_resources,
  564. .num_res = ARRAY_SIZE(edma_resources),
  565. .data = &dm355_edma_pdata,
  566. .size_data = sizeof(dm355_edma_pdata),
  567. };
  568. static struct resource dm355_asp1_resources[] = {
  569. {
  570. .name = "mpu",
  571. .start = DAVINCI_ASP1_BASE,
  572. .end = DAVINCI_ASP1_BASE + SZ_8K - 1,
  573. .flags = IORESOURCE_MEM,
  574. },
  575. {
  576. .start = DAVINCI_DMA_ASP1_TX,
  577. .end = DAVINCI_DMA_ASP1_TX,
  578. .flags = IORESOURCE_DMA,
  579. },
  580. {
  581. .start = DAVINCI_DMA_ASP1_RX,
  582. .end = DAVINCI_DMA_ASP1_RX,
  583. .flags = IORESOURCE_DMA,
  584. },
  585. };
  586. static struct platform_device dm355_asp1_device = {
  587. .name = "davinci-mcbsp",
  588. .id = 1,
  589. .num_resources = ARRAY_SIZE(dm355_asp1_resources),
  590. .resource = dm355_asp1_resources,
  591. };
  592. static void dm355_ccdc_setup_pinmux(void)
  593. {
  594. davinci_cfg_reg(DM355_VIN_PCLK);
  595. davinci_cfg_reg(DM355_VIN_CAM_WEN);
  596. davinci_cfg_reg(DM355_VIN_CAM_VD);
  597. davinci_cfg_reg(DM355_VIN_CAM_HD);
  598. davinci_cfg_reg(DM355_VIN_YIN_EN);
  599. davinci_cfg_reg(DM355_VIN_CINL_EN);
  600. davinci_cfg_reg(DM355_VIN_CINH_EN);
  601. }
  602. static struct resource dm355_vpss_resources[] = {
  603. {
  604. /* VPSS BL Base address */
  605. .name = "vpss",
  606. .start = 0x01c70800,
  607. .end = 0x01c70800 + 0xff,
  608. .flags = IORESOURCE_MEM,
  609. },
  610. {
  611. /* VPSS CLK Base address */
  612. .name = "vpss",
  613. .start = 0x01c70000,
  614. .end = 0x01c70000 + 0xf,
  615. .flags = IORESOURCE_MEM,
  616. },
  617. };
  618. static struct platform_device dm355_vpss_device = {
  619. .name = "vpss",
  620. .id = -1,
  621. .dev.platform_data = "dm355_vpss",
  622. .num_resources = ARRAY_SIZE(dm355_vpss_resources),
  623. .resource = dm355_vpss_resources,
  624. };
  625. static struct resource vpfe_resources[] = {
  626. {
  627. .start = IRQ_VDINT0,
  628. .end = IRQ_VDINT0,
  629. .flags = IORESOURCE_IRQ,
  630. },
  631. {
  632. .start = IRQ_VDINT1,
  633. .end = IRQ_VDINT1,
  634. .flags = IORESOURCE_IRQ,
  635. },
  636. };
  637. static u64 vpfe_capture_dma_mask = DMA_BIT_MASK(32);
  638. static struct resource dm355_ccdc_resource[] = {
  639. /* CCDC Base address */
  640. {
  641. .flags = IORESOURCE_MEM,
  642. .start = 0x01c70600,
  643. .end = 0x01c70600 + 0x1ff,
  644. },
  645. };
  646. static struct platform_device dm355_ccdc_dev = {
  647. .name = "dm355_ccdc",
  648. .id = -1,
  649. .num_resources = ARRAY_SIZE(dm355_ccdc_resource),
  650. .resource = dm355_ccdc_resource,
  651. .dev = {
  652. .dma_mask = &vpfe_capture_dma_mask,
  653. .coherent_dma_mask = DMA_BIT_MASK(32),
  654. .platform_data = dm355_ccdc_setup_pinmux,
  655. },
  656. };
  657. static struct platform_device vpfe_capture_dev = {
  658. .name = CAPTURE_DRV_NAME,
  659. .id = -1,
  660. .num_resources = ARRAY_SIZE(vpfe_resources),
  661. .resource = vpfe_resources,
  662. .dev = {
  663. .dma_mask = &vpfe_capture_dma_mask,
  664. .coherent_dma_mask = DMA_BIT_MASK(32),
  665. },
  666. };
  667. static struct resource dm355_osd_resources[] = {
  668. {
  669. .start = DM355_OSD_BASE,
  670. .end = DM355_OSD_BASE + 0x17f,
  671. .flags = IORESOURCE_MEM,
  672. },
  673. };
  674. static struct platform_device dm355_osd_dev = {
  675. .name = DM355_VPBE_OSD_SUBDEV_NAME,
  676. .id = -1,
  677. .num_resources = ARRAY_SIZE(dm355_osd_resources),
  678. .resource = dm355_osd_resources,
  679. .dev = {
  680. .dma_mask = &vpfe_capture_dma_mask,
  681. .coherent_dma_mask = DMA_BIT_MASK(32),
  682. },
  683. };
  684. static struct resource dm355_venc_resources[] = {
  685. {
  686. .start = IRQ_VENCINT,
  687. .end = IRQ_VENCINT,
  688. .flags = IORESOURCE_IRQ,
  689. },
  690. /* venc registers io space */
  691. {
  692. .start = DM355_VENC_BASE,
  693. .end = DM355_VENC_BASE + 0x17f,
  694. .flags = IORESOURCE_MEM,
  695. },
  696. /* VDAC config register io space */
  697. {
  698. .start = DAVINCI_SYSTEM_MODULE_BASE + SYSMOD_VDAC_CONFIG,
  699. .end = DAVINCI_SYSTEM_MODULE_BASE + SYSMOD_VDAC_CONFIG + 3,
  700. .flags = IORESOURCE_MEM,
  701. },
  702. };
  703. static struct resource dm355_v4l2_disp_resources[] = {
  704. {
  705. .start = IRQ_VENCINT,
  706. .end = IRQ_VENCINT,
  707. .flags = IORESOURCE_IRQ,
  708. },
  709. /* venc registers io space */
  710. {
  711. .start = DM355_VENC_BASE,
  712. .end = DM355_VENC_BASE + 0x17f,
  713. .flags = IORESOURCE_MEM,
  714. },
  715. };
  716. static int dm355_vpbe_setup_pinmux(u32 if_type, int field)
  717. {
  718. switch (if_type) {
  719. case MEDIA_BUS_FMT_SGRBG8_1X8:
  720. davinci_cfg_reg(DM355_VOUT_FIELD_G70);
  721. break;
  722. case MEDIA_BUS_FMT_YUYV10_1X20:
  723. if (field)
  724. davinci_cfg_reg(DM355_VOUT_FIELD);
  725. else
  726. davinci_cfg_reg(DM355_VOUT_FIELD_G70);
  727. break;
  728. default:
  729. return -EINVAL;
  730. }
  731. davinci_cfg_reg(DM355_VOUT_COUTL_EN);
  732. davinci_cfg_reg(DM355_VOUT_COUTH_EN);
  733. return 0;
  734. }
  735. static int dm355_venc_setup_clock(enum vpbe_enc_timings_type type,
  736. unsigned int pclock)
  737. {
  738. void __iomem *vpss_clk_ctrl_reg;
  739. vpss_clk_ctrl_reg = DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL);
  740. switch (type) {
  741. case VPBE_ENC_STD:
  742. writel(VPSS_DACCLKEN_ENABLE | VPSS_VENCCLKEN_ENABLE,
  743. vpss_clk_ctrl_reg);
  744. break;
  745. case VPBE_ENC_DV_TIMINGS:
  746. if (pclock > 27000000)
  747. /*
  748. * For HD, use external clock source since we cannot
  749. * support HD mode with internal clocks.
  750. */
  751. writel(VPSS_MUXSEL_EXTCLK_ENABLE, vpss_clk_ctrl_reg);
  752. break;
  753. default:
  754. return -EINVAL;
  755. }
  756. return 0;
  757. }
  758. static struct platform_device dm355_vpbe_display = {
  759. .name = "vpbe-v4l2",
  760. .id = -1,
  761. .num_resources = ARRAY_SIZE(dm355_v4l2_disp_resources),
  762. .resource = dm355_v4l2_disp_resources,
  763. .dev = {
  764. .dma_mask = &vpfe_capture_dma_mask,
  765. .coherent_dma_mask = DMA_BIT_MASK(32),
  766. },
  767. };
  768. static struct venc_platform_data dm355_venc_pdata = {
  769. .setup_pinmux = dm355_vpbe_setup_pinmux,
  770. .setup_clock = dm355_venc_setup_clock,
  771. };
  772. static struct platform_device dm355_venc_dev = {
  773. .name = DM355_VPBE_VENC_SUBDEV_NAME,
  774. .id = -1,
  775. .num_resources = ARRAY_SIZE(dm355_venc_resources),
  776. .resource = dm355_venc_resources,
  777. .dev = {
  778. .dma_mask = &vpfe_capture_dma_mask,
  779. .coherent_dma_mask = DMA_BIT_MASK(32),
  780. .platform_data = (void *)&dm355_venc_pdata,
  781. },
  782. };
  783. static struct platform_device dm355_vpbe_dev = {
  784. .name = "vpbe_controller",
  785. .id = -1,
  786. .dev = {
  787. .dma_mask = &vpfe_capture_dma_mask,
  788. .coherent_dma_mask = DMA_BIT_MASK(32),
  789. },
  790. };
  791. static struct resource dm355_gpio_resources[] = {
  792. { /* registers */
  793. .start = DAVINCI_GPIO_BASE,
  794. .end = DAVINCI_GPIO_BASE + SZ_4K - 1,
  795. .flags = IORESOURCE_MEM,
  796. },
  797. { /* interrupt */
  798. .start = IRQ_DM355_GPIOBNK0,
  799. .end = IRQ_DM355_GPIOBNK6,
  800. .flags = IORESOURCE_IRQ,
  801. },
  802. };
  803. static struct davinci_gpio_platform_data dm355_gpio_platform_data = {
  804. .ngpio = 104,
  805. };
  806. int __init dm355_gpio_register(void)
  807. {
  808. return davinci_gpio_register(dm355_gpio_resources,
  809. ARRAY_SIZE(dm355_gpio_resources),
  810. &dm355_gpio_platform_data);
  811. }
  812. /*----------------------------------------------------------------------*/
  813. static struct map_desc dm355_io_desc[] = {
  814. {
  815. .virtual = IO_VIRT,
  816. .pfn = __phys_to_pfn(IO_PHYS),
  817. .length = IO_SIZE,
  818. .type = MT_DEVICE
  819. },
  820. };
  821. /* Contents of JTAG ID register used to identify exact cpu type */
  822. static struct davinci_id dm355_ids[] = {
  823. {
  824. .variant = 0x0,
  825. .part_no = 0xb73b,
  826. .manufacturer = 0x00f,
  827. .cpu_id = DAVINCI_CPU_ID_DM355,
  828. .name = "dm355",
  829. },
  830. };
  831. static u32 dm355_psc_bases[] = { DAVINCI_PWR_SLEEP_CNTRL_BASE };
  832. /*
  833. * T0_BOT: Timer 0, bottom: clockevent source for hrtimers
  834. * T0_TOP: Timer 0, top : clocksource for generic timekeeping
  835. * T1_BOT: Timer 1, bottom: (used by DSP in TI DSPLink code)
  836. * T1_TOP: Timer 1, top : <unused>
  837. */
  838. static struct davinci_timer_info dm355_timer_info = {
  839. .timers = davinci_timer_instance,
  840. .clockevent_id = T0_BOT,
  841. .clocksource_id = T0_TOP,
  842. };
  843. static struct plat_serial8250_port dm355_serial0_platform_data[] = {
  844. {
  845. .mapbase = DAVINCI_UART0_BASE,
  846. .irq = IRQ_UARTINT0,
  847. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  848. UPF_IOREMAP,
  849. .iotype = UPIO_MEM,
  850. .regshift = 2,
  851. },
  852. {
  853. .flags = 0,
  854. }
  855. };
  856. static struct plat_serial8250_port dm355_serial1_platform_data[] = {
  857. {
  858. .mapbase = DAVINCI_UART1_BASE,
  859. .irq = IRQ_UARTINT1,
  860. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  861. UPF_IOREMAP,
  862. .iotype = UPIO_MEM,
  863. .regshift = 2,
  864. },
  865. {
  866. .flags = 0,
  867. }
  868. };
  869. static struct plat_serial8250_port dm355_serial2_platform_data[] = {
  870. {
  871. .mapbase = DM355_UART2_BASE,
  872. .irq = IRQ_DM355_UARTINT2,
  873. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  874. UPF_IOREMAP,
  875. .iotype = UPIO_MEM,
  876. .regshift = 2,
  877. },
  878. {
  879. .flags = 0,
  880. }
  881. };
  882. struct platform_device dm355_serial_device[] = {
  883. {
  884. .name = "serial8250",
  885. .id = PLAT8250_DEV_PLATFORM,
  886. .dev = {
  887. .platform_data = dm355_serial0_platform_data,
  888. }
  889. },
  890. {
  891. .name = "serial8250",
  892. .id = PLAT8250_DEV_PLATFORM1,
  893. .dev = {
  894. .platform_data = dm355_serial1_platform_data,
  895. }
  896. },
  897. {
  898. .name = "serial8250",
  899. .id = PLAT8250_DEV_PLATFORM2,
  900. .dev = {
  901. .platform_data = dm355_serial2_platform_data,
  902. }
  903. },
  904. {
  905. }
  906. };
  907. static struct davinci_soc_info davinci_soc_info_dm355 = {
  908. .io_desc = dm355_io_desc,
  909. .io_desc_num = ARRAY_SIZE(dm355_io_desc),
  910. .jtag_id_reg = 0x01c40028,
  911. .ids = dm355_ids,
  912. .ids_num = ARRAY_SIZE(dm355_ids),
  913. .cpu_clks = dm355_clks,
  914. .psc_bases = dm355_psc_bases,
  915. .psc_bases_num = ARRAY_SIZE(dm355_psc_bases),
  916. .pinmux_base = DAVINCI_SYSTEM_MODULE_BASE,
  917. .pinmux_pins = dm355_pins,
  918. .pinmux_pins_num = ARRAY_SIZE(dm355_pins),
  919. .intc_base = DAVINCI_ARM_INTC_BASE,
  920. .intc_type = DAVINCI_INTC_TYPE_AINTC,
  921. .intc_irq_prios = dm355_default_priorities,
  922. .intc_irq_num = DAVINCI_N_AINTC_IRQ,
  923. .timer_info = &dm355_timer_info,
  924. .sram_dma = 0x00010000,
  925. .sram_len = SZ_32K,
  926. };
  927. void __init dm355_init_asp1(u32 evt_enable)
  928. {
  929. /* we don't use ASP1 IRQs, or we'd need to mux them ... */
  930. if (evt_enable & ASP1_TX_EVT_EN)
  931. davinci_cfg_reg(DM355_EVT8_ASP1_TX);
  932. if (evt_enable & ASP1_RX_EVT_EN)
  933. davinci_cfg_reg(DM355_EVT9_ASP1_RX);
  934. platform_device_register(&dm355_asp1_device);
  935. }
  936. void __init dm355_init(void)
  937. {
  938. davinci_common_init(&davinci_soc_info_dm355);
  939. davinci_map_sysmod();
  940. davinci_clk_init(davinci_soc_info_dm355.cpu_clks);
  941. }
  942. int __init dm355_init_video(struct vpfe_config *vpfe_cfg,
  943. struct vpbe_config *vpbe_cfg)
  944. {
  945. if (vpfe_cfg || vpbe_cfg)
  946. platform_device_register(&dm355_vpss_device);
  947. if (vpfe_cfg) {
  948. vpfe_capture_dev.dev.platform_data = vpfe_cfg;
  949. platform_device_register(&dm355_ccdc_dev);
  950. platform_device_register(&vpfe_capture_dev);
  951. }
  952. if (vpbe_cfg) {
  953. dm355_vpbe_dev.dev.platform_data = vpbe_cfg;
  954. platform_device_register(&dm355_osd_dev);
  955. platform_device_register(&dm355_venc_dev);
  956. platform_device_register(&dm355_vpbe_dev);
  957. platform_device_register(&dm355_vpbe_display);
  958. }
  959. return 0;
  960. }
  961. static int __init dm355_init_devices(void)
  962. {
  963. struct platform_device *edma_pdev;
  964. int ret = 0;
  965. if (!cpu_is_davinci_dm355())
  966. return 0;
  967. davinci_cfg_reg(DM355_INT_EDMA_CC);
  968. edma_pdev = platform_device_register_full(&dm355_edma_device);
  969. if (IS_ERR(edma_pdev)) {
  970. pr_warn("%s: Failed to register eDMA\n", __func__);
  971. return PTR_ERR(edma_pdev);
  972. }
  973. ret = davinci_init_wdt();
  974. if (ret)
  975. pr_warn("%s: watchdog init failed: %d\n", __func__, ret);
  976. return ret;
  977. }
  978. postcore_initcall(dm355_init_devices);