Created
November 2, 2020 08:35
-
-
Save Tosainu/7f6ab0309db7e412cdec92b3edb5ca58 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/wilc/Makefile b/wilc/Makefile | |
index 7eb8cf0..b581506 100644 | |
--- a/wilc/Makefile | |
+++ b/wilc/Makefile | |
@@ -1,5 +1,6 @@ | |
# SPDX-License-Identifier: GPL-2.0 | |
-ccflags-y += -I$(src)/ -DWILC_ASIC_A0 -DWILC_DEBUGFS | |
+ccflags-y += -I$(src)/ -DWILC_ASIC_A0 | |
+ccflags-y += -DDISABLE_PWRSAVE_AND_SCAN_DURING_IP | |
wilc-objs := wilc_wfi_cfgoperations.o wilc_netdev.o wilc_mon.o \ | |
wilc_hif.o wilc_wlan_cfg.o wilc_debugfs.o \ | |
diff --git a/wilc/wilc_debugfs.h b/wilc/wilc_debugfs.h | |
index cf6efd9..622e908 100644 | |
--- a/wilc/wilc_debugfs.h | |
+++ b/wilc/wilc_debugfs.h | |
@@ -22,6 +22,8 @@ | |
#define PWRDEV_DBG BIT(10) | |
#define DBG_REGION_ALL (BIT(11)-1) | |
+#if defined(WILC_DEBUGFS) | |
+ | |
extern atomic_t WILC_DEBUG_REGION; | |
#define PRINT_D(netdev, region, format, ...) do { \ | |
@@ -45,6 +47,15 @@ extern atomic_t WILC_DEBUG_REGION; | |
#define PRINT_ER(netdev, format, ...) netdev_err(netdev, "ERR [%s:%d] "format,\ | |
__func__, __LINE__, ##__VA_ARGS__) | |
+#else | |
+ | |
+#define PRINT_D(netdev, region, format, ...) do { } while (0) | |
+#define PRINT_INFO(netdev, region, format, ...) do { } while (0) | |
+#define PRINT_WRN(netdev, region, format, ...) do { } while (0) | |
+#define PRINT_ER(netdev, format, ...) do { } while (0) | |
+ | |
+#endif | |
+ | |
int wilc_debugfs_init(void); | |
void wilc_debugfs_remove(void); | |
#endif /* WILC_DEBUGFS_H */ | |
diff --git a/wilc/wilc_netdev.c b/wilc/wilc_netdev.c | |
index 9c95f2c..c669dd5 100644 | |
--- a/wilc/wilc_netdev.c | |
+++ b/wilc/wilc_netdev.c | |
@@ -25,6 +25,7 @@ static int wilc_mac_close(struct net_device *ndev); | |
int debug_running; | |
int recovery_on; | |
int wait_for_recovery; | |
+#if defined(WILC_DEBUGFS) | |
static int debug_thread(void *arg) | |
{ | |
struct wilc *wl = arg; | |
@@ -123,6 +124,7 @@ static int debug_thread(void *arg) | |
} | |
return 0; | |
} | |
+#endif | |
void wilc_disable_irq(struct wilc *wilc, int wait) | |
{ | |
@@ -171,6 +173,9 @@ static int init_irq(struct net_device *dev) | |
struct wilc_vif *vif = netdev_priv(dev); | |
struct wilc *wl = vif->wilc; | |
+ // This is no longer supported, the firmware for the WILC3000 does not yank the IRQN line back to the gpio | |
+ return ret; | |
+ | |
#if KERNEL_VERSION(3, 13, 0) < LINUX_VERSION_CODE | |
wl->gpio_irq = gpiod_get(wl->dt_dev, "irq", GPIOD_IN); | |
@@ -784,6 +789,7 @@ static void wlan_deinitialize_threads(struct net_device *dev) | |
struct wilc_vif *vif = netdev_priv(dev); | |
struct wilc *wl = vif->wilc; | |
+#if defined(WILC_DEBUGFS) | |
PRINT_INFO(vif->ndev, INIT_DBG, "Deinitializing Threads\n"); | |
if (!recovery_on) { | |
PRINT_INFO(vif->ndev, INIT_DBG, "Deinit debug Thread\n"); | |
@@ -795,6 +801,7 @@ static void wlan_deinitialize_threads(struct net_device *dev) | |
wl->debug_thread = NULL; | |
} | |
} | |
+#endif | |
wl->close = 1; | |
PRINT_INFO(vif->ndev, INIT_DBG, "Deinitializing Threads\n"); | |
@@ -872,6 +879,7 @@ static int wlan_initialize_threads(struct net_device *dev) | |
} | |
wait_for_completion(&wilc->txq_thread_started); | |
+#if defined(WILC_DEBUGFS) | |
if (!debug_running) { | |
PRINT_INFO(vif->ndev, INIT_DBG, | |
"Creating kthread for Debugging\n"); | |
@@ -886,6 +894,7 @@ static int wlan_initialize_threads(struct net_device *dev) | |
debug_running = true; | |
wait_for_completion(&wilc->debug_thread_started); | |
} | |
+#endif | |
return 0; | |
} | |
@@ -1433,6 +1442,10 @@ static int wilc_wlan_power(struct wilc *wilc, int power) | |
pr_info("wifi_pm : %d\n", power); | |
+ // To late in the game to use these, this will undo the SDIO setup that the Xilinx driver has already done | |
+ // plus these were moved out of the wilc device tree child node so that pwrseq_simple can properly use them | |
+ return ret; | |
+ | |
gpio_reset = gpiod_get(wilc->dt_dev, "reset", GPIOD_ASIS); | |
if (IS_ERR(gpio_reset)) { | |
dev_warn(wilc->dev, "failed to get Reset GPIO, try default\r\n"); | |
diff --git a/wilc/wilc_sdio.c b/wilc/wilc_sdio.c | |
index 8e2bfe6..aed2613 100644 | |
--- a/wilc/wilc_sdio.c | |
+++ b/wilc/wilc_sdio.c | |
@@ -428,12 +428,21 @@ static int wilc_sdio_write_reg(struct wilc *wilc, u32 addr, u32 data) | |
} | |
} else { | |
struct sdio_cmd53 cmd; | |
+ u32 *pdata = kmalloc(sizeof(*pdata), GFP_KERNEL); | |
+ if (!pdata) { | |
+ dev_err(&func->dev, "kmalloc fail\n"); | |
+ goto fail; | |
+ } | |
+ | |
+ *pdata = data; | |
/** | |
* set the AHB address | |
**/ | |
- if (!wilc_sdio_set_func0_csa_address(wilc, addr)) | |
+ if (!wilc_sdio_set_func0_csa_address(wilc, addr)) { | |
+ kfree(pdata); | |
goto fail; | |
+ } | |
cmd.read_write = 1; | |
cmd.function = 0; | |
@@ -441,14 +450,17 @@ static int wilc_sdio_write_reg(struct wilc *wilc, u32 addr, u32 data) | |
cmd.block_mode = 0; | |
cmd.increment = 1; | |
cmd.count = 4; | |
- cmd.buffer = (u8 *)&data; | |
+ cmd.buffer = (u8 *)pdata; | |
cmd.block_size = sdio_priv->block_size; | |
ret = wilc_sdio_cmd53(wilc, &cmd); | |
if (ret) { | |
dev_err(&func->dev, | |
"Failed cmd53, write reg (%08x)...\n", addr); | |
+ kfree(pdata); | |
goto fail; | |
} | |
+ | |
+ kfree(pdata); | |
} | |
return 1; | |
@@ -570,9 +582,16 @@ static int wilc_sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data) | |
*data = cmd.data; | |
} else { | |
struct sdio_cmd53 cmd; | |
+ u32 *pdata = kmalloc(sizeof(*pdata), GFP_KERNEL); | |
+ if (!pdata) { | |
+ dev_err(&func->dev, "kmalloc fail\n"); | |
+ return 0; | |
+ } | |
- if (!wilc_sdio_set_func0_csa_address(wilc, addr)) | |
+ if (!wilc_sdio_set_func0_csa_address(wilc, addr)) { | |
+ kfree(pdata); | |
goto fail; | |
+ } | |
cmd.read_write = 0; | |
cmd.function = 0; | |
@@ -580,15 +599,18 @@ static int wilc_sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data) | |
cmd.block_mode = 0; | |
cmd.increment = 1; | |
cmd.count = 4; | |
- cmd.buffer = (u8 *)data; | |
+ cmd.buffer = (u8 *)pdata; | |
cmd.block_size = sdio_priv->block_size; | |
ret = wilc_sdio_cmd53(wilc, &cmd); | |
if (ret) { | |
dev_err(&func->dev, | |
"Failed cmd53, read reg (%08x)...\n", addr); | |
+ kfree(pdata); | |
goto fail; | |
} | |
+ *data = *pdata; | |
+ kfree(pdata); | |
} | |
le32_to_cpus(data); | |
diff --git a/wilc/wilc_wfi_cfgoperations.c b/wilc/wilc_wfi_cfgoperations.c | |
index 4553637..f562780 100644 | |
--- a/wilc/wilc_wfi_cfgoperations.c | |
+++ b/wilc/wilc_wfi_cfgoperations.c | |
@@ -2391,7 +2391,9 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, | |
if (ret) | |
goto free_wl; | |
+#if defined(WILC_DEBUGFS) | |
wilc_debugfs_init(); | |
+#endif | |
*wilc = wl; | |
wl->io_type = io_type; | |
wl->hif_func = ops; | |
@@ -2419,7 +2421,9 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, | |
free_wq: | |
destroy_workqueue(wl->hif_workqueue); | |
free_debug_fs: | |
+#if defined(WILC_DEBUGFS) | |
wilc_debugfs_remove(); | |
+#endif | |
cfg_deinit(wl); | |
free_wl: | |
wlan_deinit_locks(wl); | |
diff --git a/wilc/wilc_wlan.c b/wilc/wilc_wlan.c | |
index 0ec1ee2..9270835 100644 | |
--- a/wilc/wilc_wlan.c | |
+++ b/wilc/wilc_wlan.c | |
@@ -859,17 +859,20 @@ void chip_wakeup_wilc3000(struct wilc *wilc, int source) | |
do { | |
hif_func->hif_write_reg(wilc, wakeup_reg, wakeup_reg_val | | |
wakeup_bit); | |
+ /* Wait for the chip to stabilize*/ | |
+ usleep_range(1000, 1100); | |
+ | |
/* Check the clock status */ | |
hif_func->hif_read_reg(wilc, clk_status_reg, | |
&clk_status_reg_val); | |
/* | |
* in case of clocks off, wait 1ms, and check it again. | |
- * if still off, wait for another 1ms, for a total wait of 3ms. | |
+ * if still off, wait for another 1ms, for a total wait of 6ms. | |
* If still off, redo the wake up sequence | |
*/ | |
while ((clk_status_reg_val & clk_status_bit) == 0 && | |
- (++trials % 4) != 0) { | |
+ (++trials % 6) != 0) { | |
/* Wait for the chip to stabilize*/ | |
usleep_range(1000, 1100); | |
@@ -941,22 +944,31 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) | |
int ret = 0; | |
int counter; | |
int timeout; | |
- u32 vmm_table[WILC_VMM_TBL_SIZE]; | |
+ u32 *vmm_table; | |
u8 ac_pkt_num_to_chip[NQUEUES] = {0, 0, 0, 0}; | |
struct wilc_vif *vif; | |
const struct wilc_hif_func *func; | |
int srcu_idx; | |
+ vmm_table = kmalloc(sizeof(*vmm_table) * WILC_VMM_TBL_SIZE, GFP_KERNEL); | |
+ if (!vmm_table) { | |
+ PRINT_ER(vif->ndev, "kmalloc fail vmm_table\n"); | |
+ return -1; | |
+ } | |
+ | |
txb = wilc->tx_buffer; | |
if (!wilc->txq_entries) { | |
*txq_count = 0; | |
+ kfree(vmm_table); | |
return 0; | |
} | |
if (wilc->quit) | |
goto out; | |
- if (ac_balance(ac_fw_count, ac_desired_ratio)) | |
+ if (ac_balance(ac_fw_count, ac_desired_ratio)) { | |
+ kfree(vmm_table); | |
return -1; | |
+ } | |
mutex_lock(&wilc->txq_add_to_head_cs); | |
@@ -1259,6 +1271,7 @@ out: | |
*txq_count = wilc->txq_entries; | |
if (ret == 1) | |
cfg_packet_timeout = 0; | |
+ kfree(vmm_table); | |
return ret; | |
} | |
@@ -1450,6 +1463,7 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, | |
wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®); | |
reg &= ~(1ul << 10); | |
ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg); | |
+ msleep(200); | |
wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®); | |
if ((reg & (1ul << 10)) != 0) | |
pr_err("%s: Failed to reset Wifi CPU\n", __func__); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment