diff options
Diffstat (limited to 'drivers/staging/bcm/nvm.c')
-rw-r--r-- | drivers/staging/bcm/nvm.c | 314 |
1 files changed, 0 insertions, 314 deletions
diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c index 4a020533474..4f1b35a68b7 100644 --- a/drivers/staging/bcm/nvm.c +++ b/drivers/staging/bcm/nvm.c | |||
@@ -234,168 +234,6 @@ INT ReadBeceemEEPROM( PMINI_ADAPTER Adapter, | |||
234 | } /* ReadBeceemEEPROM() */ | 234 | } /* ReadBeceemEEPROM() */ |
235 | 235 | ||
236 | 236 | ||
237 | #if 0 | ||
238 | //----------------------------------------------------------------------------- | ||
239 | // Procedure: IsEEPROMWriteDone | ||
240 | // | ||
241 | // Description: Reads the SPI status to see the status of previous write. | ||
242 | // | ||
243 | // Arguments: | ||
244 | // Adapter - ptr to Adapter object instance | ||
245 | // | ||
246 | // Returns: | ||
247 | // BOOLEAN - TRUE - write went through | ||
248 | // - FALSE - Write Failed. | ||
249 | //----------------------------------------------------------------------------- | ||
250 | |||
251 | BOOLEAN IsEEPROMWriteDone(PMINI_ADAPTER Adapter) | ||
252 | { | ||
253 | UINT uiRetries = 16; | ||
254 | //UINT uiStatus = 0; | ||
255 | UINT value; | ||
256 | |||
257 | //sleep for 1.2ms ..worst case EEPROM write can take up to 1.2ms. | ||
258 | mdelay(2); | ||
259 | |||
260 | value = 0; | ||
261 | rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); | ||
262 | |||
263 | while(((value >> 14) & 1) == 1) | ||
264 | { | ||
265 | // EEPROM_SPI_Q_STATUS1_REG will be cleared only if write back to that. | ||
266 | value = (0x1 << 14); | ||
267 | wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value)); | ||
268 | udelay(1000); | ||
269 | uiRetries--; | ||
270 | if(uiRetries == 0) | ||
271 | { | ||
272 | return FALSE; | ||
273 | } | ||
274 | value = 0; | ||
275 | rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); | ||
276 | } | ||
277 | return TRUE; | ||
278 | |||
279 | |||
280 | } | ||
281 | |||
282 | |||
283 | //----------------------------------------------------------------------------- | ||
284 | // Procedure: ReadBeceemEEPROMBulk | ||
285 | // | ||
286 | // Description: This routine reads 16Byte data from EEPROM | ||
287 | // | ||
288 | // Arguments: | ||
289 | // Adapter - ptr to Adapter object instance | ||
290 | // dwAddress - EEPROM Offset to read the data from. | ||
291 | // pdwData - Pointer to double word where data needs to be stored in. | ||
292 | // | ||
293 | // Returns: | ||
294 | // OSAL_STATUS_CODE: | ||
295 | //----------------------------------------------------------------------------- | ||
296 | |||
297 | INT ReadBeceemEEPROMBulk(PMINI_ADAPTER Adapter,DWORD dwAddress, DWORD *pdwData) | ||
298 | { | ||
299 | DWORD dwRetries = 16; | ||
300 | DWORD dwIndex = 0; | ||
301 | UINT value, tmpVal; | ||
302 | |||
303 | |||
304 | value = 0; | ||
305 | rdmalt (Adapter, 0x0f003008, &value, sizeof(value)); | ||
306 | |||
307 | //read 0x0f003020 untill bit 1 of 0x0f003008 is set. | ||
308 | while(((value >> 1) & 1) == 0) | ||
309 | { | ||
310 | |||
311 | rdmalt (Adapter, 0x0f003020, &tmpVal, sizeof(tmpVal)); | ||
312 | dwRetries--; | ||
313 | if(dwRetries == 0) | ||
314 | { | ||
315 | return -1; | ||
316 | } | ||
317 | value = 0; | ||
318 | rdmalt (Adapter, 0x0f003008, &value, sizeof(value)); | ||
319 | } | ||
320 | |||
321 | value = dwAddress | 0xfb000000; | ||
322 | wrmalt (Adapter, 0x0f003018, &value, sizeof(value)); | ||
323 | |||
324 | udelay(1000); | ||
325 | value = 0; | ||
326 | for(dwIndex = 0;dwIndex < 4 ; dwIndex++) | ||
327 | { | ||
328 | value = 0; | ||
329 | rdmalt (Adapter, 0x0f003020, &value, sizeof(value)); | ||
330 | pdwData[dwIndex] = value; | ||
331 | |||
332 | value = 0; | ||
333 | rdmalt (Adapter, 0x0f003020, &value, sizeof(value)); | ||
334 | pdwData[dwIndex] |= (value << 8); | ||
335 | |||
336 | value = 0; | ||
337 | rdmalt (Adapter, 0x0f003020, &value, sizeof(value)); | ||
338 | pdwData[dwIndex] |= (value << 16); | ||
339 | |||
340 | value = 0; | ||
341 | rdmalt (Adapter, 0x0f003020, &value, sizeof(value)); | ||
342 | pdwData[dwIndex] |= (value << 24); | ||
343 | |||
344 | } | ||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | //----------------------------------------------------------------------------- | ||
349 | // Procedure: ReadBeceemEEPROM | ||
350 | // | ||
351 | // Description: This routine reads 4Byte data from EEPROM | ||
352 | // | ||
353 | // Arguments: | ||
354 | // Adapter - ptr to Adapter object instance | ||
355 | // dwAddress - EEPROM Offset to read the data from. | ||
356 | // pdwData - Pointer to double word where data needs to be stored in. | ||
357 | // | ||
358 | // Returns: | ||
359 | // OSAL_STATUS_CODE: | ||
360 | //----------------------------------------------------------------------------- | ||
361 | |||
362 | INT ReadBeceemEEPROM(PMINI_ADAPTER Adapter,DWORD dwAddress, DWORD *pdwData) | ||
363 | { | ||
364 | |||
365 | DWORD dwReadValue = 0; | ||
366 | DWORD dwRetries = 16, dwCompleteWord = 0; | ||
367 | UINT value, tmpVal; | ||
368 | |||
369 | rdmalt(Adapter, 0x0f003008, &value, sizeof(value)); | ||
370 | while (((value >> 1) & 1) == 0) { | ||
371 | rdmalt(Adapter, 0x0f003020, &tmpVal, sizeof(tmpVal)); | ||
372 | |||
373 | if (dwRetries == 0) { | ||
374 | return -1; | ||
375 | } | ||
376 | rdmalt(Adapter, 0x0f003008, &value, sizeof(value)); | ||
377 | } | ||
378 | |||
379 | |||
380 | //wrm (0x0f003018, 0xNbXXXXXX) // N is the number of bytes u want to read (0 means 1, f means 16, b is the opcode for page read) | ||
381 | // Follow it up by N executions of rdm(0x0f003020) to read the rxed bytes from rx queue. | ||
382 | dwAddress |= 0x3b000000; | ||
383 | wrmalt(Adapter, 0x0f003018,&dwAddress,4); | ||
384 | mdelay(10); | ||
385 | rdmalt(Adapter, 0x0f003020,&dwReadValue,4); | ||
386 | dwCompleteWord=dwReadValue; | ||
387 | rdmalt(Adapter, 0x0f003020,&dwReadValue,4); | ||
388 | dwCompleteWord|=(dwReadValue<<8); | ||
389 | rdmalt(Adapter, 0x0f003020,&dwReadValue,4); | ||
390 | dwCompleteWord|=(dwReadValue<<16); | ||
391 | rdmalt(Adapter, 0x0f003020,&dwReadValue,4); | ||
392 | dwCompleteWord|=(dwReadValue<<24); | ||
393 | |||
394 | *pdwData = dwCompleteWord; | ||
395 | |||
396 | return 0; | ||
397 | } | ||
398 | #endif | ||
399 | 237 | ||
400 | INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter) | 238 | INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter) |
401 | { | 239 | { |
@@ -655,14 +493,6 @@ INT BeceemFlashBulkRead( | |||
655 | 493 | ||
656 | UINT BcmGetFlashSize(PMINI_ADAPTER Adapter) | 494 | UINT BcmGetFlashSize(PMINI_ADAPTER Adapter) |
657 | { | 495 | { |
658 | #if 0 | ||
659 | if(Adapter->bDDRInitDone) | ||
660 | { | ||
661 | return rdm(Adapter,FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT|FLASH_SIZE_ADDR); | ||
662 | } | ||
663 | |||
664 | return rdm(Adapter,FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT|FLASH_SIZE_ADDR); | ||
665 | #endif | ||
666 | if(IsFlash2x(Adapter)) | 496 | if(IsFlash2x(Adapter)) |
667 | return (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER)); | 497 | return (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER)); |
668 | else | 498 | else |
@@ -733,60 +563,6 @@ UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter) | |||
733 | return 0; | 563 | return 0; |
734 | } | 564 | } |
735 | 565 | ||
736 | #if 0 | ||
737 | /***********************************************************************************/ | ||
738 | // | ||
739 | // WriteBeceemEEPROM: Writes 4 byte data to EEPROM offset. | ||
740 | // | ||
741 | // uiEEPROMOffset - Offset to be written to. | ||
742 | // uiData - Data to be written. | ||
743 | // | ||
744 | /***********************************************************************************/ | ||
745 | |||
746 | INT WriteBeceemEEPROM(PMINI_ADAPTER Adapter,UINT uiEEPROMOffset, UINT uiData) | ||
747 | { | ||
748 | INT Status = 0; | ||
749 | ULONG ulRdBk = 0; | ||
750 | ULONG ulRetryCount = 3; | ||
751 | UINT value; | ||
752 | |||
753 | if(uiEEPROMOffset > EEPROM_END) | ||
754 | { | ||
755 | |||
756 | return -1; | ||
757 | } | ||
758 | |||
759 | uiData = htonl(uiData); | ||
760 | while(ulRetryCount--) | ||
761 | { | ||
762 | value = 0x06000000; | ||
763 | wrmalt(Adapter, 0x0F003018,&value, sizeof(value));//flush the EEPROM FIFO. | ||
764 | wrmalt(Adapter, 0x0F00301C,&uiData, sizeof(uiData)); | ||
765 | value = 0x3A000000 | uiEEPROMOffset; | ||
766 | wrmalt(Adapter, 0x0F003018,&value, sizeof(value)); | ||
767 | __udelay(100000); | ||
768 | //read back and verify. | ||
769 | Status = ReadBeceemEEPROM(Adapter,uiEEPROMOffset,(UINT *)&ulRdBk); | ||
770 | if(Status == 0) | ||
771 | { | ||
772 | if(ulRdBk == uiData) | ||
773 | { | ||
774 | return Status; | ||
775 | } | ||
776 | else | ||
777 | { | ||
778 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WriteBeceemEEPROM: Readback does not match\n"); | ||
779 | } | ||
780 | } | ||
781 | else | ||
782 | { | ||
783 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WriteBeceemEEPROM: Readback failed\n"); | ||
784 | } | ||
785 | } | ||
786 | |||
787 | return 0; | ||
788 | } | ||
789 | #endif | ||
790 | 566 | ||
791 | //----------------------------------------------------------------------------- | 567 | //----------------------------------------------------------------------------- |
792 | // Procedure: FlashSectorErase | 568 | // Procedure: FlashSectorErase |
@@ -1353,15 +1129,6 @@ INT BeceemFlashBulkWrite( | |||
1353 | UINT uiTemp = 0; | 1129 | UINT uiTemp = 0; |
1354 | UINT index = 0; | 1130 | UINT index = 0; |
1355 | UINT uiPartOffset = 0; | 1131 | UINT uiPartOffset = 0; |
1356 | #if 0 | ||
1357 | struct timeval tv1 = {0}; | ||
1358 | struct timeval tv2 = {0}; | ||
1359 | |||
1360 | struct timeval tr = {0}; | ||
1361 | struct timeval te = {0}; | ||
1362 | struct timeval tw = {0}; | ||
1363 | struct timeval twv = {0}; | ||
1364 | #endif | ||
1365 | 1132 | ||
1366 | #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) | 1133 | #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) |
1367 | Status = bcmflash_raw_write((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE),( unsigned char *)pBuffer,uiNumBytes); | 1134 | Status = bcmflash_raw_write((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE),( unsigned char *)pBuffer,uiNumBytes); |
@@ -1396,7 +1163,6 @@ INT BeceemFlashBulkWrite( | |||
1396 | uiNumSectTobeRead++; | 1163 | uiNumSectTobeRead++; |
1397 | } | 1164 | } |
1398 | } | 1165 | } |
1399 | #if 1 | ||
1400 | //Check whether Requested sector is writable or not in case of flash2x write. But if write call is | 1166 | //Check whether Requested sector is writable or not in case of flash2x write. But if write call is |
1401 | // for DSD calibration, allow it without checking of sector permission | 1167 | // for DSD calibration, allow it without checking of sector permission |
1402 | 1168 | ||
@@ -1417,7 +1183,6 @@ INT BeceemFlashBulkWrite( | |||
1417 | index = index + 1 ; | 1183 | index = index + 1 ; |
1418 | } | 1184 | } |
1419 | } | 1185 | } |
1420 | #endif | ||
1421 | Adapter->SelectedChip = RESET_CHIP_SELECT; | 1186 | Adapter->SelectedChip = RESET_CHIP_SELECT; |
1422 | while(uiNumSectTobeRead) | 1187 | while(uiNumSectTobeRead) |
1423 | { | 1188 | { |
@@ -1689,21 +1454,6 @@ static INT BeceemFlashBulkWriteStatus( | |||
1689 | { | 1454 | { |
1690 | for(uiIndex = 0;uiIndex < Adapter->uiSectorSize;uiIndex += MAX_RW_SIZE) | 1455 | for(uiIndex = 0;uiIndex < Adapter->uiSectorSize;uiIndex += MAX_RW_SIZE) |
1691 | { | 1456 | { |
1692 | #if 0 | ||
1693 | if(0 == BeceemFlashBulkRead(Adapter,uiReadBk,uiOffsetFromSectStart+uiIndex + Adapter->ulFlashCalStart ,MAX_RW_SIZE)) | ||
1694 | { | ||
1695 | for(uiReadIndex = 0;uiReadIndex < 4; uiReadIndex++) | ||
1696 | { | ||
1697 | if(*((PUINT)&pTempBuff[uiIndex+uiReadIndex*4]) != uiReadBk[uiReadIndex]) | ||
1698 | { | ||
1699 | Status = -1; | ||
1700 | goto BeceemFlashBulkWriteStatus_EXIT; | ||
1701 | |||
1702 | } | ||
1703 | } | ||
1704 | |||
1705 | } | ||
1706 | #endif | ||
1707 | 1457 | ||
1708 | if(STATUS_SUCCESS == BeceemFlashBulkRead(Adapter,(PUINT)ucReadBk,uiOffsetFromSectStart+uiIndex,MAX_RW_SIZE)) | 1458 | if(STATUS_SUCCESS == BeceemFlashBulkRead(Adapter,(PUINT)ucReadBk,uiOffsetFromSectStart+uiIndex,MAX_RW_SIZE)) |
1709 | { | 1459 | { |
@@ -3158,15 +2908,6 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) | |||
3158 | 2908 | ||
3159 | Adapter->uiFlashLayoutMajorVersion = uiFlashLayoutMajorVersion; | 2909 | Adapter->uiFlashLayoutMajorVersion = uiFlashLayoutMajorVersion; |
3160 | 2910 | ||
3161 | #if 0 | ||
3162 | if(FLASH_PART_SST25VF080B == Adapter->ulFlashID) | ||
3163 | { | ||
3164 | // | ||
3165 | // 1MB flash has been selected. we have to use 64K as sector size no matter what is kept in FLASH_CS. | ||
3166 | // | ||
3167 | Adapter->uiSectorSize = 0x10000; | ||
3168 | } | ||
3169 | #endif | ||
3170 | 2911 | ||
3171 | return STATUS_SUCCESS ; | 2912 | return STATUS_SUCCESS ; |
3172 | } | 2913 | } |
@@ -4837,20 +4578,6 @@ INT BcmCopySection(PMINI_ADAPTER Adapter, | |||
4837 | return -EINVAL; | 4578 | return -EINVAL; |
4838 | } | 4579 | } |
4839 | 4580 | ||
4840 | #if 0 | ||
4841 | else | ||
4842 | { | ||
4843 | if((SrcSection == VSA0) || (SrcSection == VSA1) || (SrcSection == VSA2)) | ||
4844 | { | ||
4845 | if((DstSection != VSA0) && (DstSection != VSA1) && (DstSection != VSA2)) | ||
4846 | { | ||
4847 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Source and Destion secton is not of same type"); | ||
4848 | return -EINVAL; | ||
4849 | } | ||
4850 | } | ||
4851 | |||
4852 | } | ||
4853 | #endif | ||
4854 | //if offset zero means have to copy complete secton | 4581 | //if offset zero means have to copy complete secton |
4855 | 4582 | ||
4856 | if(numOfBytes == 0) | 4583 | if(numOfBytes == 0) |
@@ -4950,14 +4677,6 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset) | |||
4950 | UINT uiSectAlignAddr = 0; | 4677 | UINT uiSectAlignAddr = 0; |
4951 | UINT sig = 0; | 4678 | UINT sig = 0; |
4952 | 4679 | ||
4953 | #if 0 | ||
4954 | //if Chenges in Header is allowed, Return back | ||
4955 | if(Adapter->bHeaderChangeAllowed == TRUE) | ||
4956 | { | ||
4957 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Header Change is allowed"); | ||
4958 | return STATUS_SUCCESS ; | ||
4959 | } | ||
4960 | #endif | ||
4961 | //making the offset sector alligned | 4680 | //making the offset sector alligned |
4962 | uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); | 4681 | uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); |
4963 | 4682 | ||
@@ -5336,39 +5055,6 @@ INT WriteToFlashWithoutSectorErase(PMINI_ADAPTER Adapter, | |||
5336 | return Status; | 5055 | return Status; |
5337 | } | 5056 | } |
5338 | 5057 | ||
5339 | #if 0 | ||
5340 | UINT getNumOfSubSectionWithWRPermisson(PMINI_ADAPTER Adapter, SECTION_TYPE secType) | ||
5341 | { | ||
5342 | |||
5343 | UINT numOfWRSubSec = 0; | ||
5344 | switch(secType) | ||
5345 | { | ||
5346 | case ISO : | ||
5347 | if(IsSectionWritable(Adapter,ISO_IMAGE1)) | ||
5348 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5349 | if(IsSectionWritable(Adapter,ISO_IMAGE2)) | ||
5350 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5351 | break; | ||
5352 | |||
5353 | case DSD : | ||
5354 | if(IsSectionWritable(Adapter,DSD2)) | ||
5355 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5356 | if(IsSectionWritable(Adapter,DSD1)) | ||
5357 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5358 | if(IsSectionWritable(Adapter,DSD0)) | ||
5359 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5360 | break ; | ||
5361 | |||
5362 | case VSA : | ||
5363 | //for VSA Add code Here | ||
5364 | default : | ||
5365 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Invalid secton<%d> is passed", secType);\ | ||
5366 | numOfWRSubSec = 0; | ||
5367 | |||
5368 | } | ||
5369 | return numOfWRSubSec; | ||
5370 | } | ||
5371 | #endif | ||
5372 | BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section) | 5058 | BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section) |
5373 | { | 5059 | { |
5374 | 5060 | ||