spear6xx.c 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. /*
  2. * arch/arm/mach-spear6xx/spear6xx.c
  3. *
  4. * SPEAr6XX machines common source file
  5. *
  6. * Copyright (C) 2009 ST Microelectronics
  7. * Rajeev Kumar<rajeev-dlh.kumar@st.com>
  8. *
  9. * Copyright 2012 Stefan Roese <sr@denx.de>
  10. *
  11. * This file is licensed under the terms of the GNU General Public
  12. * License version 2. This program is licensed "as is" without any
  13. * warranty of any kind, whether express or implied.
  14. */
  15. #include <linux/amba/pl08x.h>
  16. #include <linux/clk.h>
  17. #include <linux/err.h>
  18. #include <linux/of.h>
  19. #include <linux/of_address.h>
  20. #include <linux/of_irq.h>
  21. #include <linux/of_platform.h>
  22. #include <asm/hardware/pl080.h>
  23. #include <asm/hardware/vic.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/time.h>
  26. #include <asm/mach/map.h>
  27. #include <plat/pl080.h>
  28. #include <mach/generic.h>
  29. #include <mach/spear.h>
  30. /* dmac device registration */
  31. static struct pl08x_channel_data spear600_dma_info[] = {
  32. {
  33. .bus_id = "ssp1_rx",
  34. .min_signal = 0,
  35. .max_signal = 0,
  36. .muxval = 0,
  37. .periph_buses = PL08X_AHB1,
  38. }, {
  39. .bus_id = "ssp1_tx",
  40. .min_signal = 1,
  41. .max_signal = 1,
  42. .muxval = 0,
  43. .periph_buses = PL08X_AHB1,
  44. }, {
  45. .bus_id = "uart0_rx",
  46. .min_signal = 2,
  47. .max_signal = 2,
  48. .muxval = 0,
  49. .periph_buses = PL08X_AHB1,
  50. }, {
  51. .bus_id = "uart0_tx",
  52. .min_signal = 3,
  53. .max_signal = 3,
  54. .muxval = 0,
  55. .periph_buses = PL08X_AHB1,
  56. }, {
  57. .bus_id = "uart1_rx",
  58. .min_signal = 4,
  59. .max_signal = 4,
  60. .muxval = 0,
  61. .periph_buses = PL08X_AHB1,
  62. }, {
  63. .bus_id = "uart1_tx",
  64. .min_signal = 5,
  65. .max_signal = 5,
  66. .muxval = 0,
  67. .periph_buses = PL08X_AHB1,
  68. }, {
  69. .bus_id = "ssp2_rx",
  70. .min_signal = 6,
  71. .max_signal = 6,
  72. .muxval = 0,
  73. .periph_buses = PL08X_AHB2,
  74. }, {
  75. .bus_id = "ssp2_tx",
  76. .min_signal = 7,
  77. .max_signal = 7,
  78. .muxval = 0,
  79. .periph_buses = PL08X_AHB2,
  80. }, {
  81. .bus_id = "ssp0_rx",
  82. .min_signal = 8,
  83. .max_signal = 8,
  84. .muxval = 0,
  85. .periph_buses = PL08X_AHB1,
  86. }, {
  87. .bus_id = "ssp0_tx",
  88. .min_signal = 9,
  89. .max_signal = 9,
  90. .muxval = 0,
  91. .periph_buses = PL08X_AHB1,
  92. }, {
  93. .bus_id = "i2c_rx",
  94. .min_signal = 10,
  95. .max_signal = 10,
  96. .muxval = 0,
  97. .periph_buses = PL08X_AHB1,
  98. }, {
  99. .bus_id = "i2c_tx",
  100. .min_signal = 11,
  101. .max_signal = 11,
  102. .muxval = 0,
  103. .periph_buses = PL08X_AHB1,
  104. }, {
  105. .bus_id = "irda",
  106. .min_signal = 12,
  107. .max_signal = 12,
  108. .muxval = 0,
  109. .periph_buses = PL08X_AHB1,
  110. }, {
  111. .bus_id = "adc",
  112. .min_signal = 13,
  113. .max_signal = 13,
  114. .muxval = 0,
  115. .periph_buses = PL08X_AHB2,
  116. }, {
  117. .bus_id = "to_jpeg",
  118. .min_signal = 14,
  119. .max_signal = 14,
  120. .muxval = 0,
  121. .periph_buses = PL08X_AHB1,
  122. }, {
  123. .bus_id = "from_jpeg",
  124. .min_signal = 15,
  125. .max_signal = 15,
  126. .muxval = 0,
  127. .periph_buses = PL08X_AHB1,
  128. }, {
  129. .bus_id = "ras0_rx",
  130. .min_signal = 0,
  131. .max_signal = 0,
  132. .muxval = 1,
  133. .periph_buses = PL08X_AHB1,
  134. }, {
  135. .bus_id = "ras0_tx",
  136. .min_signal = 1,
  137. .max_signal = 1,
  138. .muxval = 1,
  139. .periph_buses = PL08X_AHB1,
  140. }, {
  141. .bus_id = "ras1_rx",
  142. .min_signal = 2,
  143. .max_signal = 2,
  144. .muxval = 1,
  145. .periph_buses = PL08X_AHB1,
  146. }, {
  147. .bus_id = "ras1_tx",
  148. .min_signal = 3,
  149. .max_signal = 3,
  150. .muxval = 1,
  151. .periph_buses = PL08X_AHB1,
  152. }, {
  153. .bus_id = "ras2_rx",
  154. .min_signal = 4,
  155. .max_signal = 4,
  156. .muxval = 1,
  157. .periph_buses = PL08X_AHB1,
  158. }, {
  159. .bus_id = "ras2_tx",
  160. .min_signal = 5,
  161. .max_signal = 5,
  162. .muxval = 1,
  163. .periph_buses = PL08X_AHB1,
  164. }, {
  165. .bus_id = "ras3_rx",
  166. .min_signal = 6,
  167. .max_signal = 6,
  168. .muxval = 1,
  169. .periph_buses = PL08X_AHB1,
  170. }, {
  171. .bus_id = "ras3_tx",
  172. .min_signal = 7,
  173. .max_signal = 7,
  174. .muxval = 1,
  175. .periph_buses = PL08X_AHB1,
  176. }, {
  177. .bus_id = "ras4_rx",
  178. .min_signal = 8,
  179. .max_signal = 8,
  180. .muxval = 1,
  181. .periph_buses = PL08X_AHB1,
  182. }, {
  183. .bus_id = "ras4_tx",
  184. .min_signal = 9,
  185. .max_signal = 9,
  186. .muxval = 1,
  187. .periph_buses = PL08X_AHB1,
  188. }, {
  189. .bus_id = "ras5_rx",
  190. .min_signal = 10,
  191. .max_signal = 10,
  192. .muxval = 1,
  193. .periph_buses = PL08X_AHB1,
  194. }, {
  195. .bus_id = "ras5_tx",
  196. .min_signal = 11,
  197. .max_signal = 11,
  198. .muxval = 1,
  199. .periph_buses = PL08X_AHB1,
  200. }, {
  201. .bus_id = "ras6_rx",
  202. .min_signal = 12,
  203. .max_signal = 12,
  204. .muxval = 1,
  205. .periph_buses = PL08X_AHB1,
  206. }, {
  207. .bus_id = "ras6_tx",
  208. .min_signal = 13,
  209. .max_signal = 13,
  210. .muxval = 1,
  211. .periph_buses = PL08X_AHB1,
  212. }, {
  213. .bus_id = "ras7_rx",
  214. .min_signal = 14,
  215. .max_signal = 14,
  216. .muxval = 1,
  217. .periph_buses = PL08X_AHB1,
  218. }, {
  219. .bus_id = "ras7_tx",
  220. .min_signal = 15,
  221. .max_signal = 15,
  222. .muxval = 1,
  223. .periph_buses = PL08X_AHB1,
  224. }, {
  225. .bus_id = "ext0_rx",
  226. .min_signal = 0,
  227. .max_signal = 0,
  228. .muxval = 2,
  229. .periph_buses = PL08X_AHB2,
  230. }, {
  231. .bus_id = "ext0_tx",
  232. .min_signal = 1,
  233. .max_signal = 1,
  234. .muxval = 2,
  235. .periph_buses = PL08X_AHB2,
  236. }, {
  237. .bus_id = "ext1_rx",
  238. .min_signal = 2,
  239. .max_signal = 2,
  240. .muxval = 2,
  241. .periph_buses = PL08X_AHB2,
  242. }, {
  243. .bus_id = "ext1_tx",
  244. .min_signal = 3,
  245. .max_signal = 3,
  246. .muxval = 2,
  247. .periph_buses = PL08X_AHB2,
  248. }, {
  249. .bus_id = "ext2_rx",
  250. .min_signal = 4,
  251. .max_signal = 4,
  252. .muxval = 2,
  253. .periph_buses = PL08X_AHB2,
  254. }, {
  255. .bus_id = "ext2_tx",
  256. .min_signal = 5,
  257. .max_signal = 5,
  258. .muxval = 2,
  259. .periph_buses = PL08X_AHB2,
  260. }, {
  261. .bus_id = "ext3_rx",
  262. .min_signal = 6,
  263. .max_signal = 6,
  264. .muxval = 2,
  265. .periph_buses = PL08X_AHB2,
  266. }, {
  267. .bus_id = "ext3_tx",
  268. .min_signal = 7,
  269. .max_signal = 7,
  270. .muxval = 2,
  271. .periph_buses = PL08X_AHB2,
  272. }, {
  273. .bus_id = "ext4_rx",
  274. .min_signal = 8,
  275. .max_signal = 8,
  276. .muxval = 2,
  277. .periph_buses = PL08X_AHB2,
  278. }, {
  279. .bus_id = "ext4_tx",
  280. .min_signal = 9,
  281. .max_signal = 9,
  282. .muxval = 2,
  283. .periph_buses = PL08X_AHB2,
  284. }, {
  285. .bus_id = "ext5_rx",
  286. .min_signal = 10,
  287. .max_signal = 10,
  288. .muxval = 2,
  289. .periph_buses = PL08X_AHB2,
  290. }, {
  291. .bus_id = "ext5_tx",
  292. .min_signal = 11,
  293. .max_signal = 11,
  294. .muxval = 2,
  295. .periph_buses = PL08X_AHB2,
  296. }, {
  297. .bus_id = "ext6_rx",
  298. .min_signal = 12,
  299. .max_signal = 12,
  300. .muxval = 2,
  301. .periph_buses = PL08X_AHB2,
  302. }, {
  303. .bus_id = "ext6_tx",
  304. .min_signal = 13,
  305. .max_signal = 13,
  306. .muxval = 2,
  307. .periph_buses = PL08X_AHB2,
  308. }, {
  309. .bus_id = "ext7_rx",
  310. .min_signal = 14,
  311. .max_signal = 14,
  312. .muxval = 2,
  313. .periph_buses = PL08X_AHB2,
  314. }, {
  315. .bus_id = "ext7_tx",
  316. .min_signal = 15,
  317. .max_signal = 15,
  318. .muxval = 2,
  319. .periph_buses = PL08X_AHB2,
  320. },
  321. };
  322. struct pl08x_platform_data pl080_plat_data = {
  323. .memcpy_channel = {
  324. .bus_id = "memcpy",
  325. .cctl_memcpy =
  326. (PL080_BSIZE_16 << PL080_CONTROL_SB_SIZE_SHIFT | \
  327. PL080_BSIZE_16 << PL080_CONTROL_DB_SIZE_SHIFT | \
  328. PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT | \
  329. PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT | \
  330. PL080_CONTROL_PROT_BUFF | PL080_CONTROL_PROT_CACHE | \
  331. PL080_CONTROL_PROT_SYS),
  332. },
  333. .lli_buses = PL08X_AHB1,
  334. .mem_buses = PL08X_AHB1,
  335. .get_signal = pl080_get_signal,
  336. .put_signal = pl080_put_signal,
  337. .slave_channels = spear600_dma_info,
  338. .num_slave_channels = ARRAY_SIZE(spear600_dma_info),
  339. };
  340. /*
  341. * Following will create 16MB static virtual/physical mappings
  342. * PHYSICAL VIRTUAL
  343. * 0xF0000000 0xF0000000
  344. * 0xF1000000 0xF1000000
  345. * 0xD0000000 0xFD000000
  346. * 0xFC000000 0xFC000000
  347. */
  348. struct map_desc spear6xx_io_desc[] __initdata = {
  349. {
  350. .virtual = VA_SPEAR6XX_ML_CPU_BASE,
  351. .pfn = __phys_to_pfn(SPEAR6XX_ML_CPU_BASE),
  352. .length = 2 * SZ_16M,
  353. .type = MT_DEVICE
  354. }, {
  355. .virtual = VA_SPEAR6XX_ICM1_BASE,
  356. .pfn = __phys_to_pfn(SPEAR6XX_ICM1_BASE),
  357. .length = SZ_16M,
  358. .type = MT_DEVICE
  359. }, {
  360. .virtual = VA_SPEAR6XX_ICM3_SMI_CTRL_BASE,
  361. .pfn = __phys_to_pfn(SPEAR6XX_ICM3_SMI_CTRL_BASE),
  362. .length = SZ_16M,
  363. .type = MT_DEVICE
  364. },
  365. };
  366. /* This will create static memory mapping for selected devices */
  367. void __init spear6xx_map_io(void)
  368. {
  369. iotable_init(spear6xx_io_desc, ARRAY_SIZE(spear6xx_io_desc));
  370. }
  371. static void __init spear6xx_timer_init(void)
  372. {
  373. char pclk_name[] = "pll3_clk";
  374. struct clk *gpt_clk, *pclk;
  375. spear6xx_clk_init();
  376. /* get the system timer clock */
  377. gpt_clk = clk_get_sys("gpt0", NULL);
  378. if (IS_ERR(gpt_clk)) {
  379. pr_err("%s:couldn't get clk for gpt\n", __func__);
  380. BUG();
  381. }
  382. /* get the suitable parent clock for timer*/
  383. pclk = clk_get(NULL, pclk_name);
  384. if (IS_ERR(pclk)) {
  385. pr_err("%s:couldn't get %s as parent for gpt\n",
  386. __func__, pclk_name);
  387. BUG();
  388. }
  389. clk_set_parent(gpt_clk, pclk);
  390. clk_put(gpt_clk);
  391. clk_put(pclk);
  392. spear_setup_of_timer();
  393. }
  394. struct sys_timer spear6xx_timer = {
  395. .init = spear6xx_timer_init,
  396. };
  397. /* Add auxdata to pass platform data */
  398. struct of_dev_auxdata spear6xx_auxdata_lookup[] __initdata = {
  399. OF_DEV_AUXDATA("arm,pl080", SPEAR6XX_ICM3_DMA_BASE, NULL,
  400. &pl080_plat_data),
  401. {}
  402. };
  403. static void __init spear600_dt_init(void)
  404. {
  405. of_platform_populate(NULL, of_default_bus_match_table,
  406. spear6xx_auxdata_lookup, NULL);
  407. }
  408. static const char *spear600_dt_board_compat[] = {
  409. "st,spear600",
  410. NULL
  411. };
  412. static const struct of_device_id vic_of_match[] __initconst = {
  413. { .compatible = "arm,pl190-vic", .data = vic_of_init, },
  414. { /* Sentinel */ }
  415. };
  416. static void __init spear6xx_dt_init_irq(void)
  417. {
  418. of_irq_init(vic_of_match);
  419. }
  420. DT_MACHINE_START(SPEAR600_DT, "ST SPEAr600 (Flattened Device Tree)")
  421. .map_io = spear6xx_map_io,
  422. .init_irq = spear6xx_dt_init_irq,
  423. .handle_irq = vic_handle_irq,
  424. .timer = &spear6xx_timer,
  425. .init_machine = spear600_dt_init,
  426. .restart = spear_restart,
  427. .dt_compat = spear600_dt_board_compat,
  428. MACHINE_END