int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg) { int r; CsrInt32 csr_r; int already_in_test = priv->ptest_mode; /* Ensure that sme_sys_suspend() doesn't power down the chip because: * 1) Power is needed anyway for ptest. * 2) The app code uses the START ioctl as a reset, so it gets called * multiple times. If the app stops the XAPs, but the power_down/up * sequence doesn't actually power down the chip, there can be problems * resetting, because part of the power_up sequence disables function 1 */ priv->ptest_mode = 1; /* Suspend the SME and UniFi */ r = sme_sys_suspend(priv); if (r) { unifi_error(priv, "unifi_putest_start: failed to suspend UniFi\n"); return r; } /* Application may have stopped the XAPs, but they are needed for reset */ if (already_in_test) { csr_r = unifi_start_processors(priv->card); if (csr_r) { unifi_error(priv, "Failed to start XAPs. Hard reset required.\n"); } } else { /* Ensure chip is powered for the case where there's no unifi_helper */ csr_r = CsrSdioPowerOn(priv->sdio); if (csr_r) { unifi_error(priv, "CsrSdioPowerOn status %d\n", csr_r); } } csr_r = unifi_init(priv->card); if (csr_r && (csr_r != 1)) { unifi_error(priv, "unifi_putest_start: failed to init UniFi\n"); return convert_csr_error(csr_r); } return 0; }
int sme_mgt_wifi_on(unifi_priv_t *priv) { int r,i; s32 csrResult; if (priv == NULL) { return -EINVAL; } /* Initialize the interface mode to None */ for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) { priv->interfacePriv[i]->interfaceMode = 0; } /* Set up interface mode so that get_packet_priority() can * select the right QOS priority when WMM is enabled. */ priv->interfacePriv[0]->interfaceMode = CSR_WIFI_ROUTER_CTRL_MODE_STA; r = uf_request_firmware_files(priv, UNIFI_FW_STA); if (r) { unifi_error(priv, "sme_mgt_wifi_on: Failed to get f/w\n"); return r; } /* * The request to initialise UniFi might come while UniFi is running. * We need to block all I/O activity until the reset completes, otherwise * an SDIO error might occur resulting an indication to the SME which * makes it think that the initialisation has failed. */ priv->bh_thread.block_thread = 1; /* Power on UniFi */ CsrSdioClaim(priv->sdio); csrResult = CsrSdioPowerOn(priv->sdio); CsrSdioRelease(priv->sdio); if(csrResult != CSR_RESULT_SUCCESS && csrResult != CSR_SDIO_RESULT_NOT_RESET) { return -EIO; } if (csrResult == CSR_RESULT_SUCCESS) { /* Initialise UniFi hardware */ r = uf_init_hw(priv); if (r) { return r; } } /* Re-enable the I/O thread */ priv->bh_thread.block_thread = 0; /* Disable deep sleep signalling during the firmware initialisation, to * prevent the wakeup mechanism raising the SDIO clock beyond INIT before * the first MLME-RESET.ind. It gets re-enabled at the CONNECTED.ind, * immediately after the MLME-RESET.ind */ csrResult = unifi_configure_low_power_mode(priv->card, UNIFI_LOW_POWER_DISABLED, UNIFI_PERIODIC_WAKE_HOST_DISABLED); if (csrResult != CSR_RESULT_SUCCESS) { unifi_warning(priv, "sme_mgt_wifi_on: unifi_configure_low_power_mode() returned an error\n"); } /* Start the I/O thread */ CsrSdioClaim(priv->sdio); r = uf_init_bh(priv); if (r) { CsrSdioPowerOff(priv->sdio); CsrSdioRelease(priv->sdio); return r; } CsrSdioRelease(priv->sdio); priv->init_progress = UNIFI_INIT_FW_DOWNLOADED; return 0; }