int epping_wlan_startup(struct device *parent_dev, v_VOID_t *hif_sc) { int ret = 0; epping_context_t *pEpping_ctx = NULL; VosContextType *pVosContext = NULL; HTC_INIT_INFO htcInfo; struct ol_softc *scn; tSirMacAddr adapter_macAddr; adf_os_device_t adf_ctx; EPPING_LOG(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Enter", __func__); pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); if(pVosContext == NULL) { EPPING_LOG(VOS_TRACE_LEVEL_FATAL, "%s: Failed vos_get_global_context", __func__); ret = -1; return ret; } pEpping_ctx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext); if(pEpping_ctx == NULL) { EPPING_LOG(VOS_TRACE_LEVEL_FATAL, "%s: Failed to get pEpping_ctx", __func__); ret = -1; return ret; } pEpping_ctx->parent_dev = (void *)parent_dev; epping_get_dummy_mac_addr(adapter_macAddr); ((VosContextType*)pVosContext)->pHIFContext = hif_sc; /* store target type and target version info in hdd ctx */ pEpping_ctx->target_type = ((struct ol_softc *)hif_sc)->target_type; /* Initialize the timer module */ vos_timer_module_init(); scn = vos_get_context(VOS_MODULE_ID_HIF, pVosContext); if (!scn) { VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, "%s: scn is null!", __func__); return -1; } scn->enableuartprint = 0; scn->enablefwlog = 0; /* Initialize BMI and Download firmware */ if (bmi_download_firmware(scn)) { VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, "%s: BMI failed to download target", __func__); BMICleanup(scn); return -1; } EPPING_LOG(VOS_TRACE_LEVEL_INFO_HIGH, "%s: bmi_download_firmware done", __func__); htcInfo.pContext = pVosContext->pHIFContext; htcInfo.TargetFailure = ol_target_failure; htcInfo.TargetSendSuspendComplete = epping_target_suspend_acknowledge; adf_ctx = vos_get_context(VOS_MODULE_ID_ADF, pVosContext); /* Create HTC */ pVosContext->htc_ctx = HTCCreate(htcInfo.pContext, &htcInfo, adf_ctx); if (!pVosContext->htc_ctx) { VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, "%s: Failed to Create HTC", __func__); BMICleanup(scn); return -1; } pEpping_ctx->HTCHandle = vos_get_context(VOS_MODULE_ID_HTC, pVosContext); if (pEpping_ctx->HTCHandle == NULL) { EPPING_LOG(VOS_TRACE_LEVEL_FATAL, "%s: HTCHandle is NULL", __func__); return -1; } scn->htc_handle = pEpping_ctx->HTCHandle; HIFClaimDevice(scn->hif_hdl, scn); if (bmi_done(scn)) { EPPING_LOG(VOS_TRACE_LEVEL_FATAL, "%s: Failed to complete BMI phase", __func__); goto error_end; } /* start HIF */ if (HTCWaitTarget(scn->htc_handle) != A_OK) { EPPING_LOG(VOS_TRACE_LEVEL_FATAL, "%s: HTCWaitTarget error", __func__); goto error_end; } EPPING_LOG(VOS_TRACE_LEVEL_INFO_HIGH, "%s: HTC ready", __func__); ret = epping_connect_service(pEpping_ctx); if (ret != 0) { EPPING_LOG(VOS_TRACE_LEVEL_FATAL, "%s: HTCWaitTargetdone", __func__); goto error_end; } if (HTCStart(pEpping_ctx->HTCHandle) != A_OK) { goto error_end; } EPPING_LOG(VOS_TRACE_LEVEL_INFO_HIGH, "%s: HTC started", __func__); /* init the tx cookie resource */ ret = epping_cookie_init(pEpping_ctx); if (ret == 0) { pEpping_ctx->epping_adapter = epping_add_adapter(pEpping_ctx, adapter_macAddr, WLAN_HDD_INFRA_STATION); } if (ret < 0 || pEpping_ctx->epping_adapter == NULL) { EPPING_LOG(VOS_TRACE_LEVEL_FATAL, "%s: epping_add_adaptererror error", __func__); HTCStop(pEpping_ctx->HTCHandle); epping_cookie_cleanup(pEpping_ctx); goto error_end; } #ifdef HIF_PCI { int i; for (i = 0; i < EPPING_MAX_NUM_EPIDS; i++) { epping_register_tx_copier(i, pEpping_ctx); } } #endif /* HIF_PCI */ EPPING_LOG(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Exit", __func__); complete(&pEpping_ctx->wlan_start_comp); return ret; error_end: HTCDestroy(pVosContext->htc_ctx); pVosContext->htc_ctx = NULL; BMICleanup(scn); return -1; }
int ar6000_htc_raw_open(AR_SOFTC_T *ar) { A_STATUS status; int streamID, endPt, count2; raw_htc_buffer *buffer; HTC_SERVICE_ID servicepriority; AR_RAW_HTC_T *arRaw = ar->arRawHtc; if (!arRaw) { arRaw = ar->arRawHtc = A_MALLOC(sizeof(AR_RAW_HTC_T)); if (arRaw) { A_MEMZERO(arRaw, sizeof(AR_RAW_HTC_T)); } } A_ASSERT(ar->arHtcTarget != NULL); if (!arRaw) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Faile to allocate memory for HTC RAW interface\n")); return -ENOMEM; } /* wait for target */ status = HTCWaitTarget(ar->arHtcTarget); if (A_FAILED(status)) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HTCWaitTarget failed (%d)\n", status)); return -ENODEV; } for (endPt = 0; endPt < ENDPOINT_MAX; endPt++) { arRaw->arEp2RawMapping[endPt] = HTC_RAW_STREAM_NOT_MAPPED; } for (streamID = HTC_RAW_STREAM_0; streamID < HTC_RAW_STREAM_NUM_MAX; streamID++) { /* Initialize the data structures */ init_MUTEX(&arRaw->raw_htc_read_sem[streamID]); init_MUTEX(&arRaw->raw_htc_write_sem[streamID]); init_waitqueue_head(&arRaw->raw_htc_read_queue[streamID]); init_waitqueue_head(&arRaw->raw_htc_write_queue[streamID]); /* try to connect to the raw service */ status = ar6000_connect_raw_service(ar,streamID); if (A_FAILED(status)) { break; } if (arRawStream2EndpointID(ar,streamID) == 0) { break; } for (count2 = 0; count2 < RAW_HTC_READ_BUFFERS_NUM; count2 ++) { /* Initialize the receive buffers */ buffer = &arRaw->raw_htc_write_buffer[streamID][count2]; memset(buffer, 0, sizeof(raw_htc_buffer)); buffer = &arRaw->raw_htc_read_buffer[streamID][count2]; memset(buffer, 0, sizeof(raw_htc_buffer)); SET_HTC_PACKET_INFO_RX_REFILL(&buffer->HTCPacket, buffer, buffer->data, HTC_RAW_BUFFER_SIZE, arRawStream2EndpointID(ar,streamID)); /* Queue buffers to HTC for receive */ if ((status = HTCAddReceivePkt(ar->arHtcTarget, &buffer->HTCPacket)) != A_OK) { BMIInit(); return -EIO; } } for (count2 = 0; count2 < RAW_HTC_WRITE_BUFFERS_NUM; count2 ++) { /* Initialize the receive buffers */ buffer = &arRaw->raw_htc_write_buffer[streamID][count2]; memset(buffer, 0, sizeof(raw_htc_buffer)); } arRaw->read_buffer_available[streamID] = FALSE; arRaw->write_buffer_available[streamID] = TRUE; } if (A_FAILED(status)) { return -EIO; } AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("HTC RAW, number of streams the target supports: %d \n", streamID)); servicepriority = HTC_RAW_STREAMS_SVC; /* only 1 */ /* set callbacks and priority list */ HTCSetCreditDistribution(ar->arHtcTarget, ar, NULL, /* use default */ NULL, /* use default */ &servicepriority, 1); /* Start the HTC component */ if ((status = HTCStart(ar->arHtcTarget)) != A_OK) { BMIInit(); return -EIO; } (ar)->arRawIfInit = TRUE; return 0; }
A_BOOL RunAR6kTest(A_UINT32 Channel, A_CHAR *pSSID, MTE_WIFI_TEST_STATUS *pTestStatus) { AR6K_FIRMWARE_INFO firmware; A_STATUS status = A_OK; A_MEMZERO(&firmware,sizeof(firmware)); InitializeMTE(); if (!GetFirmwareInfo(&firmware)) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("Target Firmware missing!! Aborting.. \r\n")); return FALSE; } g_WifiMTE.SSIDLength = strlen(pSSID); A_ASSERT(g_WifiMTE.SSIDLength <= 32); A_MEMCPY(g_WifiMTE.SSID,pSSID,g_WifiMTE.SSIDLength); A_ASSERT(Channel <= MAX_WIFI_CHANNELS); A_ASSERT(Channel > 0); /* look up the channel hint (in Mhz) */ g_WifiMTE.WiFiChannel = g_ChannelLookUp[Channel]; DBG_LOG_PRINT(DBG_ZONE_INIT, ("Ar6k WiFi MTE Test Start..(SSID: %s , channel:%d) \r\n", g_WifiMTE.SSID, g_WifiMTE.WiFiChannel)); do { /* init test status */ g_WifiMTE.MteStatus = MTE_WIFI_STATUS_SDIO_INIT_FAILED; if (A_FAILED(HIFInit())) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** HIFInit Failed!!! \r\n")); break; } BMIInit(); /* all failures are setup failures this point forward */ g_WifiMTE.MteStatus = MTE_WIFI_STATUS_SETUP_FAILED; g_WifiMTE.HifDevice = HIFGetDevice(); DBG_LOG_PRINT(DBG_ZONE_ERR, ("Getting Target ID... \r\n")); status = BMIGetTargetInfo(g_WifiMTE.HifDevice, &g_WifiMTE.TargetInfo); if (A_FAILED(status)) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** Failed to Get Target Information \r\n")); break; } DBG_LOG_PRINT(DBG_ZONE_INIT, ("TARGET_TYPE:0x%X TARGET_VER : 0x%X \r\n", g_WifiMTE.TargetInfo.target_type, g_WifiMTE.TargetInfo.target_ver)); status = ar6000_prepare_target(g_WifiMTE.HifDevice, g_WifiMTE.TargetInfo.target_type, g_WifiMTE.TargetInfo.target_ver); if (A_FAILED(status)) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** Failed to prepare target \r\n")); break; } status = ar6000_configure_clock (g_WifiMTE.HifDevice, g_WifiMTE.TargetInfo.target_type, g_WifiMTE.TargetInfo.target_ver, BOARD_XTAL_FREQ); if (A_FAILED(status)) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** Failed to configure target XTAL \r\n")); break; } DBG_LOG_PRINT(DBG_ZONE_INIT, ("Download Firmware ... (firmware length: %d, %s) (datapatch len: %d) \r\n", firmware.AthwlanLength, firmware.AthwlanCompressed ? "COMPRESSED" : "UNCOMPRESSED", firmware.DataPatchLength)); status = DownloadFirmware(g_WifiMTE.HifDevice, g_WifiMTE.TargetInfo.target_type, g_WifiMTE.TargetInfo.target_ver, firmware.pAthwlan, firmware.AthwlanLength, firmware.AthwlanCompressed, firmware.pDataPatch, firmware.DataPatchLength); if (A_FAILED(status)) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** Failed to download firmware \r\n")); break; } DBG_LOG_PRINT(DBG_ZONE_INIT, ("Firmware Download Complete.. \r\n")); ar6000_enable_target_console(g_WifiMTE.HifDevice,g_WifiMTE.TargetInfo.target_type); status = ar6000_set_htc_params(g_WifiMTE.HifDevice, g_WifiMTE.TargetInfo.target_type, 0, 0); if (A_FAILED(status)) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** Failed to set HTC Params \r\n")); break; } DBG_LOG_PRINT(DBG_ZONE_INIT, ("Transferring EEPROM settings .. \r\n")); status = eeprom_ar6000_transfer(g_WifiMTE.HifDevice, g_WifiMTE.TargetInfo.target_type); if (A_FAILED(status)) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** Failed to transfer EEPROM settings \r\n")); break; } DBG_LOG_PRINT(DBG_ZONE_INIT, ("Starting Target .. \r\n")); status = BMIDone(g_WifiMTE.HifDevice); if (A_FAILED(status)) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** Target failed to start \r\n")); break; } /* from here on out, all mte failures are boot failures */ g_WifiMTE.MteStatus = MTE_WIFI_STATUS_BOOT_FAILED; DBG_LOG_PRINT(DBG_ZONE_INIT, ("Connecting HTC .. \r\n")); /* connect HTC layer */ g_WifiMTE.htcHandle = HTCConnect(g_WifiMTE.HifDevice); if (g_WifiMTE.htcHandle == NULL) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** HTC connection failed \r\n")); break; } status = HTCConnectService(g_WifiMTE.htcHandle, WMI_CONTROL_SVC, &g_WifiMTE.ControlEp); if (A_FAILED(status)) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** Failed to connect to WMI control service \r\n")); break; } status = HTCConnectService(g_WifiMTE.htcHandle, WMI_DATA_BE_SVC, &g_WifiMTE.DataEp); if (A_FAILED(status)) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** Failed to connect to WMI best effort data service \r\n")); break; } DBG_LOG_PRINT(DBG_ZONE_INIT, ("HTC is connected (wmi_ctrl:%d, data:%d) ... \r\n", g_WifiMTE.ControlEp, g_WifiMTE.DataEp)); status = HTCStart(g_WifiMTE.htcHandle); if (A_FAILED(status)) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** failed to start HTC \r\n")); break; } status = WMIInit(g_WifiMTE.htcHandle,g_WifiMTE.ControlEp,g_WifiMTE.DataEp); if (A_FAILED(status)) { DBG_LOG_PRINT(DBG_ZONE_ERR, ("** failed to init WMI \r\n")); break; } status = RunConnectionTest(); } while (FALSE); pTestStatus->StatusCode = g_WifiMTE.MteStatus; pTestStatus->RSSI = g_WifiMTE.RSSI; return (A_SUCCESS(status)); }