board-hestia-gpiomux.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289
  1. /* Copyright (c) 2012-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. /****************************** Revision History ******************************************
  14. *CH# Product author Description Date
  15. *-----------------------------------------------------------------------------------------
  16. *01 Atlantic LTE nc.chaudhary Intial file creation 27-Jan-2014
  17. * 3G
  18. *02 Atlantic-All nc.chaudhary Added the gpiomux settings for 30-Jan-2014
  19. * variants UART for LCIA Test failure
  20. *02 Atlantic-ATT nc.chaudhary Added the gpiomux settings for 12-Feb-2014
  21. * Kmini-ATT NC GPIOs as per new schematics
  22. ******************************************************************************************
  23. */
  24. #ifdef CONFIG_WCNSS_IRIS_REGISTER_DUMP
  25. #include <linux/gpio.h>
  26. #endif
  27. #include <linux/init.h>
  28. #include <linux/ioport.h>
  29. #include <mach/board.h>
  30. #include <mach/gpio.h>
  31. #include <mach/gpiomux.h>
  32. #include <mach/socinfo.h>
  33. #ifdef CONFIG_WCNSS_IRIS_REGISTER_DUMP
  34. #define WLAN_CLK 44
  35. #define WLAN_SET 43
  36. #define WLAN_DATA0 42
  37. #define WLAN_DATA1 41
  38. #define WLAN_DATA2 40
  39. #endif
  40. /*Adding the GPIOMUX settings for suspend states */
  41. static struct gpiomux_setting gpio_suspend_config[] = {
  42. { /* IN/ NP/ L */
  43. .func = GPIOMUX_FUNC_GPIO,
  44. .drv = GPIOMUX_DRV_2MA,
  45. .pull = GPIOMUX_PULL_NONE,
  46. .dir = GPIOMUX_IN,
  47. },
  48. { /* OUT/ NP/ L */
  49. .func = GPIOMUX_FUNC_GPIO,
  50. .drv = GPIOMUX_DRV_2MA,
  51. .pull = GPIOMUX_PULL_NONE,
  52. .dir = GPIOMUX_OUT_LOW,
  53. },
  54. { /* IN/ PD/ L */
  55. .func = GPIOMUX_FUNC_GPIO,
  56. .drv = GPIOMUX_DRV_2MA,
  57. .pull = GPIOMUX_PULL_DOWN,
  58. .dir = GPIOMUX_IN,
  59. },
  60. { /* OUT/ PD/ L */
  61. .func = GPIOMUX_FUNC_GPIO,
  62. .drv = GPIOMUX_DRV_2MA,
  63. .pull = GPIOMUX_PULL_DOWN,
  64. .dir = GPIOMUX_OUT_LOW,
  65. },
  66. };
  67. #ifdef CONFIG_USB_EHCI_MSM_HSIC
  68. static struct gpiomux_setting hsic_act_cfg = {
  69. .func = GPIOMUX_FUNC_1,
  70. .drv = GPIOMUX_DRV_16MA,
  71. .pull = GPIOMUX_PULL_NONE,
  72. };
  73. static struct msm_gpiomux_config msm_hsic_configs[] = {
  74. {
  75. .gpio = 119, /* HSIC_STROBE */
  76. .settings = {
  77. [GPIOMUX_ACTIVE] = &hsic_act_cfg,
  78. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[3],
  79. },
  80. },
  81. {
  82. .gpio = 116, /* HSIC_DATA */
  83. .settings = {
  84. [GPIOMUX_ACTIVE] = &hsic_act_cfg,
  85. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[3],
  86. },
  87. },
  88. };
  89. #endif
  90. #define KS8851_IRQ_GPIO 115
  91. #define IN_NP_2MA_CFG(gpio_num) { \
  92. .gpio = gpio_num, \
  93. .settings = {\
  94. [GPIOMUX_ACTIVE] = &gpio_suspend_config[0],\
  95. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],\
  96. }\
  97. }
  98. #define HW_CHK_BIT_CFG(gpio_num) IN_NP_2MA_CFG(gpio_num)
  99. #define OUT_NP_2MA_CFG(gpio_num) { \
  100. .gpio = gpio_num, \
  101. .settings = {\
  102. [GPIOMUX_ACTIVE] = &gpio_suspend_config[1],\
  103. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],\
  104. }\
  105. }
  106. #define IN_PD_2MA_CFG(gpio_num) { \
  107. .gpio = gpio_num, \
  108. .settings ={\
  109. [GPIOMUX_ACTIVE] = &gpio_suspend_config[2],\
  110. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[2],\
  111. }\
  112. }
  113. #define NC_GPIO_CONFIG(gpio_num) IN_PD_2MA_CFG(gpio_num)
  114. #define OUT_PD_2MA_CFG(gpio_num) { \
  115. .gpio = gpio_num, \
  116. .settings = {\
  117. [GPIOMUX_ACTIVE] = &gpio_suspend_config[3],\
  118. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[3],\
  119. }\
  120. }
  121. #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
  122. static struct gpiomux_setting gpio_eth_config = {
  123. .pull = GPIOMUX_PULL_UP,
  124. .drv = GPIOMUX_DRV_2MA,
  125. .func = GPIOMUX_FUNC_GPIO,
  126. };
  127. static struct msm_gpiomux_config msm_eth_configs[] = {
  128. {
  129. .gpio = KS8851_IRQ_GPIO,
  130. .settings = {
  131. [GPIOMUX_SUSPENDED] = &gpio_eth_config,
  132. }
  133. },
  134. };
  135. #endif
  136. static struct gpiomux_setting gpio_spi_stm_config = {
  137. .func = GPIOMUX_FUNC_1,
  138. .drv = GPIOMUX_DRV_8MA,
  139. .pull = GPIOMUX_PULL_NONE,
  140. };
  141. static struct gpiomux_setting gpio_spi_stm_sus_config[] = {
  142. {
  143. .func = GPIOMUX_FUNC_1,
  144. .drv = GPIOMUX_DRV_8MA,
  145. .pull = GPIOMUX_PULL_DOWN,
  146. },
  147. {
  148. .func = GPIOMUX_FUNC_1,
  149. .drv = GPIOMUX_DRV_8MA,
  150. .pull = GPIOMUX_PULL_UP,
  151. },
  152. {
  153. .func = GPIOMUX_FUNC_2,
  154. .drv = GPIOMUX_DRV_8MA,
  155. .pull = GPIOMUX_PULL_DOWN,
  156. },
  157. };
  158. static struct gpiomux_setting synaptics_int_act_cfg = {
  159. .func = GPIOMUX_FUNC_GPIO,
  160. .drv = GPIOMUX_DRV_8MA,
  161. .pull = GPIOMUX_PULL_UP,
  162. };
  163. static struct gpiomux_setting synaptics_int_sus_cfg = {
  164. .func = GPIOMUX_FUNC_GPIO,
  165. .drv = GPIOMUX_DRV_2MA,
  166. .pull = GPIOMUX_PULL_DOWN,
  167. };
  168. static struct gpiomux_setting gpio_i2c_tkey_active_config = {
  169. .func = GPIOMUX_FUNC_GPIO,
  170. .drv = GPIOMUX_DRV_2MA,
  171. .pull = GPIOMUX_PULL_UP,
  172. };
  173. static struct gpiomux_setting gpio_i2c_tkey_suspend_config = {
  174. .func = GPIOMUX_FUNC_GPIO,
  175. .drv = GPIOMUX_DRV_2MA,
  176. .pull = GPIOMUX_PULL_UP,
  177. };
  178. static struct gpiomux_setting gpio_keys_active = {
  179. .func = GPIOMUX_FUNC_GPIO,
  180. .drv = GPIOMUX_DRV_2MA,
  181. .pull = GPIOMUX_PULL_UP,
  182. };
  183. static struct gpiomux_setting gpio_keys_suspend = {
  184. .func = GPIOMUX_FUNC_GPIO,
  185. .drv = GPIOMUX_DRV_2MA,
  186. .pull = GPIOMUX_PULL_NONE,
  187. };
  188. static struct gpiomux_setting gpio_spi_act_config = {
  189. .func = GPIOMUX_FUNC_1,
  190. .drv = GPIOMUX_DRV_8MA,
  191. .pull = GPIOMUX_PULL_NONE,
  192. };
  193. static struct gpiomux_setting gpio_spi_cs_act_config = {
  194. .func = GPIOMUX_FUNC_1,
  195. .drv = GPIOMUX_DRV_6MA,
  196. .pull = GPIOMUX_PULL_DOWN,
  197. };
  198. static struct gpiomux_setting gpio_spi_susp_config = {
  199. .func = GPIOMUX_FUNC_GPIO,
  200. .drv = GPIOMUX_DRV_2MA,
  201. .pull = GPIOMUX_PULL_DOWN,
  202. };
  203. static struct gpiomux_setting wcnss_5wire_suspend_cfg = {
  204. .func = GPIOMUX_FUNC_GPIO,
  205. .drv = GPIOMUX_DRV_2MA,
  206. .pull = GPIOMUX_PULL_UP,
  207. };
  208. static struct gpiomux_setting wcnss_5wire_active_cfg = {
  209. .func = GPIOMUX_FUNC_1,
  210. .drv = GPIOMUX_DRV_6MA,
  211. .pull = GPIOMUX_PULL_DOWN,
  212. };
  213. #ifdef CONFIG_WCNSS_IRIS_REGISTER_DUMP
  214. static struct gpiomux_setting wcnss_5gpio_suspend_cfg = {
  215. .func = GPIOMUX_FUNC_GPIO,
  216. .drv = GPIOMUX_DRV_2MA,
  217. .pull = GPIOMUX_PULL_UP,
  218. };
  219. static struct gpiomux_setting wcnss_5gpio_active_cfg = {
  220. .func = GPIOMUX_FUNC_GPIO,
  221. .drv = GPIOMUX_DRV_6MA,
  222. .pull = GPIOMUX_PULL_DOWN,
  223. };
  224. #endif
  225. #define WCNSS_5WIRE_CFG(gpio_num) { \
  226. .gpio = gpio_num, \
  227. .settings = {\
  228. [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,\
  229. [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,\
  230. }\
  231. }
  232. static struct gpiomux_setting gpio_i2c_config = {
  233. .func = GPIOMUX_FUNC_3,
  234. .drv = GPIOMUX_DRV_2MA,
  235. .pull = GPIOMUX_PULL_NONE,
  236. .dir = GPIOMUX_IN,
  237. };
  238. #define I2C_GPIO_CONFIG(gpio_num) { \
  239. .gpio = gpio_num, \
  240. .settings = {\
  241. [GPIOMUX_ACTIVE] = &gpio_i2c_config,\
  242. [GPIOMUX_SUSPENDED] = &gpio_i2c_config,\
  243. }\
  244. }
  245. static struct msm_gpiomux_config msm_keypad_configs[] __initdata = {
  246. {
  247. .gpio = 106,
  248. .settings = {
  249. [GPIOMUX_ACTIVE] = &gpio_keys_active,
  250. [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
  251. },
  252. },
  253. {
  254. .gpio = 107,
  255. .settings = {
  256. [GPIOMUX_ACTIVE] = &gpio_keys_active,
  257. [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
  258. },
  259. },
  260. {
  261. .gpio = 108,
  262. .settings = {
  263. [GPIOMUX_ACTIVE] = &gpio_keys_active,
  264. [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
  265. },
  266. },
  267. };
  268. static struct gpiomux_setting lcd_rst_act_cfg = {
  269. .func = GPIOMUX_FUNC_GPIO,
  270. .drv = GPIOMUX_DRV_2MA,
  271. .pull = GPIOMUX_PULL_NONE,
  272. .dir = GPIOMUX_OUT_HIGH,
  273. };
  274. static struct gpiomux_setting lcd_rst_sus_cfg = {
  275. .func = GPIOMUX_FUNC_GPIO,
  276. .drv = GPIOMUX_DRV_2MA,
  277. .pull = GPIOMUX_PULL_DOWN,
  278. .dir = GPIOMUX_OUT_LOW,
  279. };
  280. static struct gpiomux_setting lcd_pwr_act_cfg = {
  281. .func = GPIOMUX_FUNC_GPIO,
  282. .drv = GPIOMUX_DRV_8MA,
  283. .pull = GPIOMUX_PULL_NONE,
  284. .dir = GPIOMUX_OUT_HIGH,
  285. };
  286. static struct gpiomux_setting lcd_pwr_sus_cfg = {
  287. .func = GPIOMUX_FUNC_GPIO,
  288. .drv = GPIOMUX_DRV_2MA,
  289. .pull = GPIOMUX_PULL_DOWN,
  290. .dir = GPIOMUX_OUT_LOW,
  291. };
  292. #define LCD_ESD_DET(gpio_num) IN_NP_2MA_CFG(gpio_num)
  293. static struct msm_gpiomux_config msm_lcd_configs[] __initdata = {
  294. {
  295. .gpio = 25, /* LCD Reset */
  296. .settings = {
  297. [GPIOMUX_ACTIVE] = &lcd_rst_act_cfg,
  298. [GPIOMUX_SUSPENDED] = &lcd_rst_sus_cfg,
  299. },
  300. },
  301. {
  302. .gpio = 60, /* LCD ON*/
  303. .settings = {
  304. [GPIOMUX_ACTIVE] = &lcd_pwr_act_cfg,
  305. [GPIOMUX_SUSPENDED] = &lcd_pwr_sus_cfg,
  306. },
  307. },
  308. LCD_ESD_DET(79),
  309. LCD_ESD_DET(80),
  310. };
  311. static struct gpiomux_setting gpio_uart_config = {
  312. .func = GPIOMUX_FUNC_2,
  313. .drv = GPIOMUX_DRV_8MA,
  314. .pull = GPIOMUX_PULL_NONE, /*should be pulled None for UART */
  315. .dir = GPIOMUX_OUT_HIGH,
  316. };
  317. static struct gpiomux_setting rx_gpio_uart_config = {
  318. .func = GPIOMUX_FUNC_2,
  319. .drv = GPIOMUX_DRV_8MA,
  320. .pull = GPIOMUX_PULL_DOWN, /*LCIA Test failure*/
  321. .dir = GPIOMUX_OUT_HIGH,
  322. };
  323. static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
  324. {
  325. .gpio = 8, /* UART TX */
  326. .settings = {
  327. [GPIOMUX_SUSPENDED] = &gpio_uart_config,
  328. },
  329. },
  330. {
  331. .gpio = 9, /* UART RX */
  332. .settings = {
  333. [GPIOMUX_SUSPENDED] = &rx_gpio_uart_config,
  334. },
  335. },
  336. {
  337. .gpio = 12, /* UART TX */
  338. .settings = {
  339. [GPIOMUX_SUSPENDED] = &gpio_uart_config,
  340. },
  341. },
  342. {
  343. .gpio = 13, /* UART RX */
  344. .settings = {
  345. [GPIOMUX_SUSPENDED] = &rx_gpio_uart_config,
  346. },
  347. },
  348. {
  349. .gpio = 16, /* UART TX */
  350. .settings = {
  351. [GPIOMUX_SUSPENDED] = &gpio_uart_config,
  352. },
  353. },
  354. {
  355. .gpio = 17, /* UART RX */
  356. .settings = {
  357. [GPIOMUX_SUSPENDED] = &rx_gpio_uart_config,
  358. },
  359. },
  360. {
  361. .gpio = 55, /* BLSP1 QUP1 SPI_DATA_MOSI */
  362. .settings = {
  363. [GPIOMUX_ACTIVE] = &gpio_i2c_tkey_active_config,
  364. [GPIOMUX_SUSPENDED] = &gpio_i2c_tkey_suspend_config,
  365. },
  366. },
  367. {
  368. .gpio = 56, /* BLSP1 QUP1 SPI_DATA_MISO */
  369. .settings = {
  370. [GPIOMUX_ACTIVE] = &gpio_i2c_tkey_active_config,
  371. [GPIOMUX_SUSPENDED] = &gpio_i2c_tkey_suspend_config,
  372. },
  373. },
  374. {
  375. .gpio = 2, /* BLSP1 QUP1 SPI_CS1 */
  376. .settings = {
  377. [GPIOMUX_ACTIVE] = &gpio_spi_cs_act_config,
  378. [GPIOMUX_SUSPENDED] = &gpio_spi_susp_config,
  379. },
  380. },
  381. {
  382. .gpio = 3, /* BLSP1 QUP1 SPI_CLK */
  383. .settings = {
  384. [GPIOMUX_ACTIVE] = &gpio_spi_act_config,
  385. [GPIOMUX_SUSPENDED] = &gpio_spi_susp_config,
  386. },
  387. },
  388. {
  389. .gpio = 4, /* BLSP1 QUP1 SPI_DATA_MOSI */
  390. .settings = {
  391. [GPIOMUX_ACTIVE] = &gpio_spi_stm_config,
  392. [GPIOMUX_SUSPENDED] = &gpio_spi_stm_sus_config[0],
  393. },
  394. },
  395. {
  396. .gpio = 5, /* BLSP1 QUP1 SPI_DATA_MISO */
  397. .settings = {
  398. [GPIOMUX_ACTIVE] = &gpio_spi_stm_config,
  399. [GPIOMUX_SUSPENDED] = &gpio_spi_stm_sus_config[0],
  400. },
  401. },
  402. {
  403. .gpio = 6, /* BLSP1 QUP1 SPI_CS1 */
  404. .settings = {
  405. [GPIOMUX_ACTIVE] = &gpio_spi_stm_config,
  406. [GPIOMUX_SUSPENDED] = &gpio_spi_stm_sus_config[1],
  407. },
  408. },
  409. {
  410. .gpio = 7, /* BLSP1 QUP1 SPI_CLK */
  411. .settings = {
  412. [GPIOMUX_ACTIVE] = &gpio_spi_stm_config,
  413. [GPIOMUX_SUSPENDED] = &gpio_spi_stm_sus_config[1],
  414. },
  415. },
  416. I2C_GPIO_CONFIG(18), /* BLSP1 QUP5 I2C_SDA */
  417. I2C_GPIO_CONFIG(19), /* BLSP1 QUP5 I2C_SCL */
  418. };
  419. #define HRM_IRQ_CFG(gpio_num) IN_NP_2MA_CFG(gpio_num)
  420. static struct msm_gpiomux_config msm_hrm_configs[] __initdata = {
  421. HRM_IRQ_CFG(63), /* HRM IRQ */
  422. };
  423. static struct gpiomux_setting ssp_setting[] = {
  424. {
  425. .func = GPIOMUX_FUNC_GPIO,
  426. .drv = GPIOMUX_DRV_2MA,
  427. .pull = GPIOMUX_PULL_NONE,
  428. },
  429. {
  430. .func = GPIOMUX_FUNC_GPIO,
  431. .drv = GPIOMUX_DRV_8MA,
  432. .pull = GPIOMUX_PULL_NONE,
  433. .dir = GPIOMUX_OUT_HIGH,
  434. },
  435. {
  436. .func = GPIOMUX_FUNC_GPIO,
  437. .drv = GPIOMUX_DRV_8MA,
  438. .pull = GPIOMUX_PULL_NONE,
  439. .dir = GPIOMUX_OUT_LOW,
  440. },
  441. };
  442. #define SSPN_CONFIG(gpio_num, n) { \
  443. .gpio = gpio_num, \
  444. .settings = {\
  445. [GPIOMUX_ACTIVE] = &ssp_setting[n],\
  446. [GPIOMUX_SUSPENDED] = &ssp_setting[n],\
  447. }\
  448. }
  449. static struct msm_gpiomux_config msm_sensorhub_configs[] __initdata = {
  450. SSPN_CONFIG(64, 0), /* MCU INT 1 IRQ */
  451. SSPN_CONFIG(65, 0), /* MCU INT 2 IRQ */
  452. SSPN_CONFIG(118, 1), /* AP INT IRQ */
  453. SSPN_CONFIG(104, 0), /* RESET */
  454. SSPN_CONFIG(111, 2), /* HRM EXT LDO EN */
  455. };
  456. #define NFC_IRQ_CFG(gpio_num) IN_NP_2MA_CFG(gpio_num)
  457. #define NFC_FW_CFG(gpio_num) OUT_NP_2MA_CFG(gpio_num)
  458. #define NFC_EN_CFG(gpio_num) OUT_PD_2MA_CFG(gpio_num)
  459. static struct msm_gpiomux_config msm_nfc_configs[] __initdata = {
  460. NFC_IRQ_CFG(46), /* NFC IRQ */
  461. };
  462. #define BGM_IRQ_CFG(gpio_num) IN_NP_2MA_CFG(gpio_num)
  463. #define BGM_IN_CFG(gpio_num) IN_NP_2MA_CFG(gpio_num)
  464. #define BGM_OUT_CFG(gpio_num) OUT_PD_2MA_CFG(gpio_num)
  465. static struct msm_gpiomux_config msm_bgm_configs[] __initdata = {
  466. BGM_IN_CFG(62),
  467. BGM_IN_CFG(115),
  468. };
  469. static struct msm_gpiomux_config msm_synaptics_configs[] __initdata = {
  470. {
  471. .gpio = 120,
  472. .settings = {
  473. [GPIOMUX_ACTIVE] = &synaptics_int_act_cfg,
  474. [GPIOMUX_SUSPENDED] = &synaptics_int_sus_cfg,
  475. },
  476. },
  477. };
  478. static struct gpiomux_setting goodix_ldo_en_act_cfg = {
  479. .func = GPIOMUX_FUNC_GPIO,
  480. .drv = GPIOMUX_DRV_6MA,
  481. .pull = GPIOMUX_PULL_UP,
  482. };
  483. static struct gpiomux_setting goodix_int_act_cfg = {
  484. .func = GPIOMUX_FUNC_GPIO,
  485. .drv = GPIOMUX_DRV_6MA,
  486. .pull = GPIOMUX_PULL_UP,
  487. };
  488. static struct msm_gpiomux_config msm_skuf_blsp_configs[] __initdata = {
  489. NC_GPIO_CONFIG(2),
  490. NC_GPIO_CONFIG(3),
  491. NC_GPIO_CONFIG(4),
  492. };
  493. static struct msm_gpiomux_config msm_skuf_goodix_configs[] __initdata = {
  494. {
  495. .gpio = 15, /* LDO EN */
  496. .settings = {
  497. [GPIOMUX_ACTIVE] = &goodix_ldo_en_act_cfg,
  498. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[2],
  499. },
  500. },
  501. {
  502. .gpio = 17, /* INT */
  503. .settings = {
  504. [GPIOMUX_ACTIVE] = &goodix_int_act_cfg,
  505. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[2],
  506. },
  507. },
  508. I2C_GPIO_CONFIG(18), /* BLSP1 QUP5 I2C_SDA */
  509. I2C_GPIO_CONFIG(19), /* BLSP1 QUP5 I2C_SCL */
  510. };
  511. static struct gpiomux_setting nfc_wake_act_cfg = {
  512. .func = GPIOMUX_FUNC_GPIO,
  513. .drv = GPIOMUX_DRV_6MA,
  514. .pull = GPIOMUX_PULL_UP,
  515. };
  516. static struct msm_gpiomux_config msm_skuf_nfc_configs[] __initdata = {
  517. { /* NFC WAKE */
  518. .gpio = 5,
  519. .settings = {
  520. [GPIOMUX_ACTIVE] = &nfc_wake_act_cfg,
  521. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
  522. },
  523. },
  524. };
  525. static struct msm_gpiomux_config wcnss_5wire_interface[] = {
  526. WCNSS_5WIRE_CFG(40),
  527. WCNSS_5WIRE_CFG(41),
  528. WCNSS_5WIRE_CFG(42),
  529. WCNSS_5WIRE_CFG(43),
  530. WCNSS_5WIRE_CFG(44),
  531. };
  532. #ifdef CONFIG_WCNSS_IRIS_REGISTER_DUMP
  533. static struct msm_gpiomux_config wcnss_5gpio_interface[] = {
  534. {
  535. .gpio = 40,
  536. .settings = {
  537. [GPIOMUX_ACTIVE] = &wcnss_5gpio_active_cfg,
  538. [GPIOMUX_SUSPENDED] = &wcnss_5gpio_suspend_cfg,
  539. },
  540. },
  541. {
  542. .gpio = 41,
  543. .settings = {
  544. [GPIOMUX_ACTIVE] = &wcnss_5gpio_active_cfg,
  545. [GPIOMUX_SUSPENDED] = &wcnss_5gpio_suspend_cfg,
  546. },
  547. },
  548. {
  549. .gpio = 42,
  550. .settings = {
  551. [GPIOMUX_ACTIVE] = &wcnss_5gpio_active_cfg,
  552. [GPIOMUX_SUSPENDED] = &wcnss_5gpio_suspend_cfg,
  553. },
  554. },
  555. {
  556. .gpio = 43,
  557. .settings = {
  558. [GPIOMUX_ACTIVE] = &wcnss_5gpio_active_cfg,
  559. [GPIOMUX_SUSPENDED] = &wcnss_5gpio_suspend_cfg,
  560. },
  561. },
  562. {
  563. .gpio = 44,
  564. .settings = {
  565. [GPIOMUX_ACTIVE] = &wcnss_5gpio_active_cfg,
  566. [GPIOMUX_SUSPENDED] = &wcnss_5gpio_suspend_cfg,
  567. },
  568. },
  569. };
  570. #endif
  571. static struct gpiomux_setting cam_settings[] = {
  572. {
  573. .func = GPIOMUX_FUNC_1, /*active 1*/ /* 0 */
  574. .drv = GPIOMUX_DRV_2MA,
  575. .pull = GPIOMUX_PULL_NONE,
  576. },
  577. {
  578. .func = GPIOMUX_FUNC_1, /*suspend*/ /* 1 */
  579. .drv = GPIOMUX_DRV_2MA,
  580. .pull = GPIOMUX_PULL_DOWN,
  581. },
  582. {
  583. .func = GPIOMUX_FUNC_1, /*i2c suspend*/ /* 2 */
  584. .drv = GPIOMUX_DRV_2MA,
  585. .pull = GPIOMUX_PULL_KEEPER,
  586. },
  587. {
  588. .func = GPIOMUX_FUNC_GPIO, /*active 0*/ /* 3 */
  589. .drv = GPIOMUX_DRV_2MA,
  590. .pull = GPIOMUX_PULL_NONE,
  591. },
  592. {
  593. .func = GPIOMUX_FUNC_GPIO, /*suspend 0*/ /* 4 */
  594. .drv = GPIOMUX_DRV_2MA,
  595. .pull = GPIOMUX_PULL_DOWN,
  596. },
  597. {
  598. .func = GPIOMUX_FUNC_GPIO, /*active 1*/ /* 5 */
  599. .drv = GPIOMUX_DRV_2MA,
  600. .pull = GPIOMUX_PULL_NONE,
  601. .dir = GPIOMUX_OUT_LOW,
  602. },
  603. {
  604. .func = GPIOMUX_FUNC_GPIO, /*suspend*/ /* 6 */
  605. .drv = GPIOMUX_DRV_4MA,
  606. .pull = GPIOMUX_PULL_DOWN,
  607. .dir = GPIOMUX_OUT_LOW,
  608. },
  609. };
  610. #define CAM_COMMON_CONFIG(gpio_num) { \
  611. .gpio = gpio_num, \
  612. .settings = {\
  613. [GPIOMUX_ACTIVE] = &cam_settings[3],\
  614. [GPIOMUX_SUSPENDED] = &cam_settings[4],\
  615. }\
  616. }
  617. static struct msm_gpiomux_config msm_sensor_configs[] __initdata = {
  618. {
  619. .gpio = 26, /* CAM_MCLK0 */
  620. .settings = {
  621. [GPIOMUX_ACTIVE] = &cam_settings[0],
  622. [GPIOMUX_SUSPENDED] = &cam_settings[1],
  623. },
  624. },
  625. {
  626. .gpio = 27, /* CAM_MCLK1 */
  627. .settings = {
  628. [GPIOMUX_ACTIVE] = &cam_settings[0],
  629. [GPIOMUX_SUSPENDED] = &cam_settings[1],
  630. },
  631. },
  632. {
  633. .gpio = 29, /* CCI_I2C_SDA0 */
  634. .settings = {
  635. [GPIOMUX_ACTIVE] = &cam_settings[0],
  636. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
  637. },
  638. },
  639. {
  640. .gpio = 30, /* CCI_I2C_SCL0 */
  641. .settings = {
  642. [GPIOMUX_ACTIVE] = &cam_settings[0],
  643. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
  644. },
  645. },
  646. CAM_COMMON_CONFIG(2), /* CCI_I2C_SDA_EEPROM */
  647. CAM_COMMON_CONFIG(3), /* CCI_I2C_SCL_EEPROM */
  648. CAM_COMMON_CONFIG(33), /* CCI_I2C_SDA_AF */
  649. CAM_COMMON_CONFIG(34), /* CCI_I2C_SCL_AF */
  650. CAM_COMMON_CONFIG(35), /* CAM2_STANDBY_N */
  651. CAM_COMMON_CONFIG(36), /* CAM1_STANDBY_N */
  652. CAM_COMMON_CONFIG(37), /* CAM1_RST_N */
  653. CAM_COMMON_CONFIG(28), /* CAM2_RST_N */
  654. {
  655. .gpio = 113, /* CAM_ANALOG_EN */
  656. .settings = {
  657. [GPIOMUX_ACTIVE] = &cam_settings[3],
  658. [GPIOMUX_SUSPENDED] = &cam_settings[6],
  659. },
  660. },
  661. };
  662. static struct msm_gpiomux_config msm_sensor_configs_skuf_plus[] __initdata = {
  663. CAM_COMMON_CONFIG(34), /* CAM1 VCM_PWDN */
  664. };
  665. #if defined(CONFIG_SENSORS_VFS61XX)
  666. static struct gpiomux_setting gpio_spi_ocp_flag_config = {
  667. .func = GPIOMUX_FUNC_GPIO,
  668. .drv = GPIOMUX_DRV_2MA,
  669. .pull = GPIOMUX_PULL_NONE,
  670. .dir = GPIOMUX_IN,
  671. };
  672. static struct gpiomux_setting gpio_spi_btp_config = {
  673. .func = GPIOMUX_FUNC_1,
  674. .drv = GPIOMUX_DRV_2MA,
  675. .pull = GPIOMUX_PULL_NONE,
  676. };
  677. static struct gpiomux_setting gpio_spi_btp_irq_config = {
  678. .func = GPIOMUX_FUNC_GPIO,
  679. .drv = GPIOMUX_DRV_2MA,
  680. .pull = GPIOMUX_PULL_UP,
  681. .dir = GPIOMUX_IN,
  682. };
  683. static struct gpiomux_setting gpio_spi_btp_rst_config = {
  684. .func = GPIOMUX_FUNC_GPIO,
  685. .drv = GPIOMUX_DRV_2MA,
  686. .pull = GPIOMUX_PULL_DOWN,
  687. .dir = GPIOMUX_OUT_LOW,
  688. };
  689. static struct msm_gpiomux_config msm_fingerprint_configs[] __initdata = {
  690. {
  691. /* MOSI */
  692. .gpio = 20,
  693. .settings = {
  694. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1], // OUT-NP-L
  695. [GPIOMUX_ACTIVE] = &gpio_spi_btp_config,
  696. },
  697. },
  698. {
  699. /* MISO */
  700. .gpio = 21,
  701. .settings = {
  702. [GPIOMUX_SUSPENDED] = &gpio_spi_btp_irq_config,
  703. [GPIOMUX_ACTIVE] = &gpio_spi_btp_config,
  704. },
  705. },
  706. {
  707. /* CS */
  708. .gpio = 22,
  709. .settings = {
  710. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1], // OUT-NP-L
  711. [GPIOMUX_ACTIVE] = &gpio_spi_btp_config,
  712. },
  713. },
  714. {
  715. /* CLK */
  716. .gpio = 23,
  717. .settings = {
  718. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1], // OUT-NP-L
  719. [GPIOMUX_ACTIVE] = &gpio_spi_btp_config,
  720. },
  721. },
  722. {
  723. /* BTP_INT */
  724. .gpio = 110,
  725. .settings = {
  726. [GPIOMUX_SUSPENDED] = &gpio_spi_btp_irq_config,
  727. [GPIOMUX_ACTIVE] = &gpio_spi_btp_irq_config,
  728. },
  729. },
  730. {
  731. /* BTP_RST_N */
  732. .gpio = 114,
  733. .settings = {
  734. [GPIOMUX_SUSPENDED] = &gpio_spi_btp_rst_config,
  735. [GPIOMUX_ACTIVE] = &gpio_spi_btp_rst_config,
  736. },
  737. },
  738. {
  739. /* BTP_LDO */
  740. .gpio = 438,
  741. .settings = {
  742. [GPIOMUX_SUSPENDED] = &gpio_spi_btp_rst_config,
  743. [GPIOMUX_ACTIVE] = &gpio_spi_btp_rst_config,
  744. },
  745. },
  746. {
  747. /* BTP_LDO2 */
  748. .gpio = 435,
  749. .settings = {
  750. [GPIOMUX_SUSPENDED] = &gpio_spi_btp_rst_config,
  751. [GPIOMUX_ACTIVE] = &gpio_spi_btp_rst_config,
  752. },
  753. },
  754. {
  755. /* BTP_OCP_EN */
  756. .gpio = 441,
  757. .settings = {
  758. [GPIOMUX_SUSPENDED] = &gpio_spi_btp_rst_config,
  759. [GPIOMUX_ACTIVE] = &gpio_spi_btp_rst_config,
  760. },
  761. },
  762. {
  763. /* BTP_OCP_FLAG */
  764. .gpio = 38,
  765. .settings = {
  766. [GPIOMUX_SUSPENDED] = &gpio_spi_ocp_flag_config,
  767. [GPIOMUX_ACTIVE] = &gpio_spi_ocp_flag_config,
  768. },
  769. },
  770. };
  771. #endif
  772. static struct gpiomux_setting auxpcm_act_cfg = {
  773. .func = GPIOMUX_FUNC_1,
  774. .drv = GPIOMUX_DRV_8MA,
  775. .pull = GPIOMUX_PULL_NONE,
  776. };
  777. static struct gpiomux_setting auxpcm_sus_cfg = {
  778. .func = GPIOMUX_FUNC_1,
  779. .drv = GPIOMUX_DRV_2MA,
  780. .pull = GPIOMUX_PULL_DOWN,
  781. };
  782. static struct msm_gpiomux_config msm_auxpcm_configs[] __initdata = {
  783. {
  784. .gpio = 64,
  785. .settings = {
  786. [GPIOMUX_SUSPENDED] = &auxpcm_sus_cfg,
  787. [GPIOMUX_ACTIVE] = &auxpcm_act_cfg,
  788. },
  789. },
  790. };
  791. #ifdef CONFIG_SND_SOC_ES705
  792. static struct gpiomux_setting es705_intrevent_config = {
  793. .func = GPIOMUX_FUNC_GPIO,
  794. .drv = GPIOMUX_DRV_2MA,
  795. .pull = GPIOMUX_PULL_NONE,
  796. .dir = GPIOMUX_IN,
  797. };
  798. static struct msm_gpiomux_config es705_config[] __initdata = {
  799. {
  800. .gpio = 0, /* es705 uart tx */
  801. .settings = {
  802. [GPIOMUX_SUSPENDED] = &gpio_uart_config,
  803. },
  804. },
  805. {
  806. .gpio = 1, /* es705 uart rx */
  807. .settings = {
  808. [GPIOMUX_SUSPENDED] = &gpio_uart_config,
  809. },
  810. },
  811. {
  812. .gpio = 305, /* es705 2mic int */
  813. .settings = {
  814. [GPIOMUX_SUSPENDED] = &es705_intrevent_config,
  815. },
  816. },
  817. };
  818. #endif /* CONFIG_SND_SOC_ES705 */
  819. #if defined (CONFIG_SAMSUNG_JACK)
  820. #define EAR_SWITCH_CFG(gpio_num) IN_PD_2MA_CFG(gpio_num)
  821. static struct msm_gpiomux_config msm_earjack_gpio_configs[] __initdata = {
  822. EAR_SWITCH_CFG(35), /* EAR_SWITCH */
  823. };
  824. #endif
  825. #ifdef CONFIG_SND_SOC_MAX98504
  826. static struct gpiomux_setting pri_mi2s_act_cfg = {
  827. .func = GPIOMUX_FUNC_1,
  828. .drv = GPIOMUX_DRV_8MA,
  829. .pull = GPIOMUX_PULL_NONE,
  830. };
  831. static struct gpiomux_setting pri_mi2s_sus_cfg = {
  832. .func = GPIOMUX_FUNC_GPIO,
  833. .drv = GPIOMUX_DRV_2MA,
  834. .pull = GPIOMUX_PULL_DOWN,
  835. };
  836. #define TERTIARY_MI2S_CONFIG(gpio_num) { \
  837. .gpio = gpio_num, \
  838. .settings = {\
  839. [GPIOMUX_ACTIVE] = &pri_mi2s_act_cfg,\
  840. [GPIOMUX_SUSPENDED] = &pri_mi2s_sus_cfg,\
  841. }\
  842. }
  843. static struct msm_gpiomux_config msm8226_tertiary_mi2s_configs[] __initdata = {
  844. TERTIARY_MI2S_CONFIG(49), /* qua mi2s sck */
  845. TERTIARY_MI2S_CONFIG(50),
  846. TERTIARY_MI2S_CONFIG(51),
  847. TERTIARY_MI2S_CONFIG(52),
  848. };
  849. #endif /* CONFIG_SND_SOC_MAX98504 */
  850. static struct gpiomux_setting usb_otg_sw_cfg = {
  851. .func = GPIOMUX_FUNC_GPIO,
  852. .drv = GPIOMUX_DRV_2MA,
  853. .dir = GPIOMUX_OUT_LOW,
  854. };
  855. static struct msm_gpiomux_config usb_otg_sw_configs[] __initdata = {
  856. {
  857. .gpio = 67,
  858. .settings = {
  859. [GPIOMUX_SUSPENDED] = &usb_otg_sw_cfg,
  860. },
  861. },
  862. };
  863. static struct gpiomux_setting wcdcodec_reset_active_cfg = {
  864. .func = GPIOMUX_FUNC_GPIO,
  865. .drv = GPIOMUX_DRV_2MA,
  866. .dir = GPIOMUX_OUT_LOW,
  867. .pull = GPIOMUX_PULL_NONE,
  868. };
  869. static struct msm_gpiomux_config wcdcodec_reset_cfg[] __initdata = {
  870. {
  871. .gpio = 72,
  872. .settings = {
  873. [GPIOMUX_ACTIVE] = &wcdcodec_reset_active_cfg,
  874. },
  875. },
  876. };
  877. #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
  878. static struct gpiomux_setting sdc3_clk_actv_cfg = {
  879. .func = GPIOMUX_FUNC_2,
  880. .drv = GPIOMUX_DRV_8MA,
  881. .pull = GPIOMUX_PULL_NONE,
  882. };
  883. static struct gpiomux_setting sdc3_cmd_data_0_3_actv_cfg = {
  884. .func = GPIOMUX_FUNC_2,
  885. .drv = GPIOMUX_DRV_8MA,
  886. .pull = GPIOMUX_PULL_UP,
  887. };
  888. static struct gpiomux_setting sdc3_suspend_cfg = {
  889. .func = GPIOMUX_FUNC_GPIO,
  890. .drv = GPIOMUX_DRV_2MA,
  891. .pull = GPIOMUX_PULL_DOWN,
  892. };
  893. static struct gpiomux_setting sdc3_data_1_suspend_cfg = {
  894. .func = GPIOMUX_FUNC_GPIO,
  895. .drv = GPIOMUX_DRV_2MA,
  896. .pull = GPIOMUX_PULL_UP,
  897. };
  898. #define SDC3_COMMON_CONFIG(gpio_num) { \
  899. .gpio = gpio_num, \
  900. .settings = {\
  901. [GPIOMUX_ACTIVE] = &sdc3_cmd_data_0_3_actv_cfg,\
  902. [GPIOMUX_SUSPENDED] = &sdc3_suspend_cfg,\
  903. }\
  904. }
  905. static struct msm_gpiomux_config msm8226_sdc3_configs[] __initdata = {
  906. SDC3_COMMON_CONFIG(39), /* DAT3 */
  907. SDC3_COMMON_CONFIG(40), /* DAT2 */
  908. {
  909. /* DAT1 */
  910. .gpio = 41,
  911. .settings = {
  912. [GPIOMUX_ACTIVE] = &sdc3_cmd_data_0_3_actv_cfg,
  913. [GPIOMUX_SUSPENDED] = &sdc3_data_1_suspend_cfg,
  914. },
  915. },
  916. SDC3_COMMON_CONFIG(42), /* DAT0 */
  917. SDC3_COMMON_CONFIG(43), /* cmd */
  918. {
  919. /* CLK */
  920. .gpio = 44,
  921. .settings = {
  922. [GPIOMUX_ACTIVE] = &sdc3_clk_actv_cfg,
  923. [GPIOMUX_SUSPENDED] = &sdc3_suspend_cfg,
  924. },
  925. },
  926. };
  927. static void msm_gpiomux_sdc3_install(void)
  928. {
  929. msm_gpiomux_install(msm8226_sdc3_configs,
  930. ARRAY_SIZE(msm8226_sdc3_configs));
  931. }
  932. #else
  933. static void msm_gpiomux_sdc3_install(void) {}
  934. #endif /* CONFIG_MMC_MSM_SDC3_SUPPORT */
  935. /* Battery charging and BMS GPIO configuration */
  936. #if defined(CONFIG_MACH_HESTIALTE_EUR) || defined(CONFIG_MACH_HESTIALTE_ATT)
  937. static struct msm_gpiomux_config msm_chg_configs[] = {
  938. IN_NP_2MA_CFG(14), /* FUEL_CHG_SDA */
  939. IN_NP_2MA_CFG(51), /* CHG_DET */
  940. IN_NP_2MA_CFG(54), /* TA_nCHG */
  941. IN_NP_2MA_CFG(66), /* BATT_ALARM */
  942. IN_NP_2MA_CFG(119), /* INOK */
  943. };
  944. #endif
  945. extern int system_rev;
  946. /*NC GPIOs configuration*/
  947. static struct msm_gpiomux_config nc_gpio_cfgs[] __initdata = {
  948. NC_GPIO_CONFIG(75),
  949. NC_GPIO_CONFIG(76),
  950. NC_GPIO_CONFIG(77),
  951. NC_GPIO_CONFIG(78),
  952. NC_GPIO_CONFIG(79),
  953. NC_GPIO_CONFIG(80),
  954. NC_GPIO_CONFIG(81),
  955. NC_GPIO_CONFIG(82),
  956. NC_GPIO_CONFIG(83),
  957. NC_GPIO_CONFIG(84),
  958. NC_GPIO_CONFIG(85),
  959. NC_GPIO_CONFIG(86),
  960. NC_GPIO_CONFIG(88),
  961. NC_GPIO_CONFIG(90),
  962. NC_GPIO_CONFIG(91),
  963. NC_GPIO_CONFIG(92),
  964. NC_GPIO_CONFIG(93),
  965. NC_GPIO_CONFIG(94),
  966. NC_GPIO_CONFIG(97),
  967. NC_GPIO_CONFIG(98),
  968. NC_GPIO_CONFIG(110),
  969. NC_GPIO_CONFIG(111),
  970. NC_GPIO_CONFIG(113),
  971. };
  972. static struct msm_gpiomux_config hw_chkbits_cfg[] __initdata = {
  973. HW_CHK_BIT_CFG(24),
  974. HW_CHK_BIT_CFG(67),
  975. HW_CHK_BIT_CFG(116),
  976. HW_CHK_BIT_CFG(117),
  977. };
  978. extern int poweroff_charging;
  979. void __init msm8226_init_gpiomux(void)
  980. {
  981. int rc;
  982. rc = msm_gpiomux_init_dt();
  983. if (rc) {
  984. pr_err("%s failed %d\n", __func__, rc);
  985. return;
  986. }
  987. /* Battery charging and BMS GPIO */
  988. #if defined(CONFIG_MACH_HESTIALTE_EUR) || defined(CONFIG_MACH_HESTIALTE_ATT)
  989. msm_gpiomux_install(msm_chg_configs, ARRAY_SIZE(msm_chg_configs));
  990. #endif
  991. msm_gpiomux_install(msm_hrm_configs,
  992. ARRAY_SIZE(msm_hrm_configs));
  993. msm_gpiomux_install(msm_sensorhub_configs,
  994. ARRAY_SIZE(msm_sensorhub_configs));
  995. msm_gpiomux_install(msm_nfc_configs,
  996. ARRAY_SIZE(msm_nfc_configs));
  997. msm_gpiomux_install(msm_bgm_configs,
  998. ARRAY_SIZE(msm_bgm_configs));
  999. #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
  1000. msm_gpiomux_install(msm_eth_configs, ARRAY_SIZE(msm_eth_configs));
  1001. #endif
  1002. msm_gpiomux_install(msm_keypad_configs,
  1003. ARRAY_SIZE(msm_keypad_configs));
  1004. if (of_board_is_skuf())
  1005. msm_gpiomux_install(msm_skuf_blsp_configs,
  1006. ARRAY_SIZE(msm_skuf_blsp_configs));
  1007. else {
  1008. if(system_rev <6) {
  1009. msm_blsp_configs[6].gpio=22;
  1010. msm_blsp_configs[7].gpio=23;
  1011. }
  1012. msm_gpiomux_install(msm_blsp_configs,
  1013. ARRAY_SIZE(msm_blsp_configs));
  1014. }
  1015. msm_gpiomux_install(wcnss_5wire_interface,
  1016. ARRAY_SIZE(wcnss_5wire_interface));
  1017. if (of_board_is_skuf())
  1018. msm_gpiomux_install(msm_skuf_goodix_configs,
  1019. ARRAY_SIZE(msm_skuf_goodix_configs));
  1020. if(system_rev <6) {
  1021. msm_synaptics_configs[0].gpio=55;
  1022. msm_gpiomux_install(msm_synaptics_configs,
  1023. ARRAY_SIZE(msm_synaptics_configs));
  1024. }
  1025. if (of_board_is_skuf())
  1026. msm_gpiomux_install(msm_skuf_nfc_configs,
  1027. ARRAY_SIZE(msm_skuf_nfc_configs));
  1028. msm_gpiomux_install_nowrite(msm_lcd_configs,
  1029. ARRAY_SIZE(msm_lcd_configs));
  1030. msm_gpiomux_install(msm_sensor_configs, ARRAY_SIZE(msm_sensor_configs));
  1031. if (of_board_is_skuf())
  1032. msm_gpiomux_install(msm_sensor_configs_skuf_plus,
  1033. ARRAY_SIZE(msm_sensor_configs_skuf_plus));
  1034. #if defined(CONFIG_SENSORS_VFS61XX)
  1035. msm_gpiomux_install(msm_fingerprint_configs, ARRAY_SIZE(msm_fingerprint_configs));
  1036. #endif
  1037. msm_gpiomux_install(msm_auxpcm_configs,
  1038. ARRAY_SIZE(msm_auxpcm_configs));
  1039. if (of_board_is_cdp() || of_board_is_mtp() || of_board_is_xpm())
  1040. msm_gpiomux_install(usb_otg_sw_configs,
  1041. ARRAY_SIZE(usb_otg_sw_configs));
  1042. /*
  1043. * gpio mux settings for the NC GPIOs
  1044. */
  1045. msm_gpiomux_install(nc_gpio_cfgs,
  1046. ARRAY_SIZE(nc_gpio_cfgs));
  1047. msm_gpiomux_install(hw_chkbits_cfg, ARRAY_SIZE(hw_chkbits_cfg));
  1048. msm_gpiomux_sdc3_install();
  1049. /*
  1050. * HSIC STROBE gpio is also used by the ethernet. Install HSIC
  1051. * gpio mux config only when HSIC is enabled. HSIC config will
  1052. * be disabled when ethernet config is enabled.
  1053. */
  1054. #ifdef CONFIG_USB_EHCI_MSM_HSIC
  1055. if (machine_is_msm8926()) {
  1056. msm_hsic_configs[0].gpio = 119; /* STROBE */
  1057. msm_hsic_configs[1].gpio = 120; /* DATA */
  1058. }
  1059. msm_gpiomux_install(msm_hsic_configs, ARRAY_SIZE(msm_hsic_configs));
  1060. #endif
  1061. #ifdef CONFIG_SND_SOC_ES705
  1062. msm_gpiomux_install(es705_config, ARRAY_SIZE(es705_config));
  1063. #endif /* CONFIG_SND_SOC_ES705 */
  1064. #if defined(CONFIG_SAMSUNG_JACK)
  1065. msm_gpiomux_install(msm_earjack_gpio_configs, ARRAY_SIZE(msm_earjack_gpio_configs));
  1066. #endif
  1067. if(!poweroff_charging)
  1068. msm_gpiomux_install(wcdcodec_reset_cfg, ARRAY_SIZE(wcdcodec_reset_cfg));
  1069. #ifdef CONFIG_SND_SOC_MAX98504
  1070. msm_gpiomux_install(msm8226_tertiary_mi2s_configs,ARRAY_SIZE(msm8226_tertiary_mi2s_configs));
  1071. #endif
  1072. }
  1073. #ifdef CONFIG_WCNSS_IRIS_REGISTER_DUMP
  1074. static void wcnss_switch_to_gpio(void)
  1075. {
  1076. /* Switch MUX to GPIO */
  1077. msm_gpiomux_install(wcnss_5gpio_interface,
  1078. ARRAY_SIZE(wcnss_5gpio_interface));
  1079. /* Ensure GPIO config */
  1080. gpio_direction_input(WLAN_DATA2);
  1081. gpio_direction_input(WLAN_DATA1);
  1082. gpio_direction_input(WLAN_DATA0);
  1083. gpio_direction_output(WLAN_SET, 0);
  1084. gpio_direction_output(WLAN_CLK, 0);
  1085. }
  1086. static void wcnss_switch_to_5wire(void)
  1087. {
  1088. msm_gpiomux_install(wcnss_5wire_interface,
  1089. ARRAY_SIZE(wcnss_5wire_interface));
  1090. }
  1091. u32 wcnss_rf_read_reg(u32 rf_reg_addr)
  1092. {
  1093. int count = 0;
  1094. u32 rf_cmd_and_addr = 0;
  1095. u32 rf_data_received = 0;
  1096. u32 rf_bit = 0;
  1097. wcnss_switch_to_gpio();
  1098. /* Reset the signal if it is already being used. */
  1099. gpio_set_value(WLAN_SET, 0);
  1100. gpio_set_value(WLAN_CLK, 0);
  1101. /* We start with cmd_set high WLAN_SET = 1. */
  1102. gpio_set_value(WLAN_SET, 1);
  1103. gpio_direction_output(WLAN_DATA0, 1);
  1104. gpio_direction_output(WLAN_DATA1, 1);
  1105. gpio_direction_output(WLAN_DATA2, 1);
  1106. gpio_set_value(WLAN_DATA0, 0);
  1107. gpio_set_value(WLAN_DATA1, 0);
  1108. gpio_set_value(WLAN_DATA2, 0);
  1109. /* Prepare command and RF register address that need to sent out.
  1110. * Make sure that we send only 14 bits from LSB.
  1111. */
  1112. rf_cmd_and_addr = (((WLAN_RF_READ_REG_CMD) |
  1113. (rf_reg_addr << WLAN_RF_REG_ADDR_START_OFFSET)) &
  1114. WLAN_RF_READ_CMD_MASK);
  1115. for (count = 0; count < 5; count++) {
  1116. gpio_set_value(WLAN_CLK, 0);
  1117. rf_bit = (rf_cmd_and_addr & 0x1);
  1118. gpio_set_value(WLAN_DATA0, rf_bit ? 1 : 0);
  1119. rf_cmd_and_addr = (rf_cmd_and_addr >> 1);
  1120. rf_bit = (rf_cmd_and_addr & 0x1);
  1121. gpio_set_value(WLAN_DATA1, rf_bit ? 1 : 0);
  1122. rf_cmd_and_addr = (rf_cmd_and_addr >> 1);
  1123. rf_bit = (rf_cmd_and_addr & 0x1);
  1124. gpio_set_value(WLAN_DATA2, rf_bit ? 1 : 0);
  1125. rf_cmd_and_addr = (rf_cmd_and_addr >> 1);
  1126. /* Send the data out WLAN_CLK = 1 */
  1127. gpio_set_value(WLAN_CLK, 1);
  1128. }
  1129. /* Pull down the clock signal */
  1130. gpio_set_value(WLAN_CLK, 0);
  1131. /* Configure data pins to input IO pins */
  1132. gpio_direction_input(WLAN_DATA0);
  1133. gpio_direction_input(WLAN_DATA1);
  1134. gpio_direction_input(WLAN_DATA2);
  1135. for (count = 0; count < 2; count++) {
  1136. gpio_set_value(WLAN_CLK, 1);
  1137. gpio_set_value(WLAN_CLK, 0);
  1138. }
  1139. rf_bit = 0;
  1140. for (count = 0; count < 6; count++) {
  1141. gpio_set_value(WLAN_CLK, 1);
  1142. gpio_set_value(WLAN_CLK, 0);
  1143. rf_bit = gpio_get_value(WLAN_DATA0);
  1144. rf_data_received |= (rf_bit << (count * 3 + 0));
  1145. if (count != 5) {
  1146. rf_bit = gpio_get_value(WLAN_DATA1);
  1147. rf_data_received |= (rf_bit << (count * 3 + 1));
  1148. rf_bit = gpio_get_value(WLAN_DATA2);
  1149. rf_data_received |= (rf_bit << (count * 3 + 2));
  1150. }
  1151. }
  1152. gpio_set_value(WLAN_SET, 0);
  1153. wcnss_switch_to_5wire();
  1154. return rf_data_received;
  1155. }
  1156. #endif