spear3xx.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. /*
  2. * arch/arm/mach-spear3xx/spear3xx.c
  3. *
  4. * SPEAr3XX machines common source file
  5. *
  6. * Copyright (C) 2009 ST Microelectronics
  7. * Viresh Kumar<viresh.kumar@st.com>
  8. *
  9. * This file is licensed under the terms of the GNU General Public
  10. * License version 2. This program is licensed "as is" without any
  11. * warranty of any kind, whether express or implied.
  12. */
  13. #include <linux/types.h>
  14. #include <linux/amba/pl061.h>
  15. #include <linux/ptrace.h>
  16. #include <linux/io.h>
  17. #include <asm/hardware/vic.h>
  18. #include <asm/irq.h>
  19. #include <asm/mach/arch.h>
  20. #include <mach/generic.h>
  21. #include <mach/hardware.h>
  22. /* Add spear3xx machines common devices here */
  23. /* gpio device registration */
  24. static struct pl061_platform_data gpio_plat_data = {
  25. .gpio_base = 0,
  26. .irq_base = SPEAR3XX_GPIO_INT_BASE,
  27. };
  28. AMBA_APB_DEVICE(spear3xx_gpio, "gpio", 0, SPEAR3XX_ICM3_GPIO_BASE,
  29. {SPEAR3XX_IRQ_BASIC_GPIO}, &gpio_plat_data);
  30. /* uart device registration */
  31. AMBA_APB_DEVICE(spear3xx_uart, "uart", 0, SPEAR3XX_ICM1_UART_BASE,
  32. {SPEAR3XX_IRQ_UART}, NULL);
  33. /* Do spear3xx familiy common initialization part here */
  34. void __init spear3xx_init(void)
  35. {
  36. /* nothing to do for now */
  37. }
  38. /* This will initialize vic */
  39. void __init spear3xx_init_irq(void)
  40. {
  41. vic_init((void __iomem *)VA_SPEAR3XX_ML1_VIC_BASE, 0, ~0, 0);
  42. }
  43. /* Following will create static virtual/physical mappings */
  44. struct map_desc spear3xx_io_desc[] __initdata = {
  45. {
  46. .virtual = VA_SPEAR3XX_ICM1_UART_BASE,
  47. .pfn = __phys_to_pfn(SPEAR3XX_ICM1_UART_BASE),
  48. .length = SZ_4K,
  49. .type = MT_DEVICE
  50. }, {
  51. .virtual = VA_SPEAR3XX_ML1_VIC_BASE,
  52. .pfn = __phys_to_pfn(SPEAR3XX_ML1_VIC_BASE),
  53. .length = SZ_4K,
  54. .type = MT_DEVICE
  55. }, {
  56. .virtual = VA_SPEAR3XX_ICM3_SYS_CTRL_BASE,
  57. .pfn = __phys_to_pfn(SPEAR3XX_ICM3_SYS_CTRL_BASE),
  58. .length = SZ_4K,
  59. .type = MT_DEVICE
  60. }, {
  61. .virtual = VA_SPEAR3XX_ICM3_MISC_REG_BASE,
  62. .pfn = __phys_to_pfn(SPEAR3XX_ICM3_MISC_REG_BASE),
  63. .length = SZ_4K,
  64. .type = MT_DEVICE
  65. },
  66. };
  67. /* This will create static memory mapping for selected devices */
  68. void __init spear3xx_map_io(void)
  69. {
  70. iotable_init(spear3xx_io_desc, ARRAY_SIZE(spear3xx_io_desc));
  71. /* This will initialize clock framework */
  72. spear3xx_clk_init();
  73. }
  74. /* pad multiplexing support */
  75. /* devices */
  76. static struct pmx_dev_mode pmx_firda_modes[] = {
  77. {
  78. .ids = 0xffffffff,
  79. .mask = PMX_FIRDA_MASK,
  80. },
  81. };
  82. struct pmx_dev spear3xx_pmx_firda = {
  83. .name = "firda",
  84. .modes = pmx_firda_modes,
  85. .mode_count = ARRAY_SIZE(pmx_firda_modes),
  86. .enb_on_reset = 0,
  87. };
  88. static struct pmx_dev_mode pmx_i2c_modes[] = {
  89. {
  90. .ids = 0xffffffff,
  91. .mask = PMX_I2C_MASK,
  92. },
  93. };
  94. struct pmx_dev spear3xx_pmx_i2c = {
  95. .name = "i2c",
  96. .modes = pmx_i2c_modes,
  97. .mode_count = ARRAY_SIZE(pmx_i2c_modes),
  98. .enb_on_reset = 0,
  99. };
  100. static struct pmx_dev_mode pmx_ssp_cs_modes[] = {
  101. {
  102. .ids = 0xffffffff,
  103. .mask = PMX_SSP_CS_MASK,
  104. },
  105. };
  106. struct pmx_dev spear3xx_pmx_ssp_cs = {
  107. .name = "ssp_chip_selects",
  108. .modes = pmx_ssp_cs_modes,
  109. .mode_count = ARRAY_SIZE(pmx_ssp_cs_modes),
  110. .enb_on_reset = 0,
  111. };
  112. static struct pmx_dev_mode pmx_ssp_modes[] = {
  113. {
  114. .ids = 0xffffffff,
  115. .mask = PMX_SSP_MASK,
  116. },
  117. };
  118. struct pmx_dev spear3xx_pmx_ssp = {
  119. .name = "ssp",
  120. .modes = pmx_ssp_modes,
  121. .mode_count = ARRAY_SIZE(pmx_ssp_modes),
  122. .enb_on_reset = 0,
  123. };
  124. static struct pmx_dev_mode pmx_mii_modes[] = {
  125. {
  126. .ids = 0xffffffff,
  127. .mask = PMX_MII_MASK,
  128. },
  129. };
  130. struct pmx_dev spear3xx_pmx_mii = {
  131. .name = "mii",
  132. .modes = pmx_mii_modes,
  133. .mode_count = ARRAY_SIZE(pmx_mii_modes),
  134. .enb_on_reset = 0,
  135. };
  136. static struct pmx_dev_mode pmx_gpio_pin0_modes[] = {
  137. {
  138. .ids = 0xffffffff,
  139. .mask = PMX_GPIO_PIN0_MASK,
  140. },
  141. };
  142. struct pmx_dev spear3xx_pmx_gpio_pin0 = {
  143. .name = "gpio_pin0",
  144. .modes = pmx_gpio_pin0_modes,
  145. .mode_count = ARRAY_SIZE(pmx_gpio_pin0_modes),
  146. .enb_on_reset = 0,
  147. };
  148. static struct pmx_dev_mode pmx_gpio_pin1_modes[] = {
  149. {
  150. .ids = 0xffffffff,
  151. .mask = PMX_GPIO_PIN1_MASK,
  152. },
  153. };
  154. struct pmx_dev spear3xx_pmx_gpio_pin1 = {
  155. .name = "gpio_pin1",
  156. .modes = pmx_gpio_pin1_modes,
  157. .mode_count = ARRAY_SIZE(pmx_gpio_pin1_modes),
  158. .enb_on_reset = 0,
  159. };
  160. static struct pmx_dev_mode pmx_gpio_pin2_modes[] = {
  161. {
  162. .ids = 0xffffffff,
  163. .mask = PMX_GPIO_PIN2_MASK,
  164. },
  165. };
  166. struct pmx_dev spear3xx_pmx_gpio_pin2 = {
  167. .name = "gpio_pin2",
  168. .modes = pmx_gpio_pin2_modes,
  169. .mode_count = ARRAY_SIZE(pmx_gpio_pin2_modes),
  170. .enb_on_reset = 0,
  171. };
  172. static struct pmx_dev_mode pmx_gpio_pin3_modes[] = {
  173. {
  174. .ids = 0xffffffff,
  175. .mask = PMX_GPIO_PIN3_MASK,
  176. },
  177. };
  178. struct pmx_dev spear3xx_pmx_gpio_pin3 = {
  179. .name = "gpio_pin3",
  180. .modes = pmx_gpio_pin3_modes,
  181. .mode_count = ARRAY_SIZE(pmx_gpio_pin3_modes),
  182. .enb_on_reset = 0,
  183. };
  184. static struct pmx_dev_mode pmx_gpio_pin4_modes[] = {
  185. {
  186. .ids = 0xffffffff,
  187. .mask = PMX_GPIO_PIN4_MASK,
  188. },
  189. };
  190. struct pmx_dev spear3xx_pmx_gpio_pin4 = {
  191. .name = "gpio_pin4",
  192. .modes = pmx_gpio_pin4_modes,
  193. .mode_count = ARRAY_SIZE(pmx_gpio_pin4_modes),
  194. .enb_on_reset = 0,
  195. };
  196. static struct pmx_dev_mode pmx_gpio_pin5_modes[] = {
  197. {
  198. .ids = 0xffffffff,
  199. .mask = PMX_GPIO_PIN5_MASK,
  200. },
  201. };
  202. struct pmx_dev spear3xx_pmx_gpio_pin5 = {
  203. .name = "gpio_pin5",
  204. .modes = pmx_gpio_pin5_modes,
  205. .mode_count = ARRAY_SIZE(pmx_gpio_pin5_modes),
  206. .enb_on_reset = 0,
  207. };
  208. static struct pmx_dev_mode pmx_uart0_modem_modes[] = {
  209. {
  210. .ids = 0xffffffff,
  211. .mask = PMX_UART0_MODEM_MASK,
  212. },
  213. };
  214. struct pmx_dev spear3xx_pmx_uart0_modem = {
  215. .name = "uart0_modem",
  216. .modes = pmx_uart0_modem_modes,
  217. .mode_count = ARRAY_SIZE(pmx_uart0_modem_modes),
  218. .enb_on_reset = 0,
  219. };
  220. static struct pmx_dev_mode pmx_uart0_modes[] = {
  221. {
  222. .ids = 0xffffffff,
  223. .mask = PMX_UART0_MASK,
  224. },
  225. };
  226. struct pmx_dev spear3xx_pmx_uart0 = {
  227. .name = "uart0",
  228. .modes = pmx_uart0_modes,
  229. .mode_count = ARRAY_SIZE(pmx_uart0_modes),
  230. .enb_on_reset = 0,
  231. };
  232. static struct pmx_dev_mode pmx_timer_3_4_modes[] = {
  233. {
  234. .ids = 0xffffffff,
  235. .mask = PMX_TIMER_3_4_MASK,
  236. },
  237. };
  238. struct pmx_dev spear3xx_pmx_timer_3_4 = {
  239. .name = "timer_3_4",
  240. .modes = pmx_timer_3_4_modes,
  241. .mode_count = ARRAY_SIZE(pmx_timer_3_4_modes),
  242. .enb_on_reset = 0,
  243. };
  244. static struct pmx_dev_mode pmx_timer_1_2_modes[] = {
  245. {
  246. .ids = 0xffffffff,
  247. .mask = PMX_TIMER_1_2_MASK,
  248. },
  249. };
  250. struct pmx_dev spear3xx_pmx_timer_1_2 = {
  251. .name = "timer_1_2",
  252. .modes = pmx_timer_1_2_modes,
  253. .mode_count = ARRAY_SIZE(pmx_timer_1_2_modes),
  254. .enb_on_reset = 0,
  255. };
  256. #if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320)
  257. /* plgpios devices */
  258. static struct pmx_dev_mode pmx_plgpio_0_1_modes[] = {
  259. {
  260. .ids = 0x00,
  261. .mask = PMX_FIRDA_MASK,
  262. },
  263. };
  264. struct pmx_dev spear3xx_pmx_plgpio_0_1 = {
  265. .name = "plgpio 0 and 1",
  266. .modes = pmx_plgpio_0_1_modes,
  267. .mode_count = ARRAY_SIZE(pmx_plgpio_0_1_modes),
  268. .enb_on_reset = 1,
  269. };
  270. static struct pmx_dev_mode pmx_plgpio_2_3_modes[] = {
  271. {
  272. .ids = 0x00,
  273. .mask = PMX_UART0_MASK,
  274. },
  275. };
  276. struct pmx_dev spear3xx_pmx_plgpio_2_3 = {
  277. .name = "plgpio 2 and 3",
  278. .modes = pmx_plgpio_2_3_modes,
  279. .mode_count = ARRAY_SIZE(pmx_plgpio_2_3_modes),
  280. .enb_on_reset = 1,
  281. };
  282. static struct pmx_dev_mode pmx_plgpio_4_5_modes[] = {
  283. {
  284. .ids = 0x00,
  285. .mask = PMX_I2C_MASK,
  286. },
  287. };
  288. struct pmx_dev spear3xx_pmx_plgpio_4_5 = {
  289. .name = "plgpio 4 and 5",
  290. .modes = pmx_plgpio_4_5_modes,
  291. .mode_count = ARRAY_SIZE(pmx_plgpio_4_5_modes),
  292. .enb_on_reset = 1,
  293. };
  294. static struct pmx_dev_mode pmx_plgpio_6_9_modes[] = {
  295. {
  296. .ids = 0x00,
  297. .mask = PMX_SSP_MASK,
  298. },
  299. };
  300. struct pmx_dev spear3xx_pmx_plgpio_6_9 = {
  301. .name = "plgpio 6 to 9",
  302. .modes = pmx_plgpio_6_9_modes,
  303. .mode_count = ARRAY_SIZE(pmx_plgpio_6_9_modes),
  304. .enb_on_reset = 1,
  305. };
  306. static struct pmx_dev_mode pmx_plgpio_10_27_modes[] = {
  307. {
  308. .ids = 0x00,
  309. .mask = PMX_MII_MASK,
  310. },
  311. };
  312. struct pmx_dev spear3xx_pmx_plgpio_10_27 = {
  313. .name = "plgpio 10 to 27",
  314. .modes = pmx_plgpio_10_27_modes,
  315. .mode_count = ARRAY_SIZE(pmx_plgpio_10_27_modes),
  316. .enb_on_reset = 1,
  317. };
  318. static struct pmx_dev_mode pmx_plgpio_28_modes[] = {
  319. {
  320. .ids = 0x00,
  321. .mask = PMX_GPIO_PIN0_MASK,
  322. },
  323. };
  324. struct pmx_dev spear3xx_pmx_plgpio_28 = {
  325. .name = "plgpio 28",
  326. .modes = pmx_plgpio_28_modes,
  327. .mode_count = ARRAY_SIZE(pmx_plgpio_28_modes),
  328. .enb_on_reset = 1,
  329. };
  330. static struct pmx_dev_mode pmx_plgpio_29_modes[] = {
  331. {
  332. .ids = 0x00,
  333. .mask = PMX_GPIO_PIN1_MASK,
  334. },
  335. };
  336. struct pmx_dev spear3xx_pmx_plgpio_29 = {
  337. .name = "plgpio 29",
  338. .modes = pmx_plgpio_29_modes,
  339. .mode_count = ARRAY_SIZE(pmx_plgpio_29_modes),
  340. .enb_on_reset = 1,
  341. };
  342. static struct pmx_dev_mode pmx_plgpio_30_modes[] = {
  343. {
  344. .ids = 0x00,
  345. .mask = PMX_GPIO_PIN2_MASK,
  346. },
  347. };
  348. struct pmx_dev spear3xx_pmx_plgpio_30 = {
  349. .name = "plgpio 30",
  350. .modes = pmx_plgpio_30_modes,
  351. .mode_count = ARRAY_SIZE(pmx_plgpio_30_modes),
  352. .enb_on_reset = 1,
  353. };
  354. static struct pmx_dev_mode pmx_plgpio_31_modes[] = {
  355. {
  356. .ids = 0x00,
  357. .mask = PMX_GPIO_PIN3_MASK,
  358. },
  359. };
  360. struct pmx_dev spear3xx_pmx_plgpio_31 = {
  361. .name = "plgpio 31",
  362. .modes = pmx_plgpio_31_modes,
  363. .mode_count = ARRAY_SIZE(pmx_plgpio_31_modes),
  364. .enb_on_reset = 1,
  365. };
  366. static struct pmx_dev_mode pmx_plgpio_32_modes[] = {
  367. {
  368. .ids = 0x00,
  369. .mask = PMX_GPIO_PIN4_MASK,
  370. },
  371. };
  372. struct pmx_dev spear3xx_pmx_plgpio_32 = {
  373. .name = "plgpio 32",
  374. .modes = pmx_plgpio_32_modes,
  375. .mode_count = ARRAY_SIZE(pmx_plgpio_32_modes),
  376. .enb_on_reset = 1,
  377. };
  378. static struct pmx_dev_mode pmx_plgpio_33_modes[] = {
  379. {
  380. .ids = 0x00,
  381. .mask = PMX_GPIO_PIN5_MASK,
  382. },
  383. };
  384. struct pmx_dev spear3xx_pmx_plgpio_33 = {
  385. .name = "plgpio 33",
  386. .modes = pmx_plgpio_33_modes,
  387. .mode_count = ARRAY_SIZE(pmx_plgpio_33_modes),
  388. .enb_on_reset = 1,
  389. };
  390. static struct pmx_dev_mode pmx_plgpio_34_36_modes[] = {
  391. {
  392. .ids = 0x00,
  393. .mask = PMX_SSP_CS_MASK,
  394. },
  395. };
  396. struct pmx_dev spear3xx_pmx_plgpio_34_36 = {
  397. .name = "plgpio 34 to 36",
  398. .modes = pmx_plgpio_34_36_modes,
  399. .mode_count = ARRAY_SIZE(pmx_plgpio_34_36_modes),
  400. .enb_on_reset = 1,
  401. };
  402. static struct pmx_dev_mode pmx_plgpio_37_42_modes[] = {
  403. {
  404. .ids = 0x00,
  405. .mask = PMX_UART0_MODEM_MASK,
  406. },
  407. };
  408. struct pmx_dev spear3xx_pmx_plgpio_37_42 = {
  409. .name = "plgpio 37 to 42",
  410. .modes = pmx_plgpio_37_42_modes,
  411. .mode_count = ARRAY_SIZE(pmx_plgpio_37_42_modes),
  412. .enb_on_reset = 1,
  413. };
  414. static struct pmx_dev_mode pmx_plgpio_43_44_47_48_modes[] = {
  415. {
  416. .ids = 0x00,
  417. .mask = PMX_TIMER_1_2_MASK,
  418. },
  419. };
  420. struct pmx_dev spear3xx_pmx_plgpio_43_44_47_48 = {
  421. .name = "plgpio 43, 44, 47 and 48",
  422. .modes = pmx_plgpio_43_44_47_48_modes,
  423. .mode_count = ARRAY_SIZE(pmx_plgpio_43_44_47_48_modes),
  424. .enb_on_reset = 1,
  425. };
  426. static struct pmx_dev_mode pmx_plgpio_45_46_49_50_modes[] = {
  427. {
  428. .ids = 0x00,
  429. .mask = PMX_TIMER_3_4_MASK,
  430. },
  431. };
  432. struct pmx_dev spear3xx_pmx_plgpio_45_46_49_50 = {
  433. .name = "plgpio 45, 46, 49 and 50",
  434. .modes = pmx_plgpio_45_46_49_50_modes,
  435. .mode_count = ARRAY_SIZE(pmx_plgpio_45_46_49_50_modes),
  436. .enb_on_reset = 1,
  437. };
  438. #endif /* CONFIG_MACH_SPEAR310 || CONFIG_MACH_SPEAR320 */
  439. static void __init spear3xx_timer_init(void)
  440. {
  441. char pclk_name[] = "pll3_48m_clk";
  442. struct clk *gpt_clk, *pclk;
  443. /* get the system timer clock */
  444. gpt_clk = clk_get_sys("gpt0", NULL);
  445. if (IS_ERR(gpt_clk)) {
  446. pr_err("%s:couldn't get clk for gpt\n", __func__);
  447. BUG();
  448. }
  449. /* get the suitable parent clock for timer*/
  450. pclk = clk_get(NULL, pclk_name);
  451. if (IS_ERR(pclk)) {
  452. pr_err("%s:couldn't get %s as parent for gpt\n",
  453. __func__, pclk_name);
  454. BUG();
  455. }
  456. clk_set_parent(gpt_clk, pclk);
  457. clk_put(gpt_clk);
  458. clk_put(pclk);
  459. spear_setup_timer();
  460. }
  461. struct sys_timer spear3xx_timer = {
  462. .init = spear3xx_timer_init,
  463. };