board-fsm9900-gpiomux.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. /* Copyright (c) 2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #include <linux/gpio.h>
  14. #include <linux/init.h>
  15. #include <linux/ioport.h>
  16. #include <mach/board.h>
  17. #include <mach/gpiomux.h>
  18. static struct gpiomux_setting blsp_uart_no_pull_config = {
  19. .func = GPIOMUX_FUNC_2,
  20. .drv = GPIOMUX_DRV_6MA,
  21. .pull = GPIOMUX_PULL_NONE,
  22. };
  23. static struct gpiomux_setting blsp_uart_pull_up_config = {
  24. .func = GPIOMUX_FUNC_2,
  25. .drv = GPIOMUX_DRV_6MA,
  26. .pull = GPIOMUX_PULL_UP,
  27. };
  28. static struct gpiomux_setting blsp_i2c_config = {
  29. .func = GPIOMUX_FUNC_3,
  30. .drv = GPIOMUX_DRV_6MA,
  31. .pull = GPIOMUX_PULL_UP,
  32. };
  33. static struct msm_gpiomux_config fsm_blsp_configs[] __initdata = {
  34. {
  35. .gpio = 0, /* BLSP UART1 TX */
  36. .settings = {
  37. [GPIOMUX_SUSPENDED] = &blsp_uart_no_pull_config,
  38. },
  39. },
  40. {
  41. .gpio = 1, /* BLSP UART1 RX */
  42. .settings = {
  43. [GPIOMUX_SUSPENDED] = &blsp_uart_pull_up_config,
  44. },
  45. },
  46. {
  47. .gpio = 2, /* BLSP I2C SDA */
  48. .settings = {
  49. [GPIOMUX_SUSPENDED] = &blsp_i2c_config,
  50. },
  51. },
  52. {
  53. .gpio = 3, /* BLSP I2C SCL */
  54. .settings = {
  55. [GPIOMUX_SUSPENDED] = &blsp_i2c_config,
  56. },
  57. },
  58. {
  59. .gpio = 6, /* BLSP I2C SDA */
  60. .settings = {
  61. [GPIOMUX_SUSPENDED] = &blsp_i2c_config,
  62. },
  63. },
  64. {
  65. .gpio = 7, /* BLSP I2C SCL */
  66. .settings = {
  67. [GPIOMUX_SUSPENDED] = &blsp_i2c_config,
  68. },
  69. },
  70. {
  71. .gpio = 36, /* BLSP UART10 TX */
  72. .settings = {
  73. [GPIOMUX_SUSPENDED] = &blsp_uart_no_pull_config,
  74. },
  75. },
  76. {
  77. .gpio = 37, /* BLSP UART10 RX */
  78. .settings = {
  79. [GPIOMUX_SUSPENDED] = &blsp_uart_pull_up_config,
  80. },
  81. },
  82. {
  83. .gpio = 38, /* BLSP I2C10 SDA */
  84. .settings = {
  85. [GPIOMUX_SUSPENDED] = &blsp_i2c_config,
  86. },
  87. },
  88. {
  89. .gpio = 39, /* BLSP I2C10 SCL */
  90. .settings = {
  91. [GPIOMUX_SUSPENDED] = &blsp_i2c_config,
  92. },
  93. },
  94. };
  95. static struct gpiomux_setting geni_func4_config = {
  96. .func = GPIOMUX_FUNC_4,
  97. .drv = GPIOMUX_DRV_8MA,
  98. .pull = GPIOMUX_PULL_DOWN,
  99. };
  100. static struct gpiomux_setting geni_func5_config = {
  101. .func = GPIOMUX_FUNC_5,
  102. .drv = GPIOMUX_DRV_8MA,
  103. .pull = GPIOMUX_PULL_DOWN,
  104. };
  105. static struct msm_gpiomux_config fsm_geni_configs[] __initdata = {
  106. {
  107. .gpio = 8, /* GENI7 DATA */
  108. .settings = {
  109. [GPIOMUX_SUSPENDED] = &geni_func4_config,
  110. },
  111. },
  112. {
  113. .gpio = 9, /* GENI1 DATA */
  114. .settings = {
  115. [GPIOMUX_SUSPENDED] = &geni_func4_config,
  116. },
  117. },
  118. {
  119. .gpio = 10, /* GENI2 DATA */
  120. .settings = {
  121. [GPIOMUX_SUSPENDED] = &geni_func4_config,
  122. },
  123. },
  124. {
  125. .gpio = 11, /* GENI7 CLK */
  126. .settings = {
  127. [GPIOMUX_SUSPENDED] = &geni_func4_config,
  128. },
  129. },
  130. {
  131. .gpio = 20, /* GENI3 DATA */
  132. .settings = {
  133. [GPIOMUX_SUSPENDED] = &geni_func5_config,
  134. },
  135. },
  136. {
  137. .gpio = 21, /* GENI4 DATA */
  138. .settings = {
  139. [GPIOMUX_SUSPENDED] = &geni_func5_config,
  140. },
  141. },
  142. {
  143. .gpio = 22, /* GENI6 DATA */
  144. .settings = {
  145. [GPIOMUX_SUSPENDED] = &geni_func5_config,
  146. },
  147. },
  148. {
  149. .gpio = 23, /* GENI6 CLK */
  150. .settings = {
  151. [GPIOMUX_SUSPENDED] = &geni_func5_config,
  152. },
  153. },
  154. {
  155. .gpio = 30, /* GENI5 DATA */
  156. .settings = {
  157. [GPIOMUX_SUSPENDED] = &geni_func4_config,
  158. },
  159. },
  160. {
  161. .gpio = 31, /* GENI5 CLK */
  162. .settings = {
  163. [GPIOMUX_SUSPENDED] = &geni_func4_config,
  164. },
  165. },
  166. };
  167. static struct gpiomux_setting dan_spi_func4_config = {
  168. .func = GPIOMUX_FUNC_4,
  169. .drv = GPIOMUX_DRV_8MA,
  170. .pull = GPIOMUX_PULL_UP,
  171. };
  172. static struct gpiomux_setting dan_spi_func1_config = {
  173. .func = GPIOMUX_FUNC_1,
  174. .drv = GPIOMUX_DRV_8MA,
  175. .pull = GPIOMUX_PULL_UP,
  176. };
  177. static struct msm_gpiomux_config fsm_dan_spi_configs[] __initdata = {
  178. {
  179. .gpio = 12, /* BLSP DAN0 SPI_MOSI */
  180. .settings = {
  181. [GPIOMUX_SUSPENDED] = &dan_spi_func4_config,
  182. },
  183. },
  184. {
  185. .gpio = 13, /* BLSP DAN0 SPI_MISO */
  186. .settings = {
  187. [GPIOMUX_SUSPENDED] = &dan_spi_func4_config,
  188. },
  189. },
  190. {
  191. .gpio = 14, /* BLSP DAN0 SPI_CS */
  192. .settings = {
  193. [GPIOMUX_SUSPENDED] = &dan_spi_func4_config,
  194. },
  195. },
  196. {
  197. .gpio = 15, /* BLSP DAN0 SPI_CLK */
  198. .settings = {
  199. [GPIOMUX_SUSPENDED] = &dan_spi_func4_config,
  200. },
  201. },
  202. {
  203. .gpio = 16, /* BLSP DAN1 SPI_MOSI */
  204. .settings = {
  205. [GPIOMUX_SUSPENDED] = &dan_spi_func4_config,
  206. },
  207. },
  208. {
  209. .gpio = 17, /* BLSP DAN1 SPI_MISO */
  210. .settings = {
  211. [GPIOMUX_SUSPENDED] = &dan_spi_func4_config,
  212. },
  213. },
  214. {
  215. .gpio = 18, /* BLSP DAN1 SPI_CS */
  216. .settings = {
  217. [GPIOMUX_SUSPENDED] = &dan_spi_func4_config,
  218. },
  219. },
  220. {
  221. .gpio = 19, /* BLSP DAN1 SPI_CLK */
  222. .settings = {
  223. [GPIOMUX_SUSPENDED] = &dan_spi_func4_config,
  224. },
  225. },
  226. {
  227. .gpio = 81, /* BLSP DAN1 SPI_CS0 */
  228. .settings = {
  229. [GPIOMUX_SUSPENDED] = &dan_spi_func1_config,
  230. },
  231. },
  232. {
  233. .gpio = 82, /* BLSP DAN1 SPI_CS1 */
  234. .settings = {
  235. [GPIOMUX_SUSPENDED] = &dan_spi_func1_config,
  236. },
  237. },
  238. };
  239. static struct gpiomux_setting uim_config = {
  240. .func = GPIOMUX_FUNC_1,
  241. .drv = GPIOMUX_DRV_4MA,
  242. .pull = GPIOMUX_PULL_UP,
  243. };
  244. static struct msm_gpiomux_config fsm_uim_configs[] __initdata = {
  245. {
  246. .gpio = 24, /* UIM_DATA */
  247. .settings = {
  248. [GPIOMUX_SUSPENDED] = &uim_config,
  249. },
  250. },
  251. {
  252. .gpio = 25, /* UIM_CLK */
  253. .settings = {
  254. [GPIOMUX_SUSPENDED] = &uim_config,
  255. },
  256. },
  257. {
  258. .gpio = 26, /* UIM_RESET */
  259. .settings = {
  260. [GPIOMUX_SUSPENDED] = &uim_config,
  261. },
  262. },
  263. {
  264. .gpio = 27, /* UIM_PRESENT */
  265. .settings = {
  266. [GPIOMUX_SUSPENDED] = &uim_config,
  267. },
  268. },
  269. };
  270. static struct gpiomux_setting pcie_config = {
  271. .func = GPIOMUX_FUNC_4,
  272. .drv = GPIOMUX_DRV_8MA,
  273. .pull = GPIOMUX_PULL_UP,
  274. };
  275. static struct msm_gpiomux_config fsm_pcie_configs[] __initdata = {
  276. {
  277. .gpio = 28, /* BLSP PCIE1_CLK */
  278. .settings = {
  279. [GPIOMUX_SUSPENDED] = &pcie_config,
  280. },
  281. },
  282. {
  283. .gpio = 32, /* BLSP PCIE0_CLK */
  284. .settings = {
  285. [GPIOMUX_SUSPENDED] = &pcie_config,
  286. },
  287. },
  288. };
  289. static struct gpiomux_setting pps_out_config = {
  290. .func = GPIOMUX_FUNC_1,
  291. .drv = GPIOMUX_DRV_4MA,
  292. .pull = GPIOMUX_PULL_NONE,
  293. };
  294. static struct gpiomux_setting pps_in_config = {
  295. .func = GPIOMUX_FUNC_1,
  296. .drv = GPIOMUX_DRV_2MA,
  297. .pull = GPIOMUX_PULL_DOWN,
  298. };
  299. static struct gpiomux_setting gps_clk_in_config = {
  300. .func = GPIOMUX_FUNC_1,
  301. .drv = GPIOMUX_DRV_2MA,
  302. .pull = GPIOMUX_PULL_DOWN,
  303. };
  304. static struct gpiomux_setting gps_nav_tlmm_blank_config = {
  305. .func = GPIOMUX_FUNC_2,
  306. .drv = GPIOMUX_DRV_2MA,
  307. .pull = GPIOMUX_PULL_DOWN,
  308. };
  309. static struct msm_gpiomux_config fsm_gps_configs[] __initdata = {
  310. {
  311. .gpio = 40, /* GPS_PPS_OUT */
  312. .settings = {
  313. [GPIOMUX_SUSPENDED] = &pps_out_config,
  314. },
  315. },
  316. {
  317. .gpio = 41, /* GPS_PPS_IN */
  318. .settings = {
  319. [GPIOMUX_SUSPENDED] = &pps_in_config,
  320. },
  321. },
  322. {
  323. .gpio = 43, /* GPS_CLK_IN */
  324. .settings = {
  325. [GPIOMUX_SUSPENDED] = &gps_clk_in_config,
  326. },
  327. },
  328. {
  329. .gpio = 120, /* GPS_NAV_TLMM_BLANK */
  330. .settings = {
  331. [GPIOMUX_SUSPENDED] = &gps_nav_tlmm_blank_config,
  332. },
  333. },
  334. };
  335. static struct gpiomux_setting sd_detect_config = {
  336. .func = GPIOMUX_FUNC_GPIO,
  337. .drv = GPIOMUX_DRV_2MA,
  338. .pull = GPIOMUX_PULL_UP,
  339. };
  340. static struct gpiomux_setting sd_wp_config = {
  341. .func = GPIOMUX_FUNC_GPIO,
  342. .drv = GPIOMUX_DRV_6MA,
  343. .pull = GPIOMUX_PULL_UP,
  344. };
  345. static struct msm_gpiomux_config fsm_sd_configs[] __initdata = {
  346. {
  347. .gpio = 42, /* SD_CARD_DET */
  348. .settings = {
  349. [GPIOMUX_SUSPENDED] = &sd_detect_config,
  350. },
  351. },
  352. {
  353. .gpio = 122, /* BLSP SD WRITE PROTECT */
  354. .settings = {
  355. [GPIOMUX_SUSPENDED] = &sd_wp_config,
  356. },
  357. },
  358. };
  359. void __init fsm9900_init_gpiomux(void)
  360. {
  361. int rc;
  362. rc = msm_gpiomux_init_dt();
  363. if (rc) {
  364. pr_err("%s failed %d\n", __func__, rc);
  365. return;
  366. }
  367. msm_gpiomux_install(fsm_blsp_configs, ARRAY_SIZE(fsm_blsp_configs));
  368. msm_gpiomux_install(fsm_geni_configs, ARRAY_SIZE(fsm_geni_configs));
  369. msm_gpiomux_install(fsm_dan_spi_configs,
  370. ARRAY_SIZE(fsm_dan_spi_configs));
  371. msm_gpiomux_install(fsm_uim_configs, ARRAY_SIZE(fsm_uim_configs));
  372. msm_gpiomux_install(fsm_pcie_configs, ARRAY_SIZE(fsm_pcie_configs));
  373. msm_gpiomux_install(fsm_gps_configs, ARRAY_SIZE(fsm_gps_configs));
  374. msm_gpiomux_install(fsm_sd_configs, ARRAY_SIZE(fsm_sd_configs));
  375. }