dm644x.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984
  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/init.h>
  12. #include <linux/clk.h>
  13. #include <linux/serial_8250.h>
  14. #include <linux/dmaengine.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/platform_data/edma.h>
  17. #include <linux/platform_data/gpio-davinci.h>
  18. #include <asm/mach/map.h>
  19. #include <mach/cputype.h>
  20. #include <mach/irqs.h>
  21. #include "psc.h"
  22. #include <mach/mux.h>
  23. #include <mach/time.h>
  24. #include <mach/serial.h>
  25. #include <mach/common.h>
  26. #include "davinci.h"
  27. #include "clock.h"
  28. #include "mux.h"
  29. #include "asp.h"
  30. /*
  31. * Device specific clocks
  32. */
  33. #define DM644X_REF_FREQ 27000000
  34. #define DM644X_EMAC_BASE 0x01c80000
  35. #define DM644X_EMAC_MDIO_BASE (DM644X_EMAC_BASE + 0x4000)
  36. #define DM644X_EMAC_CNTRL_OFFSET 0x0000
  37. #define DM644X_EMAC_CNTRL_MOD_OFFSET 0x1000
  38. #define DM644X_EMAC_CNTRL_RAM_OFFSET 0x2000
  39. #define DM644X_EMAC_CNTRL_RAM_SIZE 0x2000
  40. static struct pll_data pll1_data = {
  41. .num = 1,
  42. .phys_base = DAVINCI_PLL1_BASE,
  43. };
  44. static struct pll_data pll2_data = {
  45. .num = 2,
  46. .phys_base = DAVINCI_PLL2_BASE,
  47. };
  48. static struct clk ref_clk = {
  49. .name = "ref_clk",
  50. .rate = DM644X_REF_FREQ,
  51. };
  52. static struct clk pll1_clk = {
  53. .name = "pll1",
  54. .parent = &ref_clk,
  55. .pll_data = &pll1_data,
  56. .flags = CLK_PLL,
  57. };
  58. static struct clk pll1_sysclk1 = {
  59. .name = "pll1_sysclk1",
  60. .parent = &pll1_clk,
  61. .flags = CLK_PLL,
  62. .div_reg = PLLDIV1,
  63. };
  64. static struct clk pll1_sysclk2 = {
  65. .name = "pll1_sysclk2",
  66. .parent = &pll1_clk,
  67. .flags = CLK_PLL,
  68. .div_reg = PLLDIV2,
  69. };
  70. static struct clk pll1_sysclk3 = {
  71. .name = "pll1_sysclk3",
  72. .parent = &pll1_clk,
  73. .flags = CLK_PLL,
  74. .div_reg = PLLDIV3,
  75. };
  76. static struct clk pll1_sysclk5 = {
  77. .name = "pll1_sysclk5",
  78. .parent = &pll1_clk,
  79. .flags = CLK_PLL,
  80. .div_reg = PLLDIV5,
  81. };
  82. static struct clk pll1_aux_clk = {
  83. .name = "pll1_aux_clk",
  84. .parent = &pll1_clk,
  85. .flags = CLK_PLL | PRE_PLL,
  86. };
  87. static struct clk pll1_sysclkbp = {
  88. .name = "pll1_sysclkbp",
  89. .parent = &pll1_clk,
  90. .flags = CLK_PLL | PRE_PLL,
  91. .div_reg = BPDIV
  92. };
  93. static struct clk pll2_clk = {
  94. .name = "pll2",
  95. .parent = &ref_clk,
  96. .pll_data = &pll2_data,
  97. .flags = CLK_PLL,
  98. };
  99. static struct clk pll2_sysclk1 = {
  100. .name = "pll2_sysclk1",
  101. .parent = &pll2_clk,
  102. .flags = CLK_PLL,
  103. .div_reg = PLLDIV1,
  104. };
  105. static struct clk pll2_sysclk2 = {
  106. .name = "pll2_sysclk2",
  107. .parent = &pll2_clk,
  108. .flags = CLK_PLL,
  109. .div_reg = PLLDIV2,
  110. };
  111. static struct clk pll2_sysclkbp = {
  112. .name = "pll2_sysclkbp",
  113. .parent = &pll2_clk,
  114. .flags = CLK_PLL | PRE_PLL,
  115. .div_reg = BPDIV
  116. };
  117. static struct clk dsp_clk = {
  118. .name = "dsp",
  119. .parent = &pll1_sysclk1,
  120. .lpsc = DAVINCI_LPSC_GEM,
  121. .domain = DAVINCI_GPSC_DSPDOMAIN,
  122. .usecount = 1, /* REVISIT how to disable? */
  123. };
  124. static struct clk arm_clk = {
  125. .name = "arm",
  126. .parent = &pll1_sysclk2,
  127. .lpsc = DAVINCI_LPSC_ARM,
  128. .flags = ALWAYS_ENABLED,
  129. };
  130. static struct clk vicp_clk = {
  131. .name = "vicp",
  132. .parent = &pll1_sysclk2,
  133. .lpsc = DAVINCI_LPSC_IMCOP,
  134. .domain = DAVINCI_GPSC_DSPDOMAIN,
  135. .usecount = 1, /* REVISIT how to disable? */
  136. };
  137. static struct clk vpss_master_clk = {
  138. .name = "vpss_master",
  139. .parent = &pll1_sysclk3,
  140. .lpsc = DAVINCI_LPSC_VPSSMSTR,
  141. .flags = CLK_PSC,
  142. };
  143. static struct clk vpss_slave_clk = {
  144. .name = "vpss_slave",
  145. .parent = &pll1_sysclk3,
  146. .lpsc = DAVINCI_LPSC_VPSSSLV,
  147. };
  148. static struct clk uart0_clk = {
  149. .name = "uart0",
  150. .parent = &pll1_aux_clk,
  151. .lpsc = DAVINCI_LPSC_UART0,
  152. };
  153. static struct clk uart1_clk = {
  154. .name = "uart1",
  155. .parent = &pll1_aux_clk,
  156. .lpsc = DAVINCI_LPSC_UART1,
  157. };
  158. static struct clk uart2_clk = {
  159. .name = "uart2",
  160. .parent = &pll1_aux_clk,
  161. .lpsc = DAVINCI_LPSC_UART2,
  162. };
  163. static struct clk emac_clk = {
  164. .name = "emac",
  165. .parent = &pll1_sysclk5,
  166. .lpsc = DAVINCI_LPSC_EMAC_WRAPPER,
  167. };
  168. static struct clk i2c_clk = {
  169. .name = "i2c",
  170. .parent = &pll1_aux_clk,
  171. .lpsc = DAVINCI_LPSC_I2C,
  172. };
  173. static struct clk ide_clk = {
  174. .name = "ide",
  175. .parent = &pll1_sysclk5,
  176. .lpsc = DAVINCI_LPSC_ATA,
  177. };
  178. static struct clk asp_clk = {
  179. .name = "asp0",
  180. .parent = &pll1_sysclk5,
  181. .lpsc = DAVINCI_LPSC_McBSP,
  182. };
  183. static struct clk mmcsd_clk = {
  184. .name = "mmcsd",
  185. .parent = &pll1_sysclk5,
  186. .lpsc = DAVINCI_LPSC_MMC_SD,
  187. };
  188. static struct clk spi_clk = {
  189. .name = "spi",
  190. .parent = &pll1_sysclk5,
  191. .lpsc = DAVINCI_LPSC_SPI,
  192. };
  193. static struct clk gpio_clk = {
  194. .name = "gpio",
  195. .parent = &pll1_sysclk5,
  196. .lpsc = DAVINCI_LPSC_GPIO,
  197. };
  198. static struct clk usb_clk = {
  199. .name = "usb",
  200. .parent = &pll1_sysclk5,
  201. .lpsc = DAVINCI_LPSC_USB,
  202. };
  203. static struct clk vlynq_clk = {
  204. .name = "vlynq",
  205. .parent = &pll1_sysclk5,
  206. .lpsc = DAVINCI_LPSC_VLYNQ,
  207. };
  208. static struct clk aemif_clk = {
  209. .name = "aemif",
  210. .parent = &pll1_sysclk5,
  211. .lpsc = DAVINCI_LPSC_AEMIF,
  212. };
  213. static struct clk pwm0_clk = {
  214. .name = "pwm0",
  215. .parent = &pll1_aux_clk,
  216. .lpsc = DAVINCI_LPSC_PWM0,
  217. };
  218. static struct clk pwm1_clk = {
  219. .name = "pwm1",
  220. .parent = &pll1_aux_clk,
  221. .lpsc = DAVINCI_LPSC_PWM1,
  222. };
  223. static struct clk pwm2_clk = {
  224. .name = "pwm2",
  225. .parent = &pll1_aux_clk,
  226. .lpsc = DAVINCI_LPSC_PWM2,
  227. };
  228. static struct clk timer0_clk = {
  229. .name = "timer0",
  230. .parent = &pll1_aux_clk,
  231. .lpsc = DAVINCI_LPSC_TIMER0,
  232. };
  233. static struct clk timer1_clk = {
  234. .name = "timer1",
  235. .parent = &pll1_aux_clk,
  236. .lpsc = DAVINCI_LPSC_TIMER1,
  237. };
  238. static struct clk timer2_clk = {
  239. .name = "timer2",
  240. .parent = &pll1_aux_clk,
  241. .lpsc = DAVINCI_LPSC_TIMER2,
  242. .usecount = 1, /* REVISIT: why can't this be disabled? */
  243. };
  244. static struct clk_lookup dm644x_clks[] = {
  245. CLK(NULL, "ref", &ref_clk),
  246. CLK(NULL, "pll1", &pll1_clk),
  247. CLK(NULL, "pll1_sysclk1", &pll1_sysclk1),
  248. CLK(NULL, "pll1_sysclk2", &pll1_sysclk2),
  249. CLK(NULL, "pll1_sysclk3", &pll1_sysclk3),
  250. CLK(NULL, "pll1_sysclk5", &pll1_sysclk5),
  251. CLK(NULL, "pll1_aux", &pll1_aux_clk),
  252. CLK(NULL, "pll1_sysclkbp", &pll1_sysclkbp),
  253. CLK(NULL, "pll2", &pll2_clk),
  254. CLK(NULL, "pll2_sysclk1", &pll2_sysclk1),
  255. CLK(NULL, "pll2_sysclk2", &pll2_sysclk2),
  256. CLK(NULL, "pll2_sysclkbp", &pll2_sysclkbp),
  257. CLK(NULL, "dsp", &dsp_clk),
  258. CLK(NULL, "arm", &arm_clk),
  259. CLK(NULL, "vicp", &vicp_clk),
  260. CLK("vpss", "master", &vpss_master_clk),
  261. CLK("vpss", "slave", &vpss_slave_clk),
  262. CLK(NULL, "arm", &arm_clk),
  263. CLK("serial8250.0", NULL, &uart0_clk),
  264. CLK("serial8250.1", NULL, &uart1_clk),
  265. CLK("serial8250.2", NULL, &uart2_clk),
  266. CLK("davinci_emac.1", NULL, &emac_clk),
  267. CLK("davinci_mdio.0", "fck", &emac_clk),
  268. CLK("i2c_davinci.1", NULL, &i2c_clk),
  269. CLK("palm_bk3710", NULL, &ide_clk),
  270. CLK("davinci-mcbsp", NULL, &asp_clk),
  271. CLK("dm6441-mmc.0", NULL, &mmcsd_clk),
  272. CLK(NULL, "spi", &spi_clk),
  273. CLK(NULL, "gpio", &gpio_clk),
  274. CLK(NULL, "usb", &usb_clk),
  275. CLK(NULL, "vlynq", &vlynq_clk),
  276. CLK(NULL, "aemif", &aemif_clk),
  277. CLK(NULL, "pwm0", &pwm0_clk),
  278. CLK(NULL, "pwm1", &pwm1_clk),
  279. CLK(NULL, "pwm2", &pwm2_clk),
  280. CLK(NULL, "timer0", &timer0_clk),
  281. CLK(NULL, "timer1", &timer1_clk),
  282. CLK("davinci-wdt", NULL, &timer2_clk),
  283. CLK(NULL, NULL, NULL),
  284. };
  285. static struct emac_platform_data dm644x_emac_pdata = {
  286. .ctrl_reg_offset = DM644X_EMAC_CNTRL_OFFSET,
  287. .ctrl_mod_reg_offset = DM644X_EMAC_CNTRL_MOD_OFFSET,
  288. .ctrl_ram_offset = DM644X_EMAC_CNTRL_RAM_OFFSET,
  289. .ctrl_ram_size = DM644X_EMAC_CNTRL_RAM_SIZE,
  290. .version = EMAC_VERSION_1,
  291. };
  292. static struct resource dm644x_emac_resources[] = {
  293. {
  294. .start = DM644X_EMAC_BASE,
  295. .end = DM644X_EMAC_BASE + SZ_16K - 1,
  296. .flags = IORESOURCE_MEM,
  297. },
  298. {
  299. .start = IRQ_EMACINT,
  300. .end = IRQ_EMACINT,
  301. .flags = IORESOURCE_IRQ,
  302. },
  303. };
  304. static struct platform_device dm644x_emac_device = {
  305. .name = "davinci_emac",
  306. .id = 1,
  307. .dev = {
  308. .platform_data = &dm644x_emac_pdata,
  309. },
  310. .num_resources = ARRAY_SIZE(dm644x_emac_resources),
  311. .resource = dm644x_emac_resources,
  312. };
  313. static struct resource dm644x_mdio_resources[] = {
  314. {
  315. .start = DM644X_EMAC_MDIO_BASE,
  316. .end = DM644X_EMAC_MDIO_BASE + SZ_4K - 1,
  317. .flags = IORESOURCE_MEM,
  318. },
  319. };
  320. static struct platform_device dm644x_mdio_device = {
  321. .name = "davinci_mdio",
  322. .id = 0,
  323. .num_resources = ARRAY_SIZE(dm644x_mdio_resources),
  324. .resource = dm644x_mdio_resources,
  325. };
  326. /*
  327. * Device specific mux setup
  328. *
  329. * soc description mux mode mode mux dbg
  330. * reg offset mask mode
  331. */
  332. static const struct mux_config dm644x_pins[] = {
  333. #ifdef CONFIG_DAVINCI_MUX
  334. MUX_CFG(DM644X, HDIREN, 0, 16, 1, 1, true)
  335. MUX_CFG(DM644X, ATAEN, 0, 17, 1, 1, true)
  336. MUX_CFG(DM644X, ATAEN_DISABLE, 0, 17, 1, 0, true)
  337. MUX_CFG(DM644X, HPIEN_DISABLE, 0, 29, 1, 0, true)
  338. MUX_CFG(DM644X, AEAW, 0, 0, 31, 31, true)
  339. MUX_CFG(DM644X, AEAW0, 0, 0, 1, 0, true)
  340. MUX_CFG(DM644X, AEAW1, 0, 1, 1, 0, true)
  341. MUX_CFG(DM644X, AEAW2, 0, 2, 1, 0, true)
  342. MUX_CFG(DM644X, AEAW3, 0, 3, 1, 0, true)
  343. MUX_CFG(DM644X, AEAW4, 0, 4, 1, 0, true)
  344. MUX_CFG(DM644X, MSTK, 1, 9, 1, 0, false)
  345. MUX_CFG(DM644X, I2C, 1, 7, 1, 1, false)
  346. MUX_CFG(DM644X, MCBSP, 1, 10, 1, 1, false)
  347. MUX_CFG(DM644X, UART1, 1, 1, 1, 1, true)
  348. MUX_CFG(DM644X, UART2, 1, 2, 1, 1, true)
  349. MUX_CFG(DM644X, PWM0, 1, 4, 1, 1, false)
  350. MUX_CFG(DM644X, PWM1, 1, 5, 1, 1, false)
  351. MUX_CFG(DM644X, PWM2, 1, 6, 1, 1, false)
  352. MUX_CFG(DM644X, VLYNQEN, 0, 15, 1, 1, false)
  353. MUX_CFG(DM644X, VLSCREN, 0, 14, 1, 1, false)
  354. MUX_CFG(DM644X, VLYNQWD, 0, 12, 3, 3, false)
  355. MUX_CFG(DM644X, EMACEN, 0, 31, 1, 1, true)
  356. MUX_CFG(DM644X, GPIO3V, 0, 31, 1, 0, true)
  357. MUX_CFG(DM644X, GPIO0, 0, 24, 1, 0, true)
  358. MUX_CFG(DM644X, GPIO3, 0, 25, 1, 0, false)
  359. MUX_CFG(DM644X, GPIO43_44, 1, 7, 1, 0, false)
  360. MUX_CFG(DM644X, GPIO46_47, 0, 22, 1, 0, true)
  361. MUX_CFG(DM644X, RGB666, 0, 22, 1, 1, true)
  362. MUX_CFG(DM644X, LOEEN, 0, 24, 1, 1, true)
  363. MUX_CFG(DM644X, LFLDEN, 0, 25, 1, 1, false)
  364. #endif
  365. };
  366. /* FIQ are pri 0-1; otherwise 2-7, with 7 lowest priority */
  367. static u8 dm644x_default_priorities[DAVINCI_N_AINTC_IRQ] = {
  368. [IRQ_VDINT0] = 2,
  369. [IRQ_VDINT1] = 6,
  370. [IRQ_VDINT2] = 6,
  371. [IRQ_HISTINT] = 6,
  372. [IRQ_H3AINT] = 6,
  373. [IRQ_PRVUINT] = 6,
  374. [IRQ_RSZINT] = 6,
  375. [7] = 7,
  376. [IRQ_VENCINT] = 6,
  377. [IRQ_ASQINT] = 6,
  378. [IRQ_IMXINT] = 6,
  379. [IRQ_VLCDINT] = 6,
  380. [IRQ_USBINT] = 4,
  381. [IRQ_EMACINT] = 4,
  382. [14] = 7,
  383. [15] = 7,
  384. [IRQ_CCINT0] = 5, /* dma */
  385. [IRQ_CCERRINT] = 5, /* dma */
  386. [IRQ_TCERRINT0] = 5, /* dma */
  387. [IRQ_TCERRINT] = 5, /* dma */
  388. [IRQ_PSCIN] = 7,
  389. [21] = 7,
  390. [IRQ_IDE] = 4,
  391. [23] = 7,
  392. [IRQ_MBXINT] = 7,
  393. [IRQ_MBRINT] = 7,
  394. [IRQ_MMCINT] = 7,
  395. [IRQ_SDIOINT] = 7,
  396. [28] = 7,
  397. [IRQ_DDRINT] = 7,
  398. [IRQ_AEMIFINT] = 7,
  399. [IRQ_VLQINT] = 4,
  400. [IRQ_TINT0_TINT12] = 2, /* clockevent */
  401. [IRQ_TINT0_TINT34] = 2, /* clocksource */
  402. [IRQ_TINT1_TINT12] = 7, /* DSP timer */
  403. [IRQ_TINT1_TINT34] = 7, /* system tick */
  404. [IRQ_PWMINT0] = 7,
  405. [IRQ_PWMINT1] = 7,
  406. [IRQ_PWMINT2] = 7,
  407. [IRQ_I2C] = 3,
  408. [IRQ_UARTINT0] = 3,
  409. [IRQ_UARTINT1] = 3,
  410. [IRQ_UARTINT2] = 3,
  411. [IRQ_SPINT0] = 3,
  412. [IRQ_SPINT1] = 3,
  413. [45] = 7,
  414. [IRQ_DSP2ARM0] = 4,
  415. [IRQ_DSP2ARM1] = 4,
  416. [IRQ_GPIO0] = 7,
  417. [IRQ_GPIO1] = 7,
  418. [IRQ_GPIO2] = 7,
  419. [IRQ_GPIO3] = 7,
  420. [IRQ_GPIO4] = 7,
  421. [IRQ_GPIO5] = 7,
  422. [IRQ_GPIO6] = 7,
  423. [IRQ_GPIO7] = 7,
  424. [IRQ_GPIOBNK0] = 7,
  425. [IRQ_GPIOBNK1] = 7,
  426. [IRQ_GPIOBNK2] = 7,
  427. [IRQ_GPIOBNK3] = 7,
  428. [IRQ_GPIOBNK4] = 7,
  429. [IRQ_COMMTX] = 7,
  430. [IRQ_COMMRX] = 7,
  431. [IRQ_EMUINT] = 7,
  432. };
  433. /*----------------------------------------------------------------------*/
  434. static s8 queue_priority_mapping[][2] = {
  435. /* {event queue no, Priority} */
  436. {0, 3},
  437. {1, 7},
  438. {-1, -1},
  439. };
  440. static const struct dma_slave_map dm644x_edma_map[] = {
  441. { "davinci-mcbsp", "tx", EDMA_FILTER_PARAM(0, 2) },
  442. { "davinci-mcbsp", "rx", EDMA_FILTER_PARAM(0, 3) },
  443. { "spi_davinci", "tx", EDMA_FILTER_PARAM(0, 16) },
  444. { "spi_davinci", "rx", EDMA_FILTER_PARAM(0, 17) },
  445. { "dm6441-mmc.0", "rx", EDMA_FILTER_PARAM(0, 26) },
  446. { "dm6441-mmc.0", "tx", EDMA_FILTER_PARAM(0, 27) },
  447. };
  448. static struct edma_soc_info dm644x_edma_pdata = {
  449. .queue_priority_mapping = queue_priority_mapping,
  450. .default_queue = EVENTQ_1,
  451. .slave_map = dm644x_edma_map,
  452. .slavecnt = ARRAY_SIZE(dm644x_edma_map),
  453. };
  454. static struct resource edma_resources[] = {
  455. {
  456. .name = "edma3_cc",
  457. .start = 0x01c00000,
  458. .end = 0x01c00000 + SZ_64K - 1,
  459. .flags = IORESOURCE_MEM,
  460. },
  461. {
  462. .name = "edma3_tc0",
  463. .start = 0x01c10000,
  464. .end = 0x01c10000 + SZ_1K - 1,
  465. .flags = IORESOURCE_MEM,
  466. },
  467. {
  468. .name = "edma3_tc1",
  469. .start = 0x01c10400,
  470. .end = 0x01c10400 + SZ_1K - 1,
  471. .flags = IORESOURCE_MEM,
  472. },
  473. {
  474. .name = "edma3_ccint",
  475. .start = IRQ_CCINT0,
  476. .flags = IORESOURCE_IRQ,
  477. },
  478. {
  479. .name = "edma3_ccerrint",
  480. .start = IRQ_CCERRINT,
  481. .flags = IORESOURCE_IRQ,
  482. },
  483. /* not using TC*_ERR */
  484. };
  485. static const struct platform_device_info dm644x_edma_device __initconst = {
  486. .name = "edma",
  487. .id = 0,
  488. .dma_mask = DMA_BIT_MASK(32),
  489. .res = edma_resources,
  490. .num_res = ARRAY_SIZE(edma_resources),
  491. .data = &dm644x_edma_pdata,
  492. .size_data = sizeof(dm644x_edma_pdata),
  493. };
  494. /* DM6446 EVM uses ASP0; line-out is a pair of RCA jacks */
  495. static struct resource dm644x_asp_resources[] = {
  496. {
  497. .name = "mpu",
  498. .start = DAVINCI_ASP0_BASE,
  499. .end = DAVINCI_ASP0_BASE + SZ_8K - 1,
  500. .flags = IORESOURCE_MEM,
  501. },
  502. {
  503. .start = DAVINCI_DMA_ASP0_TX,
  504. .end = DAVINCI_DMA_ASP0_TX,
  505. .flags = IORESOURCE_DMA,
  506. },
  507. {
  508. .start = DAVINCI_DMA_ASP0_RX,
  509. .end = DAVINCI_DMA_ASP0_RX,
  510. .flags = IORESOURCE_DMA,
  511. },
  512. };
  513. static struct platform_device dm644x_asp_device = {
  514. .name = "davinci-mcbsp",
  515. .id = -1,
  516. .num_resources = ARRAY_SIZE(dm644x_asp_resources),
  517. .resource = dm644x_asp_resources,
  518. };
  519. #define DM644X_VPSS_BASE 0x01c73400
  520. static struct resource dm644x_vpss_resources[] = {
  521. {
  522. /* VPSS Base address */
  523. .name = "vpss",
  524. .start = DM644X_VPSS_BASE,
  525. .end = DM644X_VPSS_BASE + 0xff,
  526. .flags = IORESOURCE_MEM,
  527. },
  528. };
  529. static struct platform_device dm644x_vpss_device = {
  530. .name = "vpss",
  531. .id = -1,
  532. .dev.platform_data = "dm644x_vpss",
  533. .num_resources = ARRAY_SIZE(dm644x_vpss_resources),
  534. .resource = dm644x_vpss_resources,
  535. };
  536. static struct resource dm644x_vpfe_resources[] = {
  537. {
  538. .start = IRQ_VDINT0,
  539. .end = IRQ_VDINT0,
  540. .flags = IORESOURCE_IRQ,
  541. },
  542. {
  543. .start = IRQ_VDINT1,
  544. .end = IRQ_VDINT1,
  545. .flags = IORESOURCE_IRQ,
  546. },
  547. };
  548. static u64 dm644x_video_dma_mask = DMA_BIT_MASK(32);
  549. static struct resource dm644x_ccdc_resource[] = {
  550. /* CCDC Base address */
  551. {
  552. .start = 0x01c70400,
  553. .end = 0x01c70400 + 0xff,
  554. .flags = IORESOURCE_MEM,
  555. },
  556. };
  557. static struct platform_device dm644x_ccdc_dev = {
  558. .name = "dm644x_ccdc",
  559. .id = -1,
  560. .num_resources = ARRAY_SIZE(dm644x_ccdc_resource),
  561. .resource = dm644x_ccdc_resource,
  562. .dev = {
  563. .dma_mask = &dm644x_video_dma_mask,
  564. .coherent_dma_mask = DMA_BIT_MASK(32),
  565. },
  566. };
  567. static struct platform_device dm644x_vpfe_dev = {
  568. .name = CAPTURE_DRV_NAME,
  569. .id = -1,
  570. .num_resources = ARRAY_SIZE(dm644x_vpfe_resources),
  571. .resource = dm644x_vpfe_resources,
  572. .dev = {
  573. .dma_mask = &dm644x_video_dma_mask,
  574. .coherent_dma_mask = DMA_BIT_MASK(32),
  575. },
  576. };
  577. #define DM644X_OSD_BASE 0x01c72600
  578. static struct resource dm644x_osd_resources[] = {
  579. {
  580. .start = DM644X_OSD_BASE,
  581. .end = DM644X_OSD_BASE + 0x1ff,
  582. .flags = IORESOURCE_MEM,
  583. },
  584. };
  585. static struct platform_device dm644x_osd_dev = {
  586. .name = DM644X_VPBE_OSD_SUBDEV_NAME,
  587. .id = -1,
  588. .num_resources = ARRAY_SIZE(dm644x_osd_resources),
  589. .resource = dm644x_osd_resources,
  590. .dev = {
  591. .dma_mask = &dm644x_video_dma_mask,
  592. .coherent_dma_mask = DMA_BIT_MASK(32),
  593. },
  594. };
  595. #define DM644X_VENC_BASE 0x01c72400
  596. static struct resource dm644x_venc_resources[] = {
  597. {
  598. .start = DM644X_VENC_BASE,
  599. .end = DM644X_VENC_BASE + 0x17f,
  600. .flags = IORESOURCE_MEM,
  601. },
  602. };
  603. #define DM644X_VPSS_MUXSEL_PLL2_MODE BIT(0)
  604. #define DM644X_VPSS_MUXSEL_VPBECLK_MODE BIT(1)
  605. #define DM644X_VPSS_VENCLKEN BIT(3)
  606. #define DM644X_VPSS_DACCLKEN BIT(4)
  607. static int dm644x_venc_setup_clock(enum vpbe_enc_timings_type type,
  608. unsigned int pclock)
  609. {
  610. int ret = 0;
  611. u32 v = DM644X_VPSS_VENCLKEN;
  612. switch (type) {
  613. case VPBE_ENC_STD:
  614. v |= DM644X_VPSS_DACCLKEN;
  615. writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
  616. break;
  617. case VPBE_ENC_DV_TIMINGS:
  618. if (pclock <= 27000000) {
  619. v |= DM644X_VPSS_DACCLKEN;
  620. writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
  621. } else {
  622. /*
  623. * For HD, use external clock source since
  624. * HD requires higher clock rate
  625. */
  626. v |= DM644X_VPSS_MUXSEL_VPBECLK_MODE;
  627. writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
  628. }
  629. break;
  630. default:
  631. ret = -EINVAL;
  632. }
  633. return ret;
  634. }
  635. static struct resource dm644x_v4l2_disp_resources[] = {
  636. {
  637. .start = IRQ_VENCINT,
  638. .end = IRQ_VENCINT,
  639. .flags = IORESOURCE_IRQ,
  640. },
  641. };
  642. static struct platform_device dm644x_vpbe_display = {
  643. .name = "vpbe-v4l2",
  644. .id = -1,
  645. .num_resources = ARRAY_SIZE(dm644x_v4l2_disp_resources),
  646. .resource = dm644x_v4l2_disp_resources,
  647. .dev = {
  648. .dma_mask = &dm644x_video_dma_mask,
  649. .coherent_dma_mask = DMA_BIT_MASK(32),
  650. },
  651. };
  652. static struct venc_platform_data dm644x_venc_pdata = {
  653. .setup_clock = dm644x_venc_setup_clock,
  654. };
  655. static struct platform_device dm644x_venc_dev = {
  656. .name = DM644X_VPBE_VENC_SUBDEV_NAME,
  657. .id = -1,
  658. .num_resources = ARRAY_SIZE(dm644x_venc_resources),
  659. .resource = dm644x_venc_resources,
  660. .dev = {
  661. .dma_mask = &dm644x_video_dma_mask,
  662. .coherent_dma_mask = DMA_BIT_MASK(32),
  663. .platform_data = &dm644x_venc_pdata,
  664. },
  665. };
  666. static struct platform_device dm644x_vpbe_dev = {
  667. .name = "vpbe_controller",
  668. .id = -1,
  669. .dev = {
  670. .dma_mask = &dm644x_video_dma_mask,
  671. .coherent_dma_mask = DMA_BIT_MASK(32),
  672. },
  673. };
  674. static struct resource dm644_gpio_resources[] = {
  675. { /* registers */
  676. .start = DAVINCI_GPIO_BASE,
  677. .end = DAVINCI_GPIO_BASE + SZ_4K - 1,
  678. .flags = IORESOURCE_MEM,
  679. },
  680. { /* interrupt */
  681. .start = IRQ_GPIOBNK0,
  682. .end = IRQ_GPIOBNK4,
  683. .flags = IORESOURCE_IRQ,
  684. },
  685. };
  686. static struct davinci_gpio_platform_data dm644_gpio_platform_data = {
  687. .ngpio = 71,
  688. };
  689. int __init dm644x_gpio_register(void)
  690. {
  691. return davinci_gpio_register(dm644_gpio_resources,
  692. ARRAY_SIZE(dm644_gpio_resources),
  693. &dm644_gpio_platform_data);
  694. }
  695. /*----------------------------------------------------------------------*/
  696. static struct map_desc dm644x_io_desc[] = {
  697. {
  698. .virtual = IO_VIRT,
  699. .pfn = __phys_to_pfn(IO_PHYS),
  700. .length = IO_SIZE,
  701. .type = MT_DEVICE
  702. },
  703. };
  704. /* Contents of JTAG ID register used to identify exact cpu type */
  705. static struct davinci_id dm644x_ids[] = {
  706. {
  707. .variant = 0x0,
  708. .part_no = 0xb700,
  709. .manufacturer = 0x017,
  710. .cpu_id = DAVINCI_CPU_ID_DM6446,
  711. .name = "dm6446",
  712. },
  713. {
  714. .variant = 0x1,
  715. .part_no = 0xb700,
  716. .manufacturer = 0x017,
  717. .cpu_id = DAVINCI_CPU_ID_DM6446,
  718. .name = "dm6446a",
  719. },
  720. };
  721. static u32 dm644x_psc_bases[] = { DAVINCI_PWR_SLEEP_CNTRL_BASE };
  722. /*
  723. * T0_BOT: Timer 0, bottom: clockevent source for hrtimers
  724. * T0_TOP: Timer 0, top : clocksource for generic timekeeping
  725. * T1_BOT: Timer 1, bottom: (used by DSP in TI DSPLink code)
  726. * T1_TOP: Timer 1, top : <unused>
  727. */
  728. static struct davinci_timer_info dm644x_timer_info = {
  729. .timers = davinci_timer_instance,
  730. .clockevent_id = T0_BOT,
  731. .clocksource_id = T0_TOP,
  732. };
  733. static struct plat_serial8250_port dm644x_serial0_platform_data[] = {
  734. {
  735. .mapbase = DAVINCI_UART0_BASE,
  736. .irq = IRQ_UARTINT0,
  737. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  738. UPF_IOREMAP,
  739. .iotype = UPIO_MEM,
  740. .regshift = 2,
  741. },
  742. {
  743. .flags = 0,
  744. }
  745. };
  746. static struct plat_serial8250_port dm644x_serial1_platform_data[] = {
  747. {
  748. .mapbase = DAVINCI_UART1_BASE,
  749. .irq = IRQ_UARTINT1,
  750. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  751. UPF_IOREMAP,
  752. .iotype = UPIO_MEM,
  753. .regshift = 2,
  754. },
  755. {
  756. .flags = 0,
  757. }
  758. };
  759. static struct plat_serial8250_port dm644x_serial2_platform_data[] = {
  760. {
  761. .mapbase = DAVINCI_UART2_BASE,
  762. .irq = IRQ_UARTINT2,
  763. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  764. UPF_IOREMAP,
  765. .iotype = UPIO_MEM,
  766. .regshift = 2,
  767. },
  768. {
  769. .flags = 0,
  770. }
  771. };
  772. struct platform_device dm644x_serial_device[] = {
  773. {
  774. .name = "serial8250",
  775. .id = PLAT8250_DEV_PLATFORM,
  776. .dev = {
  777. .platform_data = dm644x_serial0_platform_data,
  778. }
  779. },
  780. {
  781. .name = "serial8250",
  782. .id = PLAT8250_DEV_PLATFORM1,
  783. .dev = {
  784. .platform_data = dm644x_serial1_platform_data,
  785. }
  786. },
  787. {
  788. .name = "serial8250",
  789. .id = PLAT8250_DEV_PLATFORM2,
  790. .dev = {
  791. .platform_data = dm644x_serial2_platform_data,
  792. }
  793. },
  794. {
  795. }
  796. };
  797. static struct davinci_soc_info davinci_soc_info_dm644x = {
  798. .io_desc = dm644x_io_desc,
  799. .io_desc_num = ARRAY_SIZE(dm644x_io_desc),
  800. .jtag_id_reg = 0x01c40028,
  801. .ids = dm644x_ids,
  802. .ids_num = ARRAY_SIZE(dm644x_ids),
  803. .cpu_clks = dm644x_clks,
  804. .psc_bases = dm644x_psc_bases,
  805. .psc_bases_num = ARRAY_SIZE(dm644x_psc_bases),
  806. .pinmux_base = DAVINCI_SYSTEM_MODULE_BASE,
  807. .pinmux_pins = dm644x_pins,
  808. .pinmux_pins_num = ARRAY_SIZE(dm644x_pins),
  809. .intc_base = DAVINCI_ARM_INTC_BASE,
  810. .intc_type = DAVINCI_INTC_TYPE_AINTC,
  811. .intc_irq_prios = dm644x_default_priorities,
  812. .intc_irq_num = DAVINCI_N_AINTC_IRQ,
  813. .timer_info = &dm644x_timer_info,
  814. .emac_pdata = &dm644x_emac_pdata,
  815. .sram_dma = 0x00008000,
  816. .sram_len = SZ_16K,
  817. };
  818. void __init dm644x_init_asp(void)
  819. {
  820. davinci_cfg_reg(DM644X_MCBSP);
  821. platform_device_register(&dm644x_asp_device);
  822. }
  823. void __init dm644x_init(void)
  824. {
  825. davinci_common_init(&davinci_soc_info_dm644x);
  826. davinci_map_sysmod();
  827. davinci_clk_init(davinci_soc_info_dm644x.cpu_clks);
  828. }
  829. int __init dm644x_init_video(struct vpfe_config *vpfe_cfg,
  830. struct vpbe_config *vpbe_cfg)
  831. {
  832. if (vpfe_cfg || vpbe_cfg)
  833. platform_device_register(&dm644x_vpss_device);
  834. if (vpfe_cfg) {
  835. dm644x_vpfe_dev.dev.platform_data = vpfe_cfg;
  836. platform_device_register(&dm644x_ccdc_dev);
  837. platform_device_register(&dm644x_vpfe_dev);
  838. }
  839. if (vpbe_cfg) {
  840. dm644x_vpbe_dev.dev.platform_data = vpbe_cfg;
  841. platform_device_register(&dm644x_osd_dev);
  842. platform_device_register(&dm644x_venc_dev);
  843. platform_device_register(&dm644x_vpbe_dev);
  844. platform_device_register(&dm644x_vpbe_display);
  845. }
  846. return 0;
  847. }
  848. static int __init dm644x_init_devices(void)
  849. {
  850. struct platform_device *edma_pdev;
  851. int ret = 0;
  852. if (!cpu_is_davinci_dm644x())
  853. return 0;
  854. edma_pdev = platform_device_register_full(&dm644x_edma_device);
  855. if (IS_ERR(edma_pdev)) {
  856. pr_warn("%s: Failed to register eDMA\n", __func__);
  857. return PTR_ERR(edma_pdev);
  858. }
  859. platform_device_register(&dm644x_mdio_device);
  860. platform_device_register(&dm644x_emac_device);
  861. ret = davinci_init_wdt();
  862. if (ret)
  863. pr_warn("%s: watchdog init failed: %d\n", __func__, ret);
  864. return ret;
  865. }
  866. postcore_initcall(dm644x_init_devices);