Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions drivers/staging/wilc1000/netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
#include <linux/interrupt.h>
#include <net/ip.h>
#include <linux/module.h>
#include <linux/delay.h>

#include "netdev.h"
#include "cfg80211.h"

#define WILC_MULTICAST_TABLE_SIZE 8

#define INIT_TIMEOUT 300
#define DEINIT_TIMEOUT 10000


static int wilc_mac_open(struct net_device *ndev);
static int wilc_mac_close(struct net_device *ndev);

Expand Down Expand Up @@ -786,6 +791,10 @@ static void wilc_wlan_deinitialize(struct net_device *dev)
} else {
PRINT_INFO(dev, INIT_DBG, "wilc is not initialized\n");
}

pr_info("%s: Will sleep a bit after deinitialize\n", __func__);
msleep(DEINIT_TIMEOUT);

}

static int wlan_initialize_threads(struct net_device *dev)
Expand Down Expand Up @@ -827,6 +836,9 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
int ret = 0;
struct wilc *wl = vif->wilc;

pr_info("%s: Will sleep a bit before initialize\n", __func__);
msleep(INIT_TIMEOUT);

if (!wl->initialized) {
wl->mac_status = WILC_MAC_STATUS_INIT;
wl->close = 0;
Expand Down Expand Up @@ -872,9 +884,11 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
ret = wilc_start_firmware(dev);
if (ret) {
PRINT_ER(dev, "Failed to start firmware\n");
goto fail_irq_enable;
goto fail_fw_start;
}

wl->initialized = true;

if (cfg_get(vif, 1, WID_FIRMWARE_VERSION, 1, 0)) {
int size;
char firmware_ver[50];
Expand All @@ -894,7 +908,6 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
goto fail_fw_start;
}

wl->initialized = true;
return 0;

fail_fw_start:
Expand Down
24 changes: 15 additions & 9 deletions drivers/staging/wilc1000/wlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,12 @@ static void chip_wakeup_wilc3000(struct wilc *wilc, int source)
/* in case of failure, Reset the wakeup bit to introduce a new
* edge on the next loop
*/
if ((clk_status_reg_val & clk_status_bit) == 0)
if ((clk_status_reg_val & clk_status_bit) == 0) {
hif_func->hif_write_reg(wilc, wakeup_reg,
wakeup_reg_val & (~wakeup_bit));
/* added wait before wakeup sequence retry */
usleep_range(200, 300);
}
} while (((clk_status_reg_val & clk_status_bit) == 0)
&& (wake_seq_trials-- > 0));
if (!wake_seq_trials)
Expand Down Expand Up @@ -1261,10 +1264,10 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)

out_release_bus:
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP, DEV_WIFI);
schedule();

out_unlock:
mutex_unlock(&wilc->txq_add_to_head_cs);
schedule();

out_update_cnt:
*txq_count = wilc->txq_entries;
Expand Down Expand Up @@ -1418,6 +1421,9 @@ void wilc_handle_isr(struct wilc *wilc)
{
u32 int_status;

if (wilc->close)
return;

acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP, DEV_WIFI);
wilc->hif_func->hif_read_int(wilc, &int_status);

Expand Down Expand Up @@ -1564,15 +1570,15 @@ int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif)
ret = wilc->hif_func->hif_read_reg(wilc, GLOBAL_MODE_CONTROL, &reg);
if (ret) {
PRINT_ER(vif->ndev, "Error while reading reg\n");
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP, DEV_WIFI);
release_bus(wilc, WILC_BUS_RELEASE_ONLY, DEV_WIFI);
return -EIO;
}

reg &= ~BIT(0);
ret = wilc->hif_func->hif_write_reg(wilc, GLOBAL_MODE_CONTROL, reg);
if (ret) {
PRINT_ER(vif->ndev, "Error while writing reg\n");
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP, DEV_WIFI);
release_bus(wilc, WILC_BUS_RELEASE_ONLY, DEV_WIFI);
return -EIO;
}

Expand All @@ -1582,34 +1588,34 @@ int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif)
ret = wilc->hif_func->hif_read_reg(wilc, PWR_SEQ_MISC_CTRL, &reg);
if (ret) {
PRINT_ER(vif->ndev, "Error while reading reg\n");
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP, DEV_WIFI);
release_bus(wilc, WILC_BUS_RELEASE_ONLY, DEV_WIFI);
return ret;
}

reg &= ~BIT(28);
ret = wilc->hif_func->hif_write_reg(wilc, PWR_SEQ_MISC_CTRL, reg);
if (ret) {
PRINT_ER(vif->ndev, "Error while writing reg\n");
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP, DEV_WIFI);
release_bus(wilc, WILC_BUS_RELEASE_ONLY, DEV_WIFI);
return ret;
}

ret = wilc->hif_func->hif_read_reg(wilc, WILC_GP_REG_0, &reg);
if (ret) {
PRINT_ER(vif->ndev, "Error while reading reg\n");
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP, DEV_WIFI);
release_bus(wilc, WILC_BUS_RELEASE_ONLY, DEV_WIFI);
return ret;
}

ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0,
(reg | WILC_ABORT_REQ_BIT));
if (ret) {
PRINT_ER(vif->ndev, "Error while writing reg\n");
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP, DEV_WIFI);
release_bus(wilc, WILC_BUS_RELEASE_ONLY, DEV_WIFI);
return ret;
}

release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP, DEV_WIFI);
release_bus(wilc, WILC_BUS_RELEASE_ONLY, DEV_WIFI);

return 0;
}
Expand Down