spear3xx.c 11 KB

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