diff --git a/drivers/staging/vt6655/srom.c b/drivers/staging/vt6655/srom.c index 6a0a232d1a0c..8c95d1b35967 100644 --- a/drivers/staging/vt6655/srom.c +++ b/drivers/staging/vt6655/srom.c @@ -78,36 +78,36 @@ */ unsigned char SROMbyReadEmbedded(unsigned long dwIoBase, unsigned char byContntOffset) { - unsigned short wDelay, wNoACK; - unsigned char byWait; - unsigned char byData; - unsigned char byOrg; + unsigned short wDelay, wNoACK; + unsigned char byWait; + unsigned char byData; + unsigned char byOrg; - byData = 0xFF; - VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg); - /* turn off hardware retry for getting NACK */ - VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg & (~I2MCFG_NORETRY))); - for (wNoACK = 0; wNoACK < W_MAX_I2CRETRY; wNoACK++) { - VNSvOutPortB(dwIoBase + MAC_REG_I2MTGID, EEP_I2C_DEV_ID); - VNSvOutPortB(dwIoBase + MAC_REG_I2MTGAD, byContntOffset); + byData = 0xFF; + VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg); + /* turn off hardware retry for getting NACK */ + VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg & (~I2MCFG_NORETRY))); + for (wNoACK = 0; wNoACK < W_MAX_I2CRETRY; wNoACK++) { + VNSvOutPortB(dwIoBase + MAC_REG_I2MTGID, EEP_I2C_DEV_ID); + VNSvOutPortB(dwIoBase + MAC_REG_I2MTGAD, byContntOffset); - /* issue read command */ - VNSvOutPortB(dwIoBase + MAC_REG_I2MCSR, I2MCSR_EEMR); - /* wait DONE be set */ - for (wDelay = 0; wDelay < W_MAX_TIMEOUT; wDelay++) { - VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait); - if (byWait & (I2MCSR_DONE | I2MCSR_NACK)) - break; - PCAvDelayByIO(CB_DELAY_LOOP_WAIT); - } - if ((wDelay < W_MAX_TIMEOUT) && - ( !(byWait & I2MCSR_NACK))) { - break; - } - } - VNSvInPortB(dwIoBase + MAC_REG_I2MDIPT, &byData); - VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg); - return byData; + /* issue read command */ + VNSvOutPortB(dwIoBase + MAC_REG_I2MCSR, I2MCSR_EEMR); + /* wait DONE be set */ + for (wDelay = 0; wDelay < W_MAX_TIMEOUT; wDelay++) { + VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait); + if (byWait & (I2MCSR_DONE | I2MCSR_NACK)) + break; + PCAvDelayByIO(CB_DELAY_LOOP_WAIT); + } + if ((wDelay < W_MAX_TIMEOUT) && + (!(byWait & I2MCSR_NACK))) { + break; + } + } + VNSvInPortB(dwIoBase + MAC_REG_I2MDIPT, &byData); + VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg); + return byData; } @@ -127,40 +127,40 @@ unsigned char SROMbyReadEmbedded(unsigned long dwIoBase, unsigned char byContntO */ bool SROMbWriteEmbedded(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byData) { - unsigned short wDelay, wNoACK; - unsigned char byWait; + unsigned short wDelay, wNoACK; + unsigned char byWait; - unsigned char byOrg; + unsigned char byOrg; - VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg); - /* turn off hardware retry for getting NACK */ - VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg & (~I2MCFG_NORETRY))); - for (wNoACK = 0; wNoACK < W_MAX_I2CRETRY; wNoACK++) { - VNSvOutPortB(dwIoBase + MAC_REG_I2MTGID, EEP_I2C_DEV_ID); - VNSvOutPortB(dwIoBase + MAC_REG_I2MTGAD, byContntOffset); - VNSvOutPortB(dwIoBase + MAC_REG_I2MDOPT, byData); + VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg); + /* turn off hardware retry for getting NACK */ + VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg & (~I2MCFG_NORETRY))); + for (wNoACK = 0; wNoACK < W_MAX_I2CRETRY; wNoACK++) { + VNSvOutPortB(dwIoBase + MAC_REG_I2MTGID, EEP_I2C_DEV_ID); + VNSvOutPortB(dwIoBase + MAC_REG_I2MTGAD, byContntOffset); + VNSvOutPortB(dwIoBase + MAC_REG_I2MDOPT, byData); - /* issue write command */ - VNSvOutPortB(dwIoBase + MAC_REG_I2MCSR, I2MCSR_EEMW); - /* wait DONE be set */ - for (wDelay = 0; wDelay < W_MAX_TIMEOUT; wDelay++) { - VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait); - if (byWait & (I2MCSR_DONE | I2MCSR_NACK)) - break; - PCAvDelayByIO(CB_DELAY_LOOP_WAIT); - } + /* issue write command */ + VNSvOutPortB(dwIoBase + MAC_REG_I2MCSR, I2MCSR_EEMW); + /* wait DONE be set */ + for (wDelay = 0; wDelay < W_MAX_TIMEOUT; wDelay++) { + VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait); + if (byWait & (I2MCSR_DONE | I2MCSR_NACK)) + break; + PCAvDelayByIO(CB_DELAY_LOOP_WAIT); + } - if ((wDelay < W_MAX_TIMEOUT) && - ( !(byWait & I2MCSR_NACK))) { - break; - } - } - if (wNoACK == W_MAX_I2CRETRY) { - VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg); - return false; - } - VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg); - return true; + if ((wDelay < W_MAX_TIMEOUT) && + (!(byWait & I2MCSR_NACK))) { + break; + } + } + if (wNoACK == W_MAX_I2CRETRY) { + VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg); + return false; + } + VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg); + return true; } @@ -180,10 +180,10 @@ bool SROMbWriteEmbedded(unsigned long dwIoBase, unsigned char byContntOffset, un */ void SROMvRegBitsOn(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byBits) { - unsigned char byOrgData; + unsigned char byOrgData; - byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); - SROMbWriteEmbedded(dwIoBase, byContntOffset,(unsigned char)(byOrgData | byBits)); + byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); + SROMbWriteEmbedded(dwIoBase, byContntOffset, (unsigned char)(byOrgData | byBits)); } @@ -201,10 +201,10 @@ void SROMvRegBitsOn(unsigned long dwIoBase, unsigned char byContntOffset, unsign */ void SROMvRegBitsOff(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byBits) { - unsigned char byOrgData; + unsigned char byOrgData; - byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); - SROMbWriteEmbedded(dwIoBase, byContntOffset,(unsigned char)(byOrgData & (~byBits))); + byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); + SROMbWriteEmbedded(dwIoBase, byContntOffset, (unsigned char)(byOrgData & (~byBits))); } @@ -224,10 +224,10 @@ void SROMvRegBitsOff(unsigned long dwIoBase, unsigned char byContntOffset, unsig */ bool SROMbIsRegBitsOn(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byTestBits) { - unsigned char byOrgData; + unsigned char byOrgData; - byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); - return (byOrgData & byTestBits) == byTestBits; + byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); + return (byOrgData & byTestBits) == byTestBits; } @@ -247,10 +247,10 @@ bool SROMbIsRegBitsOn(unsigned long dwIoBase, unsigned char byContntOffset, unsi */ bool SROMbIsRegBitsOff(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byTestBits) { - unsigned char byOrgData; + unsigned char byOrgData; - byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); - return !(byOrgData & byTestBits); + byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); + return !(byOrgData & byTestBits); } @@ -268,13 +268,13 @@ bool SROMbIsRegBitsOff(unsigned long dwIoBase, unsigned char byContntOffset, uns */ void SROMvReadAllContents(unsigned long dwIoBase, unsigned char *pbyEepromRegs) { - int ii; + int ii; - /* ii = Rom Address */ - for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { - *pbyEepromRegs = SROMbyReadEmbedded(dwIoBase,(unsigned char) ii); - pbyEepromRegs++; - } + /* ii = Rom Address */ + for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { + *pbyEepromRegs = SROMbyReadEmbedded(dwIoBase, (unsigned char)ii); + pbyEepromRegs++; + } } @@ -293,13 +293,13 @@ void SROMvReadAllContents(unsigned long dwIoBase, unsigned char *pbyEepromRegs) */ void SROMvWriteAllContents(unsigned long dwIoBase, unsigned char *pbyEepromRegs) { - int ii; + int ii; - /* ii = Rom Address */ - for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { - SROMbWriteEmbedded(dwIoBase,(unsigned char) ii, *pbyEepromRegs); - pbyEepromRegs++; - } + /* ii = Rom Address */ + for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { + SROMbWriteEmbedded(dwIoBase, (unsigned char)ii, *pbyEepromRegs); + pbyEepromRegs++; + } } @@ -317,13 +317,13 @@ void SROMvWriteAllContents(unsigned long dwIoBase, unsigned char *pbyEepromRegs) */ void SROMvReadEtherAddress(unsigned long dwIoBase, unsigned char *pbyEtherAddress) { - unsigned char ii; + unsigned char ii; - /* ii = Rom Address */ - for (ii = 0; ii < ETH_ALEN; ii++) { - *pbyEtherAddress = SROMbyReadEmbedded(dwIoBase, ii); - pbyEtherAddress++; - } + /* ii = Rom Address */ + for (ii = 0; ii < ETH_ALEN; ii++) { + *pbyEtherAddress = SROMbyReadEmbedded(dwIoBase, ii); + pbyEtherAddress++; + } } @@ -342,13 +342,13 @@ void SROMvReadEtherAddress(unsigned long dwIoBase, unsigned char *pbyEtherAddres */ void SROMvWriteEtherAddress(unsigned long dwIoBase, unsigned char *pbyEtherAddress) { - unsigned char ii; + unsigned char ii; - /* ii = Rom Address */ - for (ii = 0; ii < ETH_ALEN; ii++) { - SROMbWriteEmbedded(dwIoBase, ii, *pbyEtherAddress); - pbyEtherAddress++; - } + /* ii = Rom Address */ + for (ii = 0; ii < ETH_ALEN; ii++) { + SROMbWriteEmbedded(dwIoBase, ii, *pbyEtherAddress); + pbyEtherAddress++; + } } @@ -366,15 +366,15 @@ void SROMvWriteEtherAddress(unsigned long dwIoBase, unsigned char *pbyEtherAddre */ void SROMvReadSubSysVenId(unsigned long dwIoBase, unsigned long *pdwSubSysVenId) { - unsigned char *pbyData; + 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); + 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); } /* @@ -391,30 +391,30 @@ void SROMvReadSubSysVenId(unsigned long dwIoBase, unsigned long *pdwSubSysVenId) */ bool SROMbAutoLoad(unsigned long dwIoBase) { - unsigned char byWait; - int ii; + unsigned char byWait; + int ii; - unsigned char byOrg; + unsigned char byOrg; - VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg); - /* turn on hardware retry */ - VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg | I2MCFG_NORETRY)); + VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg); + /* turn on hardware retry */ + VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg | I2MCFG_NORETRY)); - MACvRegBitsOn(dwIoBase, MAC_REG_I2MCSR, I2MCSR_AUTOLD); + MACvRegBitsOn(dwIoBase, MAC_REG_I2MCSR, I2MCSR_AUTOLD); - /* ii = Rom Address */ - for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { - MACvTimer0MicroSDelay(dwIoBase, CB_EEPROM_READBYTE_WAIT); - VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait); - if ( !(byWait & I2MCSR_AUTOLD)) - break; - } + /* ii = Rom Address */ + for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { + MACvTimer0MicroSDelay(dwIoBase, CB_EEPROM_READBYTE_WAIT); + VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait); + if (!(byWait & I2MCSR_AUTOLD)) + break; + } - VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg); + VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg); - if (ii == EEP_MAX_CONTEXT_SIZE) - return false; - return true; + if (ii == EEP_MAX_CONTEXT_SIZE) + return false; + return true; } diff --git a/drivers/staging/vt6655/srom.h b/drivers/staging/vt6655/srom.h index 4c261dac01b5..32cf1093f4f7 100644 --- a/drivers/staging/vt6655/srom.h +++ b/drivers/staging/vt6655/srom.h @@ -97,34 +97,34 @@ // 2048 bits = 256 bytes = 128 words // typedef struct tagSSromReg { - unsigned char abyPAR[6]; // 0x00 (unsigned short) + unsigned char abyPAR[6]; // 0x00 (unsigned short) - unsigned short wSUB_VID; // 0x03 (unsigned short) - unsigned short wSUB_SID; + unsigned short wSUB_VID; // 0x03 (unsigned short) + unsigned short wSUB_SID; - unsigned char byBCFG0; // 0x05 (unsigned short) - unsigned char byBCFG1; + unsigned char byBCFG0; // 0x05 (unsigned short) + unsigned char byBCFG1; - unsigned char byFCR0; // 0x06 (unsigned short) - unsigned char byFCR1; - unsigned char byPMC0; // 0x07 (unsigned short) - unsigned char byPMC1; - unsigned char byMAXLAT; // 0x08 (unsigned short) - unsigned char byMINGNT; - unsigned char byCFG0; // 0x09 (unsigned short) - unsigned char byCFG1; - unsigned short wCISPTR; // 0x0A (unsigned short) - unsigned short wRsv0; // 0x0B (unsigned short) - unsigned short wRsv1; // 0x0C (unsigned short) - unsigned char byBBPAIR; // 0x0D (unsigned short) - unsigned char byRFTYPE; - unsigned char byMinChannel; // 0x0E (unsigned short) - unsigned char byMaxChannel; - unsigned char bySignature; // 0x0F (unsigned short) - unsigned char byCheckSum; + unsigned char byFCR0; // 0x06 (unsigned short) + unsigned char byFCR1; + unsigned char byPMC0; // 0x07 (unsigned short) + unsigned char byPMC1; + unsigned char byMAXLAT; // 0x08 (unsigned short) + unsigned char byMINGNT; + unsigned char byCFG0; // 0x09 (unsigned short) + unsigned char byCFG1; + unsigned short wCISPTR; // 0x0A (unsigned short) + unsigned short wRsv0; // 0x0B (unsigned short) + unsigned short wRsv1; // 0x0C (unsigned short) + unsigned char byBBPAIR; // 0x0D (unsigned short) + unsigned char byRFTYPE; + unsigned char byMinChannel; // 0x0E (unsigned short) + unsigned char byMaxChannel; + unsigned char bySignature; // 0x0F (unsigned short) + unsigned char byCheckSum; - unsigned char abyReserved0[96]; // 0x10 (unsigned short) - unsigned char abyCIS[128]; // 0x80 (unsigned short) + unsigned char abyReserved0[96]; // 0x10 (unsigned short) + unsigned char abyCIS[128]; // 0x80 (unsigned short) } SSromReg, *PSSromReg; /*--------------------- Export Macros ------------------------------*/ @@ -152,6 +152,6 @@ void SROMvWriteEtherAddress(unsigned long dwIoBase, unsigned char *pbyEtherAddre void SROMvReadSubSysVenId(unsigned long dwIoBase, unsigned long *pdwSubSysVenId); -bool SROMbAutoLoad (unsigned long dwIoBase); +bool SROMbAutoLoad(unsigned long dwIoBase); #endif // __EEPROM_H__