typedef struct {
int quit;
int io_type;
- struct wilc_hif_func hif_func;
int cfg_frame_in_use;
struct wilc_cfg_frame cfg_frame;
u32 cfg_frame_offset;
{
u32 reg = 0;
- g_wlan.hif_func.hif_read_reg(wilc, 0xf0, ®);
+ wilc->hif_func->hif_read_reg(wilc, 0xf0, ®);
- g_wlan.hif_func.hif_write_reg(wilc, 0xf0, reg & ~BIT(0));
+ wilc->hif_func->hif_write_reg(wilc, 0xf0, reg & ~BIT(0));
}
static inline void chip_wakeup(struct wilc *wilc)
if ((g_wlan.io_type & 0x1) == HIF_SPI) {
do {
- g_wlan.hif_func.hif_read_reg(wilc, 1, ®);
- g_wlan.hif_func.hif_write_reg(wilc, 1, reg | BIT(1));
- g_wlan.hif_func.hif_write_reg(wilc, 1, reg & ~BIT(1));
+ wilc->hif_func->hif_read_reg(wilc, 1, ®);
+ wilc->hif_func->hif_write_reg(wilc, 1, reg | BIT(1));
+ wilc->hif_func->hif_write_reg(wilc, 1, reg & ~BIT(1));
do {
usleep_range(2 * 1000, 2 * 1000);
} while (wilc_get_chipid(wilc, true) == 0);
} else if ((g_wlan.io_type & 0x1) == HIF_SDIO) {
- g_wlan.hif_func.hif_read_reg(wilc, 0xf0, ®);
+ wilc->hif_func->hif_read_reg(wilc, 0xf0, ®);
do {
- g_wlan.hif_func.hif_write_reg(wilc, 0xf0,
+ wilc->hif_func->hif_write_reg(wilc, 0xf0,
reg | BIT(0));
- g_wlan.hif_func.hif_read_reg(wilc, 0xf1,
+ wilc->hif_func->hif_read_reg(wilc, 0xf1,
&clk_status_reg);
while (((clk_status_reg & 0x1) == 0) && (((++trials) % 3) == 0)) {
usleep_range(2 * 1000, 2 * 1000);
- g_wlan.hif_func.hif_read_reg(wilc, 0xf1,
+ wilc->hif_func->hif_read_reg(wilc, 0xf1,
&clk_status_reg);
if ((clk_status_reg & 0x1) == 0)
wilc_debug(N_ERR, "clocks still OFF. Wake up failed\n");
}
if ((clk_status_reg & 0x1) == 0) {
- g_wlan.hif_func.hif_write_reg(wilc, 0xf0,
+ wilc->hif_func->hif_write_reg(wilc, 0xf0,
reg & (~BIT(0)));
}
} while ((clk_status_reg & 0x1) == 0);
}
if (chip_ps_state == CHIP_SLEEPING_MANUAL) {
- g_wlan.hif_func.hif_read_reg(wilc, 0x1C0C, ®);
+ wilc->hif_func->hif_read_reg(wilc, 0x1C0C, ®);
reg &= ~BIT(0);
- g_wlan.hif_func.hif_write_reg(wilc, 0x1C0C, reg);
+ wilc->hif_func->hif_write_reg(wilc, 0x1C0C, reg);
if (wilc_get_chipid(wilc, false) >= 0x1002b0) {
u32 val32;
- g_wlan.hif_func.hif_read_reg(wilc, 0x1e1c, &val32);
+ wilc->hif_func->hif_read_reg(wilc, 0x1e1c, &val32);
val32 |= BIT(6);
- g_wlan.hif_func.hif_write_reg(wilc, 0x1e1c, val32);
+ wilc->hif_func->hif_write_reg(wilc, 0x1e1c, val32);
- g_wlan.hif_func.hif_read_reg(wilc, 0x1e9c, &val32);
+ wilc->hif_func->hif_read_reg(wilc, 0x1e9c, &val32);
val32 |= BIT(6);
- g_wlan.hif_func.hif_write_reg(wilc, 0x1e9c, val32);
+ wilc->hif_func->hif_write_reg(wilc, 0x1e9c, val32);
}
}
chip_ps_state = CHIP_WAKEDUP;
do {
if ((g_wlan.io_type & 0x1) == HIF_SPI) {
- g_wlan.hif_func.hif_read_reg(wilc, 1, ®);
- g_wlan.hif_func.hif_write_reg(wilc, 1, reg & ~BIT(1));
- g_wlan.hif_func.hif_write_reg(wilc, 1, reg | BIT(1));
- g_wlan.hif_func.hif_write_reg(wilc, 1, reg & ~BIT(1));
+ wilc->hif_func->hif_read_reg(wilc, 1, ®);
+ wilc->hif_func->hif_write_reg(wilc, 1, reg & ~BIT(1));
+ wilc->hif_func->hif_write_reg(wilc, 1, reg | BIT(1));
+ wilc->hif_func->hif_write_reg(wilc, 1, reg & ~BIT(1));
} else if ((g_wlan.io_type & 0x1) == HIF_SDIO) {
- g_wlan.hif_func.hif_read_reg(wilc, 0xf0, ®);
- g_wlan.hif_func.hif_write_reg(wilc, 0xf0,
+ wilc->hif_func->hif_read_reg(wilc, 0xf0, ®);
+ wilc->hif_func->hif_write_reg(wilc, 0xf0,
reg & ~BIT(0));
- g_wlan.hif_func.hif_write_reg(wilc, 0xf0,
+ wilc->hif_func->hif_write_reg(wilc, 0xf0,
reg | BIT(0));
- g_wlan.hif_func.hif_write_reg(wilc, 0xf0,
+ wilc->hif_func->hif_write_reg(wilc, 0xf0,
reg & ~BIT(0));
}
} while (wilc_get_chipid(wilc, true) == 0);
if (chip_ps_state == CHIP_SLEEPING_MANUAL) {
- g_wlan.hif_func.hif_read_reg(wilc, 0x1C0C, ®);
+ wilc->hif_func->hif_read_reg(wilc, 0x1C0C, ®);
reg &= ~BIT(0);
- g_wlan.hif_func.hif_write_reg(wilc, 0x1C0C, reg);
+ wilc->hif_func->hif_write_reg(wilc, 0x1C0C, reg);
if (wilc_get_chipid(wilc, false) >= 0x1002b0) {
u32 val32;
- g_wlan.hif_func.hif_read_reg(wilc, 0x1e1c, &val32);
+ wilc->hif_func->hif_read_reg(wilc, 0x1e1c, &val32);
val32 |= BIT(6);
- g_wlan.hif_func.hif_write_reg(wilc, 0x1e1c, val32);
+ wilc->hif_func->hif_write_reg(wilc, 0x1e1c, val32);
- g_wlan.hif_func.hif_read_reg(wilc, 0x1e9c, &val32);
+ wilc->hif_func->hif_read_reg(wilc, 0x1e9c, &val32);
val32 |= BIT(6);
- g_wlan.hif_func.hif_write_reg(wilc, 0x1e9c, val32);
+ wilc->hif_func->hif_write_reg(wilc, 0x1e9c, val32);
}
}
chip_ps_state = CHIP_WAKEDUP;
#ifdef WILC_OPTIMIZE_SLEEP_INT
chip_allow_sleep(wilc);
#endif
- g_wlan.hif_func.hif_write_reg(wilc, 0x10a8, 1);
+ wilc->hif_func->hif_write_reg(wilc, 0x10a8, 1);
chip_ps_state = CHIP_SLEEPING_MANUAL;
release_bus(wilc, RELEASE_ONLY);
acquire_bus(wilc, ACQUIRE_AND_WAKEUP);
counter = 0;
do {
- ret = p->hif_func.hif_read_reg(wilc, WILC_HOST_TX_CTRL,
+ ret = wilc->hif_func->hif_read_reg(wilc, WILC_HOST_TX_CTRL,
®);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't read reg vmm_tbl_entry..\n");
if (counter > 200) {
counter = 0;
PRINT_D(TX_DBG, "Looping in tx ctrl , forcce quit\n");
- ret = p->hif_func.hif_write_reg(wilc, WILC_HOST_TX_CTRL, 0);
+ ret = wilc->hif_func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, 0);
break;
}
PRINT_WRN(GENERIC_DBG, "[wilc txq]: warn, vmm table not clear yet, wait...\n");
timeout = 200;
do {
- ret = p->hif_func.hif_block_tx(wilc, WILC_VMM_TBL_RX_SHADOW_BASE, (u8 *)vmm_table, ((i + 1) * 4));
+ ret = wilc->hif_func->hif_block_tx(wilc, WILC_VMM_TBL_RX_SHADOW_BASE, (u8 *)vmm_table, ((i + 1) * 4));
if (!ret) {
wilc_debug(N_ERR, "ERR block TX of VMM table.\n");
break;
}
- ret = p->hif_func.hif_write_reg(wilc, WILC_HOST_VMM_CTL,
+ ret = wilc->hif_func->hif_write_reg(wilc, WILC_HOST_VMM_CTL,
0x2);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't write reg host_vmm_ctl..\n");
}
do {
- ret = p->hif_func.hif_read_reg(wilc, WILC_HOST_VMM_CTL, ®);
+ ret = wilc->hif_func->hif_read_reg(wilc, WILC_HOST_VMM_CTL, ®);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't read reg host_vmm_ctl..\n");
break;
}
} while (--timeout);
if (timeout <= 0) {
- ret = p->hif_func.hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x0);
+ ret = wilc->hif_func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x0);
break;
}
if (entries == 0) {
PRINT_WRN(GENERIC_DBG, "[wilc txq]: no more buffer in the chip (reg: %08x), retry later [[ %d, %x ]]\n", reg, i, vmm_table[i - 1]);
- ret = p->hif_func.hif_read_reg(wilc, WILC_HOST_TX_CTRL, ®);
+ ret = wilc->hif_func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, ®);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't read reg WILC_HOST_TX_CTRL..\n");
break;
}
reg &= ~BIT(0);
- ret = p->hif_func.hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg);
+ ret = wilc->hif_func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't write reg WILC_HOST_TX_CTRL..\n");
break;
acquire_bus(wilc, ACQUIRE_AND_WAKEUP);
- ret = p->hif_func.hif_clear_int_ext(wilc, ENABLE_TX_VMM);
+ ret = wilc->hif_func->hif_clear_int_ext(wilc, ENABLE_TX_VMM);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't start tx VMM ...\n");
goto _end_;
}
- ret = p->hif_func.hif_block_tx_ext(wilc, 0, txb, offset);
+ ret = wilc->hif_func->hif_block_tx_ext(wilc, 0, txb, offset);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't block tx ext...\n");
goto _end_;
static void wilc_unknown_isr_ext(struct wilc *wilc)
{
- g_wlan.hif_func.hif_clear_int_ext(wilc, 0);
+ wilc->hif_func->hif_clear_int_ext(wilc, 0);
}
static void wilc_pllupdate_isr_ext(struct wilc *wilc, u32 int_stats)
{
int trials = 10;
- g_wlan.hif_func.hif_clear_int_ext(wilc, PLL_INT_CLR);
+ wilc->hif_func->hif_clear_int_ext(wilc, PLL_INT_CLR);
if (g_wlan.io_type == HIF_SDIO)
mdelay(WILC_PLL_TO_SDIO);
static void wilc_sleeptimer_isr_ext(struct wilc *wilc, u32 int_stats1)
{
- g_wlan.hif_func.hif_clear_int_ext(wilc, SLEEP_INT_CLR);
+ wilc->hif_func->hif_clear_int_ext(wilc, SLEEP_INT_CLR);
#ifndef WILC_OPTIMIZE_SLEEP_INT
chip_ps_state = CHIP_SLEEPING_AUTO;
#endif
u32 time = 0;
wilc_debug(N_ERR, "RX Size equal zero ... Trying to read it again for %d time\n", time++);
- p->hif_func.hif_read_size(wilc, &size);
+ wilc->hif_func->hif_read_size(wilc, &size);
size = ((size & 0x7fff) << 2);
retries++;
}
goto _end_;
}
- p->hif_func.hif_clear_int_ext(wilc,
+ wilc->hif_func->hif_clear_int_ext(wilc,
DATA_INT_CLR | ENABLE_RX_VMM);
- ret = p->hif_func.hif_block_rx_ext(wilc, 0, buffer, size);
+ ret = wilc->hif_func->hif_block_rx_ext(wilc, 0, buffer, size);
if (!ret) {
wilc_debug(N_ERR, "[wilc isr]: fail block rx...\n");
u32 int_status;
acquire_bus(wilc, ACQUIRE_AND_WAKEUP);
- g_wlan.hif_func.hif_read_int(wilc, &int_status);
+ wilc->hif_func->hif_read_int(wilc, &int_status);
if (int_status & PLL_INT_EXT)
wilc_pllupdate_isr_ext(wilc, int_status);
int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, u32 buffer_size)
{
- wilc_wlan_dev_t *p = &g_wlan;
u32 offset;
u32 addr, size, size2, blksz;
u8 *dma_buffer;
size2 = blksz;
memcpy(dma_buffer, &buffer[offset], size2);
- ret = p->hif_func.hif_block_tx(wilc, addr, dma_buffer,
+ ret = wilc->hif_func->hif_block_tx(wilc, addr, dma_buffer,
size2);
if (!ret)
break;
reg = 1;
}
acquire_bus(wilc, ACQUIRE_ONLY);
- ret = p->hif_func.hif_write_reg(wilc, WILC_VMM_CORE_CFG, reg);
+ ret = wilc->hif_func->hif_write_reg(wilc, WILC_VMM_CORE_CFG, reg);
if (!ret) {
wilc_debug(N_ERR, "[wilc start]: fail write reg vmm_core_cfg...\n");
release_bus(wilc, RELEASE_ONLY);
reg |= WILC_HAVE_DISABLE_WILC_UART;
#endif
- ret = p->hif_func.hif_write_reg(wilc, WILC_GP_REG_1, reg);
+ ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_1, reg);
if (!ret) {
wilc_debug(N_ERR, "[wilc start]: fail write WILC_GP_REG_1 ...\n");
release_bus(wilc, RELEASE_ONLY);
return ret;
}
- p->hif_func.hif_sync_ext(wilc, NUM_INT_EXT);
+ wilc->hif_func->hif_sync_ext(wilc, NUM_INT_EXT);
- ret = p->hif_func.hif_read_reg(wilc, 0x1000, &chipid);
+ ret = wilc->hif_func->hif_read_reg(wilc, 0x1000, &chipid);
if (!ret) {
wilc_debug(N_ERR, "[wilc start]: fail read reg 0x1000 ...\n");
release_bus(wilc, RELEASE_ONLY);
return ret;
}
- p->hif_func.hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
+ wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
if ((reg & BIT(10)) == BIT(10)) {
reg &= ~BIT(10);
- p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
- p->hif_func.hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
+ wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
+ wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
}
reg |= BIT(10);
- ret = p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
- p->hif_func.hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
+ ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
+ wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
release_bus(wilc, RELEASE_ONLY);
return (ret < 0) ? ret : 0;
void wilc_wlan_global_reset(struct wilc *wilc)
{
-
- wilc_wlan_dev_t *p = &g_wlan;
-
acquire_bus(wilc, ACQUIRE_AND_WAKEUP);
- p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0, 0x0);
+ wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, 0x0);
release_bus(wilc, RELEASE_ONLY);
}
int wilc_wlan_stop(struct wilc *wilc)
{
- wilc_wlan_dev_t *p = &g_wlan;
u32 reg = 0;
int ret;
u8 timeout = 10;
acquire_bus(wilc, ACQUIRE_AND_WAKEUP);
- ret = p->hif_func.hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
+ ret = wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
if (!ret) {
PRINT_ER("Error while reading reg\n");
release_bus(wilc, RELEASE_ALLOW_SLEEP);
}
reg &= ~BIT(10);
- ret = p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
+ ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
if (!ret) {
PRINT_ER("Error while writing reg\n");
release_bus(wilc, RELEASE_ALLOW_SLEEP);
}
do {
- ret = p->hif_func.hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
+ ret = wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
if (!ret) {
PRINT_ER("Error while reading reg\n");
release_bus(wilc, RELEASE_ALLOW_SLEEP);
PRINT_D(GENERIC_DBG, "Bit 10 not reset : Retry %d\n",
timeout);
reg &= ~BIT(10);
- ret = p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0,
+ ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0,
reg);
timeout--;
} else {
PRINT_D(GENERIC_DBG, "Bit 10 reset after : Retry %d\n",
timeout);
- ret = p->hif_func.hif_read_reg(wilc, WILC_GLB_RESET_0,
+ ret = wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0,
®);
if (!ret) {
PRINT_ER("Error while reading reg\n");
reg = (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(8) | BIT(9) | BIT(26) |
BIT(29) | BIT(30) | BIT(31));
- p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
+ wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
reg = (u32)~BIT(10);
- ret = p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
+ ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
release_bus(wilc, RELEASE_ALLOW_SLEEP);
acquire_bus(wilc, ACQUIRE_AND_WAKEUP);
- ret = p->hif_func.hif_read_reg(wilc, WILC_GP_REG_0, ®);
+ ret = wilc->hif_func->hif_read_reg(wilc, WILC_GP_REG_0, ®);
if (!ret) {
PRINT_ER("Error while reading reg\n");
release_bus(wilc, RELEASE_ALLOW_SLEEP);
}
PRINT_ER("Writing ABORT reg\n");
- ret = p->hif_func.hif_write_reg(wilc, WILC_GP_REG_0,
+ ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0,
(reg | ABORT_INT));
if (!ret) {
PRINT_ER("Error while writing reg\n");
release_bus(wilc, RELEASE_ALLOW_SLEEP);
}
release_bus(wilc, RELEASE_ALLOW_SLEEP);
- p->hif_func.hif_deinit(NULL);
+ wilc->hif_func->hif_deinit(NULL);
}
static int wilc_wlan_cfg_commit(struct wilc *wilc, int type, u32 drv_handler)
chipid = wilc_get_chipid(wilc, true);
if ((chipid & 0xfff) != 0xa0) {
- ret = g_wlan.hif_func.hif_read_reg(wilc, 0x1118, ®);
+ ret = wilc->hif_func->hif_read_reg(wilc, 0x1118, ®);
if (!ret) {
wilc_debug(N_ERR, "[wilc start]: fail read reg 0x1118 ...\n");
return ret;
}
reg |= BIT(0);
- ret = g_wlan.hif_func.hif_write_reg(wilc, 0x1118, reg);
+ ret = wilc->hif_func->hif_write_reg(wilc, 0x1118, reg);
if (!ret) {
wilc_debug(N_ERR, "[wilc start]: fail write reg 0x1118 ...\n");
return ret;
}
- ret = g_wlan.hif_func.hif_write_reg(wilc, 0xc0000, 0x71);
+ ret = wilc->hif_func->hif_write_reg(wilc, 0xc0000, 0x71);
if (!ret) {
wilc_debug(N_ERR, "[wilc start]: fail write reg 0xc0000 ...\n");
return ret;
u32 rfrevid;
if (chipid == 0 || update != 0) {
- g_wlan.hif_func.hif_read_reg(wilc, 0x1000, &tempchipid);
- g_wlan.hif_func.hif_read_reg(wilc, 0x13f4, &rfrevid);
+ wilc->hif_func->hif_read_reg(wilc, 0x1000, &tempchipid);
+ wilc->hif_func->hif_read_reg(wilc, 0x13f4, &rfrevid);
if (!ISWILC1000(tempchipid)) {
chipid = 0;
goto _fail_;
memset((void *)&g_wlan, 0, sizeof(wilc_wlan_dev_t));
g_wlan.io_type = wilc->io_type;
- g_wlan.hif_func = *wilc->ops;
- if (!g_wlan.hif_func.hif_init(wilc, wilc_debug)) {
+ if (!wilc->hif_func->hif_init(wilc, wilc_debug)) {
ret = -EIO;
goto _fail_;
}
wilc = nic->wilc;
mutex_lock(&wilc->hif_cs);
- ret = (&g_wlan)->hif_func.hif_read_reg(wilc, WILC_CHANGING_VIR_IF,
+ ret = wilc->hif_func->hif_read_reg(wilc, WILC_CHANGING_VIR_IF,
®);
if (!ret)
PRINT_ER("Error while Reading reg WILC_CHANGING_VIR_IF\n");
else
reg &= ~BIT(31);
- ret = (&g_wlan)->hif_func.hif_write_reg(wilc, WILC_CHANGING_VIR_IF,
+ ret = wilc->hif_func->hif_write_reg(wilc, WILC_CHANGING_VIR_IF,
reg);
if (!ret)