Example #1
0
static A_STATUS ar6000_suspend_ev(void *context)
{
    A_STATUS status = A_OK;
    int pmmode = buspm;
    AR_SOFTC_T *ar = (AR_SOFTC_T *)context;
wow_not_connected:

    switch (pmmode) {
    case WLAN_PWR_CTRL_DEEP_SLEEP:
        if (ar->arWlanState == WLAN_DISABLED) {
            ar->arOsPowerCtrl = WLAN_PWR_CTRL_DEEP_SLEEP_DISABLED;
            AR_DEBUG_PRINTF(ATH_DEBUG_SUSPEND,("%s:Suspend for deep sleep disabled mode %d\n", __func__, ar->arOsPowerCtrl));
        } else {
            ar6000_set_wlan_state(ar, WLAN_DISABLED);
            ar->arOsPowerCtrl = WLAN_PWR_CTRL_DEEP_SLEEP;
            AR_DEBUG_PRINTF(ATH_DEBUG_SUSPEND,("%s:Suspend for deep sleep mode %d\n", __func__, ar->arOsPowerCtrl));
        }              
        status = A_EBUSY;
        break;
    case WLAN_PWR_CTRL_WOW:
        if (ar->arWmiReady && ar->arWlanState==WLAN_ENABLED && ar->arConnected) {
            ar->arOsPowerCtrl = WLAN_PWR_CTRL_WOW;
            AR_DEBUG_PRINTF(ATH_DEBUG_SUSPEND,("%s:Suspend for wow mode %d\n", __func__, ar->arOsPowerCtrl));
            ar6000_wow_suspend(ar);
            /* leave for pm_device to setup wow */
            status = A_EBUSY;
        } else {
            pmmode = wow2mode;
            goto wow_not_connected;
        }
        break;
    case WLAN_PWR_CTRL_CUT_PWR:
        /* fall through */
    default:        
        ar->arOsPowerCtrl = WLAN_PWR_CTRL_CUT_PWR;
        AR_DEBUG_PRINTF(ATH_DEBUG_SUSPEND,("%s: Suspend for cut off mode %d\n", __func__, ar->arOsPowerCtrl));
        ar6000_stop_endpoint(ar->arNetDev, TRUE);
        status = A_OK;
        break;
    }

    ar->scan_triggered = 0;
    return status;
}
Example #2
0
A_STATUS 
ar6000_enter_exit_cut_power_state(AR_SOFTC_T *ar, A_BOOL exit)
{
    WMI_REPORT_SLEEP_STATE_EVENT  wmiSleepEvent ;
    A_STATUS                      status = A_OK;
    HIF_DEVICE_POWER_CHANGE_TYPE  config;

    AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("%s: Cut power %d %d \n", __func__,exit, ar->arWlanPowerState));
#ifdef CONFIG_PM
    AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("Wlan OFF %d BT OFf %d \n", ar->arWlanOff, ar->arBTOff));
#endif
    do {
        if (exit) {
            /* Not in cut power state.. exit */
            if (ar->arWlanPowerState != WLAN_POWER_STATE_CUT_PWR) {
                break;
            }

#ifdef TARGET_EUROPA
            wlan_setup_power(1,0);
#endif

            /* Change the state to ON */
            ar->arWlanPowerState = WLAN_POWER_STATE_ON;

    
            /* Indicate POWER_UP to HIF */
            config = HIF_DEVICE_POWER_UP; 
            status = HIFConfigureDevice(ar->arHifDevice,
                                HIF_DEVICE_POWER_STATE_CHANGE,
                                &config,
                                sizeof(HIF_DEVICE_POWER_CHANGE_TYPE));

            if (status == A_PENDING) {
                /* Previously, we decided to wait here until the device becomes fully functional since there is a chance that some entity tries to access the device once we return from the resume callback. However, it was observed that the resume process gets delayed too because of this wait. Commenting it out to speed up the process of resuming */
#if 0
                 /* Wait for WMI ready event */
                A_UINT32 timeleft = wait_event_interruptible_timeout(arEvent,
                            (ar->arWmiReady == TRUE), wmitimeout * HZ);
                if (!timeleft || signal_pending(current)) {
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000 : Failed to get wmi ready \n"));
                    status = A_ERROR;
                    break;
                }
#endif
                status = A_OK;
            }  else if (status == A_OK) {
                ar6000_exit_cut_power_state(ar);
            }
        } else {
            /* Already in cut power state.. exit */
            if (ar->arWlanPowerState == WLAN_POWER_STATE_CUT_PWR) {
                break;
            }

    	    wmiSleepEvent.sleepState = WMI_REPORT_SLEEP_STATUS_IS_AWAKE;
            ar6000_send_event_to_app(ar, WMI_REPORT_SLEEP_STATE_EVENTID, (A_UINT8*)&wmiSleepEvent, sizeof(WMI_REPORT_SLEEP_STATE_EVENTID));

            ar6000_stop_endpoint(ar->arNetDev, TRUE, FALSE);

            config = HIF_DEVICE_POWER_CUT; 
            status = HIFConfigureDevice(ar->arHifDevice,
                                HIF_DEVICE_POWER_STATE_CHANGE,
                                &config,
                                sizeof(HIF_DEVICE_POWER_CHANGE_TYPE));

#ifdef TARGET_EUROPA
            wlan_setup_power(0,0);
#endif

            ar->arWlanPowerState = WLAN_POWER_STATE_CUT_PWR;
        }
    } while (0);

    return status;
}