Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 1 | /* |
Pavel Machek | a253129 | 2010-07-18 14:27:13 +0200 | [diff] [blame] | 2 | * Copyright 2008 Pavel Machek <pavel@ucw.cz> |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 3 | * |
| 4 | * Distribute under GPLv2. |
Pekka Enberg | 7c49a0a | 2009-04-08 11:14:05 +0300 | [diff] [blame] | 5 | * |
| 6 | * The original driver was written by: |
| 7 | * Jeff Lee <YY_Lee@issc.com.tw> |
| 8 | * |
| 9 | * and was adapted to the 2.6 kernel by: |
| 10 | * Costantino Leandro (Rxart Desktop) <le_costantino@pixartargentina.com.ar> |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 11 | */ |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 12 | #include <net/mac80211.h> |
Pekka Enberg | 80aba53 | 2008-10-30 13:04:29 +0200 | [diff] [blame] | 13 | #include <linux/usb.h> |
Paul Gortmaker | 4529623 | 2011-08-30 17:50:46 -0400 | [diff] [blame] | 14 | #include <linux/module.h> |
Pekka Enberg | 80aba53 | 2008-10-30 13:04:29 +0200 | [diff] [blame] | 15 | |
Pekka Enberg | cc18071 | 2008-10-30 16:14:35 +0200 | [diff] [blame] | 16 | #include "core.h" |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 17 | #include "mds_f.h" |
Pekka Enberg | 64328c8 | 2009-01-07 17:33:45 +0200 | [diff] [blame] | 18 | #include "mto.h" |
Pekka Enberg | b5ef076 | 2010-11-01 21:50:06 +0200 | [diff] [blame] | 19 | #include "wbhal.h" |
Pekka Enberg | 72ca881 | 2010-11-01 21:50:05 +0200 | [diff] [blame] | 20 | #include "wb35reg_f.h" |
| 21 | #include "wb35tx_f.h" |
| 22 | #include "wb35rx_f.h" |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 23 | |
Pekka Enberg | 7b9a79b | 2008-10-30 18:12:01 +0200 | [diff] [blame] | 24 | MODULE_DESCRIPTION("IS89C35 802.11bg WLAN USB Driver"); |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 25 | MODULE_LICENSE("GPL"); |
| 26 | MODULE_VERSION("0.1"); |
| 27 | |
Greg Kroah-Hartman | 43a3469 | 2012-08-17 17:48:37 -0700 | [diff] [blame] | 28 | static const struct usb_device_id wb35_table[] = { |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 29 | { USB_DEVICE(0x0416, 0x0035) }, |
| 30 | { USB_DEVICE(0x18E8, 0x6201) }, |
| 31 | { USB_DEVICE(0x18E8, 0x6206) }, |
| 32 | { USB_DEVICE(0x18E8, 0x6217) }, |
| 33 | { USB_DEVICE(0x18E8, 0x6230) }, |
| 34 | { USB_DEVICE(0x18E8, 0x6233) }, |
| 35 | { USB_DEVICE(0x1131, 0x2035) }, |
Greg Kroah-Hartman | 68ab0c9 | 2008-10-21 10:41:45 -0700 | [diff] [blame] | 36 | { 0, } |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 37 | }; |
| 38 | |
Pekka Enberg | dd38da4 | 2008-10-21 13:01:42 +0300 | [diff] [blame] | 39 | MODULE_DEVICE_TABLE(usb, wb35_table); |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 40 | |
Greg Kroah-Hartman | 68ab0c9 | 2008-10-21 10:41:45 -0700 | [diff] [blame] | 41 | static struct ieee80211_rate wbsoft_rates[] = { |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 42 | { .bitrate = 10, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
| 43 | }; |
| 44 | |
Greg Kroah-Hartman | 68ab0c9 | 2008-10-21 10:41:45 -0700 | [diff] [blame] | 45 | static struct ieee80211_channel wbsoft_channels[] = { |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 46 | { .center_freq = 2412 }, |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 47 | }; |
| 48 | |
Pekka Enberg | a36e089 | 2008-10-28 00:20:03 +0200 | [diff] [blame] | 49 | static struct ieee80211_supported_band wbsoft_band_2GHz = { |
| 50 | .channels = wbsoft_channels, |
| 51 | .n_channels = ARRAY_SIZE(wbsoft_channels), |
| 52 | .bitrates = wbsoft_rates, |
| 53 | .n_bitrates = ARRAY_SIZE(wbsoft_rates), |
| 54 | }; |
| 55 | |
Pekka Enberg | 4074e77 | 2009-09-21 12:52:15 +0300 | [diff] [blame] | 56 | static void hal_set_beacon_period(struct hw_data *pHwData, u16 beacon_period) |
| 57 | { |
| 58 | u32 tmp; |
| 59 | |
| 60 | if (pHwData->SurpriseRemove) |
| 61 | return; |
| 62 | |
| 63 | pHwData->BeaconPeriod = beacon_period; |
| 64 | tmp = pHwData->BeaconPeriod << 16; |
| 65 | tmp |= pHwData->ProbeDelay; |
| 66 | Wb35Reg_Write(pHwData, 0x0848, tmp); |
| 67 | } |
| 68 | |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 69 | static int wbsoft_add_interface(struct ieee80211_hw *dev, |
Greg Kroah-Hartman | a71b676 | 2010-03-04 08:44:13 -0800 | [diff] [blame] | 70 | struct ieee80211_vif *vif) |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 71 | { |
Pekka Enberg | 4074e77 | 2009-09-21 12:52:15 +0300 | [diff] [blame] | 72 | struct wbsoft_priv *priv = dev->priv; |
| 73 | |
Greg Kroah-Hartman | a71b676 | 2010-03-04 08:44:13 -0800 | [diff] [blame] | 74 | hal_set_beacon_period(&priv->sHwData, vif->bss_conf.beacon_int); |
Pekka Enberg | 4074e77 | 2009-09-21 12:52:15 +0300 | [diff] [blame] | 75 | |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | static void wbsoft_remove_interface(struct ieee80211_hw *dev, |
Greg Kroah-Hartman | a71b676 | 2010-03-04 08:44:13 -0800 | [diff] [blame] | 80 | struct ieee80211_vif *vif) |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 81 | { |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 82 | } |
| 83 | |
Greg Kroah-Hartman | 68ab0c9 | 2008-10-21 10:41:45 -0700 | [diff] [blame] | 84 | static void wbsoft_stop(struct ieee80211_hw *hw) |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 85 | { |
Greg Kroah-Hartman | 68ab0c9 | 2008-10-21 10:41:45 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | static int wbsoft_get_stats(struct ieee80211_hw *hw, |
| 89 | struct ieee80211_low_level_stats *stats) |
| 90 | { |
Greg Kroah-Hartman | 68ab0c9 | 2008-10-21 10:41:45 -0700 | [diff] [blame] | 91 | return 0; |
| 92 | } |
| 93 | |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 94 | static u64 wbsoft_prepare_multicast(struct ieee80211_hw *hw, |
| 95 | struct netdev_hw_addr_list *mc_list) |
Jeff Mahoney | 6d7fd64 | 2009-10-08 17:27:51 -0400 | [diff] [blame] | 96 | { |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 97 | return netdev_hw_addr_list_count(mc_list); |
Jeff Mahoney | 6d7fd64 | 2009-10-08 17:27:51 -0400 | [diff] [blame] | 98 | } |
| 99 | |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 100 | static void wbsoft_configure_filter(struct ieee80211_hw *dev, |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 101 | unsigned int changed_flags, |
| 102 | unsigned int *total_flags, |
Jeff Mahoney | 6d7fd64 | 2009-10-08 17:27:51 -0400 | [diff] [blame] | 103 | u64 multicast) |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 104 | { |
Pekka Enberg | 6ab3212 | 2009-03-27 19:46:45 +0200 | [diff] [blame] | 105 | unsigned int new_flags; |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 106 | |
| 107 | new_flags = 0; |
| 108 | |
Pekka Enberg | 6ab3212 | 2009-03-27 19:46:45 +0200 | [diff] [blame] | 109 | if (*total_flags & FIF_PROMISC_IN_BSS) |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 110 | new_flags |= FIF_PROMISC_IN_BSS; |
Jeff Mahoney | 6d7fd64 | 2009-10-08 17:27:51 -0400 | [diff] [blame] | 111 | else if ((*total_flags & FIF_ALLMULTI) || (multicast > 32)) |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 112 | new_flags |= FIF_ALLMULTI; |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 113 | |
| 114 | dev->flags &= ~IEEE80211_HW_RX_INCLUDES_FCS; |
| 115 | |
| 116 | *total_flags = new_flags; |
| 117 | } |
| 118 | |
Thomas Huehn | 36323f8 | 2012-07-23 21:33:42 +0200 | [diff] [blame] | 119 | static void wbsoft_tx(struct ieee80211_hw *dev, |
| 120 | struct ieee80211_tx_control *control, |
| 121 | struct sk_buff *skb) |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 122 | { |
Pekka Enberg | cc18071 | 2008-10-30 16:14:35 +0200 | [diff] [blame] | 123 | struct wbsoft_priv *priv = dev->priv; |
| 124 | |
Ashvini Varatharaj | f68cae4 | 2013-10-21 19:27:30 +0530 | [diff] [blame] | 125 | if (priv->sMlmeFrame.is_in_used != PACKET_FREE_TO_USE) { |
Pekka Enberg | 11c9a55 | 2010-09-19 13:01:03 +0300 | [diff] [blame] | 126 | priv->sMlmeFrame.wNumTxMMPDUDiscarded++; |
Johannes Berg | 7bb4568 | 2011-02-24 14:42:06 +0100 | [diff] [blame] | 127 | kfree_skb(skb); |
| 128 | return; |
Pekka Enberg | 11c9a55 | 2010-09-19 13:01:03 +0300 | [diff] [blame] | 129 | } |
| 130 | |
Ashvini Varatharaj | f68cae4 | 2013-10-21 19:27:30 +0530 | [diff] [blame] | 131 | priv->sMlmeFrame.is_in_used = PACKET_COME_FROM_MLME; |
Pekka Enberg | 11c9a55 | 2010-09-19 13:01:03 +0300 | [diff] [blame] | 132 | |
| 133 | priv->sMlmeFrame.pMMPDU = skb->data; |
Ashvini Varatharaj | f68cae4 | 2013-10-21 19:27:30 +0530 | [diff] [blame] | 134 | priv->sMlmeFrame.data_type = FRAME_TYPE_802_11_MANAGEMENT; |
Pekka Enberg | 11c9a55 | 2010-09-19 13:01:03 +0300 | [diff] [blame] | 135 | priv->sMlmeFrame.len = skb->len; |
| 136 | priv->sMlmeFrame.wNumTxMMPDU++; |
| 137 | |
| 138 | /* |
| 139 | * H/W will enter power save by set the register. S/W don't send null |
| 140 | * frame with PWRMgt bit enbled to enter power save now. |
| 141 | */ |
| 142 | |
| 143 | Mds_Tx(priv); |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 144 | } |
| 145 | |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 146 | static int wbsoft_start(struct ieee80211_hw *dev) |
| 147 | { |
Pekka Enberg | c930e0c0 | 2008-10-30 18:12:04 +0200 | [diff] [blame] | 148 | struct wbsoft_priv *priv = dev->priv; |
| 149 | |
| 150 | priv->enabled = true; |
| 151 | |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 152 | return 0; |
| 153 | } |
| 154 | |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 155 | static void hal_set_radio_mode(struct hw_data *pHwData, unsigned char radio_off) |
| 156 | { |
| 157 | struct wb35_reg *reg = &pHwData->reg; |
| 158 | |
| 159 | if (pHwData->SurpriseRemove) |
| 160 | return; |
| 161 | |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 162 | if (radio_off) { /* disable Baseband receive off */ |
| 163 | pHwData->CurrentRadioSw = 1; /* off */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 164 | reg->M24_MacControl &= 0xffffffbf; |
| 165 | } else { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 166 | pHwData->CurrentRadioSw = 0; /* on */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 167 | reg->M24_MacControl |= 0x00000040; |
| 168 | } |
| 169 | Wb35Reg_Write(pHwData, 0x0824, reg->M24_MacControl); |
| 170 | } |
| 171 | |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 172 | static void hal_set_current_channel_ex(struct hw_data *pHwData, struct chan_info channel) |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 173 | { |
| 174 | struct wb35_reg *reg = &pHwData->reg; |
| 175 | |
| 176 | if (pHwData->SurpriseRemove) |
| 177 | return; |
| 178 | |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 179 | RFSynthesizer_SwitchingChannel(pHwData, channel); /* Switch channel */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 180 | pHwData->Channel = channel.ChanNo; |
| 181 | pHwData->band = channel.band; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 182 | reg->M28_MacControl &= ~0xff; /* Clean channel information field */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 183 | reg->M28_MacControl |= channel.ChanNo; |
| 184 | Wb35Reg_WriteWithCallbackValue(pHwData, 0x0828, reg->M28_MacControl, |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 185 | (s8 *) &channel, |
| 186 | sizeof(struct chan_info)); |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 187 | } |
| 188 | |
Pekka Enberg | 440a233 | 2009-12-18 23:08:18 +0200 | [diff] [blame] | 189 | static void hal_set_current_channel(struct hw_data *pHwData, struct chan_info channel) |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 190 | { |
| 191 | hal_set_current_channel_ex(pHwData, channel); |
| 192 | } |
| 193 | |
| 194 | static void hal_set_accept_broadcast(struct hw_data *pHwData, u8 enable) |
| 195 | { |
| 196 | struct wb35_reg *reg = &pHwData->reg; |
| 197 | |
| 198 | if (pHwData->SurpriseRemove) |
| 199 | return; |
| 200 | |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 201 | reg->M00_MacControl &= ~0x02000000; /* The HW value */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 202 | |
| 203 | if (enable) |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 204 | reg->M00_MacControl |= 0x02000000; /* The HW value */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 205 | |
| 206 | Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); |
| 207 | } |
| 208 | |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 209 | /* For wep key error detection, we need to accept broadcast packets to be received temporary. */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 210 | static void hal_set_accept_promiscuous(struct hw_data *pHwData, u8 enable) |
| 211 | { |
| 212 | struct wb35_reg *reg = &pHwData->reg; |
| 213 | |
| 214 | if (pHwData->SurpriseRemove) |
| 215 | return; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 216 | |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 217 | if (enable) { |
| 218 | reg->M00_MacControl |= 0x00400000; |
| 219 | Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); |
| 220 | } else { |
| 221 | reg->M00_MacControl &= ~0x00400000; |
| 222 | Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | static void hal_set_accept_multicast(struct hw_data *pHwData, u8 enable) |
| 227 | { |
| 228 | struct wb35_reg *reg = &pHwData->reg; |
| 229 | |
| 230 | if (pHwData->SurpriseRemove) |
| 231 | return; |
| 232 | |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 233 | reg->M00_MacControl &= ~0x01000000; /* The HW value */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 234 | if (enable) |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 235 | reg->M00_MacControl |= 0x01000000; /* The HW value */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 236 | Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); |
| 237 | } |
| 238 | |
| 239 | static void hal_set_accept_beacon(struct hw_data *pHwData, u8 enable) |
| 240 | { |
| 241 | struct wb35_reg *reg = &pHwData->reg; |
| 242 | |
| 243 | if (pHwData->SurpriseRemove) |
| 244 | return; |
| 245 | |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 246 | if (!enable) /* Due to SME and MLME are not suitable for 35 */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 247 | return; |
| 248 | |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 249 | reg->M00_MacControl &= ~0x04000000; /* The HW value */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 250 | if (enable) |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 251 | reg->M00_MacControl |= 0x04000000; /* The HW value */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 252 | |
| 253 | Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); |
| 254 | } |
| 255 | |
Greg Kroah-Hartman | f02466f | 2009-01-05 10:46:00 -0800 | [diff] [blame] | 256 | static int wbsoft_config(struct ieee80211_hw *dev, u32 changed) |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 257 | { |
Pekka Enberg | cc18071 | 2008-10-30 16:14:35 +0200 | [diff] [blame] | 258 | struct wbsoft_priv *priv = dev->priv; |
Pekka Enberg | 440a233 | 2009-12-18 23:08:18 +0200 | [diff] [blame] | 259 | struct chan_info ch; |
Greg Kroah-Hartman | f02466f | 2009-01-05 10:46:00 -0800 | [diff] [blame] | 260 | |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 261 | /* Should use channel_num, or something, as that is already pre-translated */ |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 262 | ch.band = 1; |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 263 | ch.ChanNo = 1; |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 264 | |
Pekka Enberg | 1e8a2b6 | 2008-10-30 16:14:38 +0200 | [diff] [blame] | 265 | hal_set_current_channel(&priv->sHwData, ch); |
Pekka Enberg | 1e8a2b6 | 2008-10-30 16:14:38 +0200 | [diff] [blame] | 266 | hal_set_accept_broadcast(&priv->sHwData, 1); |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 267 | hal_set_accept_promiscuous(&priv->sHwData, 1); |
| 268 | hal_set_accept_multicast(&priv->sHwData, 1); |
| 269 | hal_set_accept_beacon(&priv->sHwData, 1); |
| 270 | hal_set_radio_mode(&priv->sHwData, 0); |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 271 | |
| 272 | return 0; |
| 273 | } |
| 274 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 275 | static u64 wbsoft_get_tsf(struct ieee80211_hw *dev, struct ieee80211_vif *vif) |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 276 | { |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 277 | return 0; |
| 278 | } |
| 279 | |
| 280 | static const struct ieee80211_ops wbsoft_ops = { |
| 281 | .tx = wbsoft_tx, |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 282 | .start = wbsoft_start, |
Greg Kroah-Hartman | 68ab0c9 | 2008-10-21 10:41:45 -0700 | [diff] [blame] | 283 | .stop = wbsoft_stop, |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 284 | .add_interface = wbsoft_add_interface, |
| 285 | .remove_interface = wbsoft_remove_interface, |
| 286 | .config = wbsoft_config, |
Jeff Mahoney | 6d7fd64 | 2009-10-08 17:27:51 -0400 | [diff] [blame] | 287 | .prepare_multicast = wbsoft_prepare_multicast, |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 288 | .configure_filter = wbsoft_configure_filter, |
Greg Kroah-Hartman | 68ab0c9 | 2008-10-21 10:41:45 -0700 | [diff] [blame] | 289 | .get_stats = wbsoft_get_stats, |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 290 | .get_tsf = wbsoft_get_tsf, |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 291 | }; |
| 292 | |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 293 | static void hal_set_ethernet_address(struct hw_data *pHwData, u8 *current_address) |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 294 | { |
| 295 | u32 ltmp[2]; |
| 296 | |
| 297 | if (pHwData->SurpriseRemove) |
| 298 | return; |
| 299 | |
| 300 | memcpy(pHwData->CurrentMacAddress, current_address, ETH_ALEN); |
| 301 | |
| 302 | ltmp[0] = cpu_to_le32(*(u32 *) pHwData->CurrentMacAddress); |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 303 | ltmp[1] = cpu_to_le32(*(u32 *) (pHwData->CurrentMacAddress + 4)) & 0xffff; |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 304 | |
| 305 | Wb35Reg_BurstWrite(pHwData, 0x03e8, ltmp, 2, AUTO_INCREMENT); |
| 306 | } |
| 307 | |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 308 | static void hal_get_permanent_address(struct hw_data *pHwData, u8 *pethernet_address) |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 309 | { |
| 310 | if (pHwData->SurpriseRemove) |
| 311 | return; |
| 312 | |
| 313 | memcpy(pethernet_address, pHwData->PermanentMacAddress, 6); |
| 314 | } |
| 315 | |
| 316 | static void hal_stop(struct hw_data *pHwData) |
| 317 | { |
| 318 | struct wb35_reg *reg = &pHwData->reg; |
| 319 | |
| 320 | pHwData->Wb35Rx.rx_halt = 1; |
| 321 | Wb35Rx_stop(pHwData); |
| 322 | |
| 323 | pHwData->Wb35Tx.tx_halt = 1; |
| 324 | Wb35Tx_stop(pHwData); |
| 325 | |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 326 | reg->D00_DmaControl &= ~0xc0000000; /* Tx Off, Rx Off */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 327 | Wb35Reg_Write(pHwData, 0x0400, reg->D00_DmaControl); |
| 328 | } |
| 329 | |
| 330 | static unsigned char hal_idle(struct hw_data *pHwData) |
| 331 | { |
| 332 | struct wb35_reg *reg = &pHwData->reg; |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 333 | |
Pekka Enberg | 9be9881 | 2010-11-28 23:00:07 +0200 | [diff] [blame] | 334 | if (!pHwData->SurpriseRemove && reg->EP0vm_state != VM_STOP) |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 335 | return false; |
| 336 | |
| 337 | return true; |
| 338 | } |
| 339 | |
| 340 | u8 hal_get_antenna_number(struct hw_data *pHwData) |
| 341 | { |
| 342 | struct wb35_reg *reg = &pHwData->reg; |
| 343 | |
| 344 | if ((reg->BB2C & BIT(11)) == 0) |
| 345 | return 0; |
| 346 | else |
| 347 | return 1; |
| 348 | } |
| 349 | |
| 350 | /* 0 : radio on; 1: radio off */ |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 351 | static u8 hal_get_hw_radio_off(struct hw_data *pHwData) |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 352 | { |
| 353 | struct wb35_reg *reg = &pHwData->reg; |
| 354 | |
| 355 | if (pHwData->SurpriseRemove) |
| 356 | return 1; |
| 357 | |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 358 | /* read the bit16 of register U1B0 */ |
Pekka Enberg | 22a82bc | 2009-04-08 11:51:20 +0300 | [diff] [blame] | 359 | Wb35Reg_Read(pHwData, 0x3b0, ®->U1B0); |
| 360 | if ((reg->U1B0 & 0x00010000)) { |
| 361 | pHwData->CurrentRadioHw = 1; |
| 362 | return 1; |
| 363 | } else { |
| 364 | pHwData->CurrentRadioHw = 0; |
| 365 | return 0; |
| 366 | } |
| 367 | } |
| 368 | |
Pekka Enberg | 833d0cd | 2009-04-08 11:14:06 +0300 | [diff] [blame] | 369 | static u8 LED_GRAY[20] = { |
| 370 | 0, 3, 4, 6, 8, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 8, 6, 4, 2 |
| 371 | }; |
| 372 | |
| 373 | static u8 LED_GRAY2[30] = { |
| 374 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 375 | 0, 15, 14, 13, 12, 11, 10, 9, 8 |
| 376 | }; |
| 377 | |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 378 | static void hal_led_control(unsigned long data) |
| 379 | { |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 380 | struct wbsoft_priv *adapter = (struct wbsoft_priv *)data; |
| 381 | struct hw_data *pHwData = &adapter->sHwData; |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 382 | struct wb35_reg *reg = &pHwData->reg; |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 383 | u32 LEDSet = (pHwData->SoftwareSet & HAL_LED_SET_MASK) >> HAL_LED_SET_SHIFT; |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 384 | u32 TimeInterval = 500, ltmp, ltmp2; |
| 385 | ltmp = 0; |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 386 | |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 387 | if (pHwData->SurpriseRemove) |
| 388 | return; |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 389 | |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 390 | if (pHwData->LED_control) { |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 391 | ltmp2 = pHwData->LED_control & 0xff; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 392 | if (ltmp2 == 5) { /* 5 is WPS mode */ |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 393 | TimeInterval = 100; |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 394 | ltmp2 = (pHwData->LED_control >> 8) & 0xff; |
| 395 | switch (ltmp2) { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 396 | case 1: /* [0.2 On][0.1 Off]... */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 397 | pHwData->LED_Blinking %= 3; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 398 | ltmp = 0x1010; /* Led 1 & 0 Green and Red */ |
| 399 | if (pHwData->LED_Blinking == 2) /* Turn off */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 400 | ltmp = 0; |
| 401 | break; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 402 | case 2: /* [0.1 On][0.1 Off]... */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 403 | pHwData->LED_Blinking %= 2; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 404 | ltmp = 0x0010; /* Led 0 red color */ |
| 405 | if (pHwData->LED_Blinking) /* Turn off */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 406 | ltmp = 0; |
| 407 | break; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 408 | case 3: /* [0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.5 Off]... */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 409 | pHwData->LED_Blinking %= 15; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 410 | ltmp = 0x0010; /* Led 0 red color */ |
| 411 | if ((pHwData->LED_Blinking >= 9) || (pHwData->LED_Blinking % 2)) /* Turn off 0.6 sec */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 412 | ltmp = 0; |
| 413 | break; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 414 | case 4: /* [300 On][ off ] */ |
| 415 | ltmp = 0x1000; /* Led 1 Green color */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 416 | if (pHwData->LED_Blinking >= 3000) |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 417 | ltmp = 0; /* led maybe on after 300sec * 32bit counter overlap. */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 418 | break; |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 419 | } |
| 420 | pHwData->LED_Blinking++; |
| 421 | |
| 422 | reg->U1BC_LEDConfigure = ltmp; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 423 | if (LEDSet != 7) { /* Only 111 mode has 2 LEDs on PCB. */ |
| 424 | reg->U1BC_LEDConfigure |= (ltmp & 0xff) << 8; /* Copy LED result to each LED control register */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 425 | reg->U1BC_LEDConfigure |= (ltmp & 0xff00) >> 8; |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 426 | } |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 427 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 428 | } |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 429 | } else if (pHwData->CurrentRadioSw || pHwData->CurrentRadioHw) { /* If radio off */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 430 | if (reg->U1BC_LEDConfigure & 0x1010) { |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 431 | reg->U1BC_LEDConfigure &= ~0x1010; |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 432 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 433 | } |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 434 | } else { |
| 435 | switch (LEDSet) { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 436 | case 4: /* [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing */ |
| 437 | if (!pHwData->LED_LinkOn) { /* Blink only if not Link On */ |
| 438 | /* Blinking if scanning is on progress */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 439 | if (pHwData->LED_Scanning) { |
| 440 | if (pHwData->LED_Blinking == 0) { |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 441 | reg->U1BC_LEDConfigure |= 0x10; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 442 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 On */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 443 | pHwData->LED_Blinking = 1; |
| 444 | TimeInterval = 300; |
| 445 | } else { |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 446 | reg->U1BC_LEDConfigure &= ~0x10; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 447 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 448 | pHwData->LED_Blinking = 0; |
| 449 | TimeInterval = 300; |
| 450 | } |
| 451 | } else { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 452 | /* Turn Off LED_0 */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 453 | if (reg->U1BC_LEDConfigure & 0x10) { |
| 454 | reg->U1BC_LEDConfigure &= ~0x10; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 455 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */ |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 456 | } |
| 457 | } |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 458 | } else { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 459 | /* Turn On LED_0 */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 460 | if ((reg->U1BC_LEDConfigure & 0x10) == 0) { |
| 461 | reg->U1BC_LEDConfigure |= 0x10; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 462 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 463 | } |
| 464 | } |
| 465 | break; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 466 | case 6: /* [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing */ |
| 467 | if (!pHwData->LED_LinkOn) { /* Blink only if not Link On */ |
| 468 | /* Blinking if scanning is on progress */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 469 | if (pHwData->LED_Scanning) { |
| 470 | if (pHwData->LED_Blinking == 0) { |
| 471 | reg->U1BC_LEDConfigure &= ~0xf; |
| 472 | reg->U1BC_LEDConfigure |= 0x10; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 473 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 On */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 474 | pHwData->LED_Blinking = 1; |
| 475 | TimeInterval = 300; |
| 476 | } else { |
| 477 | reg->U1BC_LEDConfigure &= ~0x1f; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 478 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 479 | pHwData->LED_Blinking = 0; |
| 480 | TimeInterval = 300; |
| 481 | } |
| 482 | } else { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 483 | /* Gray blinking if in disconnect state and not scanning */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 484 | ltmp = reg->U1BC_LEDConfigure; |
| 485 | reg->U1BC_LEDConfigure &= ~0x1f; |
Pekka Enberg | 833d0cd | 2009-04-08 11:14:06 +0300 | [diff] [blame] | 486 | if (LED_GRAY2[(pHwData->LED_Blinking % 30)]) { |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 487 | reg->U1BC_LEDConfigure |= 0x10; |
| 488 | reg->U1BC_LEDConfigure |= |
Pekka Enberg | 833d0cd | 2009-04-08 11:14:06 +0300 | [diff] [blame] | 489 | LED_GRAY2[(pHwData->LED_Blinking % 30)]; |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 490 | } |
| 491 | pHwData->LED_Blinking++; |
| 492 | if (reg->U1BC_LEDConfigure != ltmp) |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 493 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 494 | TimeInterval = 100; |
| 495 | } |
| 496 | } else { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 497 | /* Turn On LED_0 */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 498 | if ((reg->U1BC_LEDConfigure & 0x10) == 0) { |
| 499 | reg->U1BC_LEDConfigure |= 0x10; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 500 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 501 | } |
| 502 | } |
| 503 | break; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 504 | case 5: /* [101] Only 1 Led be placed on PCB and use LED_1 for showing */ |
| 505 | if (!pHwData->LED_LinkOn) { /* Blink only if not Link On */ |
| 506 | /* Blinking if scanning is on progress */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 507 | if (pHwData->LED_Scanning) { |
| 508 | if (pHwData->LED_Blinking == 0) { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 509 | reg->U1BC_LEDConfigure |= 0x1000; |
| 510 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 On */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 511 | pHwData->LED_Blinking = 1; |
| 512 | TimeInterval = 300; |
| 513 | } else { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 514 | reg->U1BC_LEDConfigure &= ~0x1000; |
| 515 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 Off */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 516 | pHwData->LED_Blinking = 0; |
| 517 | TimeInterval = 300; |
| 518 | } |
| 519 | } else { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 520 | /* Turn Off LED_1 */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 521 | if (reg->U1BC_LEDConfigure & 0x1000) { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 522 | reg->U1BC_LEDConfigure &= ~0x1000; |
| 523 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 Off */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 524 | } |
| 525 | } |
| 526 | } else { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 527 | /* Is transmitting/receiving ?? */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 528 | if ((adapter->RxByteCount != |
| 529 | pHwData->RxByteCountLast) |
| 530 | || (adapter->TxByteCount != |
| 531 | pHwData->TxByteCountLast)) { |
| 532 | if ((reg->U1BC_LEDConfigure & 0x3000) != |
| 533 | 0x3000) { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 534 | reg->U1BC_LEDConfigure |= 0x3000; |
| 535 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 On */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 536 | } |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 537 | /* Update variable */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 538 | pHwData->RxByteCountLast = |
| 539 | adapter->RxByteCount; |
| 540 | pHwData->TxByteCountLast = |
| 541 | adapter->TxByteCount; |
| 542 | TimeInterval = 200; |
| 543 | } else { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 544 | /* Turn On LED_1 and blinking if transmitting/receiving */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 545 | if ((reg->U1BC_LEDConfigure & 0x3000) != |
| 546 | 0x1000) { |
| 547 | reg->U1BC_LEDConfigure &= |
| 548 | ~0x3000; |
| 549 | reg->U1BC_LEDConfigure |= |
| 550 | 0x1000; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 551 | Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 On */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 552 | } |
| 553 | } |
| 554 | } |
| 555 | break; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 556 | default: /* Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 557 | if ((reg->U1BC_LEDConfigure & 0x3000) != 0x3000) { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 558 | reg->U1BC_LEDConfigure |= 0x3000; /* LED_1 is always on and event enable */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 559 | Wb35Reg_Write(pHwData, 0x03bc, |
| 560 | reg->U1BC_LEDConfigure); |
| 561 | } |
| 562 | |
| 563 | if (pHwData->LED_Blinking) { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 564 | /* Gray blinking */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 565 | reg->U1BC_LEDConfigure &= ~0x0f; |
| 566 | reg->U1BC_LEDConfigure |= 0x10; |
| 567 | reg->U1BC_LEDConfigure |= |
Pekka Enberg | 833d0cd | 2009-04-08 11:14:06 +0300 | [diff] [blame] | 568 | LED_GRAY[(pHwData->LED_Blinking - 1) % 20]; |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 569 | Wb35Reg_Write(pHwData, 0x03bc, |
| 570 | reg->U1BC_LEDConfigure); |
| 571 | |
| 572 | pHwData->LED_Blinking += 2; |
| 573 | if (pHwData->LED_Blinking < 40) |
| 574 | TimeInterval = 100; |
| 575 | else { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 576 | pHwData->LED_Blinking = 0; /* Stop blinking */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 577 | reg->U1BC_LEDConfigure &= ~0x0f; |
| 578 | Wb35Reg_Write(pHwData, 0x03bc, |
| 579 | reg->U1BC_LEDConfigure); |
| 580 | } |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 581 | break; |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | if (pHwData->LED_LinkOn) { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 585 | if (!(reg->U1BC_LEDConfigure & 0x10)) { /* Check the LED_0 */ |
| 586 | /* Try to turn ON LED_0 after gray blinking */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 587 | reg->U1BC_LEDConfigure |= 0x10; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 588 | pHwData->LED_Blinking = 1; /* Start blinking */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 589 | TimeInterval = 50; |
| 590 | } |
| 591 | } else { |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 592 | if (reg->U1BC_LEDConfigure & 0x10) { /* Check the LED_0 */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 593 | reg->U1BC_LEDConfigure &= ~0x10; |
| 594 | Wb35Reg_Write(pHwData, 0x03bc, |
| 595 | reg->U1BC_LEDConfigure); |
| 596 | } |
| 597 | } |
| 598 | break; |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 599 | } |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | pHwData->time_count += TimeInterval; |
Lars Lindley | e5851c2 | 2010-04-02 10:57:35 +0200 | [diff] [blame] | 603 | Wb35Tx_CurrentTime(adapter, pHwData->time_count); |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 604 | pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(TimeInterval); |
| 605 | add_timer(&pHwData->LEDTimer); |
| 606 | } |
| 607 | |
Pekka Enberg | cfe31f8 | 2009-04-08 11:13:58 +0300 | [diff] [blame] | 608 | static int hal_init_hardware(struct ieee80211_hw *hw) |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 609 | { |
| 610 | struct wbsoft_priv *priv = hw->priv; |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 611 | struct hw_data *pHwData = &priv->sHwData; |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 612 | u16 SoftwareSet; |
| 613 | |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 614 | pHwData->MaxReceiveLifeTime = DEFAULT_MSDU_LIFE_TIME; |
| 615 | pHwData->FragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 616 | |
Pekka Enberg | 00e2e05 | 2009-04-08 11:13:59 +0300 | [diff] [blame] | 617 | if (!Wb35Reg_initial(pHwData)) |
Pekka Enberg | a39ee67 | 2009-04-08 11:14:00 +0300 | [diff] [blame] | 618 | goto error_reg_destroy; |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 619 | |
Pekka Enberg | 00e2e05 | 2009-04-08 11:13:59 +0300 | [diff] [blame] | 620 | if (!Wb35Tx_initial(pHwData)) |
Pekka Enberg | a39ee67 | 2009-04-08 11:14:00 +0300 | [diff] [blame] | 621 | goto error_tx_destroy; |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 622 | |
Pekka Enberg | 00e2e05 | 2009-04-08 11:13:59 +0300 | [diff] [blame] | 623 | if (!Wb35Rx_initial(pHwData)) |
Pekka Enberg | a39ee67 | 2009-04-08 11:14:00 +0300 | [diff] [blame] | 624 | goto error_rx_destroy; |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 625 | |
Pekka Enberg | 00e2e05 | 2009-04-08 11:13:59 +0300 | [diff] [blame] | 626 | init_timer(&pHwData->LEDTimer); |
| 627 | pHwData->LEDTimer.function = hal_led_control; |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 628 | pHwData->LEDTimer.data = (unsigned long)priv; |
Pekka Enberg | 00e2e05 | 2009-04-08 11:13:59 +0300 | [diff] [blame] | 629 | pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(1000); |
| 630 | add_timer(&pHwData->LEDTimer); |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 631 | |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 632 | SoftwareSet = hal_software_set(pHwData); |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 633 | |
Pekka Enberg | 00e2e05 | 2009-04-08 11:13:59 +0300 | [diff] [blame] | 634 | Wb35Rx_start(hw); |
| 635 | Wb35Tx_EP2VM_start(priv); |
| 636 | |
| 637 | return 0; |
| 638 | |
Pekka Enberg | a39ee67 | 2009-04-08 11:14:00 +0300 | [diff] [blame] | 639 | error_rx_destroy: |
| 640 | Wb35Rx_destroy(pHwData); |
| 641 | error_tx_destroy: |
| 642 | Wb35Tx_destroy(pHwData); |
| 643 | error_reg_destroy: |
| 644 | Wb35Reg_destroy(pHwData); |
| 645 | |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 646 | pHwData->SurpriseRemove = 1; |
Pekka Enberg | cfe31f8 | 2009-04-08 11:13:58 +0300 | [diff] [blame] | 647 | return -EINVAL; |
Pekka Enberg | 80767e6 | 2009-04-08 11:13:57 +0300 | [diff] [blame] | 648 | } |
| 649 | |
Pekka Enberg | 2659851 | 2009-04-08 11:13:56 +0300 | [diff] [blame] | 650 | static int wb35_hw_init(struct ieee80211_hw *hw) |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 651 | { |
| 652 | struct wbsoft_priv *priv = hw->priv; |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 653 | struct hw_data *pHwData = &priv->sHwData; |
| 654 | u8 EEPROM_region; |
| 655 | u8 HwRadioOff; |
| 656 | u8 *pMacAddr2; |
| 657 | u8 *pMacAddr; |
Pekka Enberg | 2659851 | 2009-04-08 11:13:56 +0300 | [diff] [blame] | 658 | int err; |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 659 | |
Pekka Enberg | 9ca748c | 2009-04-08 11:14:03 +0300 | [diff] [blame] | 660 | pHwData->phy_type = RF_DECIDE_BY_INF; |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 661 | |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 662 | priv->Mds.TxRTSThreshold = DEFAULT_RTSThreshold; |
| 663 | priv->Mds.TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; |
| 664 | |
| 665 | priv->sLocalPara.region_INF = REGION_AUTO; |
| 666 | priv->sLocalPara.TxRateMode = RATE_AUTO; |
| 667 | priv->sLocalPara.bMacOperationMode = MODE_802_11_BG; |
| 668 | priv->sLocalPara.MTUsize = MAX_ETHERNET_PACKET_SIZE; |
| 669 | priv->sLocalPara.bPreambleMode = AUTO_MODE; |
| 670 | priv->sLocalPara.bWepKeyError = false; |
| 671 | priv->sLocalPara.bToSelfPacketReceived = false; |
| 672 | priv->sLocalPara.WepKeyDetectTimerCount = 2 * 100; /* 2 seconds */ |
| 673 | |
| 674 | priv->sLocalPara.RadioOffStatus.boSwRadioOff = false; |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 675 | |
Pekka Enberg | cfe31f8 | 2009-04-08 11:13:58 +0300 | [diff] [blame] | 676 | err = hal_init_hardware(hw); |
| 677 | if (err) |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 678 | goto error; |
| 679 | |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 680 | EEPROM_region = hal_get_region_from_EEPROM(pHwData); |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 681 | if (EEPROM_region != REGION_AUTO) |
| 682 | priv->sLocalPara.region = EEPROM_region; |
| 683 | else { |
| 684 | if (priv->sLocalPara.region_INF != REGION_AUTO) |
| 685 | priv->sLocalPara.region = priv->sLocalPara.region_INF; |
| 686 | else |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 687 | priv->sLocalPara.region = REGION_USA; /* default setting */ |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 688 | } |
| 689 | |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 690 | Mds_initial(priv); |
| 691 | |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 692 | /* |
Uwe Kleine-König | f69b0d6 | 2010-07-12 17:15:46 +0200 | [diff] [blame] | 693 | * If no user-defined address in the registry, use the address |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 694 | * "burned" on the NIC instead. |
| 695 | */ |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 696 | pMacAddr = priv->sLocalPara.ThisMacAddress; |
| 697 | pMacAddr2 = priv->sLocalPara.PermanentAddress; |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 698 | |
| 699 | /* Reading ethernet address from EEPROM */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 700 | hal_get_permanent_address(pHwData, priv->sLocalPara.PermanentAddress); |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 701 | if (memcmp(pMacAddr, "\x00\x00\x00\x00\x00\x00", MAC_ADDR_LENGTH) == 0) |
| 702 | memcpy(pMacAddr, pMacAddr2, MAC_ADDR_LENGTH); |
| 703 | else { |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 704 | /* Set the user define MAC address */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 705 | hal_set_ethernet_address(pHwData, |
| 706 | priv->sLocalPara.ThisMacAddress); |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 707 | } |
| 708 | |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 709 | priv->sLocalPara.bAntennaNo = hal_get_antenna_number(pHwData); |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 710 | hal_get_hw_radio_off(pHwData); |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 711 | |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 712 | /* Waiting for HAL setting OK */ |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 713 | while (!hal_idle(pHwData)) |
| 714 | msleep(10); |
| 715 | |
| 716 | MTO_Init(priv); |
| 717 | |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 718 | HwRadioOff = hal_get_hw_radio_off(pHwData); |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 719 | priv->sLocalPara.RadioOffStatus.boHwRadioOff = !!HwRadioOff; |
| 720 | |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 721 | hal_set_radio_mode(pHwData, |
| 722 | (unsigned char)(priv->sLocalPara.RadioOffStatus. |
| 723 | boSwRadioOff |
| 724 | || priv->sLocalPara.RadioOffStatus. |
| 725 | boHwRadioOff)); |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 726 | |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 727 | /* Notify hal that the driver is ready now. */ |
| 728 | hal_driver_init_OK(pHwData) = 1; |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 729 | |
| 730 | error: |
Pekka Enberg | 2659851 | 2009-04-08 11:13:56 +0300 | [diff] [blame] | 731 | return err; |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 732 | } |
| 733 | |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 734 | static int wb35_probe(struct usb_interface *intf, |
| 735 | const struct usb_device_id *id_table) |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 736 | { |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 737 | struct usb_device *udev = interface_to_usbdev(intf); |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 738 | struct usb_endpoint_descriptor *endpoint; |
| 739 | struct usb_host_interface *interface; |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 740 | struct ieee80211_hw *dev; |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 741 | struct wbsoft_priv *priv; |
Devendra Naga | 6594ac5 | 2012-07-14 13:25:37 +0545 | [diff] [blame] | 742 | int err; |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 743 | u32 ltmp; |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 744 | |
| 745 | usb_get_dev(udev); |
| 746 | |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 747 | /* Check the device if it already be opened */ |
Devendra Naga | 6594ac5 | 2012-07-14 13:25:37 +0545 | [diff] [blame] | 748 | err = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 749 | 0x01, |
| 750 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, |
| 751 | 0x0, 0x400, <mp, 4, HZ * 100); |
Devendra Naga | 6594ac5 | 2012-07-14 13:25:37 +0545 | [diff] [blame] | 752 | if (err < 0) |
Pekka Enberg | dc7e04f | 2008-10-21 12:14:58 +0300 | [diff] [blame] | 753 | goto error; |
| 754 | |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 755 | /* Is already initialized? */ |
Pekka Enberg | dc7e04f | 2008-10-21 12:14:58 +0300 | [diff] [blame] | 756 | ltmp = cpu_to_le32(ltmp); |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 757 | if (ltmp) { |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 758 | err = -EBUSY; |
Pekka Enberg | dc7e04f | 2008-10-21 12:14:58 +0300 | [diff] [blame] | 759 | goto error; |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 760 | } |
Pekka Enberg | dc7e04f | 2008-10-21 12:14:58 +0300 | [diff] [blame] | 761 | |
Pekka Enberg | 1e8a2b6 | 2008-10-30 16:14:38 +0200 | [diff] [blame] | 762 | dev = ieee80211_alloc_hw(sizeof(*priv), &wbsoft_ops); |
Pekka Enberg | acfa511 | 2009-01-30 11:32:47 +0200 | [diff] [blame] | 763 | if (!dev) { |
| 764 | err = -ENOMEM; |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 765 | goto error; |
Pekka Enberg | acfa511 | 2009-01-30 11:32:47 +0200 | [diff] [blame] | 766 | } |
Pekka Enberg | dc7e04f | 2008-10-21 12:14:58 +0300 | [diff] [blame] | 767 | |
Pekka Enberg | 1e8a2b6 | 2008-10-30 16:14:38 +0200 | [diff] [blame] | 768 | priv = dev->priv; |
Pekka Enberg | 1e8a2b6 | 2008-10-30 16:14:38 +0200 | [diff] [blame] | 769 | |
Pekka Enberg | 2894c6c | 2010-11-28 23:00:08 +0200 | [diff] [blame] | 770 | priv->sHwData.udev = udev; |
Pekka Enberg | dc7e04f | 2008-10-21 12:14:58 +0300 | [diff] [blame] | 771 | |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 772 | interface = intf->cur_altsetting; |
| 773 | endpoint = &interface->endpoint[0].desc; |
Pekka Enberg | dc7e04f | 2008-10-21 12:14:58 +0300 | [diff] [blame] | 774 | |
Pekka Enberg | 2659851 | 2009-04-08 11:13:56 +0300 | [diff] [blame] | 775 | err = wb35_hw_init(dev); |
| 776 | if (err) |
Pekka Enberg | 1e8a2b6 | 2008-10-30 16:14:38 +0200 | [diff] [blame] | 777 | goto error_free_hw; |
Pekka Enberg | dc7e04f | 2008-10-21 12:14:58 +0300 | [diff] [blame] | 778 | |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 779 | SET_IEEE80211_DEV(dev, &udev->dev); |
Pekka Enberg | dc7e04f | 2008-10-21 12:14:58 +0300 | [diff] [blame] | 780 | { |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 781 | struct hw_data *pHwData = &priv->sHwData; |
| 782 | unsigned char dev_addr[MAX_ADDR_LEN]; |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 783 | hal_get_permanent_address(pHwData, dev_addr); |
| 784 | SET_IEEE80211_PERM_ADDR(dev, dev_addr); |
Pekka Enberg | dc7e04f | 2008-10-21 12:14:58 +0300 | [diff] [blame] | 785 | } |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 786 | |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 787 | dev->extra_tx_headroom = 12; /* FIXME */ |
Pavel Machek | 05e361c | 2009-01-30 10:05:25 +0100 | [diff] [blame] | 788 | dev->flags = IEEE80211_HW_SIGNAL_UNSPEC; |
| 789 | dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 790 | |
Pavel Machek | 05e361c | 2009-01-30 10:05:25 +0100 | [diff] [blame] | 791 | dev->max_signal = 100; |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 792 | dev->queues = 1; |
| 793 | |
Pekka Enberg | a36e089 | 2008-10-28 00:20:03 +0200 | [diff] [blame] | 794 | dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &wbsoft_band_2GHz; |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 795 | |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 796 | err = ieee80211_register_hw(dev); |
| 797 | if (err) |
| 798 | goto error_free_hw; |
| 799 | |
Pekka Enberg | 82fbb01 | 2009-04-16 14:43:14 +0300 | [diff] [blame] | 800 | usb_set_intfdata(intf, dev); |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 801 | |
Pekka Enberg | dc7e04f | 2008-10-21 12:14:58 +0300 | [diff] [blame] | 802 | return 0; |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 803 | |
| 804 | error_free_hw: |
| 805 | ieee80211_free_hw(dev); |
Pekka Enberg | dc7e04f | 2008-10-21 12:14:58 +0300 | [diff] [blame] | 806 | error: |
Pekka Enberg | 4af12e5 | 2008-10-27 23:29:31 +0200 | [diff] [blame] | 807 | usb_put_dev(udev); |
Pekka Enberg | 1523ddc | 2008-10-22 11:04:23 +0300 | [diff] [blame] | 808 | return err; |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 809 | } |
| 810 | |
Pekka Enberg | f592a85 | 2009-04-08 11:14:01 +0300 | [diff] [blame] | 811 | static void hal_halt(struct hw_data *pHwData) |
| 812 | { |
| 813 | del_timer_sync(&pHwData->LEDTimer); |
| 814 | /* XXX: Wait for Timer DPC exit. */ |
| 815 | msleep(100); |
| 816 | Wb35Rx_destroy(pHwData); |
| 817 | Wb35Tx_destroy(pHwData); |
| 818 | Wb35Reg_destroy(pHwData); |
| 819 | } |
| 820 | |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 821 | static void wb35_hw_halt(struct wbsoft_priv *adapter) |
| 822 | { |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 823 | /* Turn off Rx and Tx hardware ability */ |
Pekka Enberg | a32b981 | 2009-04-08 11:14:04 +0300 | [diff] [blame] | 824 | hal_stop(&adapter->sHwData); |
Pekka Enberg | bdbb883 | 2009-04-08 11:14:02 +0300 | [diff] [blame] | 825 | /* Waiting Irp completed */ |
| 826 | msleep(100); |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 827 | |
Pekka Enberg | f592a85 | 2009-04-08 11:14:01 +0300 | [diff] [blame] | 828 | hal_halt(&adapter->sHwData); |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 829 | } |
| 830 | |
Pekka Enberg | 302bae8 | 2008-10-22 19:05:54 +0300 | [diff] [blame] | 831 | static void wb35_disconnect(struct usb_interface *intf) |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 832 | { |
Pekka Enberg | 82fbb01 | 2009-04-16 14:43:14 +0300 | [diff] [blame] | 833 | struct ieee80211_hw *hw = usb_get_intfdata(intf); |
| 834 | struct wbsoft_priv *priv = hw->priv; |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 835 | |
Pekka Enberg | 912b209 | 2008-10-30 18:12:02 +0200 | [diff] [blame] | 836 | wb35_hw_halt(priv); |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 837 | |
Pekka Enberg | 82fbb01 | 2009-04-16 14:43:14 +0300 | [diff] [blame] | 838 | ieee80211_stop_queues(hw); |
| 839 | ieee80211_unregister_hw(hw); |
| 840 | ieee80211_free_hw(hw); |
| 841 | |
Pekka Enberg | 4af12e5 | 2008-10-27 23:29:31 +0200 | [diff] [blame] | 842 | usb_set_intfdata(intf, NULL); |
| 843 | usb_put_dev(interface_to_usbdev(intf)); |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 844 | } |
| 845 | |
Pekka Enberg | dd38da4 | 2008-10-21 13:01:42 +0300 | [diff] [blame] | 846 | static struct usb_driver wb35_driver = { |
| 847 | .name = "w35und", |
| 848 | .id_table = wb35_table, |
| 849 | .probe = wb35_probe, |
| 850 | .disconnect = wb35_disconnect, |
| 851 | }; |
Pavel Machek | 66101de | 2008-10-01 14:36:56 +0200 | [diff] [blame] | 852 | |
Greg Kroah-Hartman | bac2c12 | 2011-11-18 09:42:11 -0800 | [diff] [blame] | 853 | module_usb_driver(wb35_driver); |