2 * Customer code to add GPIO control during WLAN start/stop
3 * Copyright (C) 1999-2011, Broadcom Corporation
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:
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.
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.
23 * $Id: dhd_custom_gpio.c,v 1.2.42.1 2010-10-19 00:41:09 $
31 #include <dngl_stats.h>
37 #define WL_ERROR(x) printf x
41 extern void bcm_wlan_power_off(int);
42 extern void bcm_wlan_power_on(int);
43 #endif /* CUSTOMER_HW */
44 #if defined(CONFIG_MACH_MAHIMAHI)
45 int wifi_set_carddetect(int on);
46 int wifi_set_power(int on, unsigned long msec);
47 int wifi_get_irq_number(unsigned long *irq_flags_ptr);
48 int wifi_get_mac_addr(unsigned char *buf);
51 #if defined(OOB_INTR_ONLY)
53 #if defined(BCMLXSDMMC)
54 extern int sdioh_mmc_irq(int irq);
55 #endif /* (BCMLXSDMMC) */
57 #if defined(CUSTOMER_HW3) || defined(CUSTOMER_HW_SAMSUNG_SLP)
58 #include <mach/gpio.h>
61 /* Customer specific Host GPIO defintion */
62 #ifdef CUSTOMER_HW_SAMSUNG_SLP
63 static int dhd_oob_gpio_num = IRQ_EINT(21);
65 static int dhd_oob_gpio_num = -1; /* GG 19 */
68 module_param(dhd_oob_gpio_num, int, 0644);
69 MODULE_PARM_DESC(dhd_oob_gpio_num, "DHD oob gpio number");
71 /* that function will returns :
72 1) return : Host gpio interrupt number per customer platform
73 2) irq_flags_ptr : Type of Host interrupt as Level or Edge
76 Customer should check his platform definitions
77 and hist Host Interrupt spec
78 to figure out the proper setting for his platform.
79 BRCM provides just reference settings as example.
82 int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr)
86 #ifdef CONFIG_MACH_MAHIMAHI
87 host_oob_irq = wifi_get_irq_number(irq_flags_ptr);
89 #else /* for NOT CONFIG_MACH_MAHIMAHI */
90 #if defined(CUSTOM_OOB_GPIO_NUM)
91 if (dhd_oob_gpio_num < 0) {
92 dhd_oob_gpio_num = CUSTOM_OOB_GPIO_NUM;
96 if (dhd_oob_gpio_num < 0) {
97 WL_ERROR(("%s: ERROR customer specific Host GPIO is NOT defined \n",
99 return (dhd_oob_gpio_num);
102 WL_ERROR(("%s: customer specific Host GPIO number is (%d)\n",
103 __FUNCTION__, dhd_oob_gpio_num));
105 #if defined CUSTOMER_HW
106 host_oob_irq = MSM_GPIO_TO_INT(dhd_oob_gpio_num);
107 #elif defined CUSTOMER_HW3
108 gpio_request(dhd_oob_gpio_num, "oob irq");
109 host_oob_irq = gpio_to_irq(dhd_oob_gpio_num);
110 gpio_direction_input(dhd_oob_gpio_num);
111 #elif defined CUSTOMER_HW_SAMSUNG_SLP
112 host_oob_irq = dhd_oob_gpio_num;
113 #endif /* CUSTOMER_HW */
114 #endif /* CONFIG_MACH_MAHIMAHI */
116 return (host_oob_irq);
118 #endif /* defined(OOB_INTR_ONLY) */
120 /* Customer function to control hw specific wlan gpios */
122 dhd_customer_gpio_wlan_ctrl(int onoff)
126 WL_TRACE(("%s: call customer specific GPIO to insert WLAN RESET\n",
129 bcm_wlan_power_off(2);
130 #endif /* CUSTOMER_HW */
131 #ifdef CONFIG_MACH_MAHIMAHI
132 wifi_set_power(0, 0);
134 WL_ERROR(("=========== WLAN placed in RESET ========\n"));
138 WL_TRACE(("%s: callc customer specific GPIO to remove WLAN RESET\n",
141 bcm_wlan_power_on(2);
142 #endif /* CUSTOMER_HW */
143 #ifdef CONFIG_MACH_MAHIMAHI
144 wifi_set_power(1, 0);
146 WL_ERROR(("=========== WLAN going back to live ========\n"));
150 WL_TRACE(("%s: call customer specific GPIO to turn off WL_REG_ON\n",
153 bcm_wlan_power_off(1);
154 #endif /* CUSTOMER_HW */
158 WL_TRACE(("%s: call customer specific GPIO to turn on WL_REG_ON\n",
161 bcm_wlan_power_on(1);
162 #endif /* CUSTOMER_HW */
163 /* Lets customer power to get stable */
169 #ifdef GET_CUSTOM_MAC_ENABLE
170 /* Function to get custom MAC address */
172 dhd_custom_get_mac_address(unsigned char *buf)
176 WL_TRACE(("%s Enter\n", __FUNCTION__));
180 /* Customer access to MAC address stored outside of DHD driver */
181 #if defined(CONFIG_MACH_MAHIMAHI) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
182 /* Lin - this will call wifi_control_data->get_mac_addr (dhd_linux.c) */
183 ret = wifi_get_mac_addr(buf);
186 #ifdef EXAMPLE_GET_MAC
189 struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
190 bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
192 #endif /* EXAMPLE_GET_MAC */
196 #endif /* GET_CUSTOM_MAC_ENABLE */