45 #include <linux/kernel.h>
46 #include <linux/ptrace.h>
47 #include <linux/slab.h>
48 #include <linux/string.h>
49 #include <linux/ctype.h>
51 #include <asm/byteorder.h>
53 #include <asm/uaccess.h>
54 #include <linux/module.h>
55 #include <linux/netdevice.h>
58 #include <linux/if_arp.h>
60 #include <linux/fcntl.h>
62 #include <linux/wireless.h>
66 #include <linux/device.h>
73 #define DRIVER_MAJOR 0
74 #define DRIVER_MINOR 98
119 #define MAX_SSID_LENGTH 32
120 #define MGMT_JIFFIES (256 * HZ / 100)
122 #define MAX_BSS_ENTRIES 64
140 #define GCR_REMAP 0x0400
141 #define GCR_SWRES 0x0080
142 #define GCR_CORES 0x0060
143 #define GCR_ENINT 0x0002
144 #define GCR_ACKINT 0x0008
146 #define BSS_SRAM 0x0200
147 #define BSS_IRAM 0x0100
151 #define MAC_INIT_COMPLETE 0x0001
152 #define MAC_BOOT_COMPLETE 0x0010
153 #define MAC_INIT_OK 0x0002
155 #define MIB_MAX_DATA_BYTES 212
156 #define MIB_HEADER_SIZE 4
181 #define RX_DESC_FLAG_VALID 0x80
182 #define RX_DESC_FLAG_CONSUMED 0x40
183 #define RX_DESC_FLAG_IDLE 0x00
185 #define RX_STATUS_SUCCESS 0x00
187 #define RX_DESC_MSDU_POS_OFFSET 4
188 #define RX_DESC_MSDU_SIZE_OFFSET 6
189 #define RX_DESC_FLAGS_OFFSET 8
190 #define RX_DESC_STATUS_OFFSET 9
191 #define RX_DESC_RSSI_OFFSET 11
192 #define RX_DESC_LINK_QUALITY_OFFSET 12
193 #define RX_DESC_PREAMBLE_TYPE_OFFSET 13
194 #define RX_DESC_DURATION_OFFSET 14
195 #define RX_DESC_RX_TIME_OFFSET 16
218 #define TX_DESC_NEXT_OFFSET 0
219 #define TX_DESC_POS_OFFSET 4
220 #define TX_DESC_SIZE_OFFSET 6
221 #define TX_DESC_FLAGS_OFFSET 8
222 #define TX_DESC_STATUS_OFFSET 9
223 #define TX_DESC_RETRY_OFFSET 10
224 #define TX_DESC_RATE_OFFSET 11
225 #define TX_DESC_KEY_INDEX_OFFSET 12
226 #define TX_DESC_CIPHER_TYPE_OFFSET 13
227 #define TX_DESC_CIPHER_LENGTH_OFFSET 14
228 #define TX_DESC_PACKET_TYPE_OFFSET 17
229 #define TX_DESC_HOST_LENGTH_OFFSET 18
235 #define TX_STATUS_SUCCESS 0x00
237 #define TX_FIRM_OWN 0x80
240 #define TX_ERROR 0x01
242 #define TX_PACKET_TYPE_DATA 0x01
243 #define TX_PACKET_TYPE_MGMT 0x02
245 #define ISR_EMPTY 0x00
246 #define ISR_TxCOMPLETE 0x01
247 #define ISR_RxCOMPLETE 0x02
248 #define ISR_RxFRAMELOST 0x04
249 #define ISR_FATAL_ERROR 0x08
250 #define ISR_COMMAND_COMPLETE 0x10
251 #define ISR_OUT_OF_RANGE 0x20
252 #define ISR_IBSS_MERGE 0x40
253 #define ISR_GENERIC_IRQ 0x80
255 #define Local_Mib_Type 0x01
256 #define Mac_Address_Mib_Type 0x02
257 #define Mac_Mib_Type 0x03
258 #define Statistics_Mib_Type 0x04
259 #define Mac_Mgmt_Mib_Type 0x05
260 #define Mac_Wep_Mib_Type 0x06
261 #define Phy_Mib_Type 0x07
262 #define Multi_Domain_MIB 0x08
264 #define MAC_MGMT_MIB_CUR_BSSID_POS 14
265 #define MAC_MIB_FRAG_THRESHOLD_POS 8
266 #define MAC_MIB_RTS_THRESHOLD_POS 10
267 #define MAC_MIB_SHORT_RETRY_POS 16
268 #define MAC_MIB_LONG_RETRY_POS 17
269 #define MAC_MIB_SHORT_RETRY_LIMIT_POS 16
270 #define MAC_MGMT_MIB_BEACON_PER_POS 0
271 #define MAC_MGMT_MIB_STATION_ID_POS 6
272 #define MAC_MGMT_MIB_CUR_PRIVACY_POS 11
273 #define MAC_MGMT_MIB_CUR_BSSID_POS 14
274 #define MAC_MGMT_MIB_PS_MODE_POS 53
275 #define MAC_MGMT_MIB_LISTEN_INTERVAL_POS 54
276 #define MAC_MGMT_MIB_MULTI_DOMAIN_IMPLEMENTED 56
277 #define MAC_MGMT_MIB_MULTI_DOMAIN_ENABLED 57
278 #define PHY_MIB_CHANNEL_POS 14
279 #define PHY_MIB_RATE_SET_POS 20
280 #define PHY_MIB_REG_DOMAIN_POS 26
281 #define LOCAL_MIB_AUTO_TX_RATE_POS 3
282 #define LOCAL_MIB_SSID_SIZE 5
283 #define LOCAL_MIB_TX_PROMISCUOUS_POS 6
284 #define LOCAL_MIB_TX_MGMT_RATE_POS 7
285 #define LOCAL_MIB_TX_CONTROL_RATE_POS 8
286 #define LOCAL_MIB_PREAMBLE_TYPE 9
287 #define MAC_ADDR_MIB_MAC_ADDR_POS 0
289 #define CMD_Set_MIB_Vars 0x01
290 #define CMD_Get_MIB_Vars 0x02
291 #define CMD_Scan 0x03
292 #define CMD_Join 0x04
293 #define CMD_Start 0x05
294 #define CMD_EnableRadio 0x06
295 #define CMD_DisableRadio 0x07
296 #define CMD_SiteSurvey 0x0B
298 #define CMD_STATUS_IDLE 0x00
299 #define CMD_STATUS_COMPLETE 0x01
300 #define CMD_STATUS_UNKNOWN 0x02
301 #define CMD_STATUS_INVALID_PARAMETER 0x03
302 #define CMD_STATUS_FUNCTION_NOT_SUPPORTED 0x04
303 #define CMD_STATUS_TIME_OUT 0x07
304 #define CMD_STATUS_IN_PROGRESS 0x08
305 #define CMD_STATUS_REJECTED_RADIO_OFF 0x09
306 #define CMD_STATUS_HOST_ERROR 0xFF
307 #define CMD_STATUS_BUSY 0xFE
309 #define CMD_BLOCK_COMMAND_OFFSET 0
310 #define CMD_BLOCK_STATUS_OFFSET 1
311 #define CMD_BLOCK_PARAMETERS_OFFSET 4
313 #define SCAN_OPTIONS_SITE_SURVEY 0x80
315 #define MGMT_FRAME_BODY_OFFSET 24
316 #define MAX_AUTHENTICATION_RETRIES 3
317 #define MAX_ASSOCIATION_RETRIES 3
319 #define AUTHENTICATION_RESPONSE_TIME_OUT 1000
321 #define MAX_WIRELESS_BODY 2316
322 #define LOOP_RETRY_LIMIT 500000
324 #define ACTIVE_MODE 1
327 #define MAX_ENCRYPTION_KEYS 4
328 #define MAX_ENCRYPTION_KEY_SIZE 40
338 #define REG_DOMAIN_FCC 0x10
339 #define REG_DOMAIN_DOC 0x20
340 #define REG_DOMAIN_ETSI 0x30
341 #define REG_DOMAIN_SPAIN 0x31
342 #define REG_DOMAIN_FRANCE 0x32
343 #define REG_DOMAIN_MKK 0x40
344 #define REG_DOMAIN_MKK1 0x41
345 #define REG_DOMAIN_ISRAEL 0x50
347 #define BSS_TYPE_AD_HOC 1
348 #define BSS_TYPE_INFRASTRUCTURE 2
350 #define SCAN_TYPE_ACTIVE 0
351 #define SCAN_TYPE_PASSIVE 1
353 #define LONG_PREAMBLE 0
354 #define SHORT_PREAMBLE 1
355 #define AUTO_PREAMBLE 2
357 #define DATA_FRAME_WS_HEADER_SIZE 30
360 #define PROM_MODE_OFF 0x0
361 #define PROM_MODE_UNKNOWN 0x1
362 #define PROM_MODE_CRC_FAILED 0x2
363 #define PROM_MODE_DUPLICATED 0x4
364 #define PROM_MODE_MGMT 0x8
365 #define PROM_MODE_CTRL 0x10
366 #define PROM_MODE_BAD_PROTOCOL 0x20
368 #define IFACE_INT_STATUS_OFFSET 0
369 #define IFACE_INT_MASK_OFFSET 1
370 #define IFACE_LOCKOUT_HOST_OFFSET 2
371 #define IFACE_LOCKOUT_MAC_OFFSET 3
372 #define IFACE_FUNC_CTRL_OFFSET 28
373 #define IFACE_MAC_STAT_OFFSET 30
374 #define IFACE_GENERIC_INT_TYPE_OFFSET 32
376 #define CIPHER_SUITE_NONE 0
377 #define CIPHER_SUITE_WEP_64 1
378 #define CIPHER_SUITE_TKIP 2
379 #define CIPHER_SUITE_AES 3
380 #define CIPHER_SUITE_CCX 4
381 #define CIPHER_SUITE_WEP_128 5
390 #define FUNC_CTRL_TxENABLE 0x10
391 #define FUNC_CTRL_RxENABLE 0x20
392 #define FUNC_CTRL_INIT_COMPLETE 0x01
396 static u8 mac_reader[] = {
397 0x06, 0x00, 0x00, 0xea, 0x04, 0x00, 0x00, 0xea, 0x03, 0x00, 0x00, 0xea, 0x02, 0x00, 0x00, 0xea,
398 0x01, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, 0xea, 0xff, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea,
399 0xd3, 0x00, 0xa0, 0xe3, 0x00, 0xf0, 0x21, 0xe1, 0x0e, 0x04, 0xa0, 0xe3, 0x00, 0x10, 0xa0, 0xe3,
400 0x81, 0x11, 0xa0, 0xe1, 0x00, 0x10, 0x81, 0xe3, 0x00, 0x10, 0x80, 0xe5, 0x1c, 0x10, 0x90, 0xe5,
401 0x10, 0x10, 0xc1, 0xe3, 0x1c, 0x10, 0x80, 0xe5, 0x01, 0x10, 0xa0, 0xe3, 0x08, 0x10, 0x80, 0xe5,
402 0x02, 0x03, 0xa0, 0xe3, 0x00, 0x10, 0xa0, 0xe3, 0xb0, 0x10, 0xc0, 0xe1, 0xb4, 0x10, 0xc0, 0xe1,
403 0xb8, 0x10, 0xc0, 0xe1, 0xbc, 0x10, 0xc0, 0xe1, 0x56, 0xdc, 0xa0, 0xe3, 0x21, 0x00, 0x00, 0xeb,
404 0x0a, 0x00, 0xa0, 0xe3, 0x1a, 0x00, 0x00, 0xeb, 0x10, 0x00, 0x00, 0xeb, 0x07, 0x00, 0x00, 0xeb,
405 0x02, 0x03, 0xa0, 0xe3, 0x02, 0x14, 0xa0, 0xe3, 0xb4, 0x10, 0xc0, 0xe1, 0x4c, 0x10, 0x9f, 0xe5,
406 0xbc, 0x10, 0xc0, 0xe1, 0x10, 0x10, 0xa0, 0xe3, 0xb8, 0x10, 0xc0, 0xe1, 0xfe, 0xff, 0xff, 0xea,
407 0x00, 0x40, 0x2d, 0xe9, 0x00, 0x20, 0xa0, 0xe3, 0x02, 0x3c, 0xa0, 0xe3, 0x00, 0x10, 0xa0, 0xe3,
408 0x28, 0x00, 0x9f, 0xe5, 0x37, 0x00, 0x00, 0xeb, 0x00, 0x40, 0xbd, 0xe8, 0x1e, 0xff, 0x2f, 0xe1,
409 0x00, 0x40, 0x2d, 0xe9, 0x12, 0x2e, 0xa0, 0xe3, 0x06, 0x30, 0xa0, 0xe3, 0x00, 0x10, 0xa0, 0xe3,
410 0x02, 0x04, 0xa0, 0xe3, 0x2f, 0x00, 0x00, 0xeb, 0x00, 0x40, 0xbd, 0xe8, 0x1e, 0xff, 0x2f, 0xe1,
411 0x00, 0x02, 0x00, 0x02, 0x80, 0x01, 0x90, 0xe0, 0x01, 0x00, 0x00, 0x0a, 0x01, 0x00, 0x50, 0xe2,
412 0xfc, 0xff, 0xff, 0xea, 0x1e, 0xff, 0x2f, 0xe1, 0x80, 0x10, 0xa0, 0xe3, 0xf3, 0x06, 0xa0, 0xe3,
413 0x00, 0x10, 0x80, 0xe5, 0x00, 0x10, 0xa0, 0xe3, 0x00, 0x10, 0x80, 0xe5, 0x01, 0x10, 0xa0, 0xe3,
414 0x04, 0x10, 0x80, 0xe5, 0x00, 0x10, 0x80, 0xe5, 0x0e, 0x34, 0xa0, 0xe3, 0x1c, 0x10, 0x93, 0xe5,
415 0x02, 0x1a, 0x81, 0xe3, 0x1c, 0x10, 0x83, 0xe5, 0x58, 0x11, 0x9f, 0xe5, 0x30, 0x10, 0x80, 0xe5,
416 0x54, 0x11, 0x9f, 0xe5, 0x34, 0x10, 0x80, 0xe5, 0x38, 0x10, 0x80, 0xe5, 0x3c, 0x10, 0x80, 0xe5,
417 0x10, 0x10, 0x90, 0xe5, 0x08, 0x00, 0x90, 0xe5, 0x1e, 0xff, 0x2f, 0xe1, 0xf3, 0x16, 0xa0, 0xe3,
418 0x08, 0x00, 0x91, 0xe5, 0x05, 0x00, 0xa0, 0xe3, 0x0c, 0x00, 0x81, 0xe5, 0x10, 0x00, 0x91, 0xe5,
419 0x02, 0x00, 0x10, 0xe3, 0xfc, 0xff, 0xff, 0x0a, 0xff, 0x00, 0xa0, 0xe3, 0x0c, 0x00, 0x81, 0xe5,
420 0x10, 0x00, 0x91, 0xe5, 0x02, 0x00, 0x10, 0xe3, 0xfc, 0xff, 0xff, 0x0a, 0x08, 0x00, 0x91, 0xe5,
421 0x10, 0x00, 0x91, 0xe5, 0x01, 0x00, 0x10, 0xe3, 0xfc, 0xff, 0xff, 0x0a, 0x08, 0x00, 0x91, 0xe5,
422 0xff, 0x00, 0x00, 0xe2, 0x1e, 0xff, 0x2f, 0xe1, 0x30, 0x40, 0x2d, 0xe9, 0x00, 0x50, 0xa0, 0xe1,
423 0x03, 0x40, 0xa0, 0xe1, 0xa2, 0x02, 0xa0, 0xe1, 0x08, 0x00, 0x00, 0xe2, 0x03, 0x00, 0x80, 0xe2,
424 0xd8, 0x10, 0x9f, 0xe5, 0x00, 0x00, 0xc1, 0xe5, 0x01, 0x20, 0xc1, 0xe5, 0xe2, 0xff, 0xff, 0xeb,
425 0x01, 0x00, 0x10, 0xe3, 0xfc, 0xff, 0xff, 0x1a, 0x14, 0x00, 0xa0, 0xe3, 0xc4, 0xff, 0xff, 0xeb,
426 0x04, 0x20, 0xa0, 0xe1, 0x05, 0x10, 0xa0, 0xe1, 0x02, 0x00, 0xa0, 0xe3, 0x01, 0x00, 0x00, 0xeb,
427 0x30, 0x40, 0xbd, 0xe8, 0x1e, 0xff, 0x2f, 0xe1, 0x70, 0x40, 0x2d, 0xe9, 0xf3, 0x46, 0xa0, 0xe3,
428 0x00, 0x30, 0xa0, 0xe3, 0x00, 0x00, 0x50, 0xe3, 0x08, 0x00, 0x00, 0x9a, 0x8c, 0x50, 0x9f, 0xe5,
429 0x03, 0x60, 0xd5, 0xe7, 0x0c, 0x60, 0x84, 0xe5, 0x10, 0x60, 0x94, 0xe5, 0x02, 0x00, 0x16, 0xe3,
430 0xfc, 0xff, 0xff, 0x0a, 0x01, 0x30, 0x83, 0xe2, 0x00, 0x00, 0x53, 0xe1, 0xf7, 0xff, 0xff, 0x3a,
431 0xff, 0x30, 0xa0, 0xe3, 0x0c, 0x30, 0x84, 0xe5, 0x08, 0x00, 0x94, 0xe5, 0x10, 0x00, 0x94, 0xe5,
432 0x01, 0x00, 0x10, 0xe3, 0xfc, 0xff, 0xff, 0x0a, 0x08, 0x00, 0x94, 0xe5, 0x00, 0x00, 0xa0, 0xe3,
433 0x00, 0x00, 0x52, 0xe3, 0x0b, 0x00, 0x00, 0x9a, 0x10, 0x50, 0x94, 0xe5, 0x02, 0x00, 0x15, 0xe3,
434 0xfc, 0xff, 0xff, 0x0a, 0x0c, 0x30, 0x84, 0xe5, 0x10, 0x50, 0x94, 0xe5, 0x01, 0x00, 0x15, 0xe3,
435 0xfc, 0xff, 0xff, 0x0a, 0x08, 0x50, 0x94, 0xe5, 0x01, 0x50, 0xc1, 0xe4, 0x01, 0x00, 0x80, 0xe2,
436 0x02, 0x00, 0x50, 0xe1, 0xf3, 0xff, 0xff, 0x3a, 0xc8, 0x00, 0xa0, 0xe3, 0x98, 0xff, 0xff, 0xeb,
437 0x70, 0x40, 0xbd, 0xe8, 0x1e, 0xff, 0x2f, 0xe1, 0x01, 0x0c, 0x00, 0x02, 0x01, 0x02, 0x00, 0x02,
438 0x00, 0x01, 0x00, 0x02
560 static u8 atmel_basic_rates[4] = {0x82, 0x84, 0x0b, 0x16};
562 static const struct {
578 const unsigned char *
src,
u16 len);
589 u16 frame_len,
u8 rssi);
590 static void atmel_management_timer(
u_long a);
629 return priv->
host_info.rx_desc_pos + (
sizeof(
struct rx_desc) * desc) + offset;
634 return priv->
host_info.tx_desc_pos + (
sizeof(
struct tx_desc) * desc) + offset;
659 atmel_writeAR(priv->
dev, pos);
660 return atmel_read8(priv->
dev,
DR);
665 atmel_writeAR(priv->
dev, pos);
666 atmel_write8(priv->
dev,
DR, data);
671 atmel_writeAR(priv->
dev, pos);
672 return atmel_read16(priv->
dev,
DR);
677 atmel_writeAR(priv->
dev, pos);
678 atmel_write16(priv->
dev,
DR, data);
712 priv->
dev->stats.tx_packets++;
714 priv->
dev->stats.tx_errors++;
715 netif_wake_queue(priv->
dev);
727 if (bottom_free >= len)
738 static void tx_update_descriptor(
struct atmel_private *priv,
int is_bcast,
749 int cipher_type, cipher_length;
802 static const u8 SNAP_RFC1024[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
810 dev->
stats.tx_errors++;
816 dev->
stats.tx_errors++;
832 if (!(buff = find_tx_buff(priv, len + 18))) {
833 dev->
stats.tx_dropped++;
834 spin_unlock_irqrestore(&priv->
irqlock, flags);
836 netif_stop_queue(dev);
846 skb_copy_from_linear_data(skb, &
header.addr1, 6);
853 skb_copy_from_linear_data(skb, &
header.addr3, 6);
868 dev->
stats.tx_bytes += len;
870 spin_unlock_irqrestore(&priv->
irqlock, flags);
877 static void atmel_transmit_management_frame(
struct atmel_private *priv,
884 if (!(buff = find_tx_buff(priv, len)))
903 atmel_copy_to_host(priv->
dev, mac4, rx_packet_loc + 24, 6);
911 if (!(skb = dev_alloc_skb(msdu_size + 14))) {
912 priv->
dev->stats.rx_dropped++;
917 skbp =
skb_put(skb, msdu_size + 12);
918 atmel_copy_to_host(priv->
dev, skbp + 12, rx_packet_loc + 30, msdu_size);
922 crc =
crc32_le(crc, skbp + 12, msdu_size);
923 atmel_copy_to_host(priv->
dev, (
void *)&netcrc, rx_packet_loc + 30 + msdu_size, 4);
924 if ((crc ^ 0xffffffff) != netcrc) {
925 priv->
dev->stats.rx_crc_errors++;
940 priv->
dev->stats.rx_bytes += 12 + msdu_size;
941 priv->
dev->stats.rx_packets++;
949 int i = msdu_size - 4;
950 u32 netcrc, crc = 0xffffffff;
955 atmel_copy_to_host(priv->
dev, (
void *)&netcrc, packet_loc + i, 4);
957 atmel_writeAR(priv->
dev, packet_loc);
959 u8 octet = atmel_read8(priv->
dev,
DR);
963 return (crc ^ 0xffffffff) == netcrc;
969 u8 frag_no,
int more_frags)
986 atmel_copy_to_host(priv->
dev, mac4, rx_packet_loc, 6);
1000 atmel_copy_to_host(priv->
dev, &priv->
rx_buf[12], rx_packet_loc, msdu_size);
1005 atmel_copy_to_host(priv->
dev, (
void *)&netcrc, rx_packet_loc + msdu_size, 4);
1006 if ((crc ^ 0xffffffff) != netcrc) {
1007 priv->
dev->stats.rx_crc_errors++;
1012 }
else if (priv->
frag_no == frag_no &&
1017 rx_packet_loc, msdu_size);
1023 atmel_copy_to_host(priv->
dev, (
void *)&netcrc, rx_packet_loc + msdu_size, 4);
1024 if ((crc ^ 0xffffffff) != netcrc) {
1025 priv->
dev->stats.rx_crc_errors++;
1036 if (!(skb = dev_alloc_skb(priv->
frag_len + 14))) {
1037 priv->
dev->stats.rx_dropped++;
1039 skb_reserve(skb, 2);
1047 priv->
dev->stats.rx_packets++;
1051 priv->
wstats.discard.fragment++;
1066 u32 crc = 0xffffffff;
1070 priv->
wstats.discard.nwid++;
1072 priv->
dev->stats.rx_errors++;
1079 if (msdu_size < 30) {
1080 priv->
dev->stats.rx_errors++;
1085 atmel_copy_to_host(priv->
dev, (
char *)&header, rx_packet_loc, 24);
1094 priv->
do_rx_crc = probe_crc(priv, rx_packet_loc, msdu_size);
1096 priv->
do_rx_crc = probe_crc(priv, rx_packet_loc + 24, msdu_size - 24);
1108 if (priv->
do_rx_crc && (!priv->
wep_is_on || !(frame_ctl & IEEE80211_FCTL_PROTECTED))) {
1109 crc =
crc32_le(0xffffffff, (
unsigned char *)&header, 24);
1118 if (!more_fragments && packet_fragment_no == 0) {
1119 fast_rx_path(priv, &header, msdu_size, rx_packet_loc, crc);
1121 frag_rx_path(priv, &header, msdu_size, rx_packet_loc, crc,
1122 packet_sequence_no, packet_fragment_no, more_fragments);
1128 atmel_copy_to_host(priv->
dev, (
unsigned char *)&priv->
rx_buf, rx_packet_loc + 24, msdu_size);
1137 if ((crc ^ 0xffffffff) != (*((
u32 *)&priv->
rx_buf[msdu_size]))) {
1138 priv->
dev->stats.rx_crc_errors++;
1143 atmel_management_frame(priv, &header, msdu_size,
1164 static const u8 irq_order[] = {
1190 if (!atmel_lock_mac(priv)) {
1207 if (isr & irq_order[i])
1210 if (!atmel_lock_mac(priv)) {
1217 isr ^= irq_order[
i];
1221 switch (irq_order[i]) {
1227 atmel_scan(priv, 1);
1232 priv->
wstats.discard.misc++;
1248 atmel_command_irq(priv);
1256 build_wpa_mib(priv);
1271 atmel_smooth_qual(priv);
1277 priv->
wstats.qual.qual = 0;
1278 priv->
wstats.qual.level = 0;
1282 priv->
wstats.qual.noise = 0;
1287 priv->
wstats.qual.qual = 0;
1288 priv->
wstats.qual.level = 0;
1289 priv->
wstats.qual.noise = 0;
1293 priv->
wstats.miss.beacon = 0;
1299 static int atmel_change_mtu(
struct net_device *dev,
int new_mtu)
1301 if ((new_mtu < 68) || (new_mtu > 2312))
1307 static int atmel_set_mac_address(
struct net_device *dev,
void *
p)
1344 err = reset_atmel_card(dev);
1353 for (i = 0; i <
ARRAY_SIZE(channel_table); i++)
1354 if (priv->
reg_domain == channel_table[i].reg_domain)
1362 if ((channel = atmel_validate_channel(priv, priv->
channel)))
1366 atmel_scan(priv, 1);
1372 static int atmel_close(
struct net_device *dev)
1380 wrqu.
data.length = 0;
1381 wrqu.data.flags = 0;
1387 atmel_enter_state(priv, STATION_STATE_DOWN);
1389 if (priv->
bus_type == BUS_TYPE_PCCARD)
1390 atmel_write16(dev,
GCR, 0x0060);
1391 atmel_write16(dev,
GCR, 0x0040);
1401 for (i = 0; i <
ARRAY_SIZE(channel_table); i++)
1402 if (priv->
reg_domain == channel_table[i].reg_domain) {
1403 if (channel >= channel_table[i].
min &&
1404 channel <= channel_table[i].
max)
1407 return channel_table[
i].min;
1418 p +=
sprintf(p,
"Driver version:\t\t%d.%d\n",
1422 p +=
sprintf(p,
"Firmware version:\t%d.%d build %d\n"
1423 "Firmware location:\t",
1428 if (priv->
card_type != CARD_TYPE_EEPROM)
1431 p +=
sprintf(p,
"%s loaded by host\n",
1434 p +=
sprintf(p,
"%s loaded by hotplug\n",
1438 case CARD_TYPE_PARALLEL_FLASH:
1439 c =
"Parallel flash";
1441 case CARD_TYPE_SPI_FLASH:
1444 case CARD_TYPE_EEPROM:
1452 for (i = 0; i <
ARRAY_SIZE(channel_table); i++)
1453 if (priv->
reg_domain == channel_table[i].reg_domain)
1454 r = channel_table[
i].name;
1456 p +=
sprintf(p,
"MAC memory type:\t%s\n", c);
1457 p +=
sprintf(p,
"Regulatory domain:\t%s\n", r);
1458 p +=
sprintf(p,
"Host CRC checking:\t%s\n",
1460 p +=
sprintf(p,
"WPA-capable firmware:\t%s\n",
1461 priv->
use_wpa ?
"Yes" :
"No");
1465 case STATION_STATE_SCANNING:
1468 case STATION_STATE_JOINNING:
1471 case STATION_STATE_AUTHENTICATING:
1472 s =
"Authenticating";
1474 case STATION_STATE_ASSOCIATING:
1477 case STATION_STATE_READY:
1480 case STATION_STATE_REASSOCIATING:
1481 s =
"Reassociating";
1483 case STATION_STATE_MGMT_ERROR:
1484 s =
"Management error";
1486 case STATION_STATE_DOWN:
1493 p +=
sprintf(p,
"Current state:\t\t%s\n", s);
1501 int len = atmel_proc_output (page, priv);
1502 if (len <= off+count)
1504 *start = page + off;
1515 .ndo_stop = atmel_close,
1516 .ndo_change_mtu = atmel_change_mtu,
1517 .ndo_set_mac_address = atmel_set_mac_address,
1518 .ndo_start_xmit = start_tx,
1519 .ndo_do_ioctl = atmel_ioctl,
1526 int (*card_present)(
void *),
void *
card)
1534 dev = alloc_etherdev(
sizeof(*priv));
1543 priv = netdev_priv(dev);
1580 priv->
SSID[0] =
'\0';
1607 dev->wireless_handlers = &atmel_handler_def;
1626 if (!probe_atmel_card(dev)) {
1633 ent = create_proc_read_entry (
"driver/atmel", 0,
NULL, atmel_read_proc, priv);
1659 atmel_write16(dev,
GCR, 0x0060);
1660 atmel_write16(dev,
GCR, 0x0040);
1673 static int atmel_set_essid(
struct net_device *dev,
1681 if (dwrq->
flags == 0) {
1701 static int atmel_get_essid(
struct net_device *dev,
1722 static int atmel_get_wap(
struct net_device *dev,
1734 static int atmel_set_encode(
struct net_device *dev,
1755 if (index < 0 || index >= 4)
1756 index = current_index;
1778 if (index == current_index &&
1793 if (index >= 0 && index < 4) {
1823 static int atmel_get_encode(
struct net_device *dev,
1840 if (index < 0 || index >= 4)
1842 dwrq->
flags |= index + 1;
1855 static int atmel_set_encodeext(
struct net_device *dev,
1868 if (idx < 1 || idx > 4)
1879 set_key = ext->
key_len > 0 ? 1 : 0;
1895 }
else if (ext->
key_len > 0) {
1915 static int atmel_get_encodeext(
struct net_device *dev,
1923 int idx, max_key_len;
1925 max_key_len = encoding->
length -
sizeof(*ext);
1926 if (max_key_len < 0)
1931 if (idx < 1 || idx > 4)
1937 encoding->
flags = idx + 1;
1938 memset(ext, 0,
sizeof(*ext));
1958 static int atmel_set_auth(
struct net_device *dev,
1993 if (param->
value > 0)
2003 static int atmel_get_auth(
struct net_device *dev,
2033 static int atmel_get_name(
struct net_device *dev,
2038 strcpy(cwrq,
"IEEE 802.11-DS");
2042 static int atmel_set_rate(
struct net_device *dev,
2049 if (vwrq->
fixed == 0) {
2056 if ((vwrq->
value < 4) && (vwrq->
value >= 0)) {
2061 switch (vwrq->
value) {
2083 static int atmel_set_mode(
struct net_device *dev,
2097 static int atmel_get_mode(
struct net_device *dev,
2108 static int atmel_get_rate(
struct net_device *dev,
2117 vwrq->
value = 11000000;
2122 vwrq->
value = 1000000;
2125 vwrq->
value = 2000000;
2128 vwrq->
value = 5500000;
2131 vwrq->
value = 11000000;
2138 static int atmel_set_power(
struct net_device *dev,
2148 static int atmel_get_power(
struct net_device *dev,
2159 static int atmel_set_retry(
struct net_device *dev,
2182 static int atmel_get_retry(
struct net_device *dev,
2205 static int atmel_set_rts(
struct net_device *dev,
2211 int rthr = vwrq->
value;
2215 if ((rthr < 0) || (rthr > 2347)) {
2223 static int atmel_get_rts(
struct net_device *dev,
2237 static int atmel_set_frag(
struct net_device *dev,
2243 int fthr = vwrq->
value;
2247 if ((fthr < 256) || (fthr > 2346)) {
2256 static int atmel_get_frag(
struct net_device *dev,
2270 static int atmel_set_freq(
struct net_device *dev,
2280 int f = fwrq->
m / 100000;
2284 fwrq->
m = ieee80211_freq_to_dsss_chan(f);
2287 if ((fwrq->
m > 1000) || (fwrq->
e > 0))
2290 int channel = fwrq->
m;
2291 if (atmel_validate_channel(priv, channel) == 0) {
2300 static int atmel_get_freq(
struct net_device *dev,
2312 static int atmel_set_scan(
struct net_device *dev,
2318 unsigned long flags;
2344 atmel_scan(priv, 0);
2345 spin_unlock_irqrestore(&priv->
irqlock, flags);
2350 static int atmel_get_scan(
struct net_device *dev,
2357 char *current_ev =
extra;
2367 current_ev = iwe_stream_add_event(info, current_ev,
2371 iwe.u.data.length = priv->
BSSinfo[
i].SSIDsize;
2372 if (iwe.u.data.length > 32)
2373 iwe.u.data.length = 32;
2375 iwe.u.data.flags = 1;
2376 current_ev = iwe_stream_add_point(info, current_ev,
2381 iwe.u.mode = priv->
BSSinfo[
i].BSStype;
2382 current_ev = iwe_stream_add_event(info, current_ev,
2387 iwe.u.freq.m = priv->
BSSinfo[
i].channel;
2389 current_ev = iwe_stream_add_event(info, current_ev,
2395 iwe.u.qual.level = priv->
BSSinfo[
i].RSSI;
2396 iwe.u.qual.qual = iwe.u.qual.level;
2398 current_ev = iwe_stream_add_event(info, current_ev,
2404 if (priv->
BSSinfo[i].UsingWEP)
2408 iwe.u.data.length = 0;
2409 current_ev = iwe_stream_add_point(info, current_ev,
2421 static int atmel_get_range(
struct net_device *dev,
2435 for (j = 0; j <
ARRAY_SIZE(channel_table); j++)
2436 if (priv->
reg_domain == channel_table[j].reg_domain) {
2437 range->
num_channels = channel_table[
j].max - channel_table[
j].min + 1;
2441 for (k = 0, i = channel_table[j].
min; i <= channel_table[
j].max; i++) {
2445 range->
freq[
k].m = (ieee80211_dsss_chan_to_freq(i) *
2447 range->
freq[k++].e = 1;
2495 static int atmel_set_wap(
struct net_device *dev,
2502 static const u8 any[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
2503 static const u8 off[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
2504 unsigned long flags;
2513 atmel_scan(priv, 1);
2514 spin_unlock_irqrestore(&priv->
irqlock, flags);
2527 atmel_join_bss(priv, i);
2528 spin_unlock_irqrestore(&priv->
irqlock, flags);
2537 static int atmel_config_commit(
struct net_device *dev,
2615 #define ATMELFWL SIOCIWFIRSTPRIV
2616 #define ATMELIDIFC ATMELFWL + 1
2617 #define ATMELRD ATMELFWL + 2
2618 #define ATMELMAGIC 0x51807
2619 #define REGDOMAINSZ 20
2621 static const struct iw_priv_args atmel_private_args[] = {
2633 .name =
"atmelidifc"
2644 .num_private =
ARRAY_SIZE(atmel_private_handler),
2645 .num_private_args =
ARRAY_SIZE(atmel_private_args),
2647 .
private = (
iw_handler *) atmel_private_handler,
2648 .private_args = (
struct iw_priv_args *) atmel_private_args,
2658 unsigned char *new_firmware;
2683 kfree(new_firmware);
2709 for (i = 0; i <
ARRAY_SIZE(channel_table); i++) {
2711 char *
a = channel_table[
i].name;
2749 if (new_state == old_state)
2754 if (new_state == STATION_STATE_READY) {
2755 netif_start_queue(priv->
dev);
2759 if (old_state == STATION_STATE_READY) {
2761 if (netif_running(priv->
dev))
2762 netif_stop_queue(priv->
dev);
2767 static void atmel_scan(
struct atmel_private *priv,
int specific_ssid)
2781 memset(cmd.BSSID, 0xff, 6);
2800 cmd.channel = (priv->
channel & 0x7f);
2805 atmel_send_command(priv,
CMD_Scan, &cmd,
sizeof(cmd));
2809 atmel_enter_state(priv, STATION_STATE_SCANNING);
2827 cmd.channel = (priv->
channel & 0x7f);
2828 cmd.BSS_type =
type;
2831 atmel_send_command(priv,
CMD_Join, &cmd,
sizeof(cmd));
2848 cmd.BSS_type =
type;
2849 cmd.channel = (priv->
channel & 0x7f);
2851 atmel_send_command(priv,
CMD_Start, &cmd,
sizeof(cmd));
2867 if (priv->
channel != channel) {
2875 atmel_enter_state(priv, STATION_STATE_JOINNING);
2885 u8 *challenge,
int challenge_len)
2908 if (challenge_len != 0) {
2910 auth.chall_text_len = challenge_len;
2911 memcpy(
auth.chall_text, challenge, challenge_len);
2912 atmel_transmit_management_frame(priv, &header, (
u8 *)&
auth, 8 + challenge_len);
2914 atmel_transmit_management_frame(priv, &header, (
u8 *)&
auth, 6);
2918 static void send_association_request(
struct atmel_private *priv,
int is_reassoc)
2923 struct ass_req_format {
2955 ssid_el_p = &body.ssid_el_id;
2958 ssid_el_p = &body.ap[0];
2969 atmel_transmit_management_frame(priv, &header, (
void *)&body, bodysize);
2972 static int is_frame_from_current_bss(
struct atmel_private *priv,
2984 int max_rssi = -128;
3000 !(priv->
BSSinfo[i].channel & 0x80)) {
3012 atmel_validate_channel(priv, priv->
BSSinfo[i].channel) == 0) {
3013 if (priv->
BSSinfo[i].RSSI >= max_rssi) {
3024 u16 beacon_period,
u8 channel,
u8 rssi,
u8 ssid_len,
3045 if (rssi > priv->
BSSinfo[index].RSSI)
3076 atmel_enter_state(priv, STATION_STATE_REASSOCIATING);
3077 send_association_request(priv, 1);
3080 atmel_enter_state(priv, STATION_STATE_ASSOCIATING);
3081 send_association_request(priv, 0);
3087 int should_associate = 0;
3093 if (trans_seq_no == 0x0002) {
3094 should_associate = 1;
3097 if (trans_seq_no == 0x0002 &&
3101 }
else if (trans_seq_no == 0x0004) {
3102 should_associate = 1;
3106 if (should_associate) {
3108 atmel_enter_state(priv, STATION_STATE_REASSOCIATING);
3109 send_association_request(priv, 1);
3112 atmel_enter_state(priv, STATION_STATE_ASSOCIATING);
3113 send_association_request(priv, 0);
3139 if ((bss_index = retrieve_bss(priv)) != -1) {
3140 atmel_join_bss(priv, bss_index);
3147 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
3153 struct ass_resp_format {
3160 } *ass_resp = (
struct ass_resp_format *)priv->
rx_buf;
3164 u16 rates_len = ass_resp->length > 4 ? 4 : ass_resp->length;
3168 if (frame_len < 8 + rates_len)
3197 atmel_enter_state(priv, STATION_STATE_READY);
3200 wrqu.
data.length = 0;
3201 wrqu.
data.flags = 0;
3215 send_association_request(priv, 0);
3225 send_association_request(priv, 1);
3229 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
3236 if ((bss_index = retrieve_bss(priv)) != -1)
3237 atmel_join_bss(priv, bss_index);
3241 static void atmel_join_bss(
struct atmel_private *priv,
int bss_index)
3243 struct bss_info *bss = &priv->
BSSinfo[bss_index];
3250 build_wpa_mib(priv);
3266 priv->
channel = bss->channel & 0x7f;
3269 if (priv->
preamble != bss->preamble) {
3275 if (!priv->
wep_is_on && bss->UsingWEP) {
3276 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
3281 if (priv->
wep_is_on && !bss->UsingWEP) {
3282 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
3287 atmel_enter_state(priv, STATION_STATE_JOINNING);
3300 atmel_scan(priv, 1);
3304 if ((bss_index = retrieve_bss(priv)) != -1)
3305 atmel_join_bss(priv, bss_index);
3307 atmel_scan(priv, 0);
3324 rssi = rssi * 100 / max_rssi;
3325 if ((rssi + old) % 2)
3326 priv->
wstats.qual.level = (rssi + old) / 2 + 1;
3328 priv->
wstats.qual.level = (rssi + old) / 2;
3336 while (time_diff--) {
3339 priv->
wstats.qual.qual +=
3348 static void atmel_management_frame(
struct atmel_private *priv,
3350 u16 frame_len,
u8 rssi)
3362 struct beacon_format {
3377 u8 channel, rates_length, ssid_length;
3382 ssid_length =
beacon->ssid_length;
3384 if (frame_len < 14 || frame_len < ssid_length + 15)
3386 rates_length = beaconp[
beacon->ssid_length + 15];
3387 if (frame_len < ssid_length + rates_length + 18)
3391 channel = beaconp[ssid_length + rates_length + 18];
3394 smooth_rssi(priv, rssi);
3395 if (is_frame_from_current_bss(priv, header)) {
3397 atmel_smooth_qual(priv);
3401 int beacons = beacon_delay / (beacon_interval * 1000);
3403 priv->
wstats.miss.beacon += beacons - 1;
3406 handle_beacon_probe(priv, capability, channel);
3411 store_bss_info(priv, header, capability,
3412 beacon_interval, channel, rssi,
3422 authenticate(priv, frame_len);
3431 associate(priv, frame_len, subtype);
3438 is_frame_from_current_bss(priv, header)) {
3442 atmel_enter_state(priv, STATION_STATE_JOINNING);
3450 is_frame_from_current_bss(priv, header)) {
3453 atmel_enter_state(priv, STATION_STATE_JOINNING);
3462 static void atmel_management_timer(
u_long a)
3466 unsigned long flags;
3482 restart_search(priv);
3490 send_authentication_request(priv, auth,
NULL, 0);
3499 restart_search(priv);
3503 send_association_request(priv, 0);
3512 restart_search(priv);
3516 send_association_request(priv, 1);
3524 spin_unlock_irqrestore(&priv->
irqlock, flags);
3544 atmel_enter_state(priv, STATION_STATE_READY);
3553 atmel_scan(priv, 1);
3555 int bss_index = retrieve_bss(priv);
3556 int notify_scan_complete = 1;
3557 if (bss_index != -1) {
3558 atmel_join_bss(priv, bss_index);
3564 atmel_scan(priv, 1);
3565 notify_scan_complete = 0;
3568 if (notify_scan_complete) {
3569 wrqu.
data.length = 0;
3570 wrqu.
data.flags = 0;
3584 atmel_enter_state(priv, STATION_STATE_READY);
3585 wrqu.
data.length = 0;
3586 wrqu.
data.flags = 0;
3589 atmel_scan(priv, 1);
3597 atmel_enter_state(priv, STATION_STATE_READY);
3601 atmel_enter_state(priv, STATION_STATE_AUTHENTICATING);
3607 send_authentication_request(priv, auth,
NULL, 0);
3612 atmel_scan(priv, 1);
3616 static int atmel_wakeup_firmware(
struct atmel_private *priv)
3618 struct host_info_struct *iface = &priv->
host_info;
3622 if (priv->
card_type == CARD_TYPE_SPI_FLASH)
3626 atmel_clear_gcr(priv->
dev, 0x0040);
3629 if (priv->
card_type == CARD_TYPE_SPI_FLASH)
3634 mr1 = atmel_read16(priv->
dev,
MR1);
3635 mr3 = atmel_read16(priv->
dev,
MR3);
3639 if (mr1 & MAC_BOOT_COMPLETE &&
3662 mr1 = atmel_read16(priv->
dev,
MR1);
3663 mr3 = atmel_read16(priv->
dev,
MR3);
3667 if (mr1 & MAC_INIT_COMPLETE &&
3679 if ((mr3 & MAC_INIT_COMPLETE) &&
3684 if ((mr1 & MAC_INIT_COMPLETE) &&
3685 !(atmel_read16(priv->
dev,
MR1) & MAC_INIT_OK)) {
3690 atmel_copy_to_host(priv->
dev, (
unsigned char *)iface,
3693 iface->tx_buff_pos =
le16_to_cpu(iface->tx_buff_pos);
3694 iface->tx_buff_size =
le16_to_cpu(iface->tx_buff_size);
3695 iface->tx_desc_pos =
le16_to_cpu(iface->tx_desc_pos);
3696 iface->tx_desc_count =
le16_to_cpu(iface->tx_desc_count);
3697 iface->rx_buff_pos =
le16_to_cpu(iface->rx_buff_pos);
3698 iface->rx_buff_size =
le16_to_cpu(iface->rx_buff_size);
3699 iface->rx_desc_pos =
le16_to_cpu(iface->rx_desc_pos);
3700 iface->rx_desc_count =
le16_to_cpu(iface->rx_desc_count);
3701 iface->build_version =
le16_to_cpu(iface->build_version);
3702 iface->command_pos =
le16_to_cpu(iface->command_pos);
3703 iface->major_version =
le16_to_cpu(iface->major_version);
3704 iface->minor_version =
le16_to_cpu(iface->minor_version);
3706 iface->mac_status =
le16_to_cpu(iface->mac_status);
3712 static int probe_atmel_card(
struct net_device *dev)
3719 atmel_write16(dev,
GCR, 0x0060);
3721 atmel_write16(dev,
GCR, 0x0040);
3724 if (atmel_read16(dev,
MR2) == 0) {
3730 atmel_copy_to_card(dev, 0, mac_reader,
sizeof(mac_reader));
3732 atmel_clear_gcr(priv->
dev, 0x0040);
3735 if (atmel_read16(dev,
MR3) & MAC_BOOT_COMPLETE)
3740 atmel_copy_to_host(dev, dev->
dev_addr, atmel_read16(dev,
MR2), 6);
3744 atmel_write16(dev,
GCR, 0x0060);
3745 atmel_write16(dev,
GCR, 0x0040);
3748 }
else if (atmel_read16(dev,
MR4) == 0) {
3751 atmel_write16(dev,
BSR, 1);
3752 atmel_copy_to_host(dev, dev->
dev_addr, 0xc000, 6);
3753 atmel_write16(dev,
BSR, 0x200);
3759 if (atmel_wakeup_firmware(priv) == 0) {
3765 atmel_write16(dev,
GCR, 0x0060);
3766 atmel_write16(dev,
GCR, 0x0040);
3773 static const u8 default_mac[] = {
3774 0x00, 0x04, 0x25, 0x00, 0x00, 0x00
3795 u32 WEPICV_error_count;
3796 u32 WEP_excluded_count;
3807 mib.encryption_level = 2;
3809 mib.encryption_level = 1;
3811 mib.encryption_level = 0;
3829 u8 receiver_address[6];
3833 u8 exclude_unencrypted;
3837 u32 WEPICV_error_count;
3838 u32 WEP_excluded_count;
3850 memset(mib.cipher_default_key_value, 0,
sizeof(mib.cipher_default_key_value));
3856 memset(mib.key_RSC, 0,
sizeof(mib.key_RSC));
3858 mib.default_key = mib.group_key = 255;
3863 mib.default_key =
i;
3874 if (mib.default_key == 255)
3875 mib.default_key = mib.group_key != 255 ? mib.group_key : 0;
3876 if (mib.group_key == 255)
3877 mib.group_key = mib.default_key;
3884 static int reset_atmel_card(
struct net_device *dev)
3908 static char *firmware_modifier[] = {
3916 atmel_write16(priv->
dev,
GCR, 0x0060);
3919 atmel_write16(priv->
dev,
GCR, 0x0040);
3924 const unsigned char *
fw;
3930 "%s: card type is unknown: assuming at76c502 firmware is OK.\n",
3933 "%s: if not, use the firmware= module parameter.\n",
3940 "%s: firmware %s is missing, cannot continue.\n",
3956 for (i = 0; firmware_modifier[
i]; i++) {
3958 firmware_modifier[i], fw_table[fw_index].fw_file_ext);
3968 "%s: firmware %s is missing, cannot start.\n",
3975 fw = fw_entry->
data;
3976 len = fw_entry->
size;
3979 if (len <= 0x6000) {
3981 atmel_copy_to_card(priv->
dev, 0, fw, len);
3987 atmel_copy_to_card(priv->
dev, 0, fw, 0x6000);
3988 atmel_write16(priv->
dev,
BSR, 0x2ff);
3989 atmel_copy_to_card(priv->
dev, 0x8000, &fw[0x6000], len - 0x6000);
3995 err = atmel_wakeup_firmware(priv);
4053 priv->
dev->dev_addr, 6);
4060 build_wpa_mib(priv);
4062 build_wep_mib(priv);
4064 if (old_state == STATION_STATE_READY) {
4067 wrqu.
data.length = 0;
4068 wrqu.
data.flags = 0;
4077 static void atmel_send_command(
struct atmel_private *priv,
int command,
4088 static int atmel_send_command_wait(
struct atmel_private *priv,
int command,
4089 void *cmd,
int cmd_size)
4093 atmel_send_command(priv, command, cmd, cmd_size);
4095 for (i = 5000;
i; i--) {
4144 m.data[1] = data >> 8;
4160 memcpy(
m.data, data, data_len);
4165 u8 *data,
int data_len)
4176 atmel_copy_to_host(priv->
dev, data,
4190 const unsigned char *
src,
u16 len)
4193 atmel_writeAR(dev, dest);
4195 atmel_write8(dev,
DR, *src);
4198 for (i = len; i > 1 ; i -= 2) {
4201 atmel_write16(dev,
DR, lb | (hb << 8));
4204 atmel_write8(dev,
DR, *src);
4207 static void atmel_copy_to_host(
struct net_device *dev,
unsigned char *dest,
4211 atmel_writeAR(dev, src);
4213 *dest = atmel_read8(dev,
DR);
4216 for (i = len; i > 1 ; i -= 2) {
4217 u16 hw = atmel_read16(dev,
DR);
4222 *dest = atmel_read8(dev,
DR);
4230 static void atmel_clear_gcr(
struct net_device *dev,
u16 mask)
4239 for (i = 5000;
i; i--) {
4261 atmel_writeAR(priv->
dev, pos);
4262 atmel_write16(priv->
dev,
DR, data);
4263 atmel_write16(priv->
dev,
DR, data >> 16);
4304 .set MRBASE, 0x8000000
4305 .set CPSR_INITIAL, 0xD3
4306 .set CPSR_USER, 0xD1
4308 .set SP_BASE, 0x0F300000
4309 .set UNK_BASE, 0x0F000000
4310 .set SPI_CGEN_BASE, 0x0E000000
4311 .set UNK3_BASE, 0x02014000
4312 .set STACK_BASE, 0x5600
4326 .set NVRAM_CMD_RDSR, 5
4327 .set NVRAM_CMD_READ, 3
4328 .set NVRAM_SR_RDY, 1
4329 .set SPI_8CLOCKS, 0xFF
4336 .set NVRAM_SCRATCH, 0x02000100
4337 .set NVRAM_IMAGE, 0x02000200
4338 .set NVRAM_LENGTH, 0x0200
4340 .set MAC_ADDRESS_LENGTH, 6
4341 .set MAC_BOOT_FLAG, 0x10
4363 mov
r0, #CPSR_INITIAL
4367 ldr r0, =SPI_CGEN_BASE
4392 ldr r1, =MAC_ADDRESS_MIB
4394 ldr r1, =NVRAM_IMAGE
4396 mov
r1, #MAC_BOOT_FLAG
4399 .func Get_Whole_NVRAM, GET_WHOLE_NVRAM
4403 mov
r3, #NVRAM_LENGTH
4405 ldr r0, =NVRAM_IMAGE
4411 .func Get_MAC_Addr, GET_MAC_ADDR
4415 mov
r3, #MAC_ADDRESS_LENGTH
4417 ldr r0, =MAC_ADDRESS_MIB
4423 .func Delay9, DELAY9
4434 .func SP_Init, SP_INIT
4446 ldr r3, =SPI_CGEN_BASE
4465 mov
r0, #NVRAM_CMD_RDSR
4472 mov
r0, #SPI_8CLOCKS
4490 .func NVRAM_Xfer, NVRAM_XFER
4502 ldr r1, =NVRAM_SCRATCH
4507 tst r0, #NVRAM_SR_RDY
4519 .func NVRAM_Xfer2, NVRAM_XFER2
4526 ldr r5, =NVRAM_SCRATCH
4538 mov
r3, #SPI_8CLOCKS