Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010 Broadcom Corporation |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
Brett Rudley | c6ac24e | 2010-10-26 11:55:23 -0700 | [diff] [blame] | 17 | #include <linux/netdevice.h> |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 18 | #include <bcmutils.h> |
| 19 | |
| 20 | #include <dngl_stats.h> |
| 21 | #include <dhd.h> |
| 22 | |
| 23 | #include <wlioctl.h> |
| 24 | #include <wl_iw.h> |
| 25 | |
Joe Perches | f4528696d | 2010-12-14 12:51:52 -0800 | [diff] [blame] | 26 | #define WL_ERROR(fmt, args...) printk(fmt, ##args) |
| 27 | #define WL_TRACE(fmt, args...) no_printk(fmt, ##args) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 28 | |
| 29 | #ifdef CUSTOMER_HW |
| 30 | extern void bcm_wlan_power_off(int); |
| 31 | extern void bcm_wlan_power_on(int); |
| 32 | #endif /* CUSTOMER_HW */ |
| 33 | #ifdef CUSTOMER_HW2 |
| 34 | int wifi_set_carddetect(int on); |
| 35 | int wifi_set_power(int on, unsigned long msec); |
| 36 | int wifi_get_irq_number(unsigned long *irq_flags_ptr); |
| 37 | #endif |
| 38 | |
| 39 | #if defined(OOB_INTR_ONLY) |
| 40 | |
| 41 | #if defined(BCMLXSDMMC) |
| 42 | extern int sdioh_mmc_irq(int irq); |
| 43 | #endif /* (BCMLXSDMMC) */ |
| 44 | |
| 45 | #ifdef CUSTOMER_HW3 |
| 46 | #include <mach/gpio.h> |
| 47 | #endif |
| 48 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame^] | 49 | /* Customer specific Host GPIO definition */ |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 50 | static int dhd_oob_gpio_num = -1; /* GG 19 */ |
| 51 | |
| 52 | module_param(dhd_oob_gpio_num, int, 0644); |
| 53 | MODULE_PARM_DESC(dhd_oob_gpio_num, "DHD oob gpio number"); |
| 54 | |
| 55 | int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr) |
| 56 | { |
| 57 | int host_oob_irq = 0; |
| 58 | |
| 59 | #ifdef CUSTOMER_HW2 |
| 60 | host_oob_irq = wifi_get_irq_number(irq_flags_ptr); |
| 61 | |
| 62 | #else /* for NOT CUSTOMER_HW2 */ |
| 63 | #if defined(CUSTOM_OOB_GPIO_NUM) |
| 64 | if (dhd_oob_gpio_num < 0) |
| 65 | dhd_oob_gpio_num = CUSTOM_OOB_GPIO_NUM; |
| 66 | #endif |
| 67 | |
| 68 | if (dhd_oob_gpio_num < 0) { |
Joe Perches | f4528696d | 2010-12-14 12:51:52 -0800 | [diff] [blame] | 69 | WL_ERROR("%s: ERROR customer specific Host GPIO is NOT defined\n", |
| 70 | __func__); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 71 | return dhd_oob_gpio_num; |
| 72 | } |
| 73 | |
Joe Perches | f4528696d | 2010-12-14 12:51:52 -0800 | [diff] [blame] | 74 | WL_ERROR("%s: customer specific Host GPIO number is (%d)\n", |
| 75 | __func__, dhd_oob_gpio_num); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 76 | |
| 77 | #if defined CUSTOMER_HW |
| 78 | host_oob_irq = MSM_GPIO_TO_INT(dhd_oob_gpio_num); |
| 79 | #elif defined CUSTOMER_HW3 |
| 80 | gpio_request(dhd_oob_gpio_num, "oob irq"); |
| 81 | host_oob_irq = gpio_to_irq(dhd_oob_gpio_num); |
| 82 | gpio_direction_input(dhd_oob_gpio_num); |
| 83 | #endif /* CUSTOMER_HW */ |
| 84 | #endif /* CUSTOMER_HW2 */ |
| 85 | |
| 86 | return host_oob_irq; |
| 87 | } |
| 88 | #endif /* defined(OOB_INTR_ONLY) */ |
| 89 | |
| 90 | /* Customer function to control hw specific wlan gpios */ |
| 91 | void dhd_customer_gpio_wlan_ctrl(int onoff) |
| 92 | { |
| 93 | switch (onoff) { |
| 94 | case WLAN_RESET_OFF: |
Joe Perches | f4528696d | 2010-12-14 12:51:52 -0800 | [diff] [blame] | 95 | WL_TRACE("%s: call customer specific GPIO to insert WLAN RESET\n", |
| 96 | __func__); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 97 | #ifdef CUSTOMER_HW |
| 98 | bcm_wlan_power_off(2); |
| 99 | #endif /* CUSTOMER_HW */ |
| 100 | #ifdef CUSTOMER_HW2 |
| 101 | wifi_set_power(0, 0); |
| 102 | #endif |
Joe Perches | f4528696d | 2010-12-14 12:51:52 -0800 | [diff] [blame] | 103 | WL_ERROR("=========== WLAN placed in RESET ========\n"); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 104 | break; |
| 105 | |
| 106 | case WLAN_RESET_ON: |
Joe Perches | f4528696d | 2010-12-14 12:51:52 -0800 | [diff] [blame] | 107 | WL_TRACE("%s: callc customer specific GPIO to remove WLAN RESET\n", |
| 108 | __func__); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 109 | #ifdef CUSTOMER_HW |
| 110 | bcm_wlan_power_on(2); |
| 111 | #endif /* CUSTOMER_HW */ |
| 112 | #ifdef CUSTOMER_HW2 |
| 113 | wifi_set_power(1, 0); |
| 114 | #endif |
Joe Perches | f4528696d | 2010-12-14 12:51:52 -0800 | [diff] [blame] | 115 | WL_ERROR("=========== WLAN going back to live ========\n"); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 116 | break; |
| 117 | |
| 118 | case WLAN_POWER_OFF: |
Joe Perches | f4528696d | 2010-12-14 12:51:52 -0800 | [diff] [blame] | 119 | WL_TRACE("%s: call customer specific GPIO to turn off WL_REG_ON\n", |
| 120 | __func__); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 121 | #ifdef CUSTOMER_HW |
| 122 | bcm_wlan_power_off(1); |
| 123 | #endif /* CUSTOMER_HW */ |
| 124 | break; |
| 125 | |
| 126 | case WLAN_POWER_ON: |
Joe Perches | f4528696d | 2010-12-14 12:51:52 -0800 | [diff] [blame] | 127 | WL_TRACE("%s: call customer specific GPIO to turn on WL_REG_ON\n", |
| 128 | __func__); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 129 | #ifdef CUSTOMER_HW |
| 130 | bcm_wlan_power_on(1); |
| 131 | #endif /* CUSTOMER_HW */ |
| 132 | /* Lets customer power to get stable */ |
mike.rapoport@gmail.com | 7383141 | 2010-10-13 00:09:07 +0200 | [diff] [blame] | 133 | udelay(200); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 134 | break; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | #ifdef GET_CUSTOM_MAC_ENABLE |
| 139 | /* Function to get custom MAC address */ |
| 140 | int dhd_custom_get_mac_address(unsigned char *buf) |
| 141 | { |
Joe Perches | f4528696d | 2010-12-14 12:51:52 -0800 | [diff] [blame] | 142 | WL_TRACE("%s Enter\n", __func__); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 143 | if (!buf) |
| 144 | return -EINVAL; |
| 145 | |
| 146 | /* Customer access to MAC address stored outside of DHD driver */ |
| 147 | |
| 148 | #ifdef EXAMPLE_GET_MAC |
| 149 | /* EXAMPLE code */ |
| 150 | { |
Stanislav Fomichev | 0216069 | 2011-02-15 01:05:10 +0300 | [diff] [blame] | 151 | u8 ea_example[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}; |
| 152 | memcpy(buf, ea_example, ETH_ALEN); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 153 | } |
| 154 | #endif /* EXAMPLE_GET_MAC */ |
| 155 | |
| 156 | return 0; |
| 157 | } |
| 158 | #endif /* GET_CUSTOM_MAC_ENABLE */ |