Esempio n. 1
0
static void
ar6000_restart_endpoint(struct net_device *dev)
{
    A_STATUS status = A_OK;
    AR_SOFTC_T *ar = (AR_SOFTC_T*)netdev_priv(dev);
    if (down_interruptible(&ar->arSem)) {
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s(): down_interruptible failed \n", __func__));
        return ;
    }
    if (ar->bIsDestroyProgress) {
        up(&ar->arSem);
        return;
    }
    BMIInit();
    do {        
        if ( (status=ar6000_configure_target(ar))!=A_OK)
            break;
		if ( (status=ar6000_sysfs_bmi_get_config(ar, wlaninitmode)) != A_OK)
		{
			AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_sysfs_bmi_get_config failed\n"));
			break;
		}     
        rtnl_lock();
        status = (ar6000_init(dev)==0) ? A_OK : A_ERROR;
        rtnl_unlock();

        if (status!=A_OK) {
            break;
        }  
        if (ar->arWlanState==WLAN_ENABLED) {
            if (ar->arSsidLen) {
                ar6000_connect_to_ap(ar);
            }
        } else {
            WMI_SET_WOW_MODE_CMD wowMode = { .enable_wow = FALSE };
            WMI_SET_HOST_SLEEP_MODE_CMD hostSleepMode = { .awake = FALSE, .asleep = TRUE };
            WMI_REPORT_SLEEP_STATE_EVENT wmiSleepEvent = {
                .sleepState = WMI_REPORT_SLEEP_STATUS_IS_DEEP_SLEEP
            };

            wmi_set_wow_mode_cmd(ar->arWmi, &wowMode);
            ar6000_send_event_to_app(ar, WMI_REPORT_SLEEP_STATE_EVENTID, (A_UINT8*)&wmiSleepEvent, 
                                    sizeof(WMI_REPORT_SLEEP_STATE_EVENTID));
            wmi_set_host_sleep_mode_cmd(ar->arWmi, &hostSleepMode);            
        }
    } while (0);

    up(&ar->arSem);    
    if (status==A_OK) {
        return;
    }

    ar6000_devices[ar->arDeviceIndex] = NULL;
    ar6000_destroy(ar->arNetDev, 1);
}
Esempio n. 2
0
A_STATUS 
ar6000_enter_exit_deep_sleep_state(AR_SOFTC_T *ar, A_BOOL exit)
{
    A_STATUS status = A_OK;

    if (down_interruptible(&ar->arSem)) {
        return A_ERROR;
    }

    AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("%s: Deep sleep %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 {
        WMI_REPORT_SLEEP_STATE_EVENT  wmiSleepEvent ;
        WMI_SET_HOST_SLEEP_MODE_CMD hostSleepMode;

        if (exit) {
            A_UINT16 fg_start_period;

            /* Not in deep sleep state.. exit */
            if (ar->arWlanPowerState != WLAN_POWER_STATE_DEEP_SLEEP) {
                break;
            }

            fg_start_period = (ar->scParams.fg_start_period==0) ? 1 : ar->scParams.fg_start_period;
            hostSleepMode.awake = TRUE;
            hostSleepMode.asleep = FALSE;

            if ((status=wmi_set_host_sleep_mode_cmd(ar->arWmi, &hostSleepMode)) != A_OK) {
                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));

            /* Enable foreground scanning */
            if ((status=wmi_scanparams_cmd(ar->arWmi, fg_start_period,
                                    ar->scParams.fg_end_period,
                                    ar->scParams.bg_period,
                                    ar->scParams.minact_chdwell_time,
                                    ar->scParams.maxact_chdwell_time,
                                    ar->scParams.pas_chdwell_time,
                                    ar->scParams.shortScanRatio,
                                    ar->scParams.scanCtrlFlags,
                                    ar->scParams.max_dfsch_act_time,
                                    ar->scParams.maxact_scan_per_ssid)) != A_OK) 
            {
                break;
            }

            if (ar->arSsidLen) {
                if (ar6000_connect_to_ap(ar) != A_OK) {
                    /* no need to report error if connection failed */
                    break;
                }
            }

            /* Change the state to ON */
            ar->arWlanPowerState = WLAN_POWER_STATE_ON;
        } else {
            WMI_SET_WOW_MODE_CMD wowMode = { .enable_wow = FALSE };

            /* Already in deep sleep state.. exit */
            if (ar->arWlanPowerState == WLAN_POWER_STATE_DEEP_SLEEP) {
                break;
            }

            /* make sure we disable wow for deep sleep */
            if ((status=wmi_set_wow_mode_cmd(ar->arWmi, &wowMode))!=A_OK) {
                break;
            }

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

            /* Disconnect from the AP and disable foreground scanning */
            AR6000_SPIN_LOCK(&ar->arLock, 0);
            if (ar->arConnected == TRUE || ar->arConnectPending == TRUE) {
                AR6000_SPIN_UNLOCK(&ar->arLock, 0);
                wmi_disconnect_cmd(ar->arWmi);
            } else {
                AR6000_SPIN_UNLOCK(&ar->arLock, 0);
            }

            ar->scan_triggered = 0;

            if ((status=wmi_scanparams_cmd(ar->arWmi, 0xFFFF, 0, 0, 0, 0, 0, 0, 0, 0, 0)) != A_OK) {
                break;
            }
            ar6000_TxDataCleanup(ar);
#ifndef ATH6K_CONFIG_OTA_MODE
            wmi_powermode_cmd(ar->arWmi, REC_POWER);
#endif

            hostSleepMode.awake = FALSE;
            hostSleepMode.asleep = TRUE;
            if ((status=wmi_set_host_sleep_mode_cmd(ar->arWmi, &hostSleepMode))!=A_OK) {
                break;
            }
            if (ar->arTxPending[ar->arControlEp]) {
                A_UINT32 timeleft = wait_event_interruptible_timeout(arEvent,
                                ar->arTxPending[ar->arControlEp] == 0, wmitimeout * HZ);
                if (!timeleft || signal_pending(current)) {
                    status = A_ERROR;
                    break;
                }
            }   
            status = hifWaitForPendingRecv(ar->arHifDevice);

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

    if (status!=A_OK) {
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Fail to enter/exit deep sleep %d\n", exit));
    }
    up(&ar->arSem);    
    
    return status;
}