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); }
int ar6000_htc_raw_close(AR_SOFTC_T *ar) { A_PRINTF("ar6000_htc_raw_close called \n"); HTCStop(ar->arHtcTarget); /* reset the device */ ar6000_reset_device(ar->arHifDevice, ar->arTargetType, TRUE, FALSE); /* Initialize the BMI component */ BMIInit(); return 0; }
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)); }