void HIFUnMaskInterrupt(HIF_DEVICE *device) { int ret; AR_DEBUG_ASSERT(device != NULL); AR_DEBUG_ASSERT(device->func != NULL); AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: HIFUnMaskInterrupt\n")); /* Register the IRQ Handler */ sdio_claim_host(device->func); ret = sdio_claim_irq(device->func, hifIRQHandler); sdio_release_host(device->func); AR_DEBUG_ASSERT(ret == 0); }
A_STATUS DevWaitForPendingRecv(AR6K_DEVICE *pDev,A_UINT32 TimeoutInMs,A_BOOL *pbIsRecvPending) { A_STATUS status = A_OK; A_UCHAR host_int_status = 0x0; A_UINT32 counter = 0x0; if(TimeoutInMs < 100) { TimeoutInMs = 100; } counter = TimeoutInMs / 100; do { //Read the Host Interrupt Status Register status = HIFReadWrite(pDev->HIFDevice, HOST_INT_STATUS_ADDRESS, &host_int_status, sizeof(A_UCHAR), HIF_RD_SYNC_BYTE_INC, NULL); if(A_FAILED(status)) { AR_DEBUG_PRINTF(ATH_LOG_ERR,("DevWaitForPendingRecv:Read HOST_INT_STATUS_ADDRESS Failed 0x%X\n",status)); break; } host_int_status = A_SUCCESS(status) ? (host_int_status & (1 << 0)):0; if(!host_int_status) { status = A_OK; *pbIsRecvPending = FALSE; break; } else { *pbIsRecvPending = TRUE; } A_MDELAY(100); counter--; }while(counter); return status; }
int DevWaitForPendingRecv(struct ar6k_device *pDev,u32 TimeoutInMs,bool *pbIsRecvPending) { int status = 0; u8 host_int_status = 0x0; u32 counter = 0x0; if(TimeoutInMs < 100) { TimeoutInMs = 100; } counter = TimeoutInMs / 100; do { //Read the Host Interrupt Status Register status = HIFReadWrite(pDev->HIFDevice, HOST_INT_STATUS_ADDRESS, &host_int_status, sizeof(u8), HIF_RD_SYNC_BYTE_INC, NULL); if (status) { AR_DEBUG_PRINTF(ATH_LOG_ERR,("DevWaitForPendingRecv:Read HOST_INT_STATUS_ADDRESS Failed 0x%X\n",status)); break; } host_int_status = !status ? (host_int_status & (1 << 0)):0; if(!host_int_status) { status = 0; *pbIsRecvPending = false; break; } else { *pbIsRecvPending = true; } A_MDELAY(100); counter--; }while(counter); return status; }
static int hifDeviceSuspend(struct device *dev) { struct sdio_func *func = dev_to_sdio_func(dev); A_STATUS status = A_OK; HIF_DEVICE *device; device = getHifDevice(func); if (device && device->claimedContext && osdrvCallbacks.deviceSuspendHandler) { status = osdrvCallbacks.deviceSuspendHandler(device->claimedContext); } if (status == A_OK) { int oldresetvalue = reset_sdio_on_unload; reset_sdio_on_unload = 1; hifDisableFunc(device, func); reset_sdio_on_unload = oldresetvalue; device->is_suspend = TRUE; } else if (status == A_EBUSY) { A_INT32 cnt = 10; A_UINT8 host_int_status; do { while (atomic_read(&device->irqHandling)) { /* wait until irq handler finished all the jobs */ schedule_timeout(HZ/10); } /* check if there is any pending irq due to force done */ host_int_status = 0; status = HIFReadWrite(device, HOST_INT_STATUS_ADDRESS, (A_UINT8 *)&host_int_status, sizeof(host_int_status), HIF_RD_SYNC_BYTE_INC, NULL); host_int_status = A_SUCCESS(status) ? (host_int_status & (1 << 0)) : 0; if (host_int_status) { schedule(); /* schedule for next dsrHandler */ } } while (host_int_status && --cnt > 0); if (host_int_status && cnt == 0) { AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("AR6000: %s(), Unable clear up pending IRQ before the system suspended\n", __FUNCTION__)); } #if 1 status = A_OK; /* assume that sdio host controller will take care the power of wifi chip */ #else return -EBUSY; /* Return -EBUSY if customer use all android patch of mmc stack provided by us */ #endif } return A_SUCCESS(status) ? 0 : status; }
static void ar6000_hci_send_complete(void *pContext, HTC_PACKET *pPacket) { AR6K_HCI_BRIDGE_INFO *pHcidevInfo = (AR6K_HCI_BRIDGE_INFO *)pContext; void *osbuf = pPacket->pPktContext; A_ASSERT(osbuf != NULL); A_ASSERT(pHcidevInfo != NULL); if (A_FAILED(pPacket->Status)) { if ((pPacket->Status != A_ECANCELED) && (pPacket->Status != A_NO_RESOURCE)) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HCI Bridge: Send Packet Failed: %d \n",pPacket->Status)); } } FreeHTCStruct(pHcidevInfo,pPacket); FreeBtOsBuf(pHcidevInfo,osbuf); }
A_UINT8 HTCGetCreditAllocation(HTC_TARGET *target, A_UINT16 ServiceID) { A_UINT8 allocation = 0; int i; for (i = 0; i < HTC_MAX_SERVICE_ALLOC_ENTRIES; i++) { if (target->ServiceTxAllocTable[i].ServiceID == ServiceID) { allocation = target->ServiceTxAllocTable[i].CreditAllocation; } } if (0 == allocation) { AR_DEBUG_PRINTF(ATH_DEBUG_INIT,("HTC Service TX : 0x%2.2X : allocation is zero! \n",ServiceID)); } return allocation; }
void ar6000_pm_init() { #ifdef CONFIG_PM #ifdef CONFIG_HAS_WAKELOCK wake_lock_init(&ar6k_suspend_wake_lock, WAKE_LOCK_SUSPEND, "ar6k_suspend"); wake_lock_init(&ar6k_wow_wake_lock, WAKE_LOCK_SUSPEND, "ar6k_wow"); #endif /* * Register ar6000_pm_device into system. * We should also add platform_device into the first item of array * of devices[] in file arch/xxx/mach-xxx/board-xxxx.c */ if (platform_driver_register(&ar6000_pm_device)) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000: fail to register the power control driver.\n")); } #endif /* CONFIG_PM */ }
A_STATUS ar6000_power_change_ev(void *context, A_UINT32 config) { AR_SOFTC_T *ar = (AR_SOFTC_T *)context; A_STATUS status = A_OK; AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("%s: power change event callback %d \n", __func__, config)); switch (config) { case HIF_DEVICE_POWER_UP: status = ar6000_exit_cut_power_state(ar); break; case HIF_DEVICE_POWER_DOWN: case HIF_DEVICE_POWER_CUT: status = A_OK; break; } return status; }
A_STATUS BMIGetTargetInfo(HIF_DEVICE *device, struct bmi_target_info *targ_info) { if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI Get Target Info Command disallowed\n")); return A_ERROR; } #ifndef HIF_MESSAGE_BASED /* getting the target ID requires special handling because of the variable length * message */ return HIFRegBasedGetTargetInfo(device,targ_info); #else /* TODO */ return A_ERROR; #endif }
/* disable packet reception (used in case the host runs out of buffers) * this is the "override" method when the HIF reports another methods to * disable recv events */ static A_STATUS DevDoEnableDisableRecvOverride(AR6K_DEVICE *pDev, A_BOOL EnableRecv, A_BOOL AsyncMode) { A_STATUS status = A_OK; HTC_PACKET *pIOPacket = NULL; AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("DevDoEnableDisableRecvOverride: Enable:%d Mode:%d\n", EnableRecv,AsyncMode)); do { if (AsyncMode) { pIOPacket = AR6KAllocIOPacket(pDev); if (NULL == pIOPacket) { status = A_NO_MEMORY; A_ASSERT(FALSE); break; } /* stick in our completion routine when the I/O operation completes */ pIOPacket->Completion = DevDoEnableDisableRecvAsyncHandler; pIOPacket->pContext = pDev; /* call the HIF layer override and do this asynchronously */ status = pDev->HifMaskUmaskRecvEvent(pDev->HIFDevice, EnableRecv ? HIF_UNMASK_RECV : HIF_MASK_RECV, pIOPacket); break; } /* if we get here we are doing it synchronously */ status = pDev->HifMaskUmaskRecvEvent(pDev->HIFDevice, EnableRecv ? HIF_UNMASK_RECV : HIF_MASK_RECV, NULL); } while (FALSE); if (A_FAILED(status) && (pIOPacket != NULL)) { AR6KFreeIOPacket(pDev,pIOPacket); } return status; }
/* disable packet reception (used in case the host runs out of buffers) * this is the "override" method when the HIF reports another methods to * disable recv events */ static int DevDoEnableDisableRecvOverride(struct ar6k_device *pDev, bool EnableRecv, bool AsyncMode) { int status = 0; struct htc_packet *pIOPacket = NULL; AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("DevDoEnableDisableRecvOverride: Enable:%d Mode:%d\n", EnableRecv,AsyncMode)); do { if (AsyncMode) { pIOPacket = AR6KAllocIOPacket(pDev); if (NULL == pIOPacket) { status = A_NO_MEMORY; A_ASSERT(false); break; } /* stick in our completion routine when the I/O operation completes */ pIOPacket->Completion = DevDoEnableDisableRecvAsyncHandler; pIOPacket->pContext = pDev; /* call the HIF layer override and do this asynchronously */ status = pDev->HifMaskUmaskRecvEvent(pDev->HIFDevice, EnableRecv ? HIF_UNMASK_RECV : HIF_MASK_RECV, pIOPacket); break; } /* if we get here we are doing it synchronously */ status = pDev->HifMaskUmaskRecvEvent(pDev->HIFDevice, EnableRecv ? HIF_UNMASK_RECV : HIF_MASK_RECV, NULL); } while (false); if (status && (pIOPacket != NULL)) { AR6KFreeIOPacket(pDev,pIOPacket); } return status; }
BUS_REQUEST *hifAllocateBusRequest(HIF_DEVICE *device) { BUS_REQUEST *busrequest; unsigned long flag; /* Acquire lock */ spin_lock_irqsave(&device->lock, flag); /* Remove first in list */ if((busrequest = device->s_busRequestFreeQueue) != NULL) { device->s_busRequestFreeQueue = busrequest->next; } /* Release lock */ spin_unlock_irqrestore(&device->lock, flag); AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: hifAllocateBusRequest: 0x%p\n", busrequest)); return busrequest; }
void hifFreeBusRequest(HIF_DEVICE *device, BUS_REQUEST *busrequest) { unsigned long flag; AR_DEBUG_ASSERT(busrequest != NULL); AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: hifFreeBusRequest: 0x%p\n", busrequest)); /* Acquire lock */ spin_lock_irqsave(&device->lock, flag); /* Insert first in list */ busrequest->next = device->s_busRequestFreeQueue; busrequest->inusenext = NULL; device->s_busRequestFreeQueue = busrequest; /* Release lock */ spin_unlock_irqrestore(&device->lock, flag); }
void HIFMaskInterrupt(HIF_DEVICE *device) { int ret; AR_DEBUG_ASSERT(device != NULL); AR_DEBUG_ASSERT(device->func != NULL); AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: HIFMaskInterrupt\n")); /* Mask our function IRQ */ sdio_claim_host(device->func); while (atomic_read(&device->irqHandling)) { sdio_release_host(device->func); schedule_timeout(HZ/10); sdio_claim_host(device->func); } ret = sdio_release_irq(device->func); sdio_release_host(device->func); AR_DEBUG_ASSERT(ret == 0); }
A_STATUS DevGMboxRecvLookAheadPeek(AR6K_DEVICE *pDev, A_UINT8 *pLookAheadBuffer, int *pLookAheadBytes) { A_STATUS status = A_OK; AR6K_IRQ_PROC_REGISTERS procRegs; int maxCopy; do { /* on entry the caller provides the length of the lookahead buffer */ if (*pLookAheadBytes > sizeof(procRegs.rx_gmbox_lookahead_alias)) { A_ASSERT(FALSE); status = A_EINVAL; break; } maxCopy = *pLookAheadBytes; *pLookAheadBytes = 0; /* load the register table from the device */ status = HIFReadWrite(pDev->HIFDevice, HOST_INT_STATUS_ADDRESS, (A_UINT8 *)&procRegs, AR6K_IRQ_PROC_REGS_SIZE, HIF_RD_SYNC_BYTE_INC, NULL); if (A_FAILED(status)) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("DevGMboxRecvLookAheadPeek : Failed to read register table (%d) \n",status)); break; } if (procRegs.gmbox_rx_avail > 0) { int bytes = procRegs.gmbox_rx_avail > maxCopy ? maxCopy : procRegs.gmbox_rx_avail; A_MEMCPY(pLookAheadBuffer,&procRegs.rx_gmbox_lookahead_alias[0],bytes); *pLookAheadBytes = bytes; } } while (FALSE); return status; }
int DevGMboxRecvLookAheadPeek(struct ar6k_device *pDev, u8 *pLookAheadBuffer, int *pLookAheadBytes) { int status = 0; struct ar6k_irq_proc_registers procRegs; int maxCopy; do { /* on entry the caller provides the length of the lookahead buffer */ if (*pLookAheadBytes > sizeof(procRegs.rx_gmbox_lookahead_alias)) { A_ASSERT(false); status = A_EINVAL; break; } maxCopy = *pLookAheadBytes; *pLookAheadBytes = 0; /* load the register table from the device */ status = HIFReadWrite(pDev->HIFDevice, HOST_INT_STATUS_ADDRESS, (u8 *)&procRegs, AR6K_IRQ_PROC_REGS_SIZE, HIF_RD_SYNC_BYTE_INC, NULL); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("DevGMboxRecvLookAheadPeek : Failed to read register table (%d) \n",status)); break; } if (procRegs.gmbox_rx_avail > 0) { int bytes = procRegs.gmbox_rx_avail > maxCopy ? maxCopy : procRegs.gmbox_rx_avail; memcpy(pLookAheadBuffer,&procRegs.rx_gmbox_lookahead_alias[0],bytes); *pLookAheadBytes = bytes; } } while (false); return status; }
static int ath6kl_hifdev_probe(struct sdio_func *func, const struct sdio_device_id *id) { int ret; struct hif_device *device; int count; AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("ath6kl: Function: 0x%X, Vendor ID: 0x%X, " "Device ID: 0x%X, block size: 0x%X/0x%X\n", func->num, func->vendor, func->device, func->max_blksize, func->cur_blksize)); ath6kl_alloc_hifdev(func); device = ath6kl_get_hifdev(func); device->id = id; device->is_disabled = true; spin_lock_init(&device->lock); spin_lock_init(&device->asynclock); DL_LIST_INIT(&device->ScatterReqHead); /* Try to allow scatter unless globally overridden */ if (!nohifscattersupport) device->scatter_enabled = true; A_MEMZERO(device->busRequest, sizeof(device->busRequest)); for (count = 0; count < BUS_REQUEST_MAX_NUM; count++) { sema_init(&device->busRequest[count].sem_req, 0); hifFreeBusRequest(device, &device->busRequest[count]); } sema_init(&device->sem_async, 0); ret = hifEnableFunc(device, func); return ret; }
/* ------ Functions ------ */ A_STATUS HIFInit(OSDRV_CALLBACKS *callbacks) { int status; AR_DEBUG_ASSERT(callbacks != NULL); /* store the callback handlers */ osdrvCallbacks = *callbacks; /* Register with bus driver core */ AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: HIFInit registering\n")); registered = 1; status = sdio_register_driver(&ar6k_driver); AR_DEBUG_ASSERT(status==0); if (status != 0) { return A_ERROR; } return A_OK; }
static A_BOOL CheckBuffers(void) { int i; A_BOOL success = TRUE; BUFFER_PROC_LIST checkList[BUFFER_PROC_LIST_DEPTH]; /* assemble the list */ AssembleBufferList(checkList); /* scan the buffers and verify */ for (i = 0; i < BUFFER_PROC_LIST_DEPTH ; i++) { success = CheckOneBuffer((A_UINT16 *)checkList[i].pBuffer, checkList[i].length); if (!success) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Buffer : 0x%X, Length:%d failed verify \n", (A_UINT32)checkList[i].pBuffer, checkList[i].length)); break; } } return success; }
void HIFShutDownDevice(HIF_DEVICE *device) { SDIO_STATUS status; if (device != NULL) { device->shutdownInProgress = TRUE; AR_DEBUG_ASSERT(device->handle != NULL); } else { /* * Unregister with bus driver core. This should flush the pending * requests in the HCD's queues. */ AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("Unregistering with the bus driver\n")); status = SDIO_UnregisterFunction(&FunctionContext.function); AR_DEBUG_ASSERT(SDIO_SUCCESS(status)); } }
static bool CheckBuffers(void) { int i; bool success = true; struct buffer_proc_list checkList[BUFFER_PROC_LIST_DEPTH]; /* assemble the list */ AssembleBufferList(checkList); /* scan the buffers and verify */ for (i = 0; i < BUFFER_PROC_LIST_DEPTH ; i++) { success = CheckOneBuffer((u16 *)checkList[i].pBuffer, checkList[i].length); if (!success) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Buffer : 0x%X, Length:%d failed verify \n", (u32)checkList[i].pBuffer, checkList[i].length)); break; } } return success; }
void android_module_init(OSDRV_CALLBACKS *osdrvCallbacks) { bmienable = 1; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) if (ifname[0] == '\0') strcpy(ifname, def_ifname); #endif if (wow2mode!=WLAN_PWR_CTRL_CUT_PWR && wow2mode!=WLAN_PWR_CTRL_DEEP_SLEEP) { wow2mode=WLAN_PWR_CTRL_CUT_PWR; } wake_lock_init(&ar6k_init_wake_lock, WAKE_LOCK_SUSPEND, "ar6k_init"); wake_lock_init(&ar6k_wow_wake_lock, WAKE_LOCK_SUSPEND, "ar6k_wow"); #ifdef CONFIG_HAS_EARLYSUSPEND ar6k_early_suspend.suspend = android_early_suspend; ar6k_early_suspend.resume = android_late_resume; ar6k_early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN; register_early_suspend(&ar6k_early_suspend); #endif #if defined(CONFIG_PM) osdrvCallbacks->deviceSuspendHandler = ar6000_suspend_ev; osdrvCallbacks->deviceResumeHandler = ar6000_resume_ev; #endif ar6000_avail_ev_p = osdrvCallbacks->deviceInsertedHandler; osdrvCallbacks->deviceInsertedHandler = ar6000_android_avail_ev; #if defined(CONFIG_PM) /* Register ar6000_pm_device into system. * We should also add platform_device into the first item of array devices[] in * file arch/xxx/mach-xxx/board-xxxx.c * Otherwise, WoW may not work properly since we may trigger WoW GPIO before system suspend */ if (platform_driver_register(&ar6000_pm_device)) AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000: fail to register the power control driver.\n")); #endif ar6000_enable_mmchost_detect_change(1); }
/* * Write to the AR6000 through its diagnostic window. * No cooperation from the Target is required for this. */ A_STATUS ar6000_WriteRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data) { A_STATUS status; /* set write data */ status = HIFReadWrite(hifDevice, WINDOW_DATA_ADDRESS, (A_UCHAR *)data, sizeof(A_UINT32), HIF_WR_SYNC_BYTE_INC, NULL); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write 0x%x to WINDOW_DATA_ADDRESS\n", *data)); return status; } /* set window register, which starts the write cycle */ return ar6000_SetAddressWindowRegister(hifDevice, WINDOW_WRITE_ADDR_ADDRESS, *address); }
static A_STATUS wmi_cmd_send(A_UINT8 *pBuffer, int Length, WMI_COMMAND_ID cmdId) { WMI_CMD_HDR *cHdr; A_ASSERT(pBuffer != NULL); pBuffer -= sizeof(WMI_CMD_HDR); /* caller always provides headroom */ Length += sizeof(WMI_CMD_HDR); cHdr = (WMI_CMD_HDR *)pBuffer; cHdr->commandId = cmdId; AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("WMI Send Command : 0x%X (%d) len:%d \n",cmdId,cmdId, Length)); if (g_WMIloggingReq) { DebugDumpBytes(pBuffer, Length, "WMI Send Buffer Dump"); } return HTCSendMsg(g_HTCHandle, g_WMIControlEp, pBuffer, Length); }
void HTCUnblockRecv(HTC_HANDLE HTCHandle) { HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); A_BOOL unblockRecv = FALSE; LOCK_HTC_RX(target); /* check if we are blocked waiting for a new buffer */ if (target->HTCStateFlags & HTC_STATE_WAIT_BUFFERS) { AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("HTCUnblockRx : receiver was blocked on ep:%d, unblocking.. \n", target->EpWaitingForBuffers)); target->HTCStateFlags &= ~HTC_STATE_WAIT_BUFFERS; target->EpWaitingForBuffers = ENDPOINT_MAX; unblockRecv = TRUE; } UNLOCK_HTC_RX(target); if (unblockRecv && !HTC_STOPPING(target)) { /* re-enable */ DevEnableRecv(&target->Device,DEV_ENABLE_RECV_ASYNC); } }
/* callback when a control message arrives on this endpoint */ void HTCControlRecv(void *Context, HTC_PACKET *pPacket) { AR_DEBUG_ASSERT(pPacket->Endpoint == ENDPOINT_0); if (pPacket->Status == A_ECANCELED) { /* this is a flush operation, return the control packet back to the pool */ HTC_FREE_CONTROL_RX((HTC_TARGET*)Context,pPacket); return; } /* the only control messages we are expecting are NULL messages (credit resports), which should * never get here */ AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTCControlRecv, got message with length:%d \n", pPacket->ActualLength + HTC_HDR_LENGTH)); /* dump header and message */ DebugDumpBytes(pPacket->pBuffer - HTC_HDR_LENGTH, pPacket->ActualLength + HTC_HDR_LENGTH, "Unexpected ENDPOINT 0 Message"); HTC_RECYCLE_RX_PKT((HTC_TARGET*)Context,pPacket,&((HTC_TARGET*)Context)->EndPoint[0]); }
static A_STATUS RecvHCIEvent(AR3K_CONFIG_INFO *pConfig, A_UINT8 *pBuffer, int *pLength) { A_STATUS status = A_OK; HTC_PACKET *pRecvPacket = NULL; do { pRecvPacket = (HTC_PACKET *)A_MALLOC(sizeof(HTC_PACKET)); if (NULL == pRecvPacket) { status = A_NO_MEMORY; AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to alloc HTC struct \n")); break; } A_MEMZERO(pRecvPacket,sizeof(HTC_PACKET)); SET_HTC_PACKET_INFO_RX_REFILL(pRecvPacket,NULL,pBuffer,*pLength,HCI_EVENT_TYPE); status = HCI_TransportRecvHCIEventSync(pConfig->pHCIDev, pRecvPacket, HCI_EVENT_RESP_TIMEOUTMS); if (A_FAILED(status)) { break; } *pLength = pRecvPacket->ActualLength; } while (FALSE); if (pRecvPacket != NULL) { A_FREE(pRecvPacket); } return status; }
static int RecvHCIEvent(struct ar3k_config_info *pConfig, u8 *pBuffer, int *pLength) { int status = 0; struct htc_packet *pRecvPacket = NULL; do { pRecvPacket = (struct htc_packet *)A_MALLOC(sizeof(struct htc_packet)); if (NULL == pRecvPacket) { status = A_NO_MEMORY; AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to alloc HTC struct \n")); break; } A_MEMZERO(pRecvPacket,sizeof(struct htc_packet)); SET_HTC_PACKET_INFO_RX_REFILL(pRecvPacket,NULL,pBuffer,*pLength,HCI_EVENT_TYPE); status = HCI_TransportRecvHCIEventSync(pConfig->pHCIDev, pRecvPacket, HCI_EVENT_RESP_TIMEOUTMS); if (status) { break; } *pLength = pRecvPacket->ActualLength; } while (false); if (pRecvPacket != NULL) { kfree(pRecvPacket); } return status; }
A_STATUS DevGMboxWrite(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_UINT32 WriteLength) { A_UINT32 paddedLength; A_BOOL sync = (pPacket->Completion == NULL) ? TRUE : FALSE; A_STATUS status; A_UINT32 address; /* adjust the length to be a multiple of block size if appropriate */ paddedLength = DEV_CALC_SEND_PADDED_LEN(pDev, WriteLength); AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("DevGMboxWrite, Padded Length: %d Mbox:0x%X (mode:%s)\n", WriteLength, pDev->MailBoxInfo.GMboxAddress, sync ? "SYNC" : "ASYNC")); /* last byte of packet has to hit the EOM marker */ address = pDev->MailBoxInfo.GMboxAddress + pDev->MailBoxInfo.GMboxSize - paddedLength; status = HIFReadWrite(pDev->HIFDevice, address, pPacket->pBuffer, paddedLength, /* the padded length */ sync ? HIF_WR_SYNC_BLOCK_INC : HIF_WR_ASYNC_BLOCK_INC, sync ? NULL : pPacket); /* pass the packet as the context to the HIF request */ if (sync) { pPacket->Status = status; } else { if (status == A_PENDING) { status = A_OK; } } return status; }
int DevGMboxWrite(struct ar6k_device *pDev, struct htc_packet *pPacket, u32 WriteLength) { u32 paddedLength; bool sync = (pPacket->Completion == NULL) ? true : false; int status; u32 address; /* adjust the length to be a multiple of block size if appropriate */ paddedLength = DEV_CALC_SEND_PADDED_LEN(pDev, WriteLength); AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("DevGMboxWrite, Padded Length: %d Mbox:0x%X (mode:%s)\n", WriteLength, pDev->MailBoxInfo.GMboxAddress, sync ? "SYNC" : "ASYNC")); /* last byte of packet has to hit the EOM marker */ address = pDev->MailBoxInfo.GMboxAddress + pDev->MailBoxInfo.GMboxSize - paddedLength; status = HIFReadWrite(pDev->HIFDevice, address, pPacket->pBuffer, paddedLength, /* the padded length */ sync ? HIF_WR_SYNC_BLOCK_INC : HIF_WR_ASYNC_BLOCK_INC, sync ? NULL : pPacket); /* pass the packet as the context to the HIF request */ if (sync) { pPacket->Status = status; } else { if (status == A_PENDING) { status = 0; } } return status; }