static void wl1251_fw_wakeup(struct wl1251 *wl) { u32 elp_reg; elp_reg = ELPCTRL_WAKE_UP; wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg); elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); if (!(elp_reg & ELPCTRL_WLAN_READY)) wl1251_warning("WLAN not ready"); }
/* Routines to toggle sleep mode while in ELP */ void wl1251_ps_elp_sleep(struct wl1251 *wl) { if (wl->elp || !wl->psm) return; wl1251_debug(DEBUG_PSM, "chip to elp"); wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP); wl->elp = true; }
void wl1251_elp_work(struct work_struct *work) { struct delayed_work *dwork; struct wl1251 *wl; dwork = container_of(work, struct delayed_work, work); wl = container_of(dwork, struct wl1251, elp_work); wl1251_debug(DEBUG_PSM, "elp work"); mutex_lock(&wl->mutex); if (wl->elp || !wl->psm) goto out; wl1251_debug(DEBUG_PSM, "chip to elp"); wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP); wl->elp = true; out: mutex_unlock(&wl->mutex); }
int wl1251_ps_elp_wakeup(struct wl1251 *wl) { unsigned long timeout, start; u32 elp_reg; if (!wl->elp) return 0; wl1251_debug(DEBUG_PSM, "waking up chip from elp"); start = jiffies; timeout = jiffies + msecs_to_jiffies(WL1251_WAKEUP_TIMEOUT); wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_WAKE_UP); elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); /* * FIXME: we should wait for irq from chip but, as a temporary * solution to simplify locking, let's poll instead */ while (!(elp_reg & ELPCTRL_WLAN_READY)) { if (time_after(jiffies, timeout)) { wl1251_error("elp wakeup timeout"); return -ETIMEDOUT; } msleep(1); elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); } wl1251_debug(DEBUG_PSM, "wakeup time: %u ms", jiffies_to_msecs(jiffies - start)); wl->elp = false; return 0; }
void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val) { wl1251_write32(wl, wl1251_translate_reg_addr(wl, addr), val); }