#include "wilc_wfi_netdevice.h"
#include "wilc_wlan_cfg.h"
-#ifdef WILC_OPTIMIZE_SLEEP_INT
static inline void chip_allow_sleep(struct wilc *wilc);
-#endif
static inline void chip_wakeup(struct wilc *wilc);
static u32 dbgflag = N_INIT | N_ERR | N_INTR | N_TXQ | N_RXQ;
static inline void acquire_bus(struct wilc *wilc, BUS_ACQUIRE_T acquire)
{
mutex_lock(&wilc->hif_cs);
- #ifndef WILC_OPTIMIZE_SLEEP_INT
- if (chip_ps_state != CHIP_WAKEDUP)
- #endif
- {
- if (acquire == ACQUIRE_AND_WAKEUP)
- chip_wakeup(wilc);
- }
+ if (acquire == ACQUIRE_AND_WAKEUP)
+ chip_wakeup(wilc);
}
static inline void release_bus(struct wilc *wilc, BUS_RELEASE_T release)
{
- #ifdef WILC_OPTIMIZE_SLEEP_INT
if (release == RELEASE_ALLOW_SLEEP)
chip_allow_sleep(wilc);
- #endif
mutex_unlock(&wilc->hif_cs);
}
return NULL;
}
-#ifdef WILC_OPTIMIZE_SLEEP_INT
-
static inline void chip_allow_sleep(struct wilc *wilc)
{
u32 reg = 0;
static inline void chip_wakeup(struct wilc *wilc)
{
u32 reg, clk_status_reg, trials = 0;
- u32 sleep_time;
if ((wilc->io_type & 0x1) == HIF_SPI) {
do {
}
chip_ps_state = CHIP_WAKEDUP;
}
-#else
-static inline void chip_wakeup(struct wilc *wilc)
-{
- u32 reg, trials = 0;
-
- do {
- if ((wilc->io_type & 0x1) == HIF_SPI) {
- 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 ((wilc->io_type & 0x1) == HIF_SDIO) {
- wilc->hif_func->hif_read_reg(wilc, 0xf0, ®);
- wilc->hif_func->hif_write_reg(wilc, 0xf0,
- reg & ~BIT(0));
- wilc->hif_func->hif_write_reg(wilc, 0xf0,
- reg | BIT(0));
- wilc->hif_func->hif_write_reg(wilc, 0xf0,
- reg & ~BIT(0));
- }
-
- do {
- mdelay(3);
-
- if ((wilc_get_chipid(wilc, true) == 0))
- wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n");
-
- } while ((wilc_get_chipid(wilc, true) == 0) && ((++trials % 3) == 0));
-
- } while (wilc_get_chipid(wilc, true) == 0);
- if (chip_ps_state == CHIP_SLEEPING_MANUAL) {
- wilc->hif_func->hif_read_reg(wilc, 0x1C0C, ®);
- reg &= ~BIT(0);
- wilc->hif_func->hif_write_reg(wilc, 0x1C0C, reg);
-
- if (wilc_get_chipid(wilc, false) >= 0x1002b0) {
- u32 val32;
-
- wilc->hif_func->hif_read_reg(wilc, 0x1e1c, &val32);
- val32 |= BIT(6);
- wilc->hif_func->hif_write_reg(wilc, 0x1e1c, val32);
-
- wilc->hif_func->hif_read_reg(wilc, 0x1e9c, &val32);
- val32 |= BIT(6);
- wilc->hif_func->hif_write_reg(wilc, 0x1e9c, val32);
- }
- }
- chip_ps_state = CHIP_WAKEDUP;
-}
-#endif
void wilc_chip_sleep_manually(struct wilc *wilc)
{
if (chip_ps_state != CHIP_WAKEDUP)
return;
acquire_bus(wilc, ACQUIRE_ONLY);
-#ifdef WILC_OPTIMIZE_SLEEP_INT
chip_allow_sleep(wilc);
-#endif
wilc->hif_func->hif_write_reg(wilc, 0x10a8, 1);
chip_ps_state = CHIP_SLEEPING_MANUAL;
static void wilc_sleeptimer_isr_ext(struct wilc *wilc, u32 int_stats1)
{
wilc->hif_func->hif_clear_int_ext(wilc, SLEEP_INT_CLR);
-#ifndef WILC_OPTIMIZE_SLEEP_INT
- chip_ps_state = CHIP_SLEEPING_AUTO;
-#endif
}
static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status)
if (int_status & DATA_INT_EXT) {
wilc_wlan_handle_isr_ext(wilc, int_status);
- #ifndef WILC_OPTIMIZE_SLEEP_INT
- chip_ps_state = CHIP_WAKEDUP;
- #endif
}
if (int_status & SLEEP_INT_EXT)
wilc_sleeptimer_isr_ext(wilc, int_status);