spear6xx.c 8.8 KB

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