spear3xx.c 11 KB

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