• Home
  • Raw
  • Download

Lines Matching refs:wl

32 void wl1251_enable_interrupts(struct wl1251 *wl)  in wl1251_enable_interrupts()  argument
34 wl->if_ops->enable_irq(wl); in wl1251_enable_interrupts()
37 void wl1251_disable_interrupts(struct wl1251 *wl) in wl1251_disable_interrupts() argument
39 wl->if_ops->disable_irq(wl); in wl1251_disable_interrupts()
42 static int wl1251_power_off(struct wl1251 *wl) in wl1251_power_off() argument
44 return wl->if_ops->power(wl, false); in wl1251_power_off()
47 static int wl1251_power_on(struct wl1251 *wl) in wl1251_power_on() argument
49 return wl->if_ops->power(wl, true); in wl1251_power_on()
52 static int wl1251_fetch_firmware(struct wl1251 *wl) in wl1251_fetch_firmware() argument
55 struct device *dev = wiphy_dev(wl->hw->wiphy); in wl1251_fetch_firmware()
72 wl->fw_len = fw->size; in wl1251_fetch_firmware()
73 wl->fw = vmalloc(wl->fw_len); in wl1251_fetch_firmware()
75 if (!wl->fw) { in wl1251_fetch_firmware()
81 memcpy(wl->fw, fw->data, wl->fw_len); in wl1251_fetch_firmware()
91 static int wl1251_fetch_nvs(struct wl1251 *wl) in wl1251_fetch_nvs() argument
94 struct device *dev = wiphy_dev(wl->hw->wiphy); in wl1251_fetch_nvs()
111 wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL); in wl1251_fetch_nvs()
113 if (!wl->nvs) { in wl1251_fetch_nvs()
119 wl->nvs_len = fw->size; in wl1251_fetch_nvs()
129 static void wl1251_fw_wakeup(struct wl1251 *wl) in wl1251_fw_wakeup() argument
134 wl1251_write_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg); in wl1251_fw_wakeup()
135 elp_reg = wl1251_read_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); in wl1251_fw_wakeup()
141 static int wl1251_chip_wakeup(struct wl1251 *wl) in wl1251_chip_wakeup() argument
145 ret = wl1251_power_on(wl); in wl1251_chip_wakeup()
150 wl->if_ops->reset(wl); in wl1251_chip_wakeup()
154 wl1251_set_partition(wl, in wl1251_chip_wakeup()
161 wl1251_fw_wakeup(wl); in wl1251_chip_wakeup()
166 wl->chip_id = wl1251_reg_read32(wl, CHIP_ID_B); in wl1251_chip_wakeup()
170 switch (wl->chip_id) { in wl1251_chip_wakeup()
173 wl->chip_id); in wl1251_chip_wakeup()
177 wl->chip_id); in wl1251_chip_wakeup()
181 wl1251_error("unsupported chip id: 0x%x", wl->chip_id); in wl1251_chip_wakeup()
186 if (wl->fw == NULL) { in wl1251_chip_wakeup()
187 ret = wl1251_fetch_firmware(wl); in wl1251_chip_wakeup()
200 struct wl1251 *wl = in wl1251_irq_work() local
204 mutex_lock(&wl->mutex); in wl1251_irq_work()
208 if (wl->state == WL1251_STATE_OFF) in wl1251_irq_work()
211 ret = wl1251_ps_elp_wakeup(wl); in wl1251_irq_work()
215 wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, WL1251_ACX_INTR_ALL); in wl1251_irq_work()
217 intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR); in wl1251_irq_work()
221 if (wl->data_path) { in wl1251_irq_work()
222 wl->rx_counter = wl1251_mem_read32( in wl1251_irq_work()
223 wl, wl->data_path->rx_control_addr); in wl1251_irq_work()
226 switch ((wl->rx_counter - wl->rx_handled) & 0xf) { in wl1251_irq_work()
246 wl->rx_counter - wl->rx_handled); in wl1251_irq_work()
250 wl->rx_handled = wl->rx_counter; in wl1251_irq_work()
253 wl->rx_counter); in wl1251_irq_work()
256 intr &= wl->intr_mask; in wl1251_irq_work()
265 wl1251_rx(wl); in wl1251_irq_work()
270 wl1251_rx(wl); in wl1251_irq_work()
275 wl1251_tx_complete(wl); in wl1251_irq_work()
280 wl1251_event_handle(wl, 0); in wl1251_irq_work()
285 wl1251_event_handle(wl, 1); in wl1251_irq_work()
295 intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR); in wl1251_irq_work()
299 wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask)); in wl1251_irq_work()
300 wl1251_ps_elp_sleep(wl); in wl1251_irq_work()
303 mutex_unlock(&wl->mutex); in wl1251_irq_work()
306 static int wl1251_join(struct wl1251 *wl, u8 bss_type, u8 channel, in wl1251_join() argument
311 ret = wl1251_acx_frame_rates(wl, DEFAULT_HW_GEN_TX_RATE, in wl1251_join()
313 wl->tx_mgmt_frm_rate, in wl1251_join()
314 wl->tx_mgmt_frm_mod); in wl1251_join()
322 if (is_zero_ether_addr(wl->bssid)) in wl1251_join()
323 wl->rx_config &= ~CFG_BSSID_FILTER_EN; in wl1251_join()
325 ret = wl1251_cmd_join(wl, bss_type, channel, beacon_interval, in wl1251_join()
330 ret = wl1251_event_wait(wl, JOIN_EVENT_COMPLETE_ID, 100); in wl1251_join()
342 struct wl1251 *wl = hw->priv; in wl1251_op_tx() local
345 skb_queue_tail(&wl->tx_queue, skb); in wl1251_op_tx()
352 ieee80211_queue_work(wl->hw, &wl->tx_work); in wl1251_op_tx()
358 if (skb_queue_len(&wl->tx_queue) >= WL1251_TX_QUEUE_HIGH_WATERMARK) { in wl1251_op_tx()
361 spin_lock_irqsave(&wl->wl_lock, flags); in wl1251_op_tx()
362 ieee80211_stop_queues(wl->hw); in wl1251_op_tx()
363 wl->tx_queue_stopped = true; in wl1251_op_tx()
364 spin_unlock_irqrestore(&wl->wl_lock, flags); in wl1251_op_tx()
370 struct wl1251 *wl = hw->priv; in wl1251_op_start() local
376 mutex_lock(&wl->mutex); in wl1251_op_start()
378 if (wl->state != WL1251_STATE_OFF) { in wl1251_op_start()
380 wl->state); in wl1251_op_start()
385 ret = wl1251_chip_wakeup(wl); in wl1251_op_start()
389 ret = wl1251_boot(wl); in wl1251_op_start()
393 ret = wl1251_hw_init(wl); in wl1251_op_start()
397 ret = wl1251_acx_station_id(wl); in wl1251_op_start()
401 wl->state = WL1251_STATE_ON; in wl1251_op_start()
403 wl1251_info("firmware booted (%s)", wl->fw_ver); in wl1251_op_start()
406 wiphy->hw_version = wl->chip_id; in wl1251_op_start()
407 strncpy(wiphy->fw_version, wl->fw_ver, sizeof(wiphy->fw_version)); in wl1251_op_start()
411 wl1251_power_off(wl); in wl1251_op_start()
413 mutex_unlock(&wl->mutex); in wl1251_op_start()
420 struct wl1251 *wl = hw->priv; in wl1251_op_stop() local
426 mutex_lock(&wl->mutex); in wl1251_op_stop()
428 WARN_ON(wl->state != WL1251_STATE_ON); in wl1251_op_stop()
430 if (wl->scanning) { in wl1251_op_stop()
435 ieee80211_scan_completed(wl->hw, &info); in wl1251_op_stop()
436 wl->scanning = false; in wl1251_op_stop()
439 wl->state = WL1251_STATE_OFF; in wl1251_op_stop()
441 wl1251_disable_interrupts(wl); in wl1251_op_stop()
443 mutex_unlock(&wl->mutex); in wl1251_op_stop()
445 cancel_work_sync(&wl->irq_work); in wl1251_op_stop()
446 cancel_work_sync(&wl->tx_work); in wl1251_op_stop()
447 cancel_delayed_work_sync(&wl->elp_work); in wl1251_op_stop()
449 mutex_lock(&wl->mutex); in wl1251_op_stop()
452 wl1251_tx_flush(wl); in wl1251_op_stop()
453 wl1251_power_off(wl); in wl1251_op_stop()
455 eth_zero_addr(wl->bssid); in wl1251_op_stop()
456 wl->listen_int = 1; in wl1251_op_stop()
457 wl->bss_type = MAX_BSS_TYPE; in wl1251_op_stop()
459 wl->data_in_count = 0; in wl1251_op_stop()
460 wl->rx_counter = 0; in wl1251_op_stop()
461 wl->rx_handled = 0; in wl1251_op_stop()
462 wl->rx_current_buffer = 0; in wl1251_op_stop()
463 wl->rx_last_id = 0; in wl1251_op_stop()
464 wl->next_tx_complete = 0; in wl1251_op_stop()
465 wl->elp = false; in wl1251_op_stop()
466 wl->station_mode = STATION_ACTIVE_MODE; in wl1251_op_stop()
467 wl->psm_entry_retry = 0; in wl1251_op_stop()
468 wl->tx_queue_stopped = false; in wl1251_op_stop()
469 wl->power_level = WL1251_DEFAULT_POWER_LEVEL; in wl1251_op_stop()
470 wl->rssi_thold = 0; in wl1251_op_stop()
471 wl->channel = WL1251_DEFAULT_CHANNEL; in wl1251_op_stop()
472 wl->monitor_present = false; in wl1251_op_stop()
473 wl->joined = false; in wl1251_op_stop()
475 wl1251_debugfs_reset(wl); in wl1251_op_stop()
477 mutex_unlock(&wl->mutex); in wl1251_op_stop()
483 struct wl1251 *wl = hw->priv; in wl1251_op_add_interface() local
493 mutex_lock(&wl->mutex); in wl1251_op_add_interface()
494 if (wl->vif) { in wl1251_op_add_interface()
499 wl->vif = vif; in wl1251_op_add_interface()
503 wl->bss_type = BSS_TYPE_STA_BSS; in wl1251_op_add_interface()
506 wl->bss_type = BSS_TYPE_IBSS; in wl1251_op_add_interface()
513 if (!ether_addr_equal_unaligned(wl->mac_addr, vif->addr)) { in wl1251_op_add_interface()
514 memcpy(wl->mac_addr, vif->addr, ETH_ALEN); in wl1251_op_add_interface()
515 SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr); in wl1251_op_add_interface()
516 ret = wl1251_acx_station_id(wl); in wl1251_op_add_interface()
522 mutex_unlock(&wl->mutex); in wl1251_op_add_interface()
529 struct wl1251 *wl = hw->priv; in wl1251_op_remove_interface() local
531 mutex_lock(&wl->mutex); in wl1251_op_remove_interface()
533 wl->vif = NULL; in wl1251_op_remove_interface()
534 eth_zero_addr(wl->bssid); in wl1251_op_remove_interface()
535 mutex_unlock(&wl->mutex); in wl1251_op_remove_interface()
538 static int wl1251_build_null_data(struct wl1251 *wl) in wl1251_build_null_data() argument
545 if (wl->bss_type == BSS_TYPE_IBSS) { in wl1251_build_null_data()
549 skb = ieee80211_nullfunc_get(wl->hw, wl->vif, false); in wl1251_build_null_data()
556 ret = wl1251_cmd_template_set(wl, CMD_NULL_DATA, ptr, size); in wl1251_build_null_data()
566 static int wl1251_build_qos_null_data(struct wl1251 *wl) in wl1251_build_qos_null_data() argument
572 memcpy(template.addr1, wl->bssid, ETH_ALEN); in wl1251_build_qos_null_data()
573 memcpy(template.addr2, wl->mac_addr, ETH_ALEN); in wl1251_build_qos_null_data()
574 memcpy(template.addr3, wl->bssid, ETH_ALEN); in wl1251_build_qos_null_data()
583 return wl1251_cmd_template_set(wl, CMD_QOS_NULL_DATA, &template, in wl1251_build_qos_null_data()
587 static bool wl1251_can_do_pm(struct ieee80211_conf *conf, struct wl1251 *wl) in wl1251_can_do_pm() argument
589 return (conf->flags & IEEE80211_CONF_PS) && !wl->monitor_present; in wl1251_can_do_pm()
594 struct wl1251 *wl = hw->priv; in wl1251_op_config() local
608 mutex_lock(&wl->mutex); in wl1251_op_config()
610 ret = wl1251_ps_elp_wakeup(wl); in wl1251_op_config()
618 wl->monitor_present = true; in wl1251_op_config()
621 wl->monitor_present = false; in wl1251_op_config()
625 ret = wl1251_acx_feature_cfg(wl, mode); in wl1251_op_config()
630 if (channel != wl->channel) { in wl1251_op_config()
631 wl->channel = channel; in wl1251_op_config()
640 if (wl->vif == NULL) { in wl1251_op_config()
641 wl->joined = false; in wl1251_op_config()
642 ret = wl1251_cmd_data_path_rx(wl, wl->channel, 1); in wl1251_op_config()
644 ret = wl1251_join(wl, wl->bss_type, wl->channel, in wl1251_op_config()
645 wl->beacon_int, wl->dtim_period); in wl1251_op_config()
651 if (wl1251_can_do_pm(conf, wl) && !wl->psm_requested) { in wl1251_op_config()
654 wl->psm_requested = true; in wl1251_op_config()
656 wl->dtim_period = conf->ps_dtim_period; in wl1251_op_config()
658 ret = wl1251_acx_wr_tbtt_and_dtim(wl, wl->beacon_int, in wl1251_op_config()
659 wl->dtim_period); in wl1251_op_config()
664 ret = wl1251_ps_set_mode(wl, STATION_POWER_SAVE_MODE); in wl1251_op_config()
667 } else if (!wl1251_can_do_pm(conf, wl) && wl->psm_requested) { in wl1251_op_config()
670 wl->psm_requested = false; in wl1251_op_config()
672 if (wl->station_mode != STATION_ACTIVE_MODE) { in wl1251_op_config()
673 ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE); in wl1251_op_config()
679 if (changed & IEEE80211_CONF_CHANGE_IDLE && !wl->scanning) { in wl1251_op_config()
681 ret = wl1251_ps_set_mode(wl, STATION_IDLE); in wl1251_op_config()
685 ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE); in wl1251_op_config()
688 ret = wl1251_join(wl, wl->bss_type, wl->channel, in wl1251_op_config()
689 wl->beacon_int, wl->dtim_period); in wl1251_op_config()
695 if (conf->power_level != wl->power_level) { in wl1251_op_config()
696 ret = wl1251_acx_tx_power(wl, conf->power_level); in wl1251_op_config()
700 wl->power_level = conf->power_level; in wl1251_op_config()
704 wl1251_ps_elp_sleep(wl); in wl1251_op_config()
707 mutex_unlock(&wl->mutex); in wl1251_op_config()
723 struct wl1251 *wl = hw->priv; in wl1251_op_prepare_multicast() local
725 if (unlikely(wl->state == WL1251_STATE_OFF)) in wl1251_op_prepare_multicast()
762 struct wl1251 *wl = hw->priv; in wl1251_op_configure_filter() local
776 mutex_lock(&wl->mutex); in wl1251_op_configure_filter()
778 wl->rx_config = WL1251_DEFAULT_RX_CONFIG; in wl1251_op_configure_filter()
779 wl->rx_filter = WL1251_DEFAULT_RX_FILTER; in wl1251_op_configure_filter()
786 wl->rx_config &= ~CFG_MC_FILTER_EN; in wl1251_op_configure_filter()
788 wl->rx_filter |= CFG_RX_FCS_ERROR; in wl1251_op_configure_filter()
790 wl->rx_config &= ~CFG_BSSID_FILTER_EN; in wl1251_op_configure_filter()
791 wl->rx_config &= ~CFG_SSID_FILTER_EN; in wl1251_op_configure_filter()
794 wl->rx_filter |= CFG_RX_CTL_EN; in wl1251_op_configure_filter()
795 if (*total & FIF_OTHER_BSS || is_zero_ether_addr(wl->bssid)) in wl1251_op_configure_filter()
796 wl->rx_config &= ~CFG_BSSID_FILTER_EN; in wl1251_op_configure_filter()
798 wl->rx_filter |= CFG_RX_PREQ_EN; in wl1251_op_configure_filter()
800 if (wl->state == WL1251_STATE_OFF) in wl1251_op_configure_filter()
803 ret = wl1251_ps_elp_wakeup(wl); in wl1251_op_configure_filter()
808 ret = wl1251_acx_group_address_tbl(wl, false, NULL, 0); in wl1251_op_configure_filter()
810 ret = wl1251_acx_group_address_tbl(wl, fp->enabled, in wl1251_op_configure_filter()
817 wl1251_acx_rx_config(wl, wl->rx_config, wl->rx_filter); in wl1251_op_configure_filter()
819 wl1251_ps_elp_sleep(wl); in wl1251_op_configure_filter()
822 mutex_unlock(&wl->mutex); in wl1251_op_configure_filter()
827 static int wl1251_set_key_type(struct wl1251 *wl, in wl1251_set_key_type() argument
871 struct wl1251 *wl = hw->priv; in wl1251_op_set_key() local
901 mutex_lock(&wl->mutex); in wl1251_op_set_key()
905 if (wl->monitor_present) { in wl1251_op_set_key()
919 ret = wl1251_ps_elp_wakeup(wl); in wl1251_op_set_key()
923 ret = wl1251_set_key_type(wl, wl_cmd, cmd, key, addr); in wl1251_op_set_key()
954 ret = wl1251_cmd_send(wl, CMD_SET_KEYS, wl_cmd, sizeof(*wl_cmd)); in wl1251_op_set_key()
961 wl1251_ps_elp_sleep(wl); in wl1251_op_set_key()
964 mutex_unlock(&wl->mutex); in wl1251_op_set_key()
977 struct wl1251 *wl = hw->priv; in wl1251_op_hw_scan() local
990 mutex_lock(&wl->mutex); in wl1251_op_hw_scan()
992 if (wl->scanning) { in wl1251_op_hw_scan()
998 ret = wl1251_ps_elp_wakeup(wl); in wl1251_op_hw_scan()
1003 ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE); in wl1251_op_hw_scan()
1006 ret = wl1251_join(wl, wl->bss_type, wl->channel, in wl1251_op_hw_scan()
1007 wl->beacon_int, wl->dtim_period); in wl1251_op_hw_scan()
1012 skb = ieee80211_probereq_get(wl->hw, wl->vif->addr, ssid, ssid_len, in wl1251_op_hw_scan()
1021 ret = wl1251_cmd_template_set(wl, CMD_PROBE_REQ, skb->data, in wl1251_op_hw_scan()
1027 ret = wl1251_cmd_trigger_scan_to(wl, 0); in wl1251_op_hw_scan()
1031 wl->scanning = true; in wl1251_op_hw_scan()
1033 ret = wl1251_cmd_scan(wl, ssid, ssid_len, req->channels, in wl1251_op_hw_scan()
1037 wl->scanning = false; in wl1251_op_hw_scan()
1044 ret = wl1251_ps_set_mode(wl, STATION_IDLE); in wl1251_op_hw_scan()
1046 wl1251_ps_elp_sleep(wl); in wl1251_op_hw_scan()
1049 mutex_unlock(&wl->mutex); in wl1251_op_hw_scan()
1056 struct wl1251 *wl = hw->priv; in wl1251_op_set_rts_threshold() local
1059 mutex_lock(&wl->mutex); in wl1251_op_set_rts_threshold()
1061 ret = wl1251_ps_elp_wakeup(wl); in wl1251_op_set_rts_threshold()
1065 ret = wl1251_acx_rts_threshold(wl, (u16) value); in wl1251_op_set_rts_threshold()
1069 wl1251_ps_elp_sleep(wl); in wl1251_op_set_rts_threshold()
1072 mutex_unlock(&wl->mutex); in wl1251_op_set_rts_threshold()
1082 struct wl1251 *wl = hw->priv; in wl1251_op_bss_info_changed() local
1089 mutex_lock(&wl->mutex); in wl1251_op_bss_info_changed()
1091 ret = wl1251_ps_elp_wakeup(wl); in wl1251_op_bss_info_changed()
1096 ret = wl1251_acx_low_rssi(wl, bss_conf->cqm_rssi_thold, in wl1251_op_bss_info_changed()
1102 wl->rssi_thold = bss_conf->cqm_rssi_thold; in wl1251_op_bss_info_changed()
1106 memcmp(wl->bssid, bss_conf->bssid, ETH_ALEN)) { in wl1251_op_bss_info_changed()
1107 memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN); in wl1251_op_bss_info_changed()
1109 if (!is_zero_ether_addr(wl->bssid)) { in wl1251_op_bss_info_changed()
1110 ret = wl1251_build_null_data(wl); in wl1251_op_bss_info_changed()
1114 ret = wl1251_build_qos_null_data(wl); in wl1251_op_bss_info_changed()
1118 ret = wl1251_join(wl, wl->bss_type, wl->channel, in wl1251_op_bss_info_changed()
1119 wl->beacon_int, wl->dtim_period); in wl1251_op_bss_info_changed()
1127 wl->beacon_int = bss_conf->beacon_int; in wl1251_op_bss_info_changed()
1129 skb = ieee80211_pspoll_get(wl->hw, wl->vif); in wl1251_op_bss_info_changed()
1133 ret = wl1251_cmd_template_set(wl, CMD_PS_POLL, in wl1251_op_bss_info_changed()
1140 ret = wl1251_acx_aid(wl, bss_conf->aid); in wl1251_op_bss_info_changed()
1145 wl->beacon_int = WL1251_DEFAULT_BEACON_INT; in wl1251_op_bss_info_changed()
1146 wl->dtim_period = WL1251_DEFAULT_DTIM_PERIOD; in wl1251_op_bss_info_changed()
1151 ret = wl1251_acx_slot(wl, SLOT_TIME_SHORT); in wl1251_op_bss_info_changed()
1153 ret = wl1251_acx_slot(wl, SLOT_TIME_LONG); in wl1251_op_bss_info_changed()
1162 wl1251_acx_set_preamble(wl, ACX_PREAMBLE_SHORT); in wl1251_op_bss_info_changed()
1164 wl1251_acx_set_preamble(wl, ACX_PREAMBLE_LONG); in wl1251_op_bss_info_changed()
1169 ret = wl1251_acx_cts_protect(wl, CTSPROTECT_ENABLE); in wl1251_op_bss_info_changed()
1171 ret = wl1251_acx_cts_protect(wl, CTSPROTECT_DISABLE); in wl1251_op_bss_info_changed()
1180 WARN_ON(wl->bss_type != BSS_TYPE_STA_BSS); in wl1251_op_bss_info_changed()
1183 ret = wl1251_acx_arp_ip_filter(wl, enable, addr); in wl1251_op_bss_info_changed()
1193 ret = wl1251_cmd_template_set(wl, CMD_BEACON, beacon->data, in wl1251_op_bss_info_changed()
1201 ret = wl1251_cmd_template_set(wl, CMD_PROBE_RESP, beacon->data, in wl1251_op_bss_info_changed()
1209 ret = wl1251_join(wl, wl->bss_type, wl->channel, in wl1251_op_bss_info_changed()
1210 wl->beacon_int, wl->dtim_period); in wl1251_op_bss_info_changed()
1217 wl1251_ps_elp_sleep(wl); in wl1251_op_bss_info_changed()
1220 mutex_unlock(&wl->mutex); in wl1251_op_bss_info_changed()
1289 struct wl1251 *wl = hw->priv; in wl1251_op_conf_tx() local
1292 mutex_lock(&wl->mutex); in wl1251_op_conf_tx()
1296 ret = wl1251_ps_elp_wakeup(wl); in wl1251_op_conf_tx()
1301 ret = wl1251_acx_ac_cfg(wl, wl1251_tx_get_queue(queue), in wl1251_op_conf_tx()
1312 ret = wl1251_acx_tid_cfg(wl, wl1251_tx_get_queue(queue), in wl1251_op_conf_tx()
1320 wl1251_ps_elp_sleep(wl); in wl1251_op_conf_tx()
1323 mutex_unlock(&wl->mutex); in wl1251_op_conf_tx()
1331 struct wl1251 *wl = hw->priv; in wl1251_op_get_survey() local
1339 survey->noise = wl->noise; in wl1251_op_get_survey()
1369 static int wl1251_read_eeprom_byte(struct wl1251 *wl, off_t offset, u8 *data) in wl1251_read_eeprom_byte() argument
1373 wl1251_reg_write32(wl, EE_ADDR, offset); in wl1251_read_eeprom_byte()
1374 wl1251_reg_write32(wl, EE_CTL, EE_CTL_READ); in wl1251_read_eeprom_byte()
1379 if (!(wl1251_reg_read32(wl, EE_CTL) & EE_CTL_READ)) in wl1251_read_eeprom_byte()
1388 *data = wl1251_reg_read32(wl, EE_DATA); in wl1251_read_eeprom_byte()
1392 static int wl1251_read_eeprom(struct wl1251 *wl, off_t offset, in wl1251_read_eeprom() argument
1398 wl1251_reg_write32(wl, EE_START, 0); in wl1251_read_eeprom()
1401 ret = wl1251_read_eeprom_byte(wl, offset + i, &data[i]); in wl1251_read_eeprom()
1409 static int wl1251_read_eeprom_mac(struct wl1251 *wl) in wl1251_read_eeprom_mac() argument
1414 wl1251_set_partition(wl, 0, 0, REGISTERS_BASE, REGISTERS_DOWN_SIZE); in wl1251_read_eeprom_mac()
1416 ret = wl1251_read_eeprom(wl, 0x1c, mac, sizeof(mac)); in wl1251_read_eeprom_mac()
1424 wl->mac_addr[i] = mac[ETH_ALEN - i - 1]; in wl1251_read_eeprom_mac()
1434 static int wl1251_check_nvs_mac(struct wl1251 *wl) in wl1251_check_nvs_mac() argument
1436 if (wl->nvs_len < 0x24) in wl1251_check_nvs_mac()
1440 if (wl->nvs[NVS_OFF_MAC_LEN] != 2 || in wl1251_check_nvs_mac()
1441 wl->nvs[NVS_OFF_MAC_ADDR_LO] != 0x6d || in wl1251_check_nvs_mac()
1442 wl->nvs[NVS_OFF_MAC_ADDR_HI] != 0x54) in wl1251_check_nvs_mac()
1448 static int wl1251_read_nvs_mac(struct wl1251 *wl) in wl1251_read_nvs_mac() argument
1453 ret = wl1251_check_nvs_mac(wl); in wl1251_read_nvs_mac()
1459 mac[i] = wl->nvs[NVS_OFF_MAC_DATA + ETH_ALEN - i - 1]; in wl1251_read_nvs_mac()
1465 memcpy(wl->mac_addr, mac, ETH_ALEN); in wl1251_read_nvs_mac()
1469 static int wl1251_write_nvs_mac(struct wl1251 *wl) in wl1251_write_nvs_mac() argument
1473 ret = wl1251_check_nvs_mac(wl); in wl1251_write_nvs_mac()
1479 wl->nvs[NVS_OFF_MAC_DATA + i] = wl->mac_addr[ETH_ALEN - i - 1]; in wl1251_write_nvs_mac()
1484 static int wl1251_register_hw(struct wl1251 *wl) in wl1251_register_hw() argument
1488 if (wl->mac80211_registered) in wl1251_register_hw()
1491 SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr); in wl1251_register_hw()
1493 ret = ieee80211_register_hw(wl->hw); in wl1251_register_hw()
1499 wl->mac80211_registered = true; in wl1251_register_hw()
1506 int wl1251_init_ieee80211(struct wl1251 *wl) in wl1251_init_ieee80211() argument
1511 wl->hw->extra_tx_headroom = sizeof(struct tx_double_buffer_desc) in wl1251_init_ieee80211()
1517 ieee80211_hw_set(wl->hw, SIGNAL_DBM); in wl1251_init_ieee80211()
1518 ieee80211_hw_set(wl->hw, SUPPORTS_PS); in wl1251_init_ieee80211()
1520 wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | in wl1251_init_ieee80211()
1522 wl->hw->wiphy->max_scan_ssids = 1; in wl1251_init_ieee80211()
1523 wl->hw->wiphy->bands[NL80211_BAND_2GHZ] = &wl1251_band_2ghz; in wl1251_init_ieee80211()
1525 wl->hw->queues = 4; in wl1251_init_ieee80211()
1527 if (wl->nvs == NULL && !wl->use_eeprom) { in wl1251_init_ieee80211()
1528 ret = wl1251_fetch_nvs(wl); in wl1251_init_ieee80211()
1533 if (wl->use_eeprom) in wl1251_init_ieee80211()
1534 ret = wl1251_read_eeprom_mac(wl); in wl1251_init_ieee80211()
1536 ret = wl1251_read_nvs_mac(wl); in wl1251_init_ieee80211()
1538 if (ret == 0 && !is_valid_ether_addr(wl->mac_addr)) in wl1251_init_ieee80211()
1547 memcpy(wl->mac_addr, nokia_oui, 3); in wl1251_init_ieee80211()
1548 get_random_bytes(wl->mac_addr + 3, 3); in wl1251_init_ieee80211()
1549 if (!wl->use_eeprom) in wl1251_init_ieee80211()
1550 wl1251_write_nvs_mac(wl); in wl1251_init_ieee80211()
1552 wl1251_warning("Setting random MAC address: %pM", wl->mac_addr); in wl1251_init_ieee80211()
1555 ret = wl1251_register_hw(wl); in wl1251_init_ieee80211()
1559 wl1251_debugfs_init(wl); in wl1251_init_ieee80211()
1572 struct wl1251 *wl; in wl1251_alloc_hw() local
1575 hw = ieee80211_alloc_hw(sizeof(*wl), &wl1251_ops); in wl1251_alloc_hw()
1581 wl = hw->priv; in wl1251_alloc_hw()
1582 memset(wl, 0, sizeof(*wl)); in wl1251_alloc_hw()
1584 wl->hw = hw; in wl1251_alloc_hw()
1586 wl->data_in_count = 0; in wl1251_alloc_hw()
1588 skb_queue_head_init(&wl->tx_queue); in wl1251_alloc_hw()
1590 INIT_DELAYED_WORK(&wl->elp_work, wl1251_elp_work); in wl1251_alloc_hw()
1591 wl->channel = WL1251_DEFAULT_CHANNEL; in wl1251_alloc_hw()
1592 wl->monitor_present = false; in wl1251_alloc_hw()
1593 wl->joined = false; in wl1251_alloc_hw()
1594 wl->scanning = false; in wl1251_alloc_hw()
1595 wl->bss_type = MAX_BSS_TYPE; in wl1251_alloc_hw()
1596 wl->default_key = 0; in wl1251_alloc_hw()
1597 wl->listen_int = 1; in wl1251_alloc_hw()
1598 wl->rx_counter = 0; in wl1251_alloc_hw()
1599 wl->rx_handled = 0; in wl1251_alloc_hw()
1600 wl->rx_current_buffer = 0; in wl1251_alloc_hw()
1601 wl->rx_last_id = 0; in wl1251_alloc_hw()
1602 wl->rx_config = WL1251_DEFAULT_RX_CONFIG; in wl1251_alloc_hw()
1603 wl->rx_filter = WL1251_DEFAULT_RX_FILTER; in wl1251_alloc_hw()
1604 wl->elp = false; in wl1251_alloc_hw()
1605 wl->station_mode = STATION_ACTIVE_MODE; in wl1251_alloc_hw()
1606 wl->psm_requested = false; in wl1251_alloc_hw()
1607 wl->psm_entry_retry = 0; in wl1251_alloc_hw()
1608 wl->tx_queue_stopped = false; in wl1251_alloc_hw()
1609 wl->power_level = WL1251_DEFAULT_POWER_LEVEL; in wl1251_alloc_hw()
1610 wl->rssi_thold = 0; in wl1251_alloc_hw()
1611 wl->beacon_int = WL1251_DEFAULT_BEACON_INT; in wl1251_alloc_hw()
1612 wl->dtim_period = WL1251_DEFAULT_DTIM_PERIOD; in wl1251_alloc_hw()
1613 wl->vif = NULL; in wl1251_alloc_hw()
1616 wl->tx_frames[i] = NULL; in wl1251_alloc_hw()
1618 wl->next_tx_complete = 0; in wl1251_alloc_hw()
1620 INIT_WORK(&wl->irq_work, wl1251_irq_work); in wl1251_alloc_hw()
1621 INIT_WORK(&wl->tx_work, wl1251_tx_work); in wl1251_alloc_hw()
1623 wl->state = WL1251_STATE_OFF; in wl1251_alloc_hw()
1624 mutex_init(&wl->mutex); in wl1251_alloc_hw()
1625 spin_lock_init(&wl->wl_lock); in wl1251_alloc_hw()
1627 wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE; in wl1251_alloc_hw()
1628 wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE; in wl1251_alloc_hw()
1630 wl->rx_descriptor = kmalloc(sizeof(*wl->rx_descriptor), GFP_KERNEL); in wl1251_alloc_hw()
1631 if (!wl->rx_descriptor) { in wl1251_alloc_hw()
1641 int wl1251_free_hw(struct wl1251 *wl) in wl1251_free_hw() argument
1643 ieee80211_unregister_hw(wl->hw); in wl1251_free_hw()
1645 wl1251_debugfs_exit(wl); in wl1251_free_hw()
1647 kfree(wl->target_mem_map); in wl1251_free_hw()
1648 kfree(wl->data_path); in wl1251_free_hw()
1649 vfree(wl->fw); in wl1251_free_hw()
1650 wl->fw = NULL; in wl1251_free_hw()
1651 kfree(wl->nvs); in wl1251_free_hw()
1652 wl->nvs = NULL; in wl1251_free_hw()
1654 kfree(wl->rx_descriptor); in wl1251_free_hw()
1655 wl->rx_descriptor = NULL; in wl1251_free_hw()
1657 ieee80211_free_hw(wl->hw); in wl1251_free_hw()