]>
Commit | Line | Data |
---|---|---|
cf2b4488 HP |
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 | ||
c6ac24e9 | 17 | #include <linux/netdevice.h> |
cf2b4488 HP |
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 | ||
f4528696 JP |
26 | #define WL_ERROR(fmt, args...) printk(fmt, ##args) |
27 | #define WL_TRACE(fmt, args...) no_printk(fmt, ##args) | |
cf2b4488 HP |
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 | ||
25985edc | 49 | /* Customer specific Host GPIO definition */ |
cf2b4488 HP |
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) { | |
f4528696 JP |
69 | WL_ERROR("%s: ERROR customer specific Host GPIO is NOT defined\n", |
70 | __func__); | |
cf2b4488 HP |
71 | return dhd_oob_gpio_num; |
72 | } | |
73 | ||
f4528696 JP |
74 | WL_ERROR("%s: customer specific Host GPIO number is (%d)\n", |
75 | __func__, dhd_oob_gpio_num); | |
cf2b4488 HP |
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: | |
f4528696 JP |
95 | WL_TRACE("%s: call customer specific GPIO to insert WLAN RESET\n", |
96 | __func__); | |
cf2b4488 HP |
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 | |
f4528696 | 103 | WL_ERROR("=========== WLAN placed in RESET ========\n"); |
cf2b4488 HP |
104 | break; |
105 | ||
106 | case WLAN_RESET_ON: | |
f4528696 JP |
107 | WL_TRACE("%s: callc customer specific GPIO to remove WLAN RESET\n", |
108 | __func__); | |
cf2b4488 HP |
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 | |
f4528696 | 115 | WL_ERROR("=========== WLAN going back to live ========\n"); |
cf2b4488 HP |
116 | break; |
117 | ||
118 | case WLAN_POWER_OFF: | |
f4528696 JP |
119 | WL_TRACE("%s: call customer specific GPIO to turn off WL_REG_ON\n", |
120 | __func__); | |
cf2b4488 HP |
121 | #ifdef CUSTOMER_HW |
122 | bcm_wlan_power_off(1); | |
123 | #endif /* CUSTOMER_HW */ | |
124 | break; | |
125 | ||
126 | case WLAN_POWER_ON: | |
f4528696 JP |
127 | WL_TRACE("%s: call customer specific GPIO to turn on WL_REG_ON\n", |
128 | __func__); | |
cf2b4488 HP |
129 | #ifdef CUSTOMER_HW |
130 | bcm_wlan_power_on(1); | |
131 | #endif /* CUSTOMER_HW */ | |
132 | /* Lets customer power to get stable */ | |
7383141b | 133 | udelay(200); |
cf2b4488 HP |
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 | { | |
f4528696 | 142 | WL_TRACE("%s Enter\n", __func__); |
cf2b4488 HP |
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 | { | |
02160695 SF |
151 | u8 ea_example[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}; |
152 | memcpy(buf, ea_example, ETH_ALEN); | |
cf2b4488 HP |
153 | } |
154 | #endif /* EXAMPLE_GET_MAC */ | |
155 | ||
156 | return 0; | |
157 | } | |
158 | #endif /* GET_CUSTOM_MAC_ENABLE */ |