1 /* 2 * Customer code to add GPIO control during WLAN start/stop 3 * Copyright (C) 1999-2010, 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.6 2010/02/19 22:56:49 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(unsigned long *irq_flags_ptr); 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 64 int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr) 65 { 66 int host_oob_irq; 67 #ifdef CUSTOMER_HW2 68 host_oob_irq = wifi_get_irq_number(irq_flags_ptr); 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 *irq_flags_ptr = IRQF_TRIGGER_FALLING; 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 host_oob_irq = sdioh_mmc_irq(dhd_oob_gpio_num); 86 #endif 87 return (host_oob_irq); 88 } 89 #endif /* defined(OOB_INTR_ONLY) */ 90 91 /* Customer function to control hw specific wlan gpios */ 92 void 93 dhd_customer_gpio_wlan_ctrl(int onoff) 94 { 95 switch (onoff) { 96 case WLAN_RESET_OFF: 97 WL_TRACE(("%s: call customer specific GPIO to insert WLAN RESET\n", 98 __FUNCTION__)); 99 #ifdef CUSTOMER_HW 100 bcm_wlan_power_off(2); 101 #endif /* CUSTOMER_HW */ 102 #ifdef CUSTOMER_HW2 103 wifi_set_power(0, 0); 104 #endif 105 WL_ERROR(("=========== WLAN placed in RESET ========\n")); 106 break; 107 108 case WLAN_RESET_ON: 109 WL_TRACE(("%s: callc customer specific GPIO to remove WLAN RESET\n", 110 __FUNCTION__)); 111 #ifdef CUSTOMER_HW 112 bcm_wlan_power_on(2); 113 #endif /* CUSTOMER_HW */ 114 #ifdef CUSTOMER_HW2 115 wifi_set_power(1, 0); 116 #endif 117 WL_ERROR(("=========== WLAN going back to live ========\n")); 118 break; 119 120 case WLAN_POWER_OFF: 121 WL_TRACE(("%s: call customer specific GPIO to turn off WL_REG_ON\n", 122 __FUNCTION__)); 123 #ifdef CUSTOMER_HW 124 bcm_wlan_power_off(1); 125 #endif /* CUSTOMER_HW */ 126 break; 127 128 case WLAN_POWER_ON: 129 WL_TRACE(("%s: call customer specific GPIO to turn on WL_REG_ON\n", 130 __FUNCTION__)); 131 #ifdef CUSTOMER_HW 132 bcm_wlan_power_on(1); 133 #endif /* CUSTOMER_HW */ 134 /* Lets customer power to get stable */ 135 OSL_DELAY(500); 136 break; 137 } 138 } 139