/* This should be called in BMI phase after firmware is downloaded */
void
ar6000_copy_cust_data_from_target(HIF_DEVICE *hifDevice, A_UINT32 TargetType)
{
    A_UINT32 eepHeaderAddr;
    A_UINT8 AR6003CustDataShadow[AR6003_CUST_DATA_SIZE+4];
    A_UINT8 MCKINLEYCustDataShadow[MCKINLEY_CUST_DATA_SIZE+4];
    A_INT32 i;

    if (BMIReadMemory(hifDevice,
            HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_board_data),
            (A_UCHAR *)&eepHeaderAddr,
            4)!= A_OK)
    {
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMIReadMemory for reading board data address failed \n"));
        return;
    }
    if (TargetType == TARGET_TYPE_MCKINLEY) {
        eepHeaderAddr += 36;  /* MCKINLEY customer data section offset is 37 */

        for (i=0; i<MCKINLEY_CUST_DATA_SIZE+4; i+=4){
            if (BMIReadSOCRegister(hifDevice, eepHeaderAddr, (A_UINT32 *)&MCKINLEYCustDataShadow[i])!= A_OK) {
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMIReadSOCRegister () failed \n"));
                return ;
            }  
            eepHeaderAddr +=4;
        }

        memcpy(custDataMCKINLEY, MCKINLEYCustDataShadow+1, MCKINLEY_CUST_DATA_SIZE);
    }


    if (TargetType == TARGET_TYPE_AR6003) {
        eepHeaderAddr += 36;  /* AR6003 customer data section offset is 37 */

        for (i=0; i<AR6003_CUST_DATA_SIZE+4; i+=4){
            if (BMIReadSOCRegister(hifDevice, eepHeaderAddr, (A_UINT32 *)&AR6003CustDataShadow[i])!= A_OK) {
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMIReadSOCRegister () failed \n"));
                return ;
            }  
            eepHeaderAddr +=4;
        }

        memcpy(custDataAR6003, AR6003CustDataShadow+1, AR6003_CUST_DATA_SIZE);
    }

    if (TargetType == TARGET_TYPE_AR6002) {
        eepHeaderAddr += 64;  /* AR6002 customer data sectioin offset is 64 */

        for (i=0; i<AR6002_CUST_DATA_SIZE; i+=4){
            if (BMIReadSOCRegister(hifDevice, eepHeaderAddr, (A_UINT32 *)&custDataAR6002[i])!= A_OK) {
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMIReadSOCRegister () failed \n"));
                return ;
            }  
            eepHeaderAddr +=4;
        }
    }

    return;
}
示例#2
0
文件: config.c 项目: NemProjects/WLAN
/* Modules for firmware download */
A_STATUS configure_ar6000(HIF_DEVICE *hifDevice,
                           A_UINT32    TargetType,
                           A_UINT32    TargetVersion,
                           A_BOOL      enableUART,
                           A_BOOL      timerWAR,
                           A_UINT32    clkFreq,
                           wchar_t     *fileName,
                           wchar_t     *fileRoot,
                           A_BOOL      bCompressed,
                           A_BOOL      isColdBoot,
                           wchar_t     *eepromFile)
{
    A_STATUS status   = A_OK;
    A_UINT32 value    = 0;
    A_UINT32 oldSleep = 0;

    /* do any target-specific preparation that can be done through BMI */
    do
    {
        if (enableUART)
        {
            A_UINT32 uartparam;
            uartparam = 1;
            status = BMIWriteMemory(hifDevice,
                                HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_serial_enable),
                                (A_UCHAR *)&uartparam,
                                4);
            if (status != A_OK)
            {
                break;
            }
        }

        value = HTC_PROTOCOL_VERSION;
        status = BMIWriteMemory (hifDevice,
                                 HOST_INTEREST_ITEM_ADDRESS (TargetType, hi_app_host_interest),
                                (A_UCHAR *)&value,
                                4);
        if (status != A_OK)
        {
            break;
        }

        /* Selectively enable/disable the WAR for Timer Hang Symptom in the
         * firmware by setting a bit in the AR6K Scratch register. The firmware will
         * read this during init and appropriately enable/disable the WAR.
         * This setting will be retained in the firmware till target reset.
         */
        if (timerWAR)
        {
            A_UINT32 timerparam;

            status = BMIReadMemory(hifDevice,
                                   HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_option_flag),
                                   (A_UCHAR *)&timerparam,
                                   4);
            if (status != A_OK)
            {
                break;
            }
            timerparam |= HI_OPTION_TIMER_WAR;

            status = BMIWriteMemory(hifDevice,
                                    HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_option_flag),
                                    (A_UCHAR *)&timerparam,
                                    4);
            if (status != A_OK)
            {
                break;
            }
        }

        if (TargetType == TARGET_TYPE_AR6001)
        {
#ifdef FLASH_18V
            // Change the flash access time for 1.8V flash to 150ns
            status = BMIWriteSOCRegister (hifDevice,  0xac004004,  0x920100d1);
            if (status != A_OK)
            {
                break;
            }
#endif

        }
         /* set the firmware mode to AP */

        {
            A_UINT32 param;
            A_UINT32 fwmode = HI_OPTION_FW_MODE_BSS_STA;

            if (BMIReadMemory(hifDevice,
                HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_option_flag),
                (A_UCHAR *)&param,4)!= A_OK)
            {
                return -1;
            }

            param |= (fwmode << HI_OPTION_FW_MODE_SHIFT);

            if (BMIWriteMemory(hifDevice,
                HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_option_flag),
                (A_UCHAR *)&param,4) != A_OK)
            {
                return -1;
            }
        }

        if (TargetType == TARGET_TYPE_AR6002)
        {
            // Store the value of sleep
            oldSleep = 0x0;
            status = BMIReadSOCRegister (hifDevice, 0x40C4, &oldSleep);
            if (status != A_OK)
            {
                break;
            }

            // disable sleep
            status = BMIWriteSOCRegister (hifDevice, 0x40C4, oldSleep |  0x1);
            if (status != A_OK)
            {
                break;
            }

            status = ar6002_download_image(hifDevice, TargetVersion, fileName, fileRoot, bCompressed,isColdBoot);
            if (status != A_OK)
            {
               break;
            }

            // Restore the value of sleep
            status = BMIWriteSOCRegister (hifDevice, 0x40C4, oldSleep);
            if (status != A_OK)
            {
                break;
            }

            if ((TargetVersion == AR6002_VERSION_REV2) && (AR6002_REV2_APP_START_OVERRIDE != 0)) {
                    /* override default app start address known to ROM  */
                status = BMISetAppStart(hifDevice, AR6002_REV2_APP_START_OVERRIDE);
                if (status != A_OK) {
                    break;
                }
            }

        }

        status = ar6000_configure_clock (hifDevice, TargetType, TargetVersion, clkFreq);
        if (status != A_OK)
        {
            break;
        }

        status = eeprom_ar6000_transfer (hifDevice, TargetType, fileRoot, eepromFile);
        if (status != A_OK)
        {
            break;
        }

    } while (FALSE);

    return status;
}
示例#3
0
文件: config.c 项目: NemProjects/WLAN
static A_STATUS
ar6000_configure_clock (HIF_DEVICE *hifDevice,
                        A_UINT32    TargetType,
                        A_UINT32    TargetVersion,
                        A_UINT32    clkFreq)
{
    A_UINT32 ext_clk_detected = 0;
    A_STATUS status = A_OK;

    do
    {
        if (TargetType == TARGET_TYPE_AR6001)
        {
            status = BMIWriteSOCRegister(hifDevice, 0xAC000020, 0x203);
            if (status != A_OK)
            {
                break;
            }

            status = BMIWriteSOCRegister (hifDevice, 0xAC000024, 0x203);
            if (status != A_OK)
            {
                break;
            }
        }

        if (TargetType == TARGET_TYPE_AR6002)
        {
            if (TargetVersion == AR6002_VERSION_REV2)
            {
                status = BMIReadMemory(hifDevice,
                         HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_ext_clk_detected),
                         (A_UCHAR *)&ext_clk_detected,
                         4);
                if (status != A_OK)
                {
                    break;
                }

#ifdef FORCE_INTERNAL_CLOCK
                status = BMIWriteSOCRegister (hifDevice, 0x40E0, 0x10000);
                if (status != A_OK)
                {
                    break;
                }
                status = BMIWriteSOCRegister (hifDevice, 0x4028, 0x0);
                if (status != A_OK)
                {
                    break;
                }
#else
                // LPO_CAL.Enable for internal clock
                if (ext_clk_detected == 0x0)
                {
                    status = BMIWriteSOCRegister (hifDevice, 0x40E0, 0x10000);
                    if (status != A_OK)
                    {
                        break;
                    }
                }
#endif
                // Run at 40/44 MHz clock
                status = BMIWriteSOCRegister (hifDevice, 0x4020, 0x0);
                if (status != A_OK)
                {
                    break;
                }
            }

            // Write refclk
            status = BMIWriteMemory(hifDevice,
                                    HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_refclk_hz),
                                    (A_UCHAR *)&clkFreq,
                                    4);
            if (status != A_OK)
            {
                break;
            }
        }
    } while (FALSE);

    return status;
}