Пример #1
0
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;
}
void epping_exit(v_CONTEXT_t pVosContext)
{
    epping_context_t *pEpping_ctx;
    VosContextType *gpVosContext;

    pEpping_ctx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext);
    if (pEpping_ctx == NULL) {
        EPPING_LOG(VOS_TRACE_LEVEL_FATAL,
                   "%s: error: pEpping_ctx  = NULL",
                   __func__);
        return;
    }
    gpVosContext = pEpping_ctx->pVosContext;
    if (pVosContext == NULL) {
        EPPING_LOG(VOS_TRACE_LEVEL_FATAL,
                   "%s: error: pVosContext  = NULL",
                   __func__);
        return;
    }
    if (pEpping_ctx->epping_adapter) {
        epping_destroy_adapter(pEpping_ctx->epping_adapter);
        pEpping_ctx->epping_adapter = NULL;
    }
    hif_disable_isr(gpVosContext->pHIFContext);
    hif_reset_soc(gpVosContext->pHIFContext);
    HTCStop(gpVosContext->htc_ctx);
    HTCDestroy(gpVosContext->htc_ctx);
    gpVosContext->htc_ctx = NULL;
#ifdef HIF_PCI
    {
        int i;
        for (i = 0; i < EPPING_MAX_NUM_EPIDS; i++) {
            epping_unregister_tx_copier(i, pEpping_ctx);
        }
    }
#endif /* HIF_PCI */
    epping_cookie_cleanup(pEpping_ctx);
}
Пример #3
0
/* Enables Dragon interrupts */
A_STATUS
HTCStart(HTC_TARGET *target) 
{
    A_STATUS status;
    A_UINT32 address;
    HIF_REQUEST request;

    HTC_DEBUG_PRINTF(ATH_LOG_TRC, "HTCStart Enter\n");

    /* make sure htc ready event is cleared, the event could be stale (already set) from previous start/stop cycles */
    A_RESET_WAIT_EVENT(&htcEvent);

    /* Unmask the host controller interrupts */
    HIFUnMaskInterrupt(target->device);

    /* Enable all the interrupts except for the dragon interrupt */
    target->table.int_status_enable = INT_STATUS_ENABLE_ERROR_SET(0x01) |
                                      INT_STATUS_ENABLE_CPU_SET(0x01) |
                                      INT_STATUS_ENABLE_COUNTER_SET(0x01) |
                                      INT_STATUS_ENABLE_MBOX_DATA_SET(0x0F);

    /* Set up the CPU Interrupt Status Register */
    target->table.cpu_int_status_enable = CPU_INT_STATUS_ENABLE_BIT_SET(0x00);

    /* Set up the Error Interrupt Status Register */
    target->table.error_status_enable = 
                                  ERROR_STATUS_ENABLE_RX_UNDERFLOW_SET(0x01) |
                                  ERROR_STATUS_ENABLE_TX_OVERFLOW_SET(0x01);

    /* Set up the Counter Interrupt Status Register */
    target->table.counter_int_status_enable = 
                                    COUNTER_INT_STATUS_ENABLE_BIT_SET(0xFF);

    /* Write to the register */
    HIF_FRAME_REQUEST(&request, HIF_WRITE, HIF_EXTENDED_IO, HIF_SYNCHRONOUS,
                      HIF_BYTE_BASIS, HIF_INCREMENTAL_ADDRESS);
    address = getRegAddr(INT_STATUS_ENABLE_REG, ENDPOINT_UNUSED);
    status = HIFReadWrite(target->device, address, 
                          &target->table.int_status_enable, 4, &request, NULL);
    if (status != A_OK) {
        /* Can't write it for some reason */
        HTC_DEBUG_PRINTF(ATH_LOG_ERR,
                        "Failed to enable INT_STATUS_ENABLE | CPU_INT_STATUS_ENABLE | ERROR_STATUS_ENABLE | COUNTER_INT_STATUS_ENABLE, err: %d\n", status);
        HTCStop(target);
        return status;
    }

#ifdef DEBUG
    txcreditintrenable[ENDPOINT1] += 1;
    txcreditintrenable[ENDPOINT2] += 1; 
    txcreditintrenable[ENDPOINT3] += 1; 
    txcreditintrenable[ENDPOINT4] += 1;
    txcreditintrenableaggregate[ENDPOINT1] += 1;
    txcreditintrenableaggregate[ENDPOINT2] += 1;
    txcreditintrenableaggregate[ENDPOINT3] += 1;
    txcreditintrenableaggregate[ENDPOINT4] += 1;
#endif /* DEBUG */

    /* Wait on a timed semaphore that will get signalled once the block
       size negotiation with the target has completed. Furthermore, we have
       to do it only once during the lifetime of the target detection */
    if (!target->ready) {
        HTC_DEBUG_PRINTF(ATH_LOG_INF, 
                        "Waiting for the block size negotiation to finish\n");
        A_WAIT_EVENT_INTERRUPTIBLE_TIMEOUT(&htcEvent, (target->ready == TRUE), 
                                           HTC_TARGET_RESPONSE_TIMEOUT);

        if (target->ready) {
            status = A_OK;
        } else {
            status = A_ERROR;
            HTC_DEBUG_PRINTF(ATH_LOG_ERR, 
                                "Failed to negotiate the block sizes\n");
            HTCStop(target);
        }
    }

    HTC_DEBUG_PRINTF(ATH_LOG_TRC, "HTCStart Exit\n");
    return status;
}
Пример #4
0
/* Start HTC, enable interrupts and let the target know host has finished setup */
A_STATUS HTCStart(HTC_HANDLE HTCHandle)
{
    HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
    HTC_PACKET *pPacket;
    A_STATUS   status;

    AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCStart Enter\n"));
	printk("HTCStart Enter\n");

        /* make sure interrupts are disabled at the chip level,
         * this function can be called again from a reboot of the target without shutting down HTC */
    DevDisableInterrupts(&target->Device);
        /* make sure state is cleared again */
    target->HTCStateFlags = 0;
        
        /* now that we are starting, push control receive buffers into the
         * HTC control endpoint */

    while (1) {
        pPacket = HTC_ALLOC_CONTROL_RX(target);
        if (NULL == pPacket) {
            break;
        }
        HTCAddReceivePkt((HTC_HANDLE)target,pPacket);
    }

    do {

        AR_DEBUG_ASSERT(target->InitCredits != NULL);
        AR_DEBUG_ASSERT(target->EpCreditDistributionListHead != NULL);
        AR_DEBUG_ASSERT(target->EpCreditDistributionListHead->pNext != NULL);

            /* call init credits callback to do the distribution ,
             * NOTE: the first entry in the distribution list is ENDPOINT_0, so
             * we pass the start of the list after this one. */
        target->InitCredits(target->pCredDistContext,
                            target->EpCreditDistributionListHead->pNext,
                            target->TargetCredits);

        if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_TRC)) {
            DumpCreditDistStates(target);
        }

            /* the caller is done connecting to services, so we can indicate to the
            * target that the setup phase is complete */
        status = HTCSendSetupComplete(target);
        if (A_FAILED(status)) {
            break;
        }

        /* unmask interrupts */
        status = DevUnmaskInterrupts(&target->Device);
        if (A_FAILED(status)) {
            HTCStop(target);
        }

    } while (FALSE);

    AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCStart Exit\n"));
	printk("HTCStart Exit\n");
    return status;
}
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;
}