dm646x.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979
  1. /*
  2. * TI DaVinci DM644x 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/dma-mapping.h>
  12. #include <linux/dmaengine.h>
  13. #include <linux/init.h>
  14. #include <linux/clk.h>
  15. #include <linux/serial_8250.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/platform_data/edma.h>
  18. #include <linux/platform_data/gpio-davinci.h>
  19. #include <asm/mach/map.h>
  20. #include <mach/cputype.h>
  21. #include <mach/irqs.h>
  22. #include "psc.h"
  23. #include <mach/mux.h>
  24. #include <mach/time.h>
  25. #include <mach/serial.h>
  26. #include <mach/common.h>
  27. #include "davinci.h"
  28. #include "clock.h"
  29. #include "mux.h"
  30. #include "asp.h"
  31. #define DAVINCI_VPIF_BASE (0x01C12000)
  32. #define VDD3P3V_VID_MASK (BIT_MASK(3) | BIT_MASK(2) | BIT_MASK(1) |\
  33. BIT_MASK(0))
  34. #define VSCLKDIS_MASK (BIT_MASK(11) | BIT_MASK(10) | BIT_MASK(9) |\
  35. BIT_MASK(8))
  36. /*
  37. * Device specific clocks
  38. */
  39. #define DM646X_REF_FREQ 27000000
  40. #define DM646X_AUX_FREQ 24000000
  41. #define DM646X_EMAC_BASE 0x01c80000
  42. #define DM646X_EMAC_MDIO_BASE (DM646X_EMAC_BASE + 0x4000)
  43. #define DM646X_EMAC_CNTRL_OFFSET 0x0000
  44. #define DM646X_EMAC_CNTRL_MOD_OFFSET 0x1000
  45. #define DM646X_EMAC_CNTRL_RAM_OFFSET 0x2000
  46. #define DM646X_EMAC_CNTRL_RAM_SIZE 0x2000
  47. static struct pll_data pll1_data = {
  48. .num = 1,
  49. .phys_base = DAVINCI_PLL1_BASE,
  50. };
  51. static struct pll_data pll2_data = {
  52. .num = 2,
  53. .phys_base = DAVINCI_PLL2_BASE,
  54. };
  55. static struct clk ref_clk = {
  56. .name = "ref_clk",
  57. .rate = DM646X_REF_FREQ,
  58. .set_rate = davinci_simple_set_rate,
  59. };
  60. static struct clk aux_clkin = {
  61. .name = "aux_clkin",
  62. .rate = DM646X_AUX_FREQ,
  63. };
  64. static struct clk pll1_clk = {
  65. .name = "pll1",
  66. .parent = &ref_clk,
  67. .pll_data = &pll1_data,
  68. .flags = CLK_PLL,
  69. };
  70. static struct clk pll1_sysclk1 = {
  71. .name = "pll1_sysclk1",
  72. .parent = &pll1_clk,
  73. .flags = CLK_PLL,
  74. .div_reg = PLLDIV1,
  75. };
  76. static struct clk pll1_sysclk2 = {
  77. .name = "pll1_sysclk2",
  78. .parent = &pll1_clk,
  79. .flags = CLK_PLL,
  80. .div_reg = PLLDIV2,
  81. };
  82. static struct clk pll1_sysclk3 = {
  83. .name = "pll1_sysclk3",
  84. .parent = &pll1_clk,
  85. .flags = CLK_PLL,
  86. .div_reg = PLLDIV3,
  87. };
  88. static struct clk pll1_sysclk4 = {
  89. .name = "pll1_sysclk4",
  90. .parent = &pll1_clk,
  91. .flags = CLK_PLL,
  92. .div_reg = PLLDIV4,
  93. };
  94. static struct clk pll1_sysclk5 = {
  95. .name = "pll1_sysclk5",
  96. .parent = &pll1_clk,
  97. .flags = CLK_PLL,
  98. .div_reg = PLLDIV5,
  99. };
  100. static struct clk pll1_sysclk6 = {
  101. .name = "pll1_sysclk6",
  102. .parent = &pll1_clk,
  103. .flags = CLK_PLL,
  104. .div_reg = PLLDIV6,
  105. };
  106. static struct clk pll1_sysclk8 = {
  107. .name = "pll1_sysclk8",
  108. .parent = &pll1_clk,
  109. .flags = CLK_PLL,
  110. .div_reg = PLLDIV8,
  111. };
  112. static struct clk pll1_sysclk9 = {
  113. .name = "pll1_sysclk9",
  114. .parent = &pll1_clk,
  115. .flags = CLK_PLL,
  116. .div_reg = PLLDIV9,
  117. };
  118. static struct clk pll1_sysclkbp = {
  119. .name = "pll1_sysclkbp",
  120. .parent = &pll1_clk,
  121. .flags = CLK_PLL | PRE_PLL,
  122. .div_reg = BPDIV,
  123. };
  124. static struct clk pll1_aux_clk = {
  125. .name = "pll1_aux_clk",
  126. .parent = &pll1_clk,
  127. .flags = CLK_PLL | PRE_PLL,
  128. };
  129. static struct clk pll2_clk = {
  130. .name = "pll2_clk",
  131. .parent = &ref_clk,
  132. .pll_data = &pll2_data,
  133. .flags = CLK_PLL,
  134. };
  135. static struct clk pll2_sysclk1 = {
  136. .name = "pll2_sysclk1",
  137. .parent = &pll2_clk,
  138. .flags = CLK_PLL,
  139. .div_reg = PLLDIV1,
  140. };
  141. static struct clk dsp_clk = {
  142. .name = "dsp",
  143. .parent = &pll1_sysclk1,
  144. .lpsc = DM646X_LPSC_C64X_CPU,
  145. .usecount = 1, /* REVISIT how to disable? */
  146. };
  147. static struct clk arm_clk = {
  148. .name = "arm",
  149. .parent = &pll1_sysclk2,
  150. .lpsc = DM646X_LPSC_ARM,
  151. .flags = ALWAYS_ENABLED,
  152. };
  153. static struct clk edma_cc_clk = {
  154. .name = "edma_cc",
  155. .parent = &pll1_sysclk2,
  156. .lpsc = DM646X_LPSC_TPCC,
  157. .flags = ALWAYS_ENABLED,
  158. };
  159. static struct clk edma_tc0_clk = {
  160. .name = "edma_tc0",
  161. .parent = &pll1_sysclk2,
  162. .lpsc = DM646X_LPSC_TPTC0,
  163. .flags = ALWAYS_ENABLED,
  164. };
  165. static struct clk edma_tc1_clk = {
  166. .name = "edma_tc1",
  167. .parent = &pll1_sysclk2,
  168. .lpsc = DM646X_LPSC_TPTC1,
  169. .flags = ALWAYS_ENABLED,
  170. };
  171. static struct clk edma_tc2_clk = {
  172. .name = "edma_tc2",
  173. .parent = &pll1_sysclk2,
  174. .lpsc = DM646X_LPSC_TPTC2,
  175. .flags = ALWAYS_ENABLED,
  176. };
  177. static struct clk edma_tc3_clk = {
  178. .name = "edma_tc3",
  179. .parent = &pll1_sysclk2,
  180. .lpsc = DM646X_LPSC_TPTC3,
  181. .flags = ALWAYS_ENABLED,
  182. };
  183. static struct clk uart0_clk = {
  184. .name = "uart0",
  185. .parent = &aux_clkin,
  186. .lpsc = DM646X_LPSC_UART0,
  187. };
  188. static struct clk uart1_clk = {
  189. .name = "uart1",
  190. .parent = &aux_clkin,
  191. .lpsc = DM646X_LPSC_UART1,
  192. };
  193. static struct clk uart2_clk = {
  194. .name = "uart2",
  195. .parent = &aux_clkin,
  196. .lpsc = DM646X_LPSC_UART2,
  197. };
  198. static struct clk i2c_clk = {
  199. .name = "I2CCLK",
  200. .parent = &pll1_sysclk3,
  201. .lpsc = DM646X_LPSC_I2C,
  202. };
  203. static struct clk gpio_clk = {
  204. .name = "gpio",
  205. .parent = &pll1_sysclk3,
  206. .lpsc = DM646X_LPSC_GPIO,
  207. };
  208. static struct clk mcasp0_clk = {
  209. .name = "mcasp0",
  210. .parent = &pll1_sysclk3,
  211. .lpsc = DM646X_LPSC_McASP0,
  212. };
  213. static struct clk mcasp1_clk = {
  214. .name = "mcasp1",
  215. .parent = &pll1_sysclk3,
  216. .lpsc = DM646X_LPSC_McASP1,
  217. };
  218. static struct clk aemif_clk = {
  219. .name = "aemif",
  220. .parent = &pll1_sysclk3,
  221. .lpsc = DM646X_LPSC_AEMIF,
  222. .flags = ALWAYS_ENABLED,
  223. };
  224. static struct clk emac_clk = {
  225. .name = "emac",
  226. .parent = &pll1_sysclk3,
  227. .lpsc = DM646X_LPSC_EMAC,
  228. };
  229. static struct clk pwm0_clk = {
  230. .name = "pwm0",
  231. .parent = &pll1_sysclk3,
  232. .lpsc = DM646X_LPSC_PWM0,
  233. .usecount = 1, /* REVIST: disabling hangs system */
  234. };
  235. static struct clk pwm1_clk = {
  236. .name = "pwm1",
  237. .parent = &pll1_sysclk3,
  238. .lpsc = DM646X_LPSC_PWM1,
  239. .usecount = 1, /* REVIST: disabling hangs system */
  240. };
  241. static struct clk timer0_clk = {
  242. .name = "timer0",
  243. .parent = &pll1_sysclk3,
  244. .lpsc = DM646X_LPSC_TIMER0,
  245. };
  246. static struct clk timer1_clk = {
  247. .name = "timer1",
  248. .parent = &pll1_sysclk3,
  249. .lpsc = DM646X_LPSC_TIMER1,
  250. };
  251. static struct clk timer2_clk = {
  252. .name = "timer2",
  253. .parent = &pll1_sysclk3,
  254. .flags = ALWAYS_ENABLED, /* no LPSC, always enabled; c.f. spruep9a */
  255. };
  256. static struct clk ide_clk = {
  257. .name = "ide",
  258. .parent = &pll1_sysclk4,
  259. .lpsc = DAVINCI_LPSC_ATA,
  260. };
  261. static struct clk vpif0_clk = {
  262. .name = "vpif0",
  263. .parent = &ref_clk,
  264. .lpsc = DM646X_LPSC_VPSSMSTR,
  265. .flags = ALWAYS_ENABLED,
  266. };
  267. static struct clk vpif1_clk = {
  268. .name = "vpif1",
  269. .parent = &ref_clk,
  270. .lpsc = DM646X_LPSC_VPSSSLV,
  271. .flags = ALWAYS_ENABLED,
  272. };
  273. static struct clk_lookup dm646x_clks[] = {
  274. CLK(NULL, "ref", &ref_clk),
  275. CLK(NULL, "aux", &aux_clkin),
  276. CLK(NULL, "pll1", &pll1_clk),
  277. CLK(NULL, "pll1_sysclk", &pll1_sysclk1),
  278. CLK(NULL, "pll1_sysclk", &pll1_sysclk2),
  279. CLK(NULL, "pll1_sysclk", &pll1_sysclk3),
  280. CLK(NULL, "pll1_sysclk", &pll1_sysclk4),
  281. CLK(NULL, "pll1_sysclk", &pll1_sysclk5),
  282. CLK(NULL, "pll1_sysclk", &pll1_sysclk6),
  283. CLK(NULL, "pll1_sysclk", &pll1_sysclk8),
  284. CLK(NULL, "pll1_sysclk", &pll1_sysclk9),
  285. CLK(NULL, "pll1_sysclk", &pll1_sysclkbp),
  286. CLK(NULL, "pll1_aux", &pll1_aux_clk),
  287. CLK(NULL, "pll2", &pll2_clk),
  288. CLK(NULL, "pll2_sysclk1", &pll2_sysclk1),
  289. CLK(NULL, "dsp", &dsp_clk),
  290. CLK(NULL, "arm", &arm_clk),
  291. CLK(NULL, "edma_cc", &edma_cc_clk),
  292. CLK(NULL, "edma_tc0", &edma_tc0_clk),
  293. CLK(NULL, "edma_tc1", &edma_tc1_clk),
  294. CLK(NULL, "edma_tc2", &edma_tc2_clk),
  295. CLK(NULL, "edma_tc3", &edma_tc3_clk),
  296. CLK("serial8250.0", NULL, &uart0_clk),
  297. CLK("serial8250.1", NULL, &uart1_clk),
  298. CLK("serial8250.2", NULL, &uart2_clk),
  299. CLK("i2c_davinci.1", NULL, &i2c_clk),
  300. CLK(NULL, "gpio", &gpio_clk),
  301. CLK("davinci-mcasp.0", NULL, &mcasp0_clk),
  302. CLK("davinci-mcasp.1", NULL, &mcasp1_clk),
  303. CLK(NULL, "aemif", &aemif_clk),
  304. CLK("davinci_emac.1", NULL, &emac_clk),
  305. CLK("davinci_mdio.0", "fck", &emac_clk),
  306. CLK(NULL, "pwm0", &pwm0_clk),
  307. CLK(NULL, "pwm1", &pwm1_clk),
  308. CLK(NULL, "timer0", &timer0_clk),
  309. CLK(NULL, "timer1", &timer1_clk),
  310. CLK("davinci-wdt", NULL, &timer2_clk),
  311. CLK("palm_bk3710", NULL, &ide_clk),
  312. CLK(NULL, "vpif0", &vpif0_clk),
  313. CLK(NULL, "vpif1", &vpif1_clk),
  314. CLK(NULL, NULL, NULL),
  315. };
  316. static struct emac_platform_data dm646x_emac_pdata = {
  317. .ctrl_reg_offset = DM646X_EMAC_CNTRL_OFFSET,
  318. .ctrl_mod_reg_offset = DM646X_EMAC_CNTRL_MOD_OFFSET,
  319. .ctrl_ram_offset = DM646X_EMAC_CNTRL_RAM_OFFSET,
  320. .ctrl_ram_size = DM646X_EMAC_CNTRL_RAM_SIZE,
  321. .version = EMAC_VERSION_2,
  322. };
  323. static struct resource dm646x_emac_resources[] = {
  324. {
  325. .start = DM646X_EMAC_BASE,
  326. .end = DM646X_EMAC_BASE + SZ_16K - 1,
  327. .flags = IORESOURCE_MEM,
  328. },
  329. {
  330. .start = IRQ_DM646X_EMACRXTHINT,
  331. .end = IRQ_DM646X_EMACRXTHINT,
  332. .flags = IORESOURCE_IRQ,
  333. },
  334. {
  335. .start = IRQ_DM646X_EMACRXINT,
  336. .end = IRQ_DM646X_EMACRXINT,
  337. .flags = IORESOURCE_IRQ,
  338. },
  339. {
  340. .start = IRQ_DM646X_EMACTXINT,
  341. .end = IRQ_DM646X_EMACTXINT,
  342. .flags = IORESOURCE_IRQ,
  343. },
  344. {
  345. .start = IRQ_DM646X_EMACMISCINT,
  346. .end = IRQ_DM646X_EMACMISCINT,
  347. .flags = IORESOURCE_IRQ,
  348. },
  349. };
  350. static struct platform_device dm646x_emac_device = {
  351. .name = "davinci_emac",
  352. .id = 1,
  353. .dev = {
  354. .platform_data = &dm646x_emac_pdata,
  355. },
  356. .num_resources = ARRAY_SIZE(dm646x_emac_resources),
  357. .resource = dm646x_emac_resources,
  358. };
  359. static struct resource dm646x_mdio_resources[] = {
  360. {
  361. .start = DM646X_EMAC_MDIO_BASE,
  362. .end = DM646X_EMAC_MDIO_BASE + SZ_4K - 1,
  363. .flags = IORESOURCE_MEM,
  364. },
  365. };
  366. static struct platform_device dm646x_mdio_device = {
  367. .name = "davinci_mdio",
  368. .id = 0,
  369. .num_resources = ARRAY_SIZE(dm646x_mdio_resources),
  370. .resource = dm646x_mdio_resources,
  371. };
  372. /*
  373. * Device specific mux setup
  374. *
  375. * soc description mux mode mode mux dbg
  376. * reg offset mask mode
  377. */
  378. static const struct mux_config dm646x_pins[] = {
  379. #ifdef CONFIG_DAVINCI_MUX
  380. MUX_CFG(DM646X, ATAEN, 0, 0, 5, 1, true)
  381. MUX_CFG(DM646X, AUDCK1, 0, 29, 1, 0, false)
  382. MUX_CFG(DM646X, AUDCK0, 0, 28, 1, 0, false)
  383. MUX_CFG(DM646X, CRGMUX, 0, 24, 7, 5, true)
  384. MUX_CFG(DM646X, STSOMUX_DISABLE, 0, 22, 3, 0, true)
  385. MUX_CFG(DM646X, STSIMUX_DISABLE, 0, 20, 3, 0, true)
  386. MUX_CFG(DM646X, PTSOMUX_DISABLE, 0, 18, 3, 0, true)
  387. MUX_CFG(DM646X, PTSIMUX_DISABLE, 0, 16, 3, 0, true)
  388. MUX_CFG(DM646X, STSOMUX, 0, 22, 3, 2, true)
  389. MUX_CFG(DM646X, STSIMUX, 0, 20, 3, 2, true)
  390. MUX_CFG(DM646X, PTSOMUX_PARALLEL, 0, 18, 3, 2, true)
  391. MUX_CFG(DM646X, PTSIMUX_PARALLEL, 0, 16, 3, 2, true)
  392. MUX_CFG(DM646X, PTSOMUX_SERIAL, 0, 18, 3, 3, true)
  393. MUX_CFG(DM646X, PTSIMUX_SERIAL, 0, 16, 3, 3, true)
  394. #endif
  395. };
  396. static u8 dm646x_default_priorities[DAVINCI_N_AINTC_IRQ] = {
  397. [IRQ_DM646X_VP_VERTINT0] = 7,
  398. [IRQ_DM646X_VP_VERTINT1] = 7,
  399. [IRQ_DM646X_VP_VERTINT2] = 7,
  400. [IRQ_DM646X_VP_VERTINT3] = 7,
  401. [IRQ_DM646X_VP_ERRINT] = 7,
  402. [IRQ_DM646X_RESERVED_1] = 7,
  403. [IRQ_DM646X_RESERVED_2] = 7,
  404. [IRQ_DM646X_WDINT] = 7,
  405. [IRQ_DM646X_CRGENINT0] = 7,
  406. [IRQ_DM646X_CRGENINT1] = 7,
  407. [IRQ_DM646X_TSIFINT0] = 7,
  408. [IRQ_DM646X_TSIFINT1] = 7,
  409. [IRQ_DM646X_VDCEINT] = 7,
  410. [IRQ_DM646X_USBINT] = 7,
  411. [IRQ_DM646X_USBDMAINT] = 7,
  412. [IRQ_DM646X_PCIINT] = 7,
  413. [IRQ_CCINT0] = 7, /* dma */
  414. [IRQ_CCERRINT] = 7, /* dma */
  415. [IRQ_TCERRINT0] = 7, /* dma */
  416. [IRQ_TCERRINT] = 7, /* dma */
  417. [IRQ_DM646X_TCERRINT2] = 7,
  418. [IRQ_DM646X_TCERRINT3] = 7,
  419. [IRQ_DM646X_IDE] = 7,
  420. [IRQ_DM646X_HPIINT] = 7,
  421. [IRQ_DM646X_EMACRXTHINT] = 7,
  422. [IRQ_DM646X_EMACRXINT] = 7,
  423. [IRQ_DM646X_EMACTXINT] = 7,
  424. [IRQ_DM646X_EMACMISCINT] = 7,
  425. [IRQ_DM646X_MCASP0TXINT] = 7,
  426. [IRQ_DM646X_MCASP0RXINT] = 7,
  427. [IRQ_DM646X_RESERVED_3] = 7,
  428. [IRQ_DM646X_MCASP1TXINT] = 7, /* clockevent */
  429. [IRQ_TINT0_TINT34] = 7, /* clocksource */
  430. [IRQ_TINT1_TINT12] = 7, /* DSP timer */
  431. [IRQ_TINT1_TINT34] = 7, /* system tick */
  432. [IRQ_PWMINT0] = 7,
  433. [IRQ_PWMINT1] = 7,
  434. [IRQ_DM646X_VLQINT] = 7,
  435. [IRQ_I2C] = 7,
  436. [IRQ_UARTINT0] = 7,
  437. [IRQ_UARTINT1] = 7,
  438. [IRQ_DM646X_UARTINT2] = 7,
  439. [IRQ_DM646X_SPINT0] = 7,
  440. [IRQ_DM646X_SPINT1] = 7,
  441. [IRQ_DM646X_DSP2ARMINT] = 7,
  442. [IRQ_DM646X_RESERVED_4] = 7,
  443. [IRQ_DM646X_PSCINT] = 7,
  444. [IRQ_DM646X_GPIO0] = 7,
  445. [IRQ_DM646X_GPIO1] = 7,
  446. [IRQ_DM646X_GPIO2] = 7,
  447. [IRQ_DM646X_GPIO3] = 7,
  448. [IRQ_DM646X_GPIO4] = 7,
  449. [IRQ_DM646X_GPIO5] = 7,
  450. [IRQ_DM646X_GPIO6] = 7,
  451. [IRQ_DM646X_GPIO7] = 7,
  452. [IRQ_DM646X_GPIOBNK0] = 7,
  453. [IRQ_DM646X_GPIOBNK1] = 7,
  454. [IRQ_DM646X_GPIOBNK2] = 7,
  455. [IRQ_DM646X_DDRINT] = 7,
  456. [IRQ_DM646X_AEMIFINT] = 7,
  457. [IRQ_COMMTX] = 7,
  458. [IRQ_COMMRX] = 7,
  459. [IRQ_EMUINT] = 7,
  460. };
  461. /*----------------------------------------------------------------------*/
  462. /* Four Transfer Controllers on DM646x */
  463. static s8 dm646x_queue_priority_mapping[][2] = {
  464. /* {event queue no, Priority} */
  465. {0, 4},
  466. {1, 0},
  467. {2, 5},
  468. {3, 1},
  469. {-1, -1},
  470. };
  471. static const struct dma_slave_map dm646x_edma_map[] = {
  472. { "davinci-mcasp.0", "tx", EDMA_FILTER_PARAM(0, 6) },
  473. { "davinci-mcasp.0", "rx", EDMA_FILTER_PARAM(0, 9) },
  474. { "davinci-mcasp.1", "tx", EDMA_FILTER_PARAM(0, 12) },
  475. { "spi_davinci", "tx", EDMA_FILTER_PARAM(0, 16) },
  476. { "spi_davinci", "rx", EDMA_FILTER_PARAM(0, 17) },
  477. };
  478. static struct edma_soc_info dm646x_edma_pdata = {
  479. .queue_priority_mapping = dm646x_queue_priority_mapping,
  480. .default_queue = EVENTQ_1,
  481. .slave_map = dm646x_edma_map,
  482. .slavecnt = ARRAY_SIZE(dm646x_edma_map),
  483. };
  484. static struct resource edma_resources[] = {
  485. {
  486. .name = "edma3_cc",
  487. .start = 0x01c00000,
  488. .end = 0x01c00000 + SZ_64K - 1,
  489. .flags = IORESOURCE_MEM,
  490. },
  491. {
  492. .name = "edma3_tc0",
  493. .start = 0x01c10000,
  494. .end = 0x01c10000 + SZ_1K - 1,
  495. .flags = IORESOURCE_MEM,
  496. },
  497. {
  498. .name = "edma3_tc1",
  499. .start = 0x01c10400,
  500. .end = 0x01c10400 + SZ_1K - 1,
  501. .flags = IORESOURCE_MEM,
  502. },
  503. {
  504. .name = "edma3_tc2",
  505. .start = 0x01c10800,
  506. .end = 0x01c10800 + SZ_1K - 1,
  507. .flags = IORESOURCE_MEM,
  508. },
  509. {
  510. .name = "edma3_tc3",
  511. .start = 0x01c10c00,
  512. .end = 0x01c10c00 + SZ_1K - 1,
  513. .flags = IORESOURCE_MEM,
  514. },
  515. {
  516. .name = "edma3_ccint",
  517. .start = IRQ_CCINT0,
  518. .flags = IORESOURCE_IRQ,
  519. },
  520. {
  521. .name = "edma3_ccerrint",
  522. .start = IRQ_CCERRINT,
  523. .flags = IORESOURCE_IRQ,
  524. },
  525. /* not using TC*_ERR */
  526. };
  527. static const struct platform_device_info dm646x_edma_device __initconst = {
  528. .name = "edma",
  529. .id = 0,
  530. .dma_mask = DMA_BIT_MASK(32),
  531. .res = edma_resources,
  532. .num_res = ARRAY_SIZE(edma_resources),
  533. .data = &dm646x_edma_pdata,
  534. .size_data = sizeof(dm646x_edma_pdata),
  535. };
  536. static struct resource dm646x_mcasp0_resources[] = {
  537. {
  538. .name = "mpu",
  539. .start = DAVINCI_DM646X_MCASP0_REG_BASE,
  540. .end = DAVINCI_DM646X_MCASP0_REG_BASE + (SZ_1K << 1) - 1,
  541. .flags = IORESOURCE_MEM,
  542. },
  543. {
  544. .name = "tx",
  545. .start = DAVINCI_DM646X_DMA_MCASP0_AXEVT0,
  546. .end = DAVINCI_DM646X_DMA_MCASP0_AXEVT0,
  547. .flags = IORESOURCE_DMA,
  548. },
  549. {
  550. .name = "rx",
  551. .start = DAVINCI_DM646X_DMA_MCASP0_AREVT0,
  552. .end = DAVINCI_DM646X_DMA_MCASP0_AREVT0,
  553. .flags = IORESOURCE_DMA,
  554. },
  555. {
  556. .name = "tx",
  557. .start = IRQ_DM646X_MCASP0TXINT,
  558. .flags = IORESOURCE_IRQ,
  559. },
  560. {
  561. .name = "rx",
  562. .start = IRQ_DM646X_MCASP0RXINT,
  563. .flags = IORESOURCE_IRQ,
  564. },
  565. };
  566. /* DIT mode only, rx is not supported */
  567. static struct resource dm646x_mcasp1_resources[] = {
  568. {
  569. .name = "mpu",
  570. .start = DAVINCI_DM646X_MCASP1_REG_BASE,
  571. .end = DAVINCI_DM646X_MCASP1_REG_BASE + (SZ_1K << 1) - 1,
  572. .flags = IORESOURCE_MEM,
  573. },
  574. {
  575. .name = "tx",
  576. .start = DAVINCI_DM646X_DMA_MCASP1_AXEVT1,
  577. .end = DAVINCI_DM646X_DMA_MCASP1_AXEVT1,
  578. .flags = IORESOURCE_DMA,
  579. },
  580. {
  581. .name = "tx",
  582. .start = IRQ_DM646X_MCASP1TXINT,
  583. .flags = IORESOURCE_IRQ,
  584. },
  585. };
  586. static struct platform_device dm646x_mcasp0_device = {
  587. .name = "davinci-mcasp",
  588. .id = 0,
  589. .num_resources = ARRAY_SIZE(dm646x_mcasp0_resources),
  590. .resource = dm646x_mcasp0_resources,
  591. };
  592. static struct platform_device dm646x_mcasp1_device = {
  593. .name = "davinci-mcasp",
  594. .id = 1,
  595. .num_resources = ARRAY_SIZE(dm646x_mcasp1_resources),
  596. .resource = dm646x_mcasp1_resources,
  597. };
  598. static struct platform_device dm646x_dit_device = {
  599. .name = "spdif-dit",
  600. .id = -1,
  601. };
  602. static u64 vpif_dma_mask = DMA_BIT_MASK(32);
  603. static struct resource vpif_resource[] = {
  604. {
  605. .start = DAVINCI_VPIF_BASE,
  606. .end = DAVINCI_VPIF_BASE + 0x03ff,
  607. .flags = IORESOURCE_MEM,
  608. }
  609. };
  610. static struct platform_device vpif_dev = {
  611. .name = "vpif",
  612. .id = -1,
  613. .dev = {
  614. .dma_mask = &vpif_dma_mask,
  615. .coherent_dma_mask = DMA_BIT_MASK(32),
  616. },
  617. .resource = vpif_resource,
  618. .num_resources = ARRAY_SIZE(vpif_resource),
  619. };
  620. static struct resource vpif_display_resource[] = {
  621. {
  622. .start = IRQ_DM646X_VP_VERTINT2,
  623. .end = IRQ_DM646X_VP_VERTINT2,
  624. .flags = IORESOURCE_IRQ,
  625. },
  626. {
  627. .start = IRQ_DM646X_VP_VERTINT3,
  628. .end = IRQ_DM646X_VP_VERTINT3,
  629. .flags = IORESOURCE_IRQ,
  630. },
  631. };
  632. static struct platform_device vpif_display_dev = {
  633. .name = "vpif_display",
  634. .id = -1,
  635. .dev = {
  636. .dma_mask = &vpif_dma_mask,
  637. .coherent_dma_mask = DMA_BIT_MASK(32),
  638. },
  639. .resource = vpif_display_resource,
  640. .num_resources = ARRAY_SIZE(vpif_display_resource),
  641. };
  642. static struct resource vpif_capture_resource[] = {
  643. {
  644. .start = IRQ_DM646X_VP_VERTINT0,
  645. .end = IRQ_DM646X_VP_VERTINT0,
  646. .flags = IORESOURCE_IRQ,
  647. },
  648. {
  649. .start = IRQ_DM646X_VP_VERTINT1,
  650. .end = IRQ_DM646X_VP_VERTINT1,
  651. .flags = IORESOURCE_IRQ,
  652. },
  653. };
  654. static struct platform_device vpif_capture_dev = {
  655. .name = "vpif_capture",
  656. .id = -1,
  657. .dev = {
  658. .dma_mask = &vpif_dma_mask,
  659. .coherent_dma_mask = DMA_BIT_MASK(32),
  660. },
  661. .resource = vpif_capture_resource,
  662. .num_resources = ARRAY_SIZE(vpif_capture_resource),
  663. };
  664. static struct resource dm646x_gpio_resources[] = {
  665. { /* registers */
  666. .start = DAVINCI_GPIO_BASE,
  667. .end = DAVINCI_GPIO_BASE + SZ_4K - 1,
  668. .flags = IORESOURCE_MEM,
  669. },
  670. { /* interrupt */
  671. .start = IRQ_DM646X_GPIOBNK0,
  672. .end = IRQ_DM646X_GPIOBNK2,
  673. .flags = IORESOURCE_IRQ,
  674. },
  675. };
  676. static struct davinci_gpio_platform_data dm646x_gpio_platform_data = {
  677. .ngpio = 43,
  678. };
  679. int __init dm646x_gpio_register(void)
  680. {
  681. return davinci_gpio_register(dm646x_gpio_resources,
  682. ARRAY_SIZE(dm646x_gpio_resources),
  683. &dm646x_gpio_platform_data);
  684. }
  685. /*----------------------------------------------------------------------*/
  686. static struct map_desc dm646x_io_desc[] = {
  687. {
  688. .virtual = IO_VIRT,
  689. .pfn = __phys_to_pfn(IO_PHYS),
  690. .length = IO_SIZE,
  691. .type = MT_DEVICE
  692. },
  693. };
  694. /* Contents of JTAG ID register used to identify exact cpu type */
  695. static struct davinci_id dm646x_ids[] = {
  696. {
  697. .variant = 0x0,
  698. .part_no = 0xb770,
  699. .manufacturer = 0x017,
  700. .cpu_id = DAVINCI_CPU_ID_DM6467,
  701. .name = "dm6467_rev1.x",
  702. },
  703. {
  704. .variant = 0x1,
  705. .part_no = 0xb770,
  706. .manufacturer = 0x017,
  707. .cpu_id = DAVINCI_CPU_ID_DM6467,
  708. .name = "dm6467_rev3.x",
  709. },
  710. };
  711. static u32 dm646x_psc_bases[] = { DAVINCI_PWR_SLEEP_CNTRL_BASE };
  712. /*
  713. * T0_BOT: Timer 0, bottom: clockevent source for hrtimers
  714. * T0_TOP: Timer 0, top : clocksource for generic timekeeping
  715. * T1_BOT: Timer 1, bottom: (used by DSP in TI DSPLink code)
  716. * T1_TOP: Timer 1, top : <unused>
  717. */
  718. static struct davinci_timer_info dm646x_timer_info = {
  719. .timers = davinci_timer_instance,
  720. .clockevent_id = T0_BOT,
  721. .clocksource_id = T0_TOP,
  722. };
  723. static struct plat_serial8250_port dm646x_serial0_platform_data[] = {
  724. {
  725. .mapbase = DAVINCI_UART0_BASE,
  726. .irq = IRQ_UARTINT0,
  727. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  728. UPF_IOREMAP,
  729. .iotype = UPIO_MEM32,
  730. .regshift = 2,
  731. },
  732. {
  733. .flags = 0,
  734. }
  735. };
  736. static struct plat_serial8250_port dm646x_serial1_platform_data[] = {
  737. {
  738. .mapbase = DAVINCI_UART1_BASE,
  739. .irq = IRQ_UARTINT1,
  740. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  741. UPF_IOREMAP,
  742. .iotype = UPIO_MEM32,
  743. .regshift = 2,
  744. },
  745. {
  746. .flags = 0,
  747. }
  748. };
  749. static struct plat_serial8250_port dm646x_serial2_platform_data[] = {
  750. {
  751. .mapbase = DAVINCI_UART2_BASE,
  752. .irq = IRQ_DM646X_UARTINT2,
  753. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  754. UPF_IOREMAP,
  755. .iotype = UPIO_MEM32,
  756. .regshift = 2,
  757. },
  758. {
  759. .flags = 0,
  760. }
  761. };
  762. struct platform_device dm646x_serial_device[] = {
  763. {
  764. .name = "serial8250",
  765. .id = PLAT8250_DEV_PLATFORM,
  766. .dev = {
  767. .platform_data = dm646x_serial0_platform_data,
  768. }
  769. },
  770. {
  771. .name = "serial8250",
  772. .id = PLAT8250_DEV_PLATFORM1,
  773. .dev = {
  774. .platform_data = dm646x_serial1_platform_data,
  775. }
  776. },
  777. {
  778. .name = "serial8250",
  779. .id = PLAT8250_DEV_PLATFORM2,
  780. .dev = {
  781. .platform_data = dm646x_serial2_platform_data,
  782. }
  783. },
  784. {
  785. }
  786. };
  787. static struct davinci_soc_info davinci_soc_info_dm646x = {
  788. .io_desc = dm646x_io_desc,
  789. .io_desc_num = ARRAY_SIZE(dm646x_io_desc),
  790. .jtag_id_reg = 0x01c40028,
  791. .ids = dm646x_ids,
  792. .ids_num = ARRAY_SIZE(dm646x_ids),
  793. .cpu_clks = dm646x_clks,
  794. .psc_bases = dm646x_psc_bases,
  795. .psc_bases_num = ARRAY_SIZE(dm646x_psc_bases),
  796. .pinmux_base = DAVINCI_SYSTEM_MODULE_BASE,
  797. .pinmux_pins = dm646x_pins,
  798. .pinmux_pins_num = ARRAY_SIZE(dm646x_pins),
  799. .intc_base = DAVINCI_ARM_INTC_BASE,
  800. .intc_type = DAVINCI_INTC_TYPE_AINTC,
  801. .intc_irq_prios = dm646x_default_priorities,
  802. .intc_irq_num = DAVINCI_N_AINTC_IRQ,
  803. .timer_info = &dm646x_timer_info,
  804. .emac_pdata = &dm646x_emac_pdata,
  805. .sram_dma = 0x10010000,
  806. .sram_len = SZ_32K,
  807. };
  808. void __init dm646x_init_mcasp0(struct snd_platform_data *pdata)
  809. {
  810. dm646x_mcasp0_device.dev.platform_data = pdata;
  811. platform_device_register(&dm646x_mcasp0_device);
  812. }
  813. void __init dm646x_init_mcasp1(struct snd_platform_data *pdata)
  814. {
  815. dm646x_mcasp1_device.dev.platform_data = pdata;
  816. platform_device_register(&dm646x_mcasp1_device);
  817. platform_device_register(&dm646x_dit_device);
  818. }
  819. void dm646x_setup_vpif(struct vpif_display_config *display_config,
  820. struct vpif_capture_config *capture_config)
  821. {
  822. unsigned int value;
  823. value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
  824. value &= ~VSCLKDIS_MASK;
  825. __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
  826. value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VDD3P3VPWDN));
  827. value &= ~VDD3P3V_VID_MASK;
  828. __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VDD3P3VPWDN));
  829. davinci_cfg_reg(DM646X_STSOMUX_DISABLE);
  830. davinci_cfg_reg(DM646X_STSIMUX_DISABLE);
  831. davinci_cfg_reg(DM646X_PTSOMUX_DISABLE);
  832. davinci_cfg_reg(DM646X_PTSIMUX_DISABLE);
  833. vpif_display_dev.dev.platform_data = display_config;
  834. vpif_capture_dev.dev.platform_data = capture_config;
  835. platform_device_register(&vpif_dev);
  836. platform_device_register(&vpif_display_dev);
  837. platform_device_register(&vpif_capture_dev);
  838. }
  839. int __init dm646x_init_edma(struct edma_rsv_info *rsv)
  840. {
  841. struct platform_device *edma_pdev;
  842. dm646x_edma_pdata.rsv = rsv;
  843. edma_pdev = platform_device_register_full(&dm646x_edma_device);
  844. return IS_ERR(edma_pdev) ? PTR_ERR(edma_pdev) : 0;
  845. }
  846. void __init dm646x_init(void)
  847. {
  848. davinci_common_init(&davinci_soc_info_dm646x);
  849. davinci_map_sysmod();
  850. davinci_clk_init(davinci_soc_info_dm646x.cpu_clks);
  851. }
  852. static int __init dm646x_init_devices(void)
  853. {
  854. int ret = 0;
  855. if (!cpu_is_davinci_dm646x())
  856. return 0;
  857. platform_device_register(&dm646x_mdio_device);
  858. platform_device_register(&dm646x_emac_device);
  859. ret = davinci_init_wdt();
  860. if (ret)
  861. pr_warn("%s: watchdog init failed: %d\n", __func__, ret);
  862. return ret;
  863. }
  864. postcore_initcall(dm646x_init_devices);