dm646x.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/clk.h>
  14. #include <linux/platform_device.h>
  15. #include <asm/mach/map.h>
  16. #include <mach/dm646x.h>
  17. #include <mach/clock.h>
  18. #include <mach/cputype.h>
  19. #include <mach/edma.h>
  20. #include <mach/irqs.h>
  21. #include <mach/psc.h>
  22. #include <mach/mux.h>
  23. #include <mach/common.h>
  24. #include "clock.h"
  25. #include "mux.h"
  26. /*
  27. * Device specific clocks
  28. */
  29. #define DM646X_REF_FREQ 27000000
  30. #define DM646X_AUX_FREQ 24000000
  31. static struct pll_data pll1_data = {
  32. .num = 1,
  33. .phys_base = DAVINCI_PLL1_BASE,
  34. };
  35. static struct pll_data pll2_data = {
  36. .num = 2,
  37. .phys_base = DAVINCI_PLL2_BASE,
  38. };
  39. static struct clk ref_clk = {
  40. .name = "ref_clk",
  41. .rate = DM646X_REF_FREQ,
  42. };
  43. static struct clk aux_clkin = {
  44. .name = "aux_clkin",
  45. .rate = DM646X_AUX_FREQ,
  46. };
  47. static struct clk pll1_clk = {
  48. .name = "pll1",
  49. .parent = &ref_clk,
  50. .pll_data = &pll1_data,
  51. .flags = CLK_PLL,
  52. };
  53. static struct clk pll1_sysclk1 = {
  54. .name = "pll1_sysclk1",
  55. .parent = &pll1_clk,
  56. .flags = CLK_PLL,
  57. .div_reg = PLLDIV1,
  58. };
  59. static struct clk pll1_sysclk2 = {
  60. .name = "pll1_sysclk2",
  61. .parent = &pll1_clk,
  62. .flags = CLK_PLL,
  63. .div_reg = PLLDIV2,
  64. };
  65. static struct clk pll1_sysclk3 = {
  66. .name = "pll1_sysclk3",
  67. .parent = &pll1_clk,
  68. .flags = CLK_PLL,
  69. .div_reg = PLLDIV3,
  70. };
  71. static struct clk pll1_sysclk4 = {
  72. .name = "pll1_sysclk4",
  73. .parent = &pll1_clk,
  74. .flags = CLK_PLL,
  75. .div_reg = PLLDIV4,
  76. };
  77. static struct clk pll1_sysclk5 = {
  78. .name = "pll1_sysclk5",
  79. .parent = &pll1_clk,
  80. .flags = CLK_PLL,
  81. .div_reg = PLLDIV5,
  82. };
  83. static struct clk pll1_sysclk6 = {
  84. .name = "pll1_sysclk6",
  85. .parent = &pll1_clk,
  86. .flags = CLK_PLL,
  87. .div_reg = PLLDIV6,
  88. };
  89. static struct clk pll1_sysclk8 = {
  90. .name = "pll1_sysclk8",
  91. .parent = &pll1_clk,
  92. .flags = CLK_PLL,
  93. .div_reg = PLLDIV8,
  94. };
  95. static struct clk pll1_sysclk9 = {
  96. .name = "pll1_sysclk9",
  97. .parent = &pll1_clk,
  98. .flags = CLK_PLL,
  99. .div_reg = PLLDIV9,
  100. };
  101. static struct clk pll1_sysclkbp = {
  102. .name = "pll1_sysclkbp",
  103. .parent = &pll1_clk,
  104. .flags = CLK_PLL | PRE_PLL,
  105. .div_reg = BPDIV,
  106. };
  107. static struct clk pll1_aux_clk = {
  108. .name = "pll1_aux_clk",
  109. .parent = &pll1_clk,
  110. .flags = CLK_PLL | PRE_PLL,
  111. };
  112. static struct clk pll2_clk = {
  113. .name = "pll2_clk",
  114. .parent = &ref_clk,
  115. .pll_data = &pll2_data,
  116. .flags = CLK_PLL,
  117. };
  118. static struct clk pll2_sysclk1 = {
  119. .name = "pll2_sysclk1",
  120. .parent = &pll2_clk,
  121. .flags = CLK_PLL,
  122. .div_reg = PLLDIV1,
  123. };
  124. static struct clk dsp_clk = {
  125. .name = "dsp",
  126. .parent = &pll1_sysclk1,
  127. .lpsc = DM646X_LPSC_C64X_CPU,
  128. .flags = PSC_DSP,
  129. .usecount = 1, /* REVISIT how to disable? */
  130. };
  131. static struct clk arm_clk = {
  132. .name = "arm",
  133. .parent = &pll1_sysclk2,
  134. .lpsc = DM646X_LPSC_ARM,
  135. .flags = ALWAYS_ENABLED,
  136. };
  137. static struct clk uart0_clk = {
  138. .name = "uart0",
  139. .parent = &aux_clkin,
  140. .lpsc = DM646X_LPSC_UART0,
  141. };
  142. static struct clk uart1_clk = {
  143. .name = "uart1",
  144. .parent = &aux_clkin,
  145. .lpsc = DM646X_LPSC_UART1,
  146. };
  147. static struct clk uart2_clk = {
  148. .name = "uart2",
  149. .parent = &aux_clkin,
  150. .lpsc = DM646X_LPSC_UART2,
  151. };
  152. static struct clk i2c_clk = {
  153. .name = "I2CCLK",
  154. .parent = &pll1_sysclk3,
  155. .lpsc = DM646X_LPSC_I2C,
  156. };
  157. static struct clk gpio_clk = {
  158. .name = "gpio",
  159. .parent = &pll1_sysclk3,
  160. .lpsc = DM646X_LPSC_GPIO,
  161. };
  162. static struct clk aemif_clk = {
  163. .name = "aemif",
  164. .parent = &pll1_sysclk3,
  165. .lpsc = DM646X_LPSC_AEMIF,
  166. .flags = ALWAYS_ENABLED,
  167. };
  168. static struct clk emac_clk = {
  169. .name = "emac",
  170. .parent = &pll1_sysclk3,
  171. .lpsc = DM646X_LPSC_EMAC,
  172. };
  173. static struct clk pwm0_clk = {
  174. .name = "pwm0",
  175. .parent = &pll1_sysclk3,
  176. .lpsc = DM646X_LPSC_PWM0,
  177. .usecount = 1, /* REVIST: disabling hangs system */
  178. };
  179. static struct clk pwm1_clk = {
  180. .name = "pwm1",
  181. .parent = &pll1_sysclk3,
  182. .lpsc = DM646X_LPSC_PWM1,
  183. .usecount = 1, /* REVIST: disabling hangs system */
  184. };
  185. static struct clk timer0_clk = {
  186. .name = "timer0",
  187. .parent = &pll1_sysclk3,
  188. .lpsc = DM646X_LPSC_TIMER0,
  189. };
  190. static struct clk timer1_clk = {
  191. .name = "timer1",
  192. .parent = &pll1_sysclk3,
  193. .lpsc = DM646X_LPSC_TIMER1,
  194. };
  195. static struct clk timer2_clk = {
  196. .name = "timer2",
  197. .parent = &pll1_sysclk3,
  198. .flags = ALWAYS_ENABLED, /* no LPSC, always enabled; c.f. spruep9a */
  199. };
  200. static struct clk vpif0_clk = {
  201. .name = "vpif0",
  202. .parent = &ref_clk,
  203. .lpsc = DM646X_LPSC_VPSSMSTR,
  204. .flags = ALWAYS_ENABLED,
  205. };
  206. static struct clk vpif1_clk = {
  207. .name = "vpif1",
  208. .parent = &ref_clk,
  209. .lpsc = DM646X_LPSC_VPSSSLV,
  210. .flags = ALWAYS_ENABLED,
  211. };
  212. struct davinci_clk dm646x_clks[] = {
  213. CLK(NULL, "ref", &ref_clk),
  214. CLK(NULL, "aux", &aux_clkin),
  215. CLK(NULL, "pll1", &pll1_clk),
  216. CLK(NULL, "pll1_sysclk", &pll1_sysclk1),
  217. CLK(NULL, "pll1_sysclk", &pll1_sysclk2),
  218. CLK(NULL, "pll1_sysclk", &pll1_sysclk3),
  219. CLK(NULL, "pll1_sysclk", &pll1_sysclk4),
  220. CLK(NULL, "pll1_sysclk", &pll1_sysclk5),
  221. CLK(NULL, "pll1_sysclk", &pll1_sysclk6),
  222. CLK(NULL, "pll1_sysclk", &pll1_sysclk8),
  223. CLK(NULL, "pll1_sysclk", &pll1_sysclk9),
  224. CLK(NULL, "pll1_sysclk", &pll1_sysclkbp),
  225. CLK(NULL, "pll1_aux", &pll1_aux_clk),
  226. CLK(NULL, "pll2", &pll2_clk),
  227. CLK(NULL, "pll2_sysclk1", &pll2_sysclk1),
  228. CLK(NULL, "dsp", &dsp_clk),
  229. CLK(NULL, "arm", &arm_clk),
  230. CLK(NULL, "uart0", &uart0_clk),
  231. CLK(NULL, "uart1", &uart1_clk),
  232. CLK(NULL, "uart2", &uart2_clk),
  233. CLK("i2c_davinci.1", NULL, &i2c_clk),
  234. CLK(NULL, "gpio", &gpio_clk),
  235. CLK(NULL, "aemif", &aemif_clk),
  236. CLK("davinci_emac.1", NULL, &emac_clk),
  237. CLK(NULL, "pwm0", &pwm0_clk),
  238. CLK(NULL, "pwm1", &pwm1_clk),
  239. CLK(NULL, "timer0", &timer0_clk),
  240. CLK(NULL, "timer1", &timer1_clk),
  241. CLK("watchdog", NULL, &timer2_clk),
  242. CLK(NULL, "vpif0", &vpif0_clk),
  243. CLK(NULL, "vpif1", &vpif1_clk),
  244. CLK(NULL, NULL, NULL),
  245. };
  246. #if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
  247. static struct resource dm646x_emac_resources[] = {
  248. {
  249. .start = DM646X_EMAC_BASE,
  250. .end = DM646X_EMAC_BASE + 0x47ff,
  251. .flags = IORESOURCE_MEM,
  252. },
  253. {
  254. .start = IRQ_DM646X_EMACRXTHINT,
  255. .end = IRQ_DM646X_EMACRXTHINT,
  256. .flags = IORESOURCE_IRQ,
  257. },
  258. {
  259. .start = IRQ_DM646X_EMACRXINT,
  260. .end = IRQ_DM646X_EMACRXINT,
  261. .flags = IORESOURCE_IRQ,
  262. },
  263. {
  264. .start = IRQ_DM646X_EMACTXINT,
  265. .end = IRQ_DM646X_EMACTXINT,
  266. .flags = IORESOURCE_IRQ,
  267. },
  268. {
  269. .start = IRQ_DM646X_EMACMISCINT,
  270. .end = IRQ_DM646X_EMACMISCINT,
  271. .flags = IORESOURCE_IRQ,
  272. },
  273. };
  274. static struct platform_device dm646x_emac_device = {
  275. .name = "davinci_emac",
  276. .id = 1,
  277. .num_resources = ARRAY_SIZE(dm646x_emac_resources),
  278. .resource = dm646x_emac_resources,
  279. };
  280. #endif
  281. /*
  282. * Device specific mux setup
  283. *
  284. * soc description mux mode mode mux dbg
  285. * reg offset mask mode
  286. */
  287. static const struct mux_config dm646x_pins[] = {
  288. #ifdef CONFIG_DAVINCI_MUX
  289. MUX_CFG(DM646X, ATAEN, 0, 0, 1, 1, true)
  290. MUX_CFG(DM646X, AUDCK1, 0, 29, 1, 0, false)
  291. MUX_CFG(DM646X, AUDCK0, 0, 28, 1, 0, false)
  292. MUX_CFG(DM646X, CRGMUX, 0, 24, 7, 5, true)
  293. MUX_CFG(DM646X, STSOMUX_DISABLE, 0, 22, 3, 0, true)
  294. MUX_CFG(DM646X, STSIMUX_DISABLE, 0, 20, 3, 0, true)
  295. MUX_CFG(DM646X, PTSOMUX_DISABLE, 0, 18, 3, 0, true)
  296. MUX_CFG(DM646X, PTSIMUX_DISABLE, 0, 16, 3, 0, true)
  297. MUX_CFG(DM646X, STSOMUX, 0, 22, 3, 2, true)
  298. MUX_CFG(DM646X, STSIMUX, 0, 20, 3, 2, true)
  299. MUX_CFG(DM646X, PTSOMUX_PARALLEL, 0, 18, 3, 2, true)
  300. MUX_CFG(DM646X, PTSIMUX_PARALLEL, 0, 16, 3, 2, true)
  301. MUX_CFG(DM646X, PTSOMUX_SERIAL, 0, 18, 3, 3, true)
  302. MUX_CFG(DM646X, PTSIMUX_SERIAL, 0, 16, 3, 3, true)
  303. #endif
  304. };
  305. /*----------------------------------------------------------------------*/
  306. static const s8 dma_chan_dm646x_no_event[] = {
  307. 0, 1, 2, 3, 13,
  308. 14, 15, 24, 25, 26,
  309. 27, 30, 31, 54, 55,
  310. 56,
  311. -1
  312. };
  313. static struct edma_soc_info dm646x_edma_info = {
  314. .n_channel = 64,
  315. .n_region = 6, /* 0-1, 4-7 */
  316. .n_slot = 512,
  317. .n_tc = 4,
  318. .noevent = dma_chan_dm646x_no_event,
  319. };
  320. static struct resource edma_resources[] = {
  321. {
  322. .name = "edma_cc",
  323. .start = 0x01c00000,
  324. .end = 0x01c00000 + SZ_64K - 1,
  325. .flags = IORESOURCE_MEM,
  326. },
  327. {
  328. .name = "edma_tc0",
  329. .start = 0x01c10000,
  330. .end = 0x01c10000 + SZ_1K - 1,
  331. .flags = IORESOURCE_MEM,
  332. },
  333. {
  334. .name = "edma_tc1",
  335. .start = 0x01c10400,
  336. .end = 0x01c10400 + SZ_1K - 1,
  337. .flags = IORESOURCE_MEM,
  338. },
  339. {
  340. .name = "edma_tc2",
  341. .start = 0x01c10800,
  342. .end = 0x01c10800 + SZ_1K - 1,
  343. .flags = IORESOURCE_MEM,
  344. },
  345. {
  346. .name = "edma_tc3",
  347. .start = 0x01c10c00,
  348. .end = 0x01c10c00 + SZ_1K - 1,
  349. .flags = IORESOURCE_MEM,
  350. },
  351. {
  352. .start = IRQ_CCINT0,
  353. .flags = IORESOURCE_IRQ,
  354. },
  355. {
  356. .start = IRQ_CCERRINT,
  357. .flags = IORESOURCE_IRQ,
  358. },
  359. /* not using TC*_ERR */
  360. };
  361. static struct platform_device dm646x_edma_device = {
  362. .name = "edma",
  363. .id = -1,
  364. .dev.platform_data = &dm646x_edma_info,
  365. .num_resources = ARRAY_SIZE(edma_resources),
  366. .resource = edma_resources,
  367. };
  368. /*----------------------------------------------------------------------*/
  369. #if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
  370. void dm646x_init_emac(struct emac_platform_data *pdata)
  371. {
  372. pdata->ctrl_reg_offset = DM646X_EMAC_CNTRL_OFFSET;
  373. pdata->ctrl_mod_reg_offset = DM646X_EMAC_CNTRL_MOD_OFFSET;
  374. pdata->ctrl_ram_offset = DM646X_EMAC_CNTRL_RAM_OFFSET;
  375. pdata->mdio_reg_offset = DM646X_EMAC_MDIO_OFFSET;
  376. pdata->ctrl_ram_size = DM646X_EMAC_CNTRL_RAM_SIZE;
  377. pdata->version = EMAC_VERSION_2;
  378. dm646x_emac_device.dev.platform_data = pdata;
  379. platform_device_register(&dm646x_emac_device);
  380. }
  381. #else
  382. void dm646x_init_emac(struct emac_platform_data *unused) {}
  383. #endif
  384. static struct map_desc dm646x_io_desc[] = {
  385. {
  386. .virtual = IO_VIRT,
  387. .pfn = __phys_to_pfn(IO_PHYS),
  388. .length = IO_SIZE,
  389. .type = MT_DEVICE
  390. },
  391. };
  392. /* Contents of JTAG ID register used to identify exact cpu type */
  393. static struct davinci_id dm646x_ids[] = {
  394. {
  395. .variant = 0x0,
  396. .part_no = 0xb770,
  397. .manufacturer = 0x017,
  398. .cpu_id = DAVINCI_CPU_ID_DM6467,
  399. .name = "dm6467",
  400. },
  401. };
  402. static void __iomem *dm646x_psc_bases[] = {
  403. IO_ADDRESS(DAVINCI_PWR_SLEEP_CNTRL_BASE),
  404. };
  405. static struct davinci_soc_info davinci_soc_info_dm646x = {
  406. .io_desc = dm646x_io_desc,
  407. .io_desc_num = ARRAY_SIZE(dm646x_io_desc),
  408. .jtag_id_base = IO_ADDRESS(0x01c40028),
  409. .ids = dm646x_ids,
  410. .ids_num = ARRAY_SIZE(dm646x_ids),
  411. .cpu_clks = dm646x_clks,
  412. .psc_bases = dm646x_psc_bases,
  413. .psc_bases_num = ARRAY_SIZE(dm646x_psc_bases),
  414. .pinmux_base = IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE),
  415. .pinmux_pins = dm646x_pins,
  416. .pinmux_pins_num = ARRAY_SIZE(dm646x_pins),
  417. };
  418. void __init dm646x_init(void)
  419. {
  420. davinci_common_init(&davinci_soc_info_dm646x);
  421. }
  422. static int __init dm646x_init_devices(void)
  423. {
  424. if (!cpu_is_davinci_dm646x())
  425. return 0;
  426. platform_device_register(&dm646x_edma_device);
  427. return 0;
  428. }
  429. postcore_initcall(dm646x_init_devices);