board-t10-gpiomux.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083
  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 Millet-All nc.chaudhary Added the gpiomux settings for 30-Jan-2014
  17. * variants UART for LCIA Test failure
  18. ******************************************************************************************
  19. */
  20. #ifdef CONFIG_WCNSS_IRIS_REGISTER_DUMP
  21. #include <linux/gpio.h>
  22. #endif
  23. #include <linux/init.h>
  24. #include <linux/ioport.h>
  25. #include <mach/board.h>
  26. #include <mach/gpio.h>
  27. #include <mach/gpiomux.h>
  28. #include <mach/socinfo.h>
  29. #ifdef CONFIG_WCNSS_IRIS_REGISTER_DUMP
  30. #define WLAN_CLK 44
  31. #define WLAN_SET 43
  32. #define WLAN_DATA0 42
  33. #define WLAN_DATA1 41
  34. #define WLAN_DATA2 40
  35. #endif
  36. /*Adding the GPIOMUX settings for suspend states */
  37. static struct gpiomux_setting gpio_suspend_config[] = {
  38. { /* IN/ NP/ L */
  39. .func = GPIOMUX_FUNC_GPIO,
  40. .drv = GPIOMUX_DRV_2MA,
  41. .pull = GPIOMUX_PULL_NONE,
  42. .dir = GPIOMUX_IN,
  43. },
  44. { /* OUT/ NP/ L */
  45. .func = GPIOMUX_FUNC_GPIO,
  46. .drv = GPIOMUX_DRV_2MA,
  47. .pull = GPIOMUX_PULL_NONE,
  48. .dir = GPIOMUX_OUT_LOW,
  49. },
  50. { /* IN/ PD/ L */
  51. .func = GPIOMUX_FUNC_GPIO,
  52. .drv = GPIOMUX_DRV_2MA,
  53. .pull = GPIOMUX_PULL_DOWN,
  54. .dir = GPIOMUX_IN,
  55. },
  56. { /* OUT/ PD/ L */
  57. .func = GPIOMUX_FUNC_GPIO,
  58. .drv = GPIOMUX_DRV_2MA,
  59. .pull = GPIOMUX_PULL_DOWN,
  60. .dir = GPIOMUX_OUT_LOW,
  61. },
  62. };
  63. #ifdef CONFIG_USB_EHCI_MSM_HSIC
  64. #if !defined(CONFIG_MACH_T10_3G_OPEN)
  65. static struct gpiomux_setting hsic_act_cfg = {
  66. .func = GPIOMUX_FUNC_1,
  67. .drv = GPIOMUX_DRV_16MA,
  68. .pull = GPIOMUX_PULL_NONE,
  69. };
  70. static struct msm_gpiomux_config msm_hsic_configs[] = {
  71. {
  72. .gpio = 115, /* HSIC_STROBE */
  73. .settings = {
  74. [GPIOMUX_ACTIVE] = &hsic_act_cfg,
  75. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[3], //OUT-PD-L
  76. },
  77. },
  78. {
  79. .gpio = 116, /* HSIC_DATA */
  80. .settings = {
  81. [GPIOMUX_ACTIVE] = &hsic_act_cfg,
  82. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[3], //OUT-PD-L
  83. },
  84. },
  85. };
  86. #endif
  87. #endif
  88. #define KS8851_IRQ_GPIO 115
  89. #define IN_PD_2MA_CFG(gpio_num) { \
  90. .gpio = gpio_num, \
  91. .settings ={\
  92. [GPIOMUX_ACTIVE] = &gpio_suspend_config[2],\
  93. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[2],\
  94. }\
  95. }
  96. #define MAKE_NC_CONFIG_INIT_SLEEP(gpio_num) IN_PD_2MA_CFG(gpio_num)
  97. #define IN_NP_2MA_CFG(gpio_num) { \
  98. .gpio = gpio_num, \
  99. .settings = {\
  100. [GPIOMUX_ACTIVE] = &gpio_suspend_config[0],\
  101. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],\
  102. }\
  103. }
  104. #define HW_CHK_BIT_CFG(gpio_num) IN_NP_2MA_CFG(gpio_num)
  105. #define OUT_NP_2MA_CFG(gpio_num) { \
  106. .gpio = gpio_num, \
  107. .settings = {\
  108. [GPIOMUX_ACTIVE] = &gpio_suspend_config[1],\
  109. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],\
  110. }\
  111. }
  112. #define OUT_PD_2MA_CFG(gpio_num) { \
  113. .gpio = gpio_num, \
  114. .settings = {\
  115. [GPIOMUX_ACTIVE] = &gpio_suspend_config[3],\
  116. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[3],\
  117. }\
  118. }
  119. #if defined(CONFIG_MACH_T10_WIFI_OPEN)
  120. static struct msm_gpiomux_config tn10_wifi_open_nc_gpio_cfgs[] __initdata = {
  121. MAKE_NC_CONFIG_INIT_SLEEP(0),
  122. MAKE_NC_CONFIG_INIT_SLEEP(1),
  123. MAKE_NC_CONFIG_INIT_SLEEP(2),
  124. MAKE_NC_CONFIG_INIT_SLEEP(3),
  125. MAKE_NC_CONFIG_INIT_SLEEP(4),
  126. MAKE_NC_CONFIG_INIT_SLEEP(5),
  127. MAKE_NC_CONFIG_INIT_SLEEP(32),
  128. MAKE_NC_CONFIG_INIT_SLEEP(56),
  129. MAKE_NC_CONFIG_INIT_SLEEP(57),
  130. MAKE_NC_CONFIG_INIT_SLEEP(58),
  131. MAKE_NC_CONFIG_INIT_SLEEP(59),
  132. MAKE_NC_CONFIG_INIT_SLEEP(60),
  133. MAKE_NC_CONFIG_INIT_SLEEP(62),
  134. MAKE_NC_CONFIG_INIT_SLEEP(64),
  135. MAKE_NC_CONFIG_INIT_SLEEP(66),
  136. MAKE_NC_CONFIG_INIT_SLEEP(116),
  137. };
  138. #endif
  139. #if defined(CONFIG_MACH_T10_3G_OPEN)
  140. static struct msm_gpiomux_config tn10_3g_nc_gpio_cfgs[] __initdata = {
  141. MAKE_NC_CONFIG_INIT_SLEEP(2),
  142. MAKE_NC_CONFIG_INIT_SLEEP(3),
  143. MAKE_NC_CONFIG_INIT_SLEEP(4),
  144. MAKE_NC_CONFIG_INIT_SLEEP(5),
  145. MAKE_NC_CONFIG_INIT_SLEEP(27),
  146. MAKE_NC_CONFIG_INIT_SLEEP(51),
  147. MAKE_NC_CONFIG_INIT_SLEEP(56),
  148. MAKE_NC_CONFIG_INIT_SLEEP(62),
  149. MAKE_NC_CONFIG_INIT_SLEEP(116),
  150. };
  151. static struct msm_gpiomux_config tn10_3g_nc_gpio22_cfgs[] __initdata = {
  152. MAKE_NC_CONFIG_INIT_SLEEP(22),
  153. };
  154. #endif
  155. static struct msm_gpiomux_config tn10_hw_chk_bit_cfgs[] __initdata = {
  156. HW_CHK_BIT_CFG(63), // BIT 0
  157. HW_CHK_BIT_CFG(49), // BIT 1
  158. HW_CHK_BIT_CFG(50), // BIT 2
  159. HW_CHK_BIT_CFG(114), // BIT 3
  160. };
  161. #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
  162. static struct gpiomux_setting gpio_eth_config = {
  163. .pull = GPIOMUX_PULL_UP,
  164. .drv = GPIOMUX_DRV_2MA,
  165. .func = GPIOMUX_FUNC_GPIO,
  166. };
  167. static struct msm_gpiomux_config msm_eth_configs[] = {
  168. {
  169. .gpio = KS8851_IRQ_GPIO,
  170. .settings = {
  171. [GPIOMUX_SUSPENDED] = &gpio_eth_config,
  172. }
  173. },
  174. };
  175. #endif
  176. static struct gpiomux_setting gpio_keys_active = {
  177. .func = GPIOMUX_FUNC_GPIO,
  178. .drv = GPIOMUX_DRV_2MA,
  179. .pull = GPIOMUX_PULL_UP,
  180. .dir = GPIOMUX_IN,
  181. };
  182. static struct gpiomux_setting gpio_keys_suspend = {
  183. .func = GPIOMUX_FUNC_GPIO,
  184. .drv = GPIOMUX_DRV_2MA,
  185. .pull = GPIOMUX_PULL_NONE,
  186. };
  187. static struct gpiomux_setting gpio_keys_suspend_vd = {
  188. .func = GPIOMUX_FUNC_GPIO,
  189. .drv = GPIOMUX_DRV_2MA,
  190. .pull = GPIOMUX_PULL_UP,
  191. .dir = GPIOMUX_IN,
  192. };
  193. #ifndef CONFIG_SND_SOC_MAX98504
  194. #if !defined(CONFIG_SEC_T10_WIFI_COMMON)
  195. static struct gpiomux_setting gpio_spi_cs_eth_config = {
  196. .func = GPIOMUX_FUNC_4,
  197. .drv = GPIOMUX_DRV_6MA,
  198. .pull = GPIOMUX_PULL_DOWN,
  199. };
  200. #endif
  201. #endif
  202. static struct gpiomux_setting wcnss_5wire_suspend_cfg = {
  203. .func = GPIOMUX_FUNC_GPIO,
  204. .drv = GPIOMUX_DRV_2MA,
  205. .pull = GPIOMUX_PULL_UP,
  206. };
  207. static struct gpiomux_setting wcnss_5wire_active_cfg = {
  208. .func = GPIOMUX_FUNC_1,
  209. .drv = GPIOMUX_DRV_6MA,
  210. .pull = GPIOMUX_PULL_DOWN,
  211. };
  212. #define WCNSS_5WIRE_CFG(gpio_num) { \
  213. .gpio = gpio_num, \
  214. .settings = {\
  215. [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,\
  216. [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,\
  217. }\
  218. }
  219. #ifdef CONFIG_WCNSS_IRIS_REGISTER_DUMP
  220. static struct gpiomux_setting wcnss_5gpio_suspend_cfg = {
  221. .func = GPIOMUX_FUNC_GPIO,
  222. .drv = GPIOMUX_DRV_2MA,
  223. .pull = GPIOMUX_PULL_UP,
  224. };
  225. static struct gpiomux_setting wcnss_5gpio_active_cfg = {
  226. .func = GPIOMUX_FUNC_GPIO,
  227. .drv = GPIOMUX_DRV_6MA,
  228. .pull = GPIOMUX_PULL_DOWN,
  229. };
  230. #define WCNSS_5GPIO_CFG(gpio_num) { \
  231. .gpio = gpio_num, \
  232. .settings = {\
  233. [GPIOMUX_ACTIVE] = &wcnss_5gpio_active_cfg,\
  234. [GPIOMUX_SUSPENDED] = &wcnss_5gpio_suspend_cfg,\
  235. }\
  236. }
  237. #endif
  238. static struct gpiomux_setting gpio_i2c_config = {
  239. .func = GPIOMUX_FUNC_3,
  240. .drv = GPIOMUX_DRV_2MA,
  241. .pull = GPIOMUX_PULL_NONE,
  242. };
  243. static struct msm_gpiomux_config msm_keypad_configs[] __initdata = {
  244. {
  245. .gpio = 106,
  246. .settings = {
  247. [GPIOMUX_ACTIVE] = &gpio_keys_active,
  248. [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
  249. },
  250. },
  251. {
  252. .gpio = 107,
  253. .settings = {
  254. [GPIOMUX_ACTIVE] = &gpio_keys_active,
  255. [GPIOMUX_SUSPENDED] = &gpio_keys_suspend_vd,
  256. },
  257. },
  258. {
  259. .gpio = 108,
  260. .settings = {
  261. [GPIOMUX_ACTIVE] = &gpio_keys_active,
  262. [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
  263. },
  264. },
  265. };
  266. static struct gpiomux_setting lcd_rst_act_cfg = {
  267. .func = GPIOMUX_FUNC_GPIO,
  268. .drv = GPIOMUX_DRV_2MA,
  269. .pull = GPIOMUX_PULL_NONE,
  270. .dir = GPIOMUX_OUT_HIGH,
  271. };
  272. static struct gpiomux_setting lcd_in_gpio_cfg = {
  273. .func = GPIOMUX_FUNC_GPIO,
  274. .drv = GPIOMUX_DRV_2MA,
  275. .pull = GPIOMUX_PULL_NONE,
  276. .dir = GPIOMUX_IN,
  277. };
  278. #define LCD_GPIO_CONFIG_1(gpio_num) { \
  279. .gpio = gpio_num, \
  280. .settings = {\
  281. [GPIOMUX_ACTIVE] = &lcd_in_gpio_cfg,\
  282. [GPIOMUX_SUSPENDED] = &lcd_in_gpio_cfg,\
  283. }\
  284. }
  285. #define LCD_GPIO_CONFIG_2(gpio_num) { \
  286. .gpio = gpio_num, \
  287. .settings = {\
  288. [GPIOMUX_ACTIVE] = &lcd_rst_act_cfg,\
  289. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[3],\
  290. }\
  291. }
  292. #define LCD_GPIO_CONFIG_3(gpio_num) { \
  293. .gpio = gpio_num, \
  294. .settings = {\
  295. [GPIOMUX_ACTIVE] = &gpio_suspend_config[1],\
  296. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[3],\
  297. }\
  298. }
  299. #define LCD_GPIO_CONFIG_4(gpio_num) { \
  300. .gpio = gpio_num, \
  301. .settings = {\
  302. [GPIOMUX_ACTIVE] = &lcd_rst_act_cfg,\
  303. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],\
  304. }\
  305. }
  306. static struct msm_gpiomux_config msm_lcd_configs[] __initdata = {
  307. LCD_GPIO_CONFIG_4(25), /* LVDS Ldo EN */
  308. LCD_GPIO_CONFIG_1(53), /* LCD LDI INT */
  309. LCD_GPIO_CONFIG_1(20), /* Backlight SDA */
  310. LCD_GPIO_CONFIG_1(21), /* Backlight SCL */
  311. LCD_GPIO_CONFIG_2(74), /* Backlight Reset */
  312. LCD_GPIO_CONFIG_2(51), /*LVDS Reset*/
  313. LCD_GPIO_CONFIG_3(33), /* Backlight PWM AP */
  314. };
  315. static struct gpiomux_setting gpio_uart_config = {
  316. .func = GPIOMUX_FUNC_2,
  317. .drv = GPIOMUX_DRV_8MA,
  318. .pull = GPIOMUX_PULL_NONE, /*should be pulled None for UART */
  319. .dir = GPIOMUX_OUT_HIGH,
  320. };
  321. static struct gpiomux_setting rx_gpio_uart_config = {
  322. .func = GPIOMUX_FUNC_2,
  323. .drv = GPIOMUX_DRV_8MA,
  324. .pull = GPIOMUX_PULL_DOWN, /*LCIA Test failure*/
  325. .dir = GPIOMUX_OUT_HIGH,
  326. };
  327. #define TSP_CFG(gpio_num) IN_NP_2MA_CFG(gpio_num)
  328. #define I2C_GPIO_CFG(gpio_num) { \
  329. .gpio = gpio_num,\
  330. .settings = {\
  331. [GPIOMUX_ACTIVE] = &gpio_i2c_config,\
  332. [GPIOMUX_SUSPENDED] = &gpio_i2c_config,\
  333. },\
  334. }
  335. #if defined(CONFIG_SEC_T10_PROJECT)
  336. static struct gpiomux_setting gpio_i2c_config_tsp = {
  337. .func = GPIOMUX_FUNC_GPIO,
  338. .drv = GPIOMUX_DRV_2MA,
  339. .pull = GPIOMUX_PULL_NONE,
  340. };
  341. #endif
  342. static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
  343. {
  344. .gpio = 8, /* UART TX */
  345. .settings = {
  346. [GPIOMUX_SUSPENDED] = &gpio_uart_config,
  347. },
  348. },
  349. {
  350. .gpio = 9, /* UART RX */
  351. .settings = {
  352. [GPIOMUX_SUSPENDED] = &rx_gpio_uart_config,
  353. },
  354. },
  355. {
  356. .gpio = 18, /* SW I2C_SDA */
  357. .settings = {
  358. [GPIOMUX_ACTIVE] = &gpio_i2c_config_tsp,
  359. [GPIOMUX_SUSPENDED] = &gpio_i2c_config_tsp,
  360. },
  361. },
  362. {
  363. .gpio = 19, /* SW I2C_SCL */
  364. .settings = {
  365. [GPIOMUX_ACTIVE] = &gpio_i2c_config_tsp,
  366. [GPIOMUX_SUSPENDED] = &gpio_i2c_config_tsp,
  367. },
  368. },
  369. TSP_CFG(55), /* BLSP1 QUP5 I2C_SCL TSP GPIO */
  370. #ifndef CONFIG_SND_SOC_MAX98504
  371. #if !defined(CONFIG_SEC_T10_WIFI_COMMON)
  372. {
  373. .gpio = 22, /* BLSP1 QUP1 SPI_CS_ETH */
  374. .settings = {
  375. [GPIOMUX_SUSPENDED] = &gpio_spi_cs_eth_config,
  376. },
  377. },
  378. #endif
  379. #endif
  380. I2C_GPIO_CFG(6), /* BLSP1 QUP2 I2C_SDA */
  381. I2C_GPIO_CFG(7), /* BLSP1 QUP2 I2C_SCL */
  382. };
  383. static struct gpiomux_setting gpio_nc_cfg = {
  384. .func = GPIOMUX_FUNC_GPIO,
  385. .drv = GPIOMUX_DRV_2MA,
  386. .pull = GPIOMUX_PULL_NONE,
  387. };
  388. static struct gpiomux_setting goodix_ldo_en_act_cfg = {
  389. .func = GPIOMUX_FUNC_GPIO,
  390. .drv = GPIOMUX_DRV_6MA,
  391. .pull = GPIOMUX_PULL_UP,
  392. };
  393. static struct gpiomux_setting goodix_int_act_cfg = {
  394. .func = GPIOMUX_FUNC_GPIO,
  395. .drv = GPIOMUX_DRV_6MA,
  396. .pull = GPIOMUX_PULL_UP,
  397. };
  398. static struct gpiomux_setting goodix_reset_act_cfg = {
  399. .func = GPIOMUX_FUNC_GPIO,
  400. .drv = GPIOMUX_DRV_6MA,
  401. .pull = GPIOMUX_PULL_UP,
  402. };
  403. static struct msm_gpiomux_config msm_skuf_blsp_configs[] __initdata = {
  404. {
  405. .gpio = 2, /* NC */
  406. .settings = {
  407. [GPIOMUX_SUSPENDED] = &gpio_nc_cfg,
  408. },
  409. },
  410. {
  411. .gpio = 3, /* NC */
  412. .settings = {
  413. [GPIOMUX_SUSPENDED] = &gpio_nc_cfg,
  414. },
  415. },
  416. {
  417. .gpio = 4, /* NC */
  418. .settings = {
  419. [GPIOMUX_SUSPENDED] = &gpio_nc_cfg,
  420. },
  421. },
  422. {
  423. .gpio = 14, /* NC */
  424. .settings = {
  425. [GPIOMUX_SUSPENDED] = &gpio_nc_cfg,
  426. },
  427. },
  428. };
  429. static struct msm_gpiomux_config msm_skuf_goodix_configs[] __initdata = {
  430. {
  431. .gpio = 15, /* LDO EN */
  432. .settings = {
  433. [GPIOMUX_ACTIVE] = &goodix_ldo_en_act_cfg,
  434. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[2], // IN-PD-L
  435. },
  436. },
  437. {
  438. .gpio = 16, /* RESET */
  439. .settings = {
  440. [GPIOMUX_ACTIVE] = &goodix_reset_act_cfg,
  441. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[2], // IN-PD-L
  442. },
  443. },
  444. {
  445. .gpio = 17, /* INT */
  446. .settings = {
  447. [GPIOMUX_ACTIVE] = &goodix_int_act_cfg,
  448. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[2], // IN-PD-L
  449. },
  450. },
  451. {
  452. .gpio = 18, /* BLSP1 QUP5 I2C_SDA */
  453. .settings = {
  454. [GPIOMUX_ACTIVE] = &gpio_i2c_config,
  455. [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
  456. },
  457. },
  458. {
  459. .gpio = 19, /* BLSP1 QUP5 I2C_SCL */
  460. .settings = {
  461. [GPIOMUX_ACTIVE] = &gpio_i2c_config,
  462. [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
  463. },
  464. },
  465. };
  466. static struct gpiomux_setting nfc_wake_act_cfg = {
  467. .func = GPIOMUX_FUNC_GPIO,
  468. .drv = GPIOMUX_DRV_6MA,
  469. .pull = GPIOMUX_PULL_UP,
  470. };
  471. static struct msm_gpiomux_config msm_skuf_nfc_configs[] __initdata = {
  472. { /* NFC WAKE */
  473. .gpio = 5,
  474. .settings = {
  475. [GPIOMUX_ACTIVE] = &nfc_wake_act_cfg,
  476. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1], // OUT-NP-L
  477. },
  478. },
  479. };
  480. static struct gpiomux_setting sd_card_det_active_config = {
  481. .func = GPIOMUX_FUNC_GPIO,
  482. .drv = GPIOMUX_DRV_2MA,
  483. .pull = GPIOMUX_PULL_NONE,
  484. .dir = GPIOMUX_IN,
  485. };
  486. static struct msm_gpiomux_config sd_card_det __initdata = {
  487. .gpio = 38,
  488. .settings = {
  489. [GPIOMUX_ACTIVE] = &sd_card_det_active_config,
  490. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0], // IN-NP-L
  491. },
  492. };
  493. #define GRIP_IRQ_CFG(gpio_num) IN_NP_2MA_CFG(gpio_num)
  494. #define ACCEL_IRQ_CFG(gpio_num) IN_PD_2MA_CFG(gpio_num)
  495. #define HALL_IC_CFG(gpio_num) IN_NP_2MA_CFG(gpio_num)
  496. static struct msm_gpiomux_config msm_nativesensors_configs[] __initdata = {
  497. GRIP_IRQ_CFG(66), /* GRIP IRQ */
  498. ACCEL_IRQ_CFG(54), /* ACCEL IRQ */
  499. HALL_IC_CFG(110), /* Hall IC GPIOs */
  500. };
  501. #if defined(CONFIG_SEC_T10_WIFI_COMMON)
  502. #define NFC_EN_CFG(gpio_num) IN_NP_2MA_CFG(gpio_num)
  503. #define NFC_IRQ_CFG(gpio_num) IN_PD_2MA_CFG(gpio_num)
  504. #define NFC_FW_CFG(gpio_num) OUT_NP_2MA_CFG(gpio_num)
  505. static struct msm_gpiomux_config msm_nfc_configs[] __initdata = {
  506. NFC_IRQ_CFG(13), /* NFC IRQ */
  507. NFC_EN_CFG(0), /* NFC EN */
  508. NFC_FW_CFG(1), /* NFC FIRMWARE */
  509. };
  510. #endif
  511. static struct msm_gpiomux_config wcnss_5wire_interface[] = {
  512. WCNSS_5WIRE_CFG(40),
  513. WCNSS_5WIRE_CFG(41),
  514. WCNSS_5WIRE_CFG(42),
  515. WCNSS_5WIRE_CFG(43),
  516. WCNSS_5WIRE_CFG(44),
  517. };
  518. #ifdef CONFIG_WCNSS_IRIS_REGISTER_DUMP
  519. static struct msm_gpiomux_config wcnss_5gpio_interface[] = {
  520. WCNSS_5GPIO_CFG(40),
  521. WCNSS_5GPIO_CFG(41),
  522. WCNSS_5GPIO_CFG(42),
  523. WCNSS_5GPIO_CFG(43),
  524. WCNSS_5GPIO_CFG(44),
  525. };
  526. #endif
  527. static struct msm_gpiomux_config tsp_gpiomux_config[] = {
  528. {
  529. .gpio = 55, /* TSP_VENDOR1 */
  530. .settings = {
  531. [GPIOMUX_ACTIVE] = &gpio_suspend_config[0], //IP NP and Low
  532. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0], //IP NP and Low
  533. },
  534. },
  535. {
  536. .gpio = 73, /* TSP_VENDOR2 */
  537. .settings = {
  538. [GPIOMUX_ACTIVE] = &gpio_suspend_config[0], //IP NP and Low
  539. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0], //IP NP and Low
  540. },
  541. },
  542. {
  543. .gpio = 31, /* TOUCH_EN */
  544. .settings = {
  545. [GPIOMUX_ACTIVE] = &gpio_suspend_config[1], //OP NP and Low
  546. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1], //OP NP and Low
  547. },
  548. },
  549. };
  550. static struct gpiomux_setting cam_settings[] = {
  551. {
  552. .func = GPIOMUX_FUNC_1, /*active 1*/ /* 0 */
  553. .drv = GPIOMUX_DRV_2MA,
  554. .pull = GPIOMUX_PULL_NONE,
  555. },
  556. {
  557. .func = GPIOMUX_FUNC_1, /*suspend*/ /* 1 */
  558. .drv = GPIOMUX_DRV_2MA,
  559. .pull = GPIOMUX_PULL_DOWN,
  560. },
  561. {
  562. .func = GPIOMUX_FUNC_1, /*i2c suspend*/ /* 2 */
  563. .drv = GPIOMUX_DRV_2MA,
  564. .pull = GPIOMUX_PULL_KEEPER,
  565. },
  566. {
  567. .func = GPIOMUX_FUNC_GPIO, /*active 0*/ /* 3 */
  568. .drv = GPIOMUX_DRV_2MA,
  569. .pull = GPIOMUX_PULL_NONE,
  570. },
  571. {
  572. .func = GPIOMUX_FUNC_GPIO, /*suspend 0*/ /* 4 */
  573. .drv = GPIOMUX_DRV_2MA,
  574. .pull = GPIOMUX_PULL_DOWN,
  575. },
  576. {
  577. .func = GPIOMUX_FUNC_GPIO, /*active 1*/ /* 5 */
  578. .drv = GPIOMUX_DRV_2MA,
  579. .pull = GPIOMUX_PULL_NONE,
  580. .dir = GPIOMUX_OUT_LOW,
  581. },
  582. };
  583. static struct msm_gpiomux_config msm_sensor_configs[] __initdata = {
  584. {
  585. .gpio = 16, /* VTCAM_1.8V */
  586. .settings = {
  587. [GPIOMUX_ACTIVE] = &cam_settings[5],
  588. [GPIOMUX_SUSPENDED] = &cam_settings[5],
  589. },
  590. },
  591. {
  592. .gpio = 26, /* CAM_MCLK0 */
  593. .settings = {
  594. [GPIOMUX_ACTIVE] = &cam_settings[0],
  595. [GPIOMUX_SUSPENDED] = &cam_settings[1],
  596. },
  597. },
  598. {
  599. .gpio = 28, /* CAM2_RST_N */
  600. .settings = {
  601. [GPIOMUX_ACTIVE] = &cam_settings[3],
  602. [GPIOMUX_SUSPENDED] = &cam_settings[4],
  603. },
  604. },
  605. {
  606. .gpio = 29, /* CCI_I2C_SDA0 */
  607. .settings = {
  608. [GPIOMUX_ACTIVE] = &cam_settings[0],
  609. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0], // IN-NP-L
  610. },
  611. },
  612. {
  613. .gpio = 30, /* CCI_I2C_SCL0 */
  614. .settings = {
  615. [GPIOMUX_ACTIVE] = &cam_settings[0],
  616. [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0], // IN-NP-L
  617. },
  618. },
  619. {
  620. .gpio = 35, /* CAM2_STANDBY_N */
  621. .settings = {
  622. [GPIOMUX_ACTIVE] = &cam_settings[3],
  623. [GPIOMUX_SUSPENDED] = &cam_settings[4],
  624. },
  625. },
  626. {
  627. .gpio = 36, /* CAM1_STANDBY_N */
  628. .settings = {
  629. [GPIOMUX_ACTIVE] = &cam_settings[3],
  630. [GPIOMUX_SUSPENDED] = &cam_settings[4],
  631. },
  632. },
  633. {
  634. .gpio = 37, /* CAM1_RST_N */
  635. .settings = {
  636. [GPIOMUX_ACTIVE] = &cam_settings[3],
  637. [GPIOMUX_SUSPENDED] = &cam_settings[4],
  638. },
  639. },
  640. {
  641. .gpio = 112, /* CAM1_ANALOG_EN */
  642. .settings = {
  643. [GPIOMUX_ACTIVE] = &cam_settings[5],
  644. [GPIOMUX_SUSPENDED] = &cam_settings[5],
  645. },
  646. },
  647. };
  648. static struct msm_gpiomux_config msm_sensor_configs_skuf_plus[] __initdata = {
  649. #if !defined(CONFIG_SEC_T10_WIFI_COMMON)
  650. {
  651. .gpio = 22, /* CAM1_VDD */
  652. .settings = {
  653. [GPIOMUX_ACTIVE] = &cam_settings[3],
  654. [GPIOMUX_SUSPENDED] = &cam_settings[4],
  655. },
  656. },
  657. #endif
  658. {
  659. .gpio = 34, /* CAM1 VCM_PWDN */
  660. .settings = {
  661. [GPIOMUX_ACTIVE] = &cam_settings[3],
  662. [GPIOMUX_SUSPENDED] = &cam_settings[4],
  663. },
  664. },
  665. };
  666. #define TA_NCHG_CFG(gpio_num) IN_NP_2MA_CFG(gpio_num)
  667. #define OVP_ENABLE_CFG(gpio_num) OUT_NP_2MA_CFG(gpio_num)
  668. static struct msm_gpiomux_config msm_ta_nchg_configs[] = {
  669. TA_NCHG_CFG(10), /* CHG SDA 1.8V */
  670. TA_NCHG_CFG(52), /* TA_NCHG */
  671. TA_NCHG_CFG(115), /* TA_INT_N */
  672. IN_PD_2MA_CFG(46), /* Fuel alert*/
  673. };
  674. static struct msm_gpiomux_config ovp_enable_configs[] = {
  675. OVP_ENABLE_CFG(64),
  676. };
  677. #if defined (CONFIG_SAMSUNG_JACK)
  678. #define EARJACK_CFG(gpio_num) IN_NP_2MA_CFG(gpio_num)
  679. static struct msm_gpiomux_config msm_earjack_gpio_configs[] __initdata = {
  680. EARJACK_CFG(111), /* EAR_SEND_END */
  681. };
  682. #endif
  683. static struct gpiomux_setting lineout_en_gpio_configs = {
  684. .func = GPIOMUX_FUNC_GPIO,
  685. .drv = GPIOMUX_DRV_2MA,
  686. .dir = GPIOMUX_OUT_LOW,
  687. .pull = GPIOMUX_PULL_DOWN,
  688. };
  689. static struct msm_gpiomux_config msm_lineout_en_gpio_configs[] __initdata = {
  690. {
  691. #if defined(CONFIG_SEC_T10_WIFI_COMMON)
  692. .gpio = 12, /* LINEOUT_EN */
  693. #else
  694. .gpio = 23, /* LINEOUT_EN */
  695. #endif
  696. .settings = {
  697. [GPIOMUX_ACTIVE] = &lineout_en_gpio_configs,
  698. [GPIOMUX_SUSPENDED] = &lineout_en_gpio_configs,
  699. },
  700. }
  701. };
  702. static struct gpiomux_setting spk_en_gpio_configs = {
  703. .func = GPIOMUX_FUNC_GPIO,
  704. .drv = GPIOMUX_DRV_2MA,
  705. .dir = GPIOMUX_OUT_LOW,
  706. .pull = GPIOMUX_PULL_NONE,
  707. };
  708. static struct msm_gpiomux_config msm_spk_en_gpio_configs[] __initdata = {
  709. {
  710. .gpio = 24, /* SPK_EN */
  711. .settings = {
  712. [GPIOMUX_ACTIVE] = &spk_en_gpio_configs,
  713. [GPIOMUX_SUSPENDED] = &spk_en_gpio_configs,
  714. },
  715. }
  716. };
  717. static struct gpiomux_setting usb_otg_sw_cfg = {
  718. .func = GPIOMUX_FUNC_GPIO,
  719. .drv = GPIOMUX_DRV_2MA,
  720. .dir = GPIOMUX_OUT_LOW,
  721. };
  722. static struct msm_gpiomux_config usb_otg_sw_configs[] __initdata = {
  723. {
  724. .gpio = 67,
  725. .settings = {
  726. [GPIOMUX_SUSPENDED] = &usb_otg_sw_cfg,
  727. },
  728. },
  729. };
  730. #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
  731. static struct gpiomux_setting sdc3_clk_actv_cfg = {
  732. .func = GPIOMUX_FUNC_2,
  733. .drv = GPIOMUX_DRV_8MA,
  734. .pull = GPIOMUX_PULL_NONE,
  735. };
  736. static struct gpiomux_setting sdc3_cmd_data_0_3_actv_cfg = {
  737. .func = GPIOMUX_FUNC_2,
  738. .drv = GPIOMUX_DRV_8MA,
  739. .pull = GPIOMUX_PULL_UP,
  740. };
  741. static struct gpiomux_setting sdc3_suspend_cfg = {
  742. .func = GPIOMUX_FUNC_GPIO,
  743. .drv = GPIOMUX_DRV_2MA,
  744. .pull = GPIOMUX_PULL_DOWN,
  745. };
  746. static struct gpiomux_setting sdc3_data_1_suspend_cfg = {
  747. .func = GPIOMUX_FUNC_GPIO,
  748. .drv = GPIOMUX_DRV_2MA,
  749. .pull = GPIOMUX_PULL_UP,
  750. };
  751. static struct msm_gpiomux_config msm8226_sdc3_configs[] __initdata = {
  752. {
  753. /* DAT3 */
  754. .gpio = 39,
  755. .settings = {
  756. [GPIOMUX_ACTIVE] = &sdc3_cmd_data_0_3_actv_cfg,
  757. [GPIOMUX_SUSPENDED] = &sdc3_suspend_cfg,
  758. },
  759. },
  760. {
  761. /* DAT2 */
  762. .gpio = 40,
  763. .settings = {
  764. [GPIOMUX_ACTIVE] = &sdc3_cmd_data_0_3_actv_cfg,
  765. [GPIOMUX_SUSPENDED] = &sdc3_suspend_cfg,
  766. },
  767. },
  768. {
  769. /* DAT1 */
  770. .gpio = 41,
  771. .settings = {
  772. [GPIOMUX_ACTIVE] = &sdc3_cmd_data_0_3_actv_cfg,
  773. [GPIOMUX_SUSPENDED] = &sdc3_data_1_suspend_cfg,
  774. },
  775. },
  776. {
  777. /* DAT0 */
  778. .gpio = 42,
  779. .settings = {
  780. [GPIOMUX_ACTIVE] = &sdc3_cmd_data_0_3_actv_cfg,
  781. [GPIOMUX_SUSPENDED] = &sdc3_suspend_cfg,
  782. },
  783. },
  784. {
  785. /* CMD */
  786. .gpio = 43,
  787. .settings = {
  788. [GPIOMUX_ACTIVE] = &sdc3_cmd_data_0_3_actv_cfg,
  789. [GPIOMUX_SUSPENDED] = &sdc3_suspend_cfg,
  790. },
  791. },
  792. {
  793. /* CLK */
  794. .gpio = 44,
  795. .settings = {
  796. [GPIOMUX_ACTIVE] = &sdc3_clk_actv_cfg,
  797. [GPIOMUX_SUSPENDED] = &sdc3_suspend_cfg,
  798. },
  799. },
  800. };
  801. static void msm_gpiomux_sdc3_install(void)
  802. {
  803. msm_gpiomux_install(msm8226_sdc3_configs,
  804. ARRAY_SIZE(msm8226_sdc3_configs));
  805. }
  806. #else
  807. static void msm_gpiomux_sdc3_install(void) {}
  808. #endif /* CONFIG_MMC_MSM_SDC3_SUPPORT */
  809. extern int system_rev;
  810. void __init msm8226_init_gpiomux(void)
  811. {
  812. int rc;
  813. rc = msm_gpiomux_init_dt();
  814. if (rc) {
  815. pr_err("%s failed %d\n", __func__, rc);
  816. return;
  817. }
  818. #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
  819. msm_gpiomux_install(msm_eth_configs, ARRAY_SIZE(msm_eth_configs));
  820. #endif
  821. msm_gpiomux_install(msm_keypad_configs,
  822. ARRAY_SIZE(msm_keypad_configs));
  823. if (of_board_is_skuf())
  824. msm_gpiomux_install(msm_skuf_blsp_configs,
  825. ARRAY_SIZE(msm_skuf_blsp_configs));
  826. else
  827. msm_gpiomux_install(msm_blsp_configs,
  828. ARRAY_SIZE(msm_blsp_configs));
  829. msm_gpiomux_install(wcnss_5wire_interface,
  830. ARRAY_SIZE(wcnss_5wire_interface));
  831. msm_gpiomux_install(tsp_gpiomux_config,
  832. ARRAY_SIZE(tsp_gpiomux_config));
  833. msm_gpiomux_install(&sd_card_det, 1);
  834. if (of_board_is_skuf())
  835. msm_gpiomux_install(msm_skuf_goodix_configs,
  836. ARRAY_SIZE(msm_skuf_goodix_configs));
  837. if (of_board_is_skuf())
  838. msm_gpiomux_install(msm_skuf_nfc_configs,
  839. ARRAY_SIZE(msm_skuf_nfc_configs));
  840. msm_gpiomux_install_nowrite(msm_lcd_configs,
  841. ARRAY_SIZE(msm_lcd_configs));
  842. msm_gpiomux_install(msm_sensor_configs, ARRAY_SIZE(msm_sensor_configs));
  843. if (of_board_is_skuf())
  844. msm_gpiomux_install(msm_sensor_configs_skuf_plus,
  845. ARRAY_SIZE(msm_sensor_configs_skuf_plus));
  846. msm_gpiomux_install(msm_ta_nchg_configs, ARRAY_SIZE(msm_ta_nchg_configs));
  847. msm_gpiomux_install(ovp_enable_configs, ARRAY_SIZE(ovp_enable_configs));
  848. if (of_board_is_cdp() || of_board_is_mtp() || of_board_is_xpm())
  849. msm_gpiomux_install(usb_otg_sw_configs,
  850. ARRAY_SIZE(usb_otg_sw_configs));
  851. msm_gpiomux_install(msm_nativesensors_configs,ARRAY_SIZE(msm_nativesensors_configs));
  852. msm_gpiomux_sdc3_install();
  853. #if defined(CONFIG_SEC_T10_WIFI_COMMON)
  854. msm_gpiomux_install(msm_nfc_configs, ARRAY_SIZE(msm_nfc_configs));
  855. #endif
  856. /*
  857. * HSIC STROBE gpio is also used by the ethernet. Install HSIC
  858. * gpio mux config only when HSIC is enabled. HSIC config will
  859. * be disabled when ethernet config is enabled.
  860. */
  861. #ifdef CONFIG_USB_EHCI_MSM_HSIC
  862. #if !defined(CONFIG_MACH_T10_3G_OPEN)
  863. if (machine_is_msm8926()) {
  864. msm_hsic_configs[0].gpio = 119; /* STROBE */
  865. msm_hsic_configs[1].gpio = 120; /* DATA */
  866. }
  867. msm_gpiomux_install(msm_hsic_configs, ARRAY_SIZE(msm_hsic_configs));
  868. #endif
  869. #endif
  870. #if defined(CONFIG_SAMSUNG_JACK)
  871. msm_gpiomux_install(msm_earjack_gpio_configs, ARRAY_SIZE(msm_earjack_gpio_configs));
  872. #endif
  873. msm_gpiomux_install(msm_lineout_en_gpio_configs, ARRAY_SIZE(msm_lineout_en_gpio_configs));
  874. msm_gpiomux_install(msm_spk_en_gpio_configs, ARRAY_SIZE(msm_spk_en_gpio_configs));
  875. #ifdef CONFIG_SND_SOC_MAX98504
  876. {
  877. msm_gpiomux_install(msm8226_tertiary_mi2s_configs,ARRAY_SIZE(msm8226_tertiary_mi2s_configs));
  878. msm_gpiomux_install(msm8226_blsp_codec_configs,ARRAY_SIZE(msm8226_blsp_codec_configs));
  879. }
  880. #endif
  881. /* Install NC Configurations */
  882. #if defined(CONFIG_MACH_T10_WIFI_OPEN)
  883. msm_gpiomux_install(tn10_wifi_open_nc_gpio_cfgs, ARRAY_SIZE(tn10_wifi_open_nc_gpio_cfgs));
  884. #endif
  885. msm_gpiomux_install(tn10_hw_chk_bit_cfgs, ARRAY_SIZE(tn10_hw_chk_bit_cfgs));
  886. #if defined (CONFIG_MACH_T10_3G_OPEN)
  887. msm_gpiomux_install(tn10_3g_nc_gpio_cfgs, ARRAY_SIZE(tn10_3g_nc_gpio_cfgs));
  888. if(system_rev >= 2)
  889. msm_gpiomux_install(tn10_3g_nc_gpio22_cfgs, ARRAY_SIZE(tn10_3g_nc_gpio22_cfgs));
  890. #endif
  891. }
  892. #ifdef CONFIG_WCNSS_IRIS_REGISTER_DUMP
  893. static void wcnss_switch_to_gpio(void)
  894. {
  895. /* Switch MUX to GPIO */
  896. msm_gpiomux_install(wcnss_5gpio_interface,
  897. ARRAY_SIZE(wcnss_5gpio_interface));
  898. /* Ensure GPIO config */
  899. gpio_direction_input(WLAN_DATA2);
  900. gpio_direction_input(WLAN_DATA1);
  901. gpio_direction_input(WLAN_DATA0);
  902. gpio_direction_output(WLAN_SET, 0);
  903. gpio_direction_output(WLAN_CLK, 0);
  904. }
  905. static void wcnss_switch_to_5wire(void)
  906. {
  907. msm_gpiomux_install(wcnss_5wire_interface,
  908. ARRAY_SIZE(wcnss_5wire_interface));
  909. }
  910. u32 wcnss_rf_read_reg(u32 rf_reg_addr)
  911. {
  912. int count = 0;
  913. u32 rf_cmd_and_addr = 0;
  914. u32 rf_data_received = 0;
  915. u32 rf_bit = 0;
  916. wcnss_switch_to_gpio();
  917. /* Reset the signal if it is already being used. */
  918. gpio_set_value(WLAN_SET, 0);
  919. gpio_set_value(WLAN_CLK, 0);
  920. /* We start with cmd_set high WLAN_SET = 1. */
  921. gpio_set_value(WLAN_SET, 1);
  922. gpio_direction_output(WLAN_DATA0, 1);
  923. gpio_direction_output(WLAN_DATA1, 1);
  924. gpio_direction_output(WLAN_DATA2, 1);
  925. gpio_set_value(WLAN_DATA0, 0);
  926. gpio_set_value(WLAN_DATA1, 0);
  927. gpio_set_value(WLAN_DATA2, 0);
  928. /* Prepare command and RF register address that need to sent out.
  929. * Make sure that we send only 14 bits from LSB.
  930. */
  931. rf_cmd_and_addr = (((WLAN_RF_READ_REG_CMD) |
  932. (rf_reg_addr << WLAN_RF_REG_ADDR_START_OFFSET)) &
  933. WLAN_RF_READ_CMD_MASK);
  934. for (count = 0; count < 5; count++) {
  935. gpio_set_value(WLAN_CLK, 0);
  936. rf_bit = (rf_cmd_and_addr & 0x1);
  937. gpio_set_value(WLAN_DATA0, rf_bit ? 1 : 0);
  938. rf_cmd_and_addr = (rf_cmd_and_addr >> 1);
  939. rf_bit = (rf_cmd_and_addr & 0x1);
  940. gpio_set_value(WLAN_DATA1, rf_bit ? 1 : 0);
  941. rf_cmd_and_addr = (rf_cmd_and_addr >> 1);
  942. rf_bit = (rf_cmd_and_addr & 0x1);
  943. gpio_set_value(WLAN_DATA2, rf_bit ? 1 : 0);
  944. rf_cmd_and_addr = (rf_cmd_and_addr >> 1);
  945. /* Send the data out WLAN_CLK = 1 */
  946. gpio_set_value(WLAN_CLK, 1);
  947. }
  948. /* Pull down the clock signal */
  949. gpio_set_value(WLAN_CLK, 0);
  950. /* Configure data pins to input IO pins */
  951. gpio_direction_input(WLAN_DATA0);
  952. gpio_direction_input(WLAN_DATA1);
  953. gpio_direction_input(WLAN_DATA2);
  954. for (count = 0; count < 2; count++) {
  955. gpio_set_value(WLAN_CLK, 1);
  956. gpio_set_value(WLAN_CLK, 0);
  957. }
  958. rf_bit = 0;
  959. for (count = 0; count < 6; count++) {
  960. gpio_set_value(WLAN_CLK, 1);
  961. gpio_set_value(WLAN_CLK, 0);
  962. rf_bit = gpio_get_value(WLAN_DATA0);
  963. rf_data_received |= (rf_bit << (count * 3 + 0));
  964. if (count != 5) {
  965. rf_bit = gpio_get_value(WLAN_DATA1);
  966. rf_data_received |= (rf_bit << (count * 3 + 1));
  967. rf_bit = gpio_get_value(WLAN_DATA2);
  968. rf_data_received |= (rf_bit << (count * 3 + 2));
  969. }
  970. }
  971. gpio_set_value(WLAN_SET, 0);
  972. wcnss_switch_to_5wire();
  973. return rf_data_received;
  974. }
  975. #endif