1 /******************************************************************************
2 * Customer code to add GPIO control during WLAN start/stop
4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 ******************************************************************************/
21 #include "drv_types.h"
23 #ifdef CONFIG_PLATFORM_SPRD
25 //gspi func & GPIO define
26 #include <mach/gpio.h>//0915
27 #include <mach/board.h>
29 #if !(defined ANDROID_2X)
31 #ifdef CONFIG_RTL8188E
32 #include <mach/regulator.h>
33 #include <linux/regulator/consumer.h>
34 #endif // CONFIG_RTL8188E
36 #ifndef GPIO_WIFI_POWER
37 #define GPIO_WIFI_POWER -1
38 #endif // !GPIO_WIFI_POWER
40 #ifndef GPIO_WIFI_RESET
41 #define GPIO_WIFI_RESET -1
42 #endif // !GPIO_WIFI_RESET
44 #ifndef GPIO_WIFI_PWDN
45 #define GPIO_WIFI_PWDN -1
46 #endif // !GPIO_WIFI_RESET
47 #ifdef CONFIG_GSPI_HCI
48 extern unsigned int oob_irq;
49 #endif // CONFIG_GSPI_HCI
51 #ifdef CONFIG_SDIO_HCI
52 extern int rtw_mp_mode;
53 #else // !CONFIG_SDIO_HCI
54 #endif // !CONFIG_SDIO_HCI
56 int rtw_wifi_gpio_init(void)
58 #ifdef CONFIG_GSPI_HCI
59 if (GPIO_WIFI_IRQ > 0) {
60 gpio_request(GPIO_WIFI_IRQ, "oob_irq");
61 gpio_direction_input(GPIO_WIFI_IRQ);
63 oob_irq = gpio_to_irq(GPIO_WIFI_IRQ);
65 DBG_8192C("%s oob_irq:%d\n", __func__, oob_irq);
68 if (GPIO_WIFI_RESET > 0)
69 gpio_request(GPIO_WIFI_RESET , "wifi_rst");
70 if (GPIO_WIFI_POWER > 0)
71 gpio_request(GPIO_WIFI_POWER, "wifi_power");
73 #ifdef CONFIG_SDIO_HCI
74 #if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B)) && (MP_DRIVER == 1)
76 DBG_871X("%s GPIO_BT_RESET pin special for mp_test\n", __func__);
77 if (GPIO_BT_RESET > 0)
78 gpio_request(GPIO_BT_RESET , "bt_rst");
85 int rtw_wifi_gpio_deinit(void)
87 #ifdef CONFIG_GSPI_HCI
88 if (GPIO_WIFI_IRQ > 0)
89 gpio_free(GPIO_WIFI_IRQ);
91 if (GPIO_WIFI_RESET > 0)
92 gpio_free(GPIO_WIFI_RESET );
93 if (GPIO_WIFI_POWER > 0)
94 gpio_free(GPIO_WIFI_POWER);
96 #ifdef CONFIG_SDIO_HCI
97 #if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B)) && (MP_DRIVER == 1)
99 DBG_871X("%s GPIO_BT_RESET pin special for mp_test\n", __func__);
100 if (GPIO_BT_RESET > 0)
101 gpio_free(GPIO_BT_RESET);
108 /* Customer function to control hw specific wlan gpios */
109 void rtw_wifi_gpio_wlan_ctrl(int onoff)
114 DBG_8192C("%s: call customer specific GPIO(%d) to set wifi power down pin to 0\n",
115 __FUNCTION__, GPIO_WIFI_RESET);
117 #ifndef CONFIG_DONT_BUS_SCAN
118 if (GPIO_WIFI_RESET > 0)
119 gpio_direction_output(GPIO_WIFI_RESET , 0);
124 DBG_8192C("%s: callc customer specific GPIO(%d) to set wifi power down pin to 1\n",
125 __FUNCTION__, GPIO_WIFI_RESET);
127 if (GPIO_WIFI_RESET > 0)
128 gpio_direction_output(GPIO_WIFI_RESET , 1);
136 #ifdef CONFIG_SDIO_HCI
137 #if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B)) && (MP_DRIVER == 1)
138 case WLAN_BT_PWDN_OFF:
141 DBG_871X("%s: call customer specific GPIO to set wifi power down pin to 0\n",
143 if (GPIO_BT_RESET > 0)
144 gpio_direction_output(GPIO_BT_RESET , 0);
148 case WLAN_BT_PWDN_ON:
151 DBG_871X("%s: callc customer specific GPIO to set wifi power down pin to 1 %x\n",
152 __FUNCTION__, GPIO_BT_RESET);
154 if (GPIO_BT_RESET > 0)
155 gpio_direction_output(GPIO_BT_RESET , 1);
165 #include <mach/ldo.h>
167 #ifdef CONFIG_RTL8188E
168 extern int sprd_3rdparty_gpio_wifi_power;
170 extern int sprd_3rdparty_gpio_wifi_pwd;
171 #if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B))
172 extern int sprd_3rdparty_gpio_bt_reset;
175 int rtw_wifi_gpio_init(void)
177 #if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B))
178 if (sprd_3rdparty_gpio_bt_reset > 0)
179 gpio_direction_output(sprd_3rdparty_gpio_bt_reset, 1);
185 int rtw_wifi_gpio_deinit(void)
190 /* Customer function to control hw specific wlan gpios */
191 void rtw_wifi_gpio_wlan_ctrl(int onoff)
196 DBG_8192C("%s: call customer specific GPIO to set wifi power down pin to 0\n",
198 if (sprd_3rdparty_gpio_wifi_pwd > 0)
200 gpio_set_value(sprd_3rdparty_gpio_wifi_pwd, 0);
203 if (sprd_3rdparty_gpio_wifi_pwd == 60) {
204 DBG_8192C("%s: turn off VSIM2 2.8V\n", __func__);
205 LDO_TurnOffLDO(LDO_LDO_SIM2);
210 DBG_8192C("%s: callc customer specific GPIO to set wifi power down pin to 1\n",
212 if (sprd_3rdparty_gpio_wifi_pwd == 60) {
213 DBG_8192C("%s: turn on VSIM2 2.8V\n", __func__);
214 LDO_SetVoltLevel(LDO_LDO_SIM2, LDO_VOLT_LEVEL0);
215 LDO_TurnOnLDO(LDO_LDO_SIM2);
217 if (sprd_3rdparty_gpio_wifi_pwd > 0)
219 gpio_set_value(sprd_3rdparty_gpio_wifi_pwd, 1);
224 #ifdef CONFIG_RTL8188E
225 #ifdef CONFIG_WIF1_LDO
226 DBG_8192C("%s: turn off VDD-WIFI0 1.2V\n", __FUNCTION__);
227 LDO_TurnOffLDO(LDO_LDO_WIF1);
228 #endif //CONFIG_WIF1_LDO
230 DBG_8192C("%s: turn off VDD-WIFI0 3.3V\n", __FUNCTION__);
231 LDO_TurnOffLDO(LDO_LDO_WIF0);
233 DBG_8192C("%s: call customer specific GPIO(%d) to turn off wifi power\n",
234 __FUNCTION__, sprd_3rdparty_gpio_wifi_power);
235 if (sprd_3rdparty_gpio_wifi_power != 65535)
236 gpio_set_value(sprd_3rdparty_gpio_wifi_power, 0);
241 #ifdef CONFIG_RTL8188E
242 DBG_8192C("%s: call customer specific GPIO(%d) to turn on wifi power\n",
243 __FUNCTION__, sprd_3rdparty_gpio_wifi_power);
244 if (sprd_3rdparty_gpio_wifi_power != 65535)
245 gpio_set_value(sprd_3rdparty_gpio_wifi_power, 1);
247 DBG_8192C("%s: turn on VDD-WIFI0 3.3V\n", __FUNCTION__);
248 LDO_TurnOnLDO(LDO_LDO_WIF0);
249 LDO_SetVoltLevel(LDO_LDO_WIF0,LDO_VOLT_LEVEL1);
251 #ifdef CONFIG_WIF1_LDO
252 DBG_8192C("%s: turn on VDD-WIFI1 1.2V\n", __func__);
253 LDO_TurnOnLDO(LDO_LDO_WIF1);
254 LDO_SetVoltLevel(LDO_LDO_WIF1,LDO_VOLT_LEVEL3);
255 #endif //CONFIG_WIF1_LDO
259 case WLAN_BT_PWDN_OFF:
260 DBG_8192C("%s: call customer specific GPIO to set bt power down pin to 0\n",
262 #if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B))
263 if (sprd_3rdparty_gpio_bt_reset > 0)
264 gpio_set_value(sprd_3rdparty_gpio_bt_reset, 0);
268 case WLAN_BT_PWDN_ON:
269 DBG_8192C("%s: callc customer specific GPIO to set bt power down pin to 1\n",
271 #if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B))
272 if (sprd_3rdparty_gpio_bt_reset > 0)
273 gpio_set_value(sprd_3rdparty_gpio_bt_reset, 1);
280 #else // !CONFIG_PLATFORM_SPRD
282 int rtw_wifi_gpio_init(void)
287 void rtw_wifi_gpio_wlan_ctrl(int onoff)
290 #endif //CONFIG_PLATFORM_SPRD