1 /*
2 * Customer code to add GPIO control during WLAN start/stop
3 * Copyright (C) 1999-2009, Broadcom Corporation
4 *
5 * Unless you and Broadcom execute a separate written software license
6 * agreement governing use of this software, this software is licensed to you
7 * under the terms of the GNU General Public License version 2 (the "GPL"),
8 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
9 * following added to such license:
10 *
11 * As a special exception, the copyright holders of this software give you
12 * permission to link this software with independent modules, and to copy and
13 * distribute the resulting executable under terms of your choice, provided that
14 * you also meet, for each linked independent module, the terms and conditions of
15 * the license of that module. An independent module is a module which is not
16 * derived from this software. The special exception does not apply to any
17 * modifications of the software.
18 *
19 * Notwithstanding the above, under no circumstances may you combine this
20 * software in any way with any other Broadcom software provided under a license
21 * other than the GPL, without Broadcom's express prior written consent.
22 *
23 * $Id: dhd_custom_gpio.c,v 1.1.4.3 2009/10/14 04:29:34 Exp $
24 */
25
26
27 #include <typedefs.h>
28 #include <linuxver.h>
29 #include <osl.h>
30 #include <bcmutils.h>
31
32 #include <dngl_stats.h>
33 #include <dhd.h>
34
35 #include <wlioctl.h>
36 #include <wl_iw.h>
37
38 #define WL_ERROR(x) printf x
39 #define WL_TRACE(x)
40
41 #ifdef CUSTOMER_HW
42 extern void bcm_wlan_power_off(int);
43 extern void bcm_wlan_power_on(int);
44 #endif /* CUSTOMER_HW */
45
46 #ifdef CUSTOMER_HW2
47 int wifi_set_carddetect(int on);
48 int wifi_set_power(int on, unsigned long msec);
49 int wifi_get_irq_number(void);
50 #endif
51
52 #if defined(OOB_INTR_ONLY)
53
54 #if defined(BCMLXSDMMC)
55 extern int sdioh_mmc_irq(int irq);
56 #endif /* (BCMLXSDMMC) */
57
58 /* Customer specific Host GPIO defintion */
59 static int dhd_oob_gpio_num = -1; /* GG 19 */
60
61 module_param(dhd_oob_gpio_num, int, 0644);
62 MODULE_PARM_DESC(dhd_oob_gpio_num, "DHD oob gpio number");
63
dhd_customer_oob_irq_map(void)64 int dhd_customer_oob_irq_map(void)
65 {
66 int host_oob_irq;
67 #ifdef CUSTOMER_HW2
68 host_oob_irq = wifi_get_irq_number();
69 #else
70 #if defined(CUSTOM_OOB_GPIO_NUM)
71 if (dhd_oob_gpio_num < 0) {
72 dhd_oob_gpio_num = CUSTOM_OOB_GPIO_NUM;
73 }
74 #endif
75
76 if (dhd_oob_gpio_num < 0) {
77 WL_ERROR(("%s: ERROR customer specific Host GPIO is NOT defined \n", \
78 __FUNCTION__));
79 return (dhd_oob_gpio_num);
80 }
81
82 WL_ERROR(("%s: customer specific Host GPIO number is (%d)\n", \
83 __FUNCTION__, dhd_oob_gpio_num));
84
85 /* TODO : move it mmc specific code */
86 host_oob_irq = sdioh_mmc_irq(dhd_oob_gpio_num);
87 #endif
88 return (host_oob_irq);
89 }
90 #endif /* defined(OOB_INTR_ONLY) */
91
92 /* Customer function to control hw specific wlan gpios */
93 void
dhd_customer_gpio_wlan_ctrl(int onoff)94 dhd_customer_gpio_wlan_ctrl(int onoff)
95 {
96 switch (onoff) {
97 case WLAN_RESET_OFF:
98 WL_TRACE(("%s: call customer specific GPIO to insert WLAN RESET\n",
99 __FUNCTION__));
100 #ifdef CUSTOMER_HW
101 bcm_wlan_power_off(2);
102 #endif /* CUSTOMER_HW */
103 #ifdef CUSTOMER_HW2
104 wifi_set_power(0, 0);
105 #endif
106 WL_ERROR(("=========== WLAN placed in RESET ========\n"));
107 break;
108
109 case WLAN_RESET_ON:
110 WL_TRACE(("%s: callc customer specific GPIO to remove WLAN RESET\n",
111 __FUNCTION__));
112 #ifdef CUSTOMER_HW
113 bcm_wlan_power_on(2);
114 #endif /* CUSTOMER_HW */
115 #ifdef CUSTOMER_HW2
116 wifi_set_power(1, 0);
117 #endif
118 WL_ERROR(("=========== WLAN going back to live ========\n"));
119 break;
120
121 case WLAN_POWER_OFF:
122 WL_TRACE(("%s: call customer specific GPIO to turn off WL_REG_ON\n",
123 __FUNCTION__));
124 #ifdef CUSTOMER_HW
125 bcm_wlan_power_off(1);
126 #endif /* CUSTOMER_HW */
127 break;
128
129 case WLAN_POWER_ON:
130 WL_TRACE(("%s: call customer specific GPIO to turn on WL_REG_ON\n",
131 __FUNCTION__));
132 #ifdef CUSTOMER_HW
133 bcm_wlan_power_on(1);
134 #endif /* CUSTOMER_HW */
135 /* Lets customer power to get stable */
136 OSL_DELAY(500);
137 break;
138 }
139 }
140