/* * Description: Read Sub_VID and Sub_SysId from eeprom to buffer * * Parameters: * In: * dwIoBase - I/O base address * Out: * pdwSubSysVenId - Sub_VID and Sub_SysId read * * Return Value: none * */ void SROMvReadSubSysVenId (DWORD_PTR dwIoBase, PDWORD pdwSubSysVenId) { PBYTE pbyData; pbyData = (PBYTE)pdwSubSysVenId; // sub vendor *pbyData = SROMbyReadEmbedded(dwIoBase, 6); *(pbyData+1) = SROMbyReadEmbedded(dwIoBase, 7); // sub system *(pbyData+2) = SROMbyReadEmbedded(dwIoBase, 8); *(pbyData+3) = SROMbyReadEmbedded(dwIoBase, 9); }
/* * Description: Read Sub_VID and Sub_SysId from eeprom to buffer * * Parameters: * In: * dwIoBase - I/O base address * Out: * pdwSubSysVenId - Sub_VID and Sub_SysId read * * Return Value: none * */ void SROMvReadSubSysVenId(unsigned long dwIoBase, unsigned long *pdwSubSysVenId) { unsigned char *pbyData; pbyData = (unsigned char *)pdwSubSysVenId; /* sub vendor */ *pbyData = SROMbyReadEmbedded(dwIoBase, 6); *(pbyData+1) = SROMbyReadEmbedded(dwIoBase, 7); /* sub system */ *(pbyData+2) = SROMbyReadEmbedded(dwIoBase, 8); *(pbyData+3) = SROMbyReadEmbedded(dwIoBase, 9); }
/* * Description: Test if bits off in eeprom * * Parameters: * In: * dwIoBase - I/O base address * byContntOffset - address of EEPROM * byTestBits - bits to test * Out: * none * * Return Value: TRUE if all test bits off; otherwise FALSE * */ BOOL SROMbIsRegBitsOff (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits) { BYTE byOrgData; byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); return !(byOrgData & byTestBits); }
/* * Description: Turn bits off in eeprom * * Parameters: * In: * dwIoBase - I/O base address * byContntOffset - address of EEPROM * byBits - bits to turn off * Out: * none * */ void SROMvRegBitsOff (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits) { BYTE byOrgData; byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); SROMbWriteEmbedded(dwIoBase, byContntOffset,(BYTE)(byOrgData & (~byBits))); }
/* * Description: Test if bits off in eeprom * * Parameters: * In: * dwIoBase - I/O base address * byContntOffset - address of EEPROM * byTestBits - bits to test * Out: * none * * Return Value: true if all test bits off; otherwise false * */ bool SROMbIsRegBitsOff(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byTestBits) { unsigned char byOrgData; byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); return !(byOrgData & byTestBits); }
/* * Description: Turn bits off in eeprom * * Parameters: * In: * dwIoBase - I/O base address * byContntOffset - address of EEPROM * byBits - bits to turn off * Out: * none * */ void SROMvRegBitsOff(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byBits) { unsigned char byOrgData; byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); SROMbWriteEmbedded(dwIoBase, byContntOffset,(unsigned char)(byOrgData & (~byBits))); }
/* * Description: Read Ethernet Address from eeprom to buffer * * Parameters: * In: * dwIoBase - I/O base address * Out: * pbyEtherAddress - Ethernet Address buffer * * Return Value: none * */ void SROMvReadEtherAddress (DWORD_PTR dwIoBase, PBYTE pbyEtherAddress) { BYTE ii; // ii = Rom Address for (ii = 0; ii < U_ETHER_ADDR_LEN; ii++) { *pbyEtherAddress = SROMbyReadEmbedded(dwIoBase, ii); pbyEtherAddress++; } }
/* * Description: Read all contents of eeprom to buffer * * Parameters: * In: * dwIoBase - I/O base address * Out: * pbyEepromRegs - EEPROM content Buffer * * Return Value: none * */ void SROMvReadAllContents (DWORD_PTR dwIoBase, PBYTE pbyEepromRegs) { int ii; // ii = Rom Address for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { *pbyEepromRegs = SROMbyReadEmbedded(dwIoBase,(BYTE) ii); pbyEepromRegs++; } }
/* * Description: Read Ethernet Address from eeprom to buffer * * Parameters: * In: * dwIoBase - I/O base address * Out: * pbyEtherAddress - Ethernet Address buffer * * Return Value: none * */ void SROMvReadEtherAddress(unsigned long dwIoBase, unsigned char *pbyEtherAddress) { unsigned char ii; /* ii = Rom Address */ for (ii = 0; ii < ETH_ALEN; ii++) { *pbyEtherAddress = SROMbyReadEmbedded(dwIoBase, ii); pbyEtherAddress++; } }
/* * Description: Read all contents of eeprom to buffer * * Parameters: * In: * dwIoBase - I/O base address * Out: * pbyEepromRegs - EEPROM content Buffer * * Return Value: none * */ void SROMvReadAllContents(unsigned long dwIoBase, unsigned char *pbyEepromRegs) { int ii; /* ii = Rom Address */ for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { *pbyEepromRegs = SROMbyReadEmbedded(dwIoBase,(unsigned char) ii); pbyEepromRegs++; } }
void SROMvReadEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress) { BYTE ii; /* ii = Rom Address */ for (ii = 0; ii < ETH_ALEN; ii++) { *pbyEtherAddress = SROMbyReadEmbedded(dwIoBase, ii); pbyEtherAddress++; } }
/* * Description: Read Ethernet Address from eeprom to buffer * * Parameters: * In: * iobase - I/O base address * Out: * pbyEtherAddress - Ethernet Address buffer * * Return Value: none * */ void SROMvReadEtherAddress(void __iomem *iobase, unsigned char *pbyEtherAddress) { unsigned char ii; /* ii = Rom Address */ for (ii = 0; ii < ETH_ALEN; ii++) { *pbyEtherAddress = SROMbyReadEmbedded(iobase, ii); pbyEtherAddress++; } }
static void device_init_registers(struct vnt_private *pDevice) { unsigned long flags; unsigned int ii; unsigned char byValue; unsigned char byCCKPwrdBm = 0; unsigned char byOFDMPwrdBm = 0; MACbShutdown(pDevice->PortOffset); BBvSoftwareReset(pDevice); /* Do MACbSoftwareReset in MACvInitialize */ MACbSoftwareReset(pDevice->PortOffset); pDevice->bAES = false; /* Only used in 11g type, sync with ERP IE */ pDevice->bProtectMode = false; pDevice->bNonERPPresent = false; pDevice->bBarkerPreambleMd = false; pDevice->wCurrentRate = RATE_1M; pDevice->byTopOFDMBasicRate = RATE_24M; pDevice->byTopCCKBasicRate = RATE_1M; /* Target to IF pin while programming to RF chip. */ pDevice->byRevId = 0; /* init MAC */ MACvInitialize(pDevice->PortOffset); /* Get Local ID */ VNSvInPortB(pDevice->PortOffset + MAC_REG_LOCALID, &pDevice->byLocalID); spin_lock_irqsave(&pDevice->lock, flags); SROMvReadAllContents(pDevice->PortOffset, pDevice->abyEEPROM); spin_unlock_irqrestore(&pDevice->lock, flags); /* Get Channel range */ pDevice->byMinChannel = 1; pDevice->byMaxChannel = CB_MAX_CHANNEL; /* Get Antena */ byValue = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_ANTENNA); if (byValue & EEP_ANTINV) pDevice->bTxRxAntInv = true; else pDevice->bTxRxAntInv = false; byValue &= (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN); /* if not set default is All */ if (byValue == 0) byValue = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN); if (byValue == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) { pDevice->byAntennaCount = 2; pDevice->byTxAntennaMode = ANT_B; pDevice->dwTxAntennaSel = 1; pDevice->dwRxAntennaSel = 1; if (pDevice->bTxRxAntInv) pDevice->byRxAntennaMode = ANT_A; else pDevice->byRxAntennaMode = ANT_B; } else { pDevice->byAntennaCount = 1; pDevice->dwTxAntennaSel = 0; pDevice->dwRxAntennaSel = 0; if (byValue & EEP_ANTENNA_AUX) { pDevice->byTxAntennaMode = ANT_A; if (pDevice->bTxRxAntInv) pDevice->byRxAntennaMode = ANT_B; else pDevice->byRxAntennaMode = ANT_A; } else { pDevice->byTxAntennaMode = ANT_B; if (pDevice->bTxRxAntInv) pDevice->byRxAntennaMode = ANT_A; else pDevice->byRxAntennaMode = ANT_B; } } /* Set initial antenna mode */ BBvSetTxAntennaMode(pDevice, pDevice->byTxAntennaMode); BBvSetRxAntennaMode(pDevice, pDevice->byRxAntennaMode); /* zonetype initial */ pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE]; /* Get RFType */ pDevice->byRFType = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_RFTYPE); /* force change RevID for VT3253 emu */ if ((pDevice->byRFType & RF_EMU) != 0) pDevice->byRevId = 0x80; pDevice->byRFType &= RF_MASK; pr_debug("pDevice->byRFType = %x\n", pDevice->byRFType); if (!pDevice->bZoneRegExist) pDevice->byZoneType = pDevice->abyEEPROM[EEP_OFS_ZONETYPE]; pr_debug("pDevice->byZoneType = %x\n", pDevice->byZoneType); /* Init RF module */ RFbInit(pDevice); /* Get Desire Power Value */ pDevice->byCurPwr = 0xFF; pDevice->byCCKPwr = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_PWR_CCK); pDevice->byOFDMPwrG = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_PWR_OFDMG); /* Load power Table */ for (ii = 0; ii < CB_MAX_CHANNEL_24G; ii++) { pDevice->abyCCKPwrTbl[ii + 1] = SROMbyReadEmbedded(pDevice->PortOffset, (unsigned char)(ii + EEP_OFS_CCK_PWR_TBL)); if (pDevice->abyCCKPwrTbl[ii + 1] == 0) pDevice->abyCCKPwrTbl[ii+1] = pDevice->byCCKPwr; pDevice->abyOFDMPwrTbl[ii + 1] = SROMbyReadEmbedded(pDevice->PortOffset, (unsigned char)(ii + EEP_OFS_OFDM_PWR_TBL)); if (pDevice->abyOFDMPwrTbl[ii + 1] == 0) pDevice->abyOFDMPwrTbl[ii + 1] = pDevice->byOFDMPwrG; pDevice->abyCCKDefaultPwr[ii + 1] = byCCKPwrdBm; pDevice->abyOFDMDefaultPwr[ii + 1] = byOFDMPwrdBm; } /* recover 12,13 ,14channel for EUROPE by 11 channel */ for (ii = 11; ii < 14; ii++) { pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10]; pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10]; } /* Load OFDM A Power Table */ for (ii = 0; ii < CB_MAX_CHANNEL_5G; ii++) { pDevice->abyOFDMPwrTbl[ii + CB_MAX_CHANNEL_24G + 1] = SROMbyReadEmbedded(pDevice->PortOffset, (unsigned char)(ii + EEP_OFS_OFDMA_PWR_TBL)); pDevice->abyOFDMDefaultPwr[ii + CB_MAX_CHANNEL_24G + 1] = SROMbyReadEmbedded(pDevice->PortOffset, (unsigned char)(ii + EEP_OFS_OFDMA_PWR_dBm)); } if (pDevice->byLocalID > REV_ID_VT3253_B1) { MACvSelectPage1(pDevice->PortOffset); VNSvOutPortB(pDevice->PortOffset + MAC_REG_MSRCTL + 1, (MSRCTL1_TXPWR | MSRCTL1_CSAPAREN)); MACvSelectPage0(pDevice->PortOffset); } /* use relative tx timeout and 802.11i D4 */ MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_CFG, (CFG_TKIPOPT | CFG_NOTXTIMEOUT)); /* set performance parameter by registry */ MACvSetShortRetryLimit(pDevice->PortOffset, pDevice->byShortRetryLimit); MACvSetLongRetryLimit(pDevice->PortOffset, pDevice->byLongRetryLimit); /* reset TSF counter */ VNSvOutPortB(pDevice->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); /* enable TSF counter */ VNSvOutPortB(pDevice->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN); /* initialize BBP registers */ BBbVT3253Init(pDevice); if (pDevice->bUpdateBBVGA) { pDevice->byBBVGACurrent = pDevice->abyBBVGA[0]; pDevice->byBBVGANew = pDevice->byBBVGACurrent; BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]); } BBvSetRxAntennaMode(pDevice, pDevice->byRxAntennaMode); BBvSetTxAntennaMode(pDevice, pDevice->byTxAntennaMode); /* Set BB and packet type at the same time. */ /* Set Short Slot Time, xIFS, and RSPINF. */ pDevice->wCurrentRate = RATE_54M; pDevice->bRadioOff = false; pDevice->byRadioCtl = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_RADIOCTL); pDevice->bHWRadioOff = false; if (pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) { /* Get GPIO */ MACvGPIOIn(pDevice->PortOffset, &pDevice->byGPIO); if (((pDevice->byGPIO & GPIO0_DATA) && !(pDevice->byRadioCtl & EEP_RADIOCTL_INV)) || (!(pDevice->byGPIO & GPIO0_DATA) && (pDevice->byRadioCtl & EEP_RADIOCTL_INV))) pDevice->bHWRadioOff = true; } if (pDevice->bHWRadioOff || pDevice->bRadioControlOff) CARDbRadioPowerOff(pDevice); /* get Permanent network address */ SROMvReadEtherAddress(pDevice->PortOffset, pDevice->abyCurrentNetAddr); pr_debug("Network address = %pM\n", pDevice->abyCurrentNetAddr); /* reset Tx pointer */ CARDvSafeResetRx(pDevice); /* reset Rx pointer */ CARDvSafeResetTx(pDevice); if (pDevice->byLocalID <= REV_ID_VT3253_A1) MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_WPAERR); /* Turn On Rx DMA */ MACvReceive0(pDevice->PortOffset); MACvReceive1(pDevice->PortOffset); /* start the adapter */ MACvStart(pDevice->PortOffset); }