diff options
Diffstat (limited to 'drivers/staging/bcm/nvm.c')
-rw-r--r-- | drivers/staging/bcm/nvm.c | 642 |
1 files changed, 117 insertions, 525 deletions
diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c index 41c9ab8a238..c7292373a65 100644 --- a/drivers/staging/bcm/nvm.c +++ b/drivers/staging/bcm/nvm.c | |||
@@ -1,6 +1,56 @@ | |||
1 | #include "headers.h" | 1 | #include "headers.h" |
2 | 2 | ||
3 | #define DWORD unsigned int | 3 | #define DWORD unsigned int |
4 | |||
5 | static INT BcmDoChipSelect(PMINI_ADAPTER Adapter, UINT offset); | ||
6 | static INT BcmGetActiveDSD(PMINI_ADAPTER Adapter); | ||
7 | static INT BcmGetActiveISO(PMINI_ADAPTER Adapter); | ||
8 | static UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter); | ||
9 | static INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter); | ||
10 | static UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter, UINT FlashSectorSizeSig, UINT FlashSectorSize); | ||
11 | |||
12 | static VOID BcmValidateNvmType(PMINI_ADAPTER Adapter); | ||
13 | static INT BcmGetNvmSize(PMINI_ADAPTER Adapter); | ||
14 | static UINT BcmGetFlashSize(PMINI_ADAPTER Adapter); | ||
15 | static NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter); | ||
16 | |||
17 | static INT BcmGetSectionValEndOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); | ||
18 | |||
19 | static B_UINT8 IsOffsetWritable(PMINI_ADAPTER Adapter, UINT uiOffset); | ||
20 | static INT IsSectionWritable(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL Section); | ||
21 | static INT IsSectionExistInVendorInfo(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section); | ||
22 | |||
23 | static INT ReadDSDPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd); | ||
24 | static INT ReadDSDSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd); | ||
25 | static INT ReadISOPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso); | ||
26 | static INT ReadISOSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso); | ||
27 | |||
28 | static INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); | ||
29 | static INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); | ||
30 | static INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiSectAlignAddr); | ||
31 | static INT WriteToFlashWithoutSectorErase(PMINI_ADAPTER Adapter, PUINT pBuff, | ||
32 | FLASH2X_SECTION_VAL eFlash2xSectionVal, | ||
33 | UINT uiOffset, UINT uiNumBytes); | ||
34 | static FLASH2X_SECTION_VAL getHighestPriDSD(PMINI_ADAPTER Adapter); | ||
35 | static FLASH2X_SECTION_VAL getHighestPriISO(PMINI_ADAPTER Adapter); | ||
36 | |||
37 | static INT BeceemFlashBulkRead( | ||
38 | PMINI_ADAPTER Adapter, | ||
39 | PUINT pBuffer, | ||
40 | UINT uiOffset, | ||
41 | UINT uiNumBytes); | ||
42 | |||
43 | static INT BeceemFlashBulkWrite( | ||
44 | PMINI_ADAPTER Adapter, | ||
45 | PUINT pBuffer, | ||
46 | UINT uiOffset, | ||
47 | UINT uiNumBytes, | ||
48 | BOOLEAN bVerify); | ||
49 | |||
50 | static INT GetFlashBaseAddr(PMINI_ADAPTER Adapter); | ||
51 | |||
52 | static INT ReadBeceemEEPROMBulk(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData, UINT dwNumData); | ||
53 | |||
4 | // Procedure: ReadEEPROMStatusRegister | 54 | // Procedure: ReadEEPROMStatusRegister |
5 | // | 55 | // |
6 | // Description: Reads the standard EEPROM Status Register. | 56 | // Description: Reads the standard EEPROM Status Register. |
@@ -228,213 +278,27 @@ INT ReadBeceemEEPROM( PMINI_ADAPTER Adapter, | |||
228 | ReadBeceemEEPROMBulk(Adapter, uiTempOffset + MAX_RW_SIZE, (PUINT)&uiData[4], 4); | 278 | ReadBeceemEEPROMBulk(Adapter, uiTempOffset + MAX_RW_SIZE, (PUINT)&uiData[4], 4); |
229 | } | 279 | } |
230 | 280 | ||
231 | OsalMemMove( (PUCHAR) pBuffer, ( ((PUCHAR)&uiData[0]) + uiByteOffset ), 4); | 281 | memcpy( (PUCHAR) pBuffer, ( ((PUCHAR)&uiData[0]) + uiByteOffset ), 4); |
232 | 282 | ||
233 | return STATUS_SUCCESS; | 283 | return STATUS_SUCCESS; |
234 | } /* ReadBeceemEEPROM() */ | 284 | } /* ReadBeceemEEPROM() */ |
235 | 285 | ||
236 | 286 | ||
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 | 287 | ||
400 | INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter) | 288 | INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter) |
401 | { | 289 | { |
402 | INT Status=0, i; | 290 | INT Status; |
403 | unsigned char puMacAddr[6] = {0}; | 291 | unsigned char puMacAddr[6]; |
404 | INT AllZeroMac = 0; | ||
405 | INT AllFFMac = 0; | ||
406 | 292 | ||
407 | Status = BeceemNVMRead(Adapter, | 293 | Status = BeceemNVMRead(Adapter, |
408 | (PUINT)&puMacAddr[0], | 294 | (PUINT)&puMacAddr[0], |
409 | INIT_PARAMS_1_MACADDRESS_ADDRESS, | 295 | INIT_PARAMS_1_MACADDRESS_ADDRESS, |
410 | MAC_ADDRESS_SIZE); | 296 | MAC_ADDRESS_SIZE); |
411 | 297 | ||
412 | if(Status != STATUS_SUCCESS) | 298 | if(Status == STATUS_SUCCESS) |
413 | { | 299 | memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); |
414 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Error in Reading the mac Addres with status :%d", Status); | ||
415 | return Status; | ||
416 | } | ||
417 | |||
418 | memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); | ||
419 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Modem MAC Addr :"); | ||
420 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_PRINTK, 0, DBG_LVL_ALL,&Adapter->dev->dev_addr[0],MAC_ADDRESS_SIZE); | ||
421 | for(i=0;i<MAC_ADDRESS_SIZE;i++) | ||
422 | { | ||
423 | |||
424 | if(Adapter->dev->dev_addr[i] == 0x00) | ||
425 | AllZeroMac++; | ||
426 | if(Adapter->dev->dev_addr[i] == 0xFF) | ||
427 | AllFFMac++; | ||
428 | |||
429 | } | ||
430 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\n"); | ||
431 | if(AllZeroMac == MAC_ADDRESS_SIZE) | ||
432 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Warning :: MAC Address has all 00's"); | ||
433 | if(AllFFMac == MAC_ADDRESS_SIZE) | ||
434 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Warning :: MAC Address has all FF's"); | ||
435 | 300 | ||
436 | return Status; | 301 | return Status; |
437 | |||
438 | } | 302 | } |
439 | 303 | ||
440 | //----------------------------------------------------------------------------- | 304 | //----------------------------------------------------------------------------- |
@@ -476,7 +340,7 @@ INT BeceemEEPROMBulkRead( | |||
476 | ReadBeceemEEPROMBulk(Adapter,uiTempOffset,(PUINT)&uiData[0],4); | 340 | ReadBeceemEEPROMBulk(Adapter,uiTempOffset,(PUINT)&uiData[0],4); |
477 | if(uiBytesRemaining >= (MAX_RW_SIZE - uiExtraBytes)) | 341 | if(uiBytesRemaining >= (MAX_RW_SIZE - uiExtraBytes)) |
478 | { | 342 | { |
479 | OsalMemMove(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),MAX_RW_SIZE - uiExtraBytes); | 343 | memcpy(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),MAX_RW_SIZE - uiExtraBytes); |
480 | 344 | ||
481 | uiBytesRemaining -= (MAX_RW_SIZE - uiExtraBytes); | 345 | uiBytesRemaining -= (MAX_RW_SIZE - uiExtraBytes); |
482 | uiIndex += (MAX_RW_SIZE - uiExtraBytes); | 346 | uiIndex += (MAX_RW_SIZE - uiExtraBytes); |
@@ -484,7 +348,7 @@ INT BeceemEEPROMBulkRead( | |||
484 | } | 348 | } |
485 | else | 349 | else |
486 | { | 350 | { |
487 | OsalMemMove(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),uiBytesRemaining); | 351 | memcpy(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),uiBytesRemaining); |
488 | uiIndex += uiBytesRemaining; | 352 | uiIndex += uiBytesRemaining; |
489 | uiOffset += uiBytesRemaining; | 353 | uiOffset += uiBytesRemaining; |
490 | uiBytesRemaining = 0; | 354 | uiBytesRemaining = 0; |
@@ -508,7 +372,7 @@ INT BeceemEEPROMBulkRead( | |||
508 | * We read 4 Dwords of data */ | 372 | * We read 4 Dwords of data */ |
509 | if(0 == ReadBeceemEEPROMBulk(Adapter,uiOffset,&uiData[0],4)) | 373 | if(0 == ReadBeceemEEPROMBulk(Adapter,uiOffset,&uiData[0],4)) |
510 | { | 374 | { |
511 | OsalMemMove(pcBuff+uiIndex,&uiData[0],MAX_RW_SIZE); | 375 | memcpy(pcBuff+uiIndex,&uiData[0],MAX_RW_SIZE); |
512 | uiOffset += MAX_RW_SIZE; | 376 | uiOffset += MAX_RW_SIZE; |
513 | uiBytesRemaining -= MAX_RW_SIZE; | 377 | uiBytesRemaining -= MAX_RW_SIZE; |
514 | uiIndex += MAX_RW_SIZE; | 378 | uiIndex += MAX_RW_SIZE; |
@@ -523,7 +387,7 @@ INT BeceemEEPROMBulkRead( | |||
523 | { | 387 | { |
524 | if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0])) | 388 | if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0])) |
525 | { | 389 | { |
526 | OsalMemMove(pcBuff+uiIndex,&uiData[0],4); | 390 | memcpy(pcBuff+uiIndex,&uiData[0],4); |
527 | uiOffset += 4; | 391 | uiOffset += 4; |
528 | uiBytesRemaining -= 4; | 392 | uiBytesRemaining -= 4; |
529 | uiIndex +=4; | 393 | uiIndex +=4; |
@@ -540,7 +404,7 @@ INT BeceemEEPROMBulkRead( | |||
540 | pCharBuff += uiIndex; | 404 | pCharBuff += uiIndex; |
541 | if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0])) | 405 | if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0])) |
542 | { | 406 | { |
543 | OsalMemMove(pCharBuff,&uiData[0],uiBytesRemaining);//copy only bytes requested. | 407 | memcpy(pCharBuff,&uiData[0],uiBytesRemaining);//copy only bytes requested. |
544 | uiBytesRemaining = 0; | 408 | uiBytesRemaining = 0; |
545 | } | 409 | } |
546 | else | 410 | else |
@@ -571,7 +435,7 @@ INT BeceemEEPROMBulkRead( | |||
571 | // <FAILURE> - if failed. | 435 | // <FAILURE> - if failed. |
572 | //----------------------------------------------------------------------------- | 436 | //----------------------------------------------------------------------------- |
573 | 437 | ||
574 | INT BeceemFlashBulkRead( | 438 | static INT BeceemFlashBulkRead( |
575 | PMINI_ADAPTER Adapter, | 439 | PMINI_ADAPTER Adapter, |
576 | PUINT pBuffer, | 440 | PUINT pBuffer, |
577 | UINT uiOffset, | 441 | UINT uiOffset, |
@@ -653,16 +517,8 @@ INT BeceemFlashBulkRead( | |||
653 | // | 517 | // |
654 | //----------------------------------------------------------------------------- | 518 | //----------------------------------------------------------------------------- |
655 | 519 | ||
656 | UINT BcmGetFlashSize(PMINI_ADAPTER Adapter) | 520 | static UINT BcmGetFlashSize(PMINI_ADAPTER Adapter) |
657 | { | 521 | { |
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)) | 522 | if(IsFlash2x(Adapter)) |
667 | return (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER)); | 523 | return (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER)); |
668 | else | 524 | else |
@@ -684,7 +540,7 @@ UINT BcmGetFlashSize(PMINI_ADAPTER Adapter) | |||
684 | // | 540 | // |
685 | //----------------------------------------------------------------------------- | 541 | //----------------------------------------------------------------------------- |
686 | 542 | ||
687 | UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter) | 543 | static UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter) |
688 | { | 544 | { |
689 | UINT uiData = 0; | 545 | UINT uiData = 0; |
690 | UINT uiIndex = 0; | 546 | UINT uiIndex = 0; |
@@ -733,60 +589,6 @@ UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter) | |||
733 | return 0; | 589 | return 0; |
734 | } | 590 | } |
735 | 591 | ||
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 | 592 | ||
791 | //----------------------------------------------------------------------------- | 593 | //----------------------------------------------------------------------------- |
792 | // Procedure: FlashSectorErase | 594 | // Procedure: FlashSectorErase |
@@ -973,7 +775,7 @@ static INT flashWrite( | |||
973 | // need not write 0xFFFFFFFF because write requires an erase and erase will | 775 | // need not write 0xFFFFFFFF because write requires an erase and erase will |
974 | // make whole sector 0xFFFFFFFF. | 776 | // make whole sector 0xFFFFFFFF. |
975 | // | 777 | // |
976 | if (!OsalMemCompare(pData, uiErasePattern, MAX_RW_SIZE)) | 778 | if (!memcmp(pData, uiErasePattern, MAX_RW_SIZE)) |
977 | { | 779 | { |
978 | return 0; | 780 | return 0; |
979 | } | 781 | } |
@@ -1138,7 +940,7 @@ static INT flashWriteStatus( | |||
1138 | // need not write 0xFFFFFFFF because write requires an erase and erase will | 940 | // need not write 0xFFFFFFFF because write requires an erase and erase will |
1139 | // make whole sector 0xFFFFFFFF. | 941 | // make whole sector 0xFFFFFFFF. |
1140 | // | 942 | // |
1141 | if (!OsalMemCompare(pData,uiErasePattern,MAX_RW_SIZE)) | 943 | if (!memcmp(pData,uiErasePattern,MAX_RW_SIZE)) |
1142 | { | 944 | { |
1143 | return 0; | 945 | return 0; |
1144 | } | 946 | } |
@@ -1332,7 +1134,7 @@ static ULONG BcmFlashUnProtectBlock(PMINI_ADAPTER Adapter,UINT uiOffset, UINT ui | |||
1332 | // | 1134 | // |
1333 | //----------------------------------------------------------------------------- | 1135 | //----------------------------------------------------------------------------- |
1334 | 1136 | ||
1335 | INT BeceemFlashBulkWrite( | 1137 | static INT BeceemFlashBulkWrite( |
1336 | PMINI_ADAPTER Adapter, | 1138 | PMINI_ADAPTER Adapter, |
1337 | PUINT pBuffer, | 1139 | PUINT pBuffer, |
1338 | UINT uiOffset, | 1140 | UINT uiOffset, |
@@ -1353,15 +1155,6 @@ INT BeceemFlashBulkWrite( | |||
1353 | UINT uiTemp = 0; | 1155 | UINT uiTemp = 0; |
1354 | UINT index = 0; | 1156 | UINT index = 0; |
1355 | UINT uiPartOffset = 0; | 1157 | 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 | 1158 | ||
1366 | #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) | 1159 | #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); | 1160 | Status = bcmflash_raw_write((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE),( unsigned char *)pBuffer,uiNumBytes); |
@@ -1377,12 +1170,9 @@ INT BeceemFlashBulkWrite( | |||
1377 | uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1); | 1170 | uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1); |
1378 | uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize; | 1171 | uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize; |
1379 | 1172 | ||
1380 | //pTempBuff = OsalMemAlloc(MAX_SECTOR_SIZE,'!MVN'); | 1173 | pTempBuff = kmalloc(Adapter->uiSectorSize, GFP_KERNEL); |
1381 | pTempBuff = OsalMemAlloc(Adapter->uiSectorSize ,"!MVN"); | ||
1382 | if(NULL == pTempBuff) | 1174 | if(NULL == pTempBuff) |
1383 | { | ||
1384 | goto BeceemFlashBulkWrite_EXIT; | 1175 | goto BeceemFlashBulkWrite_EXIT; |
1385 | } | ||
1386 | // | 1176 | // |
1387 | // check if the data to be written is overlapped accross sectors | 1177 | // check if the data to be written is overlapped accross sectors |
1388 | // | 1178 | // |
@@ -1399,7 +1189,6 @@ INT BeceemFlashBulkWrite( | |||
1399 | uiNumSectTobeRead++; | 1189 | uiNumSectTobeRead++; |
1400 | } | 1190 | } |
1401 | } | 1191 | } |
1402 | #if 1 | ||
1403 | //Check whether Requested sector is writable or not in case of flash2x write. But if write call is | 1192 | //Check whether Requested sector is writable or not in case of flash2x write. But if write call is |
1404 | // for DSD calibration, allow it without checking of sector permission | 1193 | // for DSD calibration, allow it without checking of sector permission |
1405 | 1194 | ||
@@ -1420,7 +1209,6 @@ INT BeceemFlashBulkWrite( | |||
1420 | index = index + 1 ; | 1209 | index = index + 1 ; |
1421 | } | 1210 | } |
1422 | } | 1211 | } |
1423 | #endif | ||
1424 | Adapter->SelectedChip = RESET_CHIP_SELECT; | 1212 | Adapter->SelectedChip = RESET_CHIP_SELECT; |
1425 | while(uiNumSectTobeRead) | 1213 | while(uiNumSectTobeRead) |
1426 | { | 1214 | { |
@@ -1448,13 +1236,13 @@ INT BeceemFlashBulkWrite( | |||
1448 | if(uiNumSectTobeRead > 1) | 1236 | if(uiNumSectTobeRead > 1) |
1449 | { | 1237 | { |
1450 | 1238 | ||
1451 | OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); | 1239 | memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); |
1452 | pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr))); | 1240 | pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr))); |
1453 | uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); | 1241 | uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); |
1454 | } | 1242 | } |
1455 | else | 1243 | else |
1456 | { | 1244 | { |
1457 | OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes); | 1245 | memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes); |
1458 | } | 1246 | } |
1459 | 1247 | ||
1460 | if(IsFlash2x(Adapter)) | 1248 | if(IsFlash2x(Adapter)) |
@@ -1503,7 +1291,7 @@ INT BeceemFlashBulkWrite( | |||
1503 | } | 1291 | } |
1504 | else | 1292 | else |
1505 | { | 1293 | { |
1506 | if(OsalMemCompare(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE)) | 1294 | if(memcmp(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE)) |
1507 | { | 1295 | { |
1508 | if(STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex,&pTempBuff[uiIndex])) | 1296 | if(STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex,&pTempBuff[uiIndex])) |
1509 | { | 1297 | { |
@@ -1541,10 +1329,8 @@ BeceemFlashBulkWrite_EXIT: | |||
1541 | { | 1329 | { |
1542 | BcmRestoreBlockProtectStatus(Adapter,ulStatus); | 1330 | BcmRestoreBlockProtectStatus(Adapter,ulStatus); |
1543 | } | 1331 | } |
1544 | if(pTempBuff) | 1332 | |
1545 | { | 1333 | kfree(pTempBuff); |
1546 | OsalMemFree(pTempBuff,Adapter->uiSectorSize); | ||
1547 | } | ||
1548 | 1334 | ||
1549 | Adapter->SelectedChip = RESET_CHIP_SELECT; | 1335 | Adapter->SelectedChip = RESET_CHIP_SELECT; |
1550 | return Status; | 1336 | return Status; |
@@ -1599,14 +1385,10 @@ static INT BeceemFlashBulkWriteStatus( | |||
1599 | uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1); | 1385 | uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1); |
1600 | uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize; | 1386 | uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize; |
1601 | 1387 | ||
1602 | 1388 | pTempBuff = kmalloc(Adapter->uiSectorSize, GFP_KERNEL); | |
1603 | |||
1604 | // pTempBuff = OsalMemAlloc(MAX_SECTOR_SIZE,'!MVN'); | ||
1605 | pTempBuff = OsalMemAlloc(Adapter->uiSectorSize,"!MVN"); | ||
1606 | if(NULL == pTempBuff) | 1389 | if(NULL == pTempBuff) |
1607 | { | ||
1608 | goto BeceemFlashBulkWriteStatus_EXIT; | 1390 | goto BeceemFlashBulkWriteStatus_EXIT; |
1609 | } | 1391 | |
1610 | // | 1392 | // |
1611 | // check if the data to be written is overlapped accross sectors | 1393 | // check if the data to be written is overlapped accross sectors |
1612 | // | 1394 | // |
@@ -1662,13 +1444,13 @@ static INT BeceemFlashBulkWriteStatus( | |||
1662 | if(uiNumSectTobeRead > 1) | 1444 | if(uiNumSectTobeRead > 1) |
1663 | { | 1445 | { |
1664 | 1446 | ||
1665 | OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); | 1447 | memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); |
1666 | pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr))); | 1448 | pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr))); |
1667 | uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); | 1449 | uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)); |
1668 | } | 1450 | } |
1669 | else | 1451 | else |
1670 | { | 1452 | { |
1671 | OsalMemMove(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes); | 1453 | memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes); |
1672 | } | 1454 | } |
1673 | 1455 | ||
1674 | if(IsFlash2x(Adapter)) | 1456 | if(IsFlash2x(Adapter)) |
@@ -1698,25 +1480,10 @@ static INT BeceemFlashBulkWriteStatus( | |||
1698 | { | 1480 | { |
1699 | for(uiIndex = 0;uiIndex < Adapter->uiSectorSize;uiIndex += MAX_RW_SIZE) | 1481 | for(uiIndex = 0;uiIndex < Adapter->uiSectorSize;uiIndex += MAX_RW_SIZE) |
1700 | { | 1482 | { |
1701 | #if 0 | ||
1702 | if(0 == BeceemFlashBulkRead(Adapter,uiReadBk,uiOffsetFromSectStart+uiIndex + Adapter->ulFlashCalStart ,MAX_RW_SIZE)) | ||
1703 | { | ||
1704 | for(uiReadIndex = 0;uiReadIndex < 4; uiReadIndex++) | ||
1705 | { | ||
1706 | if(*((PUINT)&pTempBuff[uiIndex+uiReadIndex*4]) != uiReadBk[uiReadIndex]) | ||
1707 | { | ||
1708 | Status = -1; | ||
1709 | goto BeceemFlashBulkWriteStatus_EXIT; | ||
1710 | |||
1711 | } | ||
1712 | } | ||
1713 | |||
1714 | } | ||
1715 | #endif | ||
1716 | 1483 | ||
1717 | if(STATUS_SUCCESS == BeceemFlashBulkRead(Adapter,(PUINT)ucReadBk,uiOffsetFromSectStart+uiIndex,MAX_RW_SIZE)) | 1484 | if(STATUS_SUCCESS == BeceemFlashBulkRead(Adapter,(PUINT)ucReadBk,uiOffsetFromSectStart+uiIndex,MAX_RW_SIZE)) |
1718 | { | 1485 | { |
1719 | if(OsalMemCompare(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE)) | 1486 | if(memcmp(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE)) |
1720 | { | 1487 | { |
1721 | Status = STATUS_FAILURE; | 1488 | Status = STATUS_FAILURE; |
1722 | goto BeceemFlashBulkWriteStatus_EXIT; | 1489 | goto BeceemFlashBulkWriteStatus_EXIT; |
@@ -1747,10 +1514,8 @@ BeceemFlashBulkWriteStatus_EXIT: | |||
1747 | { | 1514 | { |
1748 | BcmRestoreBlockProtectStatus(Adapter,ulStatus); | 1515 | BcmRestoreBlockProtectStatus(Adapter,ulStatus); |
1749 | } | 1516 | } |
1750 | if(pTempBuff) | 1517 | |
1751 | { | 1518 | kfree(pTempBuff); |
1752 | OsalMemFree(pTempBuff,Adapter->uiSectorSize); | ||
1753 | } | ||
1754 | Adapter->SelectedChip = RESET_CHIP_SELECT; | 1519 | Adapter->SelectedChip = RESET_CHIP_SELECT; |
1755 | return Status; | 1520 | return Status; |
1756 | 1521 | ||
@@ -1771,7 +1536,7 @@ BeceemFlashBulkWriteStatus_EXIT: | |||
1771 | 1536 | ||
1772 | INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter) | 1537 | INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter) |
1773 | { | 1538 | { |
1774 | PCHAR pBuff = OsalMemAlloc(BUFFER_4K,"3MVN"); | 1539 | PCHAR pBuff = kmalloc(BUFFER_4K, GFP_KERNEL); |
1775 | UINT uiEepromSize = 0; | 1540 | UINT uiEepromSize = 0; |
1776 | UINT uiIndex = 0; | 1541 | UINT uiIndex = 0; |
1777 | UINT uiBytesToCopy = 0; | 1542 | UINT uiBytesToCopy = 0; |
@@ -1787,14 +1552,14 @@ INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter) | |||
1787 | if(0 != BeceemEEPROMBulkRead(Adapter,&uiEepromSize,EEPROM_SIZE_OFFSET,4)) | 1552 | if(0 != BeceemEEPROMBulkRead(Adapter,&uiEepromSize,EEPROM_SIZE_OFFSET,4)) |
1788 | { | 1553 | { |
1789 | 1554 | ||
1790 | OsalMemFree(pBuff,BUFFER_4K); | 1555 | kfree(pBuff); |
1791 | return -1; | 1556 | return -1; |
1792 | } | 1557 | } |
1793 | 1558 | ||
1794 | uiEepromSize >>= 16; | 1559 | uiEepromSize >>= 16; |
1795 | if(uiEepromSize > 1024*1024) | 1560 | if(uiEepromSize > 1024*1024) |
1796 | { | 1561 | { |
1797 | OsalMemFree(pBuff,BUFFER_4K); | 1562 | kfree(pBuff); |
1798 | return -1; | 1563 | return -1; |
1799 | } | 1564 | } |
1800 | 1565 | ||
@@ -1820,7 +1585,7 @@ INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter) | |||
1820 | wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-4,&value, sizeof(value)); | 1585 | wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-4,&value, sizeof(value)); |
1821 | value = 0xbeadbead; | 1586 | value = 0xbeadbead; |
1822 | wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-8,&value, sizeof(value)); | 1587 | wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-8,&value, sizeof(value)); |
1823 | OsalMemFree(pBuff,MAX_RW_SIZE); | 1588 | kfree(pBuff); |
1824 | 1589 | ||
1825 | return Status; | 1590 | return Status; |
1826 | 1591 | ||
@@ -1873,16 +1638,13 @@ INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter) | |||
1873 | return -1; | 1638 | return -1; |
1874 | } | 1639 | } |
1875 | 1640 | ||
1876 | pBuff = OsalMemAlloc(uiEepromSize, 0); | 1641 | pBuff = kmalloc(uiEepromSize, GFP_KERNEL); |
1877 | |||
1878 | if ( pBuff == NULL ) | 1642 | if ( pBuff == NULL ) |
1879 | { | ||
1880 | return -1; | 1643 | return -1; |
1881 | } | ||
1882 | 1644 | ||
1883 | if(0 != BeceemNVMRead(Adapter,(PUINT)pBuff,uiCalStartAddr, uiEepromSize)) | 1645 | if(0 != BeceemNVMRead(Adapter,(PUINT)pBuff,uiCalStartAddr, uiEepromSize)) |
1884 | { | 1646 | { |
1885 | OsalMemFree(pBuff, 0); | 1647 | kfree(pBuff); |
1886 | return -1; | 1648 | return -1; |
1887 | } | 1649 | } |
1888 | 1650 | ||
@@ -1905,7 +1667,7 @@ INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter) | |||
1905 | uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize); | 1667 | uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize); |
1906 | } | 1668 | } |
1907 | 1669 | ||
1908 | OsalMemFree(pBuff, 0); | 1670 | kfree(pBuff); |
1909 | return Status; | 1671 | return Status; |
1910 | 1672 | ||
1911 | } | 1673 | } |
@@ -1947,14 +1709,14 @@ static INT BeceemEEPROMReadBackandVerify( | |||
1947 | {// for the requests more than or equal to MAX_RW_SIZE bytes, use bulk read function to make the access faster. | 1709 | {// for the requests more than or equal to MAX_RW_SIZE bytes, use bulk read function to make the access faster. |
1948 | BeceemEEPROMBulkRead(Adapter,&auiData[0],uiOffset,MAX_RW_SIZE); | 1710 | BeceemEEPROMBulkRead(Adapter,&auiData[0],uiOffset,MAX_RW_SIZE); |
1949 | 1711 | ||
1950 | if(OsalMemCompare(&pBuffer[uiIndex],&auiData[0],MAX_RW_SIZE)) | 1712 | if(memcmp(&pBuffer[uiIndex],&auiData[0],MAX_RW_SIZE)) |
1951 | { | 1713 | { |
1952 | // re-write | 1714 | // re-write |
1953 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)(pBuffer+uiIndex),uiOffset,MAX_RW_SIZE,FALSE); | 1715 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)(pBuffer+uiIndex),uiOffset,MAX_RW_SIZE,FALSE); |
1954 | mdelay(3); | 1716 | mdelay(3); |
1955 | BeceemEEPROMBulkRead(Adapter,&auiData[0],uiOffset,MAX_RW_SIZE); | 1717 | BeceemEEPROMBulkRead(Adapter,&auiData[0],uiOffset,MAX_RW_SIZE); |
1956 | 1718 | ||
1957 | if(OsalMemCompare(&pBuffer[uiIndex],&auiData[0],MAX_RW_SIZE)) | 1719 | if(memcmp(&pBuffer[uiIndex],&auiData[0],MAX_RW_SIZE)) |
1958 | { | 1720 | { |
1959 | return -1; | 1721 | return -1; |
1960 | } | 1722 | } |
@@ -1986,7 +1748,7 @@ static INT BeceemEEPROMReadBackandVerify( | |||
1986 | else | 1748 | else |
1987 | { // Handle the reads less than 4 bytes... | 1749 | { // Handle the reads less than 4 bytes... |
1988 | uiData = 0; | 1750 | uiData = 0; |
1989 | OsalMemMove(&uiData,((PUCHAR)pBuffer)+(uiIndex*sizeof(UINT)),uiNumBytes); | 1751 | memcpy(&uiData,((PUCHAR)pBuffer)+(uiIndex*sizeof(UINT)),uiNumBytes); |
1990 | BeceemEEPROMBulkRead(Adapter,&uiRdbk,uiOffset,4); | 1752 | BeceemEEPROMBulkRead(Adapter,&uiRdbk,uiOffset,4); |
1991 | 1753 | ||
1992 | if(memcmp(&uiData, &uiRdbk, uiNumBytes)) | 1754 | if(memcmp(&uiData, &uiRdbk, uiNumBytes)) |
@@ -2186,7 +1948,7 @@ INT BeceemEEPROMBulkWrite( | |||
2186 | 1948 | ||
2187 | if(uiBytesToCopy >= (16 -uiExtraBytes)) | 1949 | if(uiBytesToCopy >= (16 -uiExtraBytes)) |
2188 | { | 1950 | { |
2189 | OsalMemMove((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,MAX_RW_SIZE- uiExtraBytes); | 1951 | memcpy((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,MAX_RW_SIZE- uiExtraBytes); |
2190 | 1952 | ||
2191 | if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) ) | 1953 | if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) ) |
2192 | return STATUS_FAILURE; | 1954 | return STATUS_FAILURE; |
@@ -2197,7 +1959,7 @@ INT BeceemEEPROMBulkWrite( | |||
2197 | } | 1959 | } |
2198 | else | 1960 | else |
2199 | { | 1961 | { |
2200 | OsalMemMove((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,uiBytesToCopy); | 1962 | memcpy((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,uiBytesToCopy); |
2201 | 1963 | ||
2202 | if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) ) | 1964 | if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) ) |
2203 | return STATUS_FAILURE; | 1965 | return STATUS_FAILURE; |
@@ -2233,7 +1995,7 @@ INT BeceemEEPROMBulkWrite( | |||
2233 | // To program non 16byte aligned data, read 16byte and then update. | 1995 | // To program non 16byte aligned data, read 16byte and then update. |
2234 | // | 1996 | // |
2235 | BeceemEEPROMBulkRead(Adapter,&uiData[0],uiOffset,16); | 1997 | BeceemEEPROMBulkRead(Adapter,&uiData[0],uiOffset,16); |
2236 | OsalMemMove(&uiData[0],pBuffer+uiIndex,uiBytesToCopy); | 1998 | memcpy(&uiData[0],pBuffer+uiIndex,uiBytesToCopy); |
2237 | 1999 | ||
2238 | 2000 | ||
2239 | if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiOffset ) ) | 2001 | if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiOffset ) ) |
@@ -2535,7 +2297,7 @@ INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize) | |||
2535 | // | 2297 | // |
2536 | //----------------------------------------------------------------------------- | 2298 | //----------------------------------------------------------------------------- |
2537 | 2299 | ||
2538 | UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter, UINT FlashSectorSizeSig, UINT FlashSectorSize) | 2300 | static UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter, UINT FlashSectorSizeSig, UINT FlashSectorSize) |
2539 | { | 2301 | { |
2540 | UINT uiSectorSize = 0; | 2302 | UINT uiSectorSize = 0; |
2541 | UINT uiSectorSig = 0; | 2303 | UINT uiSectorSig = 0; |
@@ -2642,20 +2404,8 @@ static INT BcmInitEEPROMQueues(PMINI_ADAPTER Adapter) | |||
2642 | 2404 | ||
2643 | INT BcmInitNVM(PMINI_ADAPTER ps_adapter) | 2405 | INT BcmInitNVM(PMINI_ADAPTER ps_adapter) |
2644 | { | 2406 | { |
2645 | #ifdef BCM_SHM_INTERFACE | ||
2646 | #ifdef FLASH_DIRECT_ACCESS | ||
2647 | unsigned int data,data1,data2 = 1; | ||
2648 | wrm(ps_adapter, PAD_SELECT_REGISTER, &data2, 4); | ||
2649 | data1 = rdm(ps_adapter,SYS_CFG,&data,4); | ||
2650 | data1 = rdm(ps_adapter,SYS_CFG,&data,4); | ||
2651 | data2 = (data | 0x80 | 0x8000); | ||
2652 | wrm(ps_adapter,SYS_CFG, &data2,4); // over-write as Flash boot mode | ||
2653 | #endif | ||
2654 | ps_adapter->eNVMType = NVM_FLASH; | ||
2655 | #else | ||
2656 | BcmValidateNvmType(ps_adapter); | 2407 | BcmValidateNvmType(ps_adapter); |
2657 | BcmInitEEPROMQueues(ps_adapter); | 2408 | BcmInitEEPROMQueues(ps_adapter); |
2658 | #endif | ||
2659 | 2409 | ||
2660 | if(ps_adapter->eNVMType == NVM_AUTODETECT) | 2410 | if(ps_adapter->eNVMType == NVM_AUTODETECT) |
2661 | { | 2411 | { |
@@ -2684,7 +2434,7 @@ INT BcmInitNVM(PMINI_ADAPTER ps_adapter) | |||
2684 | */ | 2434 | */ |
2685 | /***************************************************************************/ | 2435 | /***************************************************************************/ |
2686 | 2436 | ||
2687 | INT BcmGetNvmSize(PMINI_ADAPTER Adapter) | 2437 | static INT BcmGetNvmSize(PMINI_ADAPTER Adapter) |
2688 | { | 2438 | { |
2689 | if(Adapter->eNVMType == NVM_EEPROM) | 2439 | if(Adapter->eNVMType == NVM_EEPROM) |
2690 | { | 2440 | { |
@@ -2708,7 +2458,7 @@ INT BcmGetNvmSize(PMINI_ADAPTER Adapter) | |||
2708 | // Returns: | 2458 | // Returns: |
2709 | // <VOID> | 2459 | // <VOID> |
2710 | //----------------------------------------------------------------------------- | 2460 | //----------------------------------------------------------------------------- |
2711 | VOID BcmValidateNvmType(PMINI_ADAPTER Adapter) | 2461 | static VOID BcmValidateNvmType(PMINI_ADAPTER Adapter) |
2712 | { | 2462 | { |
2713 | 2463 | ||
2714 | // | 2464 | // |
@@ -2775,7 +2525,7 @@ INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter) | |||
2775 | if(psAdapter->psFlash2xCSInfo == NULL) | 2525 | if(psAdapter->psFlash2xCSInfo == NULL) |
2776 | { | 2526 | { |
2777 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate memory for Flash 2.x"); | 2527 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate memory for Flash 2.x"); |
2778 | bcm_kfree(psAdapter->psFlashCSInfo); | 2528 | kfree(psAdapter->psFlashCSInfo); |
2779 | return -ENOMEM; | 2529 | return -ENOMEM; |
2780 | } | 2530 | } |
2781 | 2531 | ||
@@ -2783,8 +2533,8 @@ INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter) | |||
2783 | if(psAdapter->psFlash2xVendorInfo == NULL) | 2533 | if(psAdapter->psFlash2xVendorInfo == NULL) |
2784 | { | 2534 | { |
2785 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate Vendor Info Memory for Flash 2.x"); | 2535 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate Vendor Info Memory for Flash 2.x"); |
2786 | bcm_kfree(psAdapter->psFlashCSInfo); | 2536 | kfree(psAdapter->psFlashCSInfo); |
2787 | bcm_kfree(psAdapter->psFlash2xCSInfo); | 2537 | kfree(psAdapter->psFlash2xCSInfo); |
2788 | return -ENOMEM; | 2538 | return -ENOMEM; |
2789 | } | 2539 | } |
2790 | 2540 | ||
@@ -2798,9 +2548,9 @@ INT BcmDeAllocFlashCSStructure(PMINI_ADAPTER psAdapter) | |||
2798 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0," Adapter structure point is NULL"); | 2548 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0," Adapter structure point is NULL"); |
2799 | return -EINVAL; | 2549 | return -EINVAL; |
2800 | } | 2550 | } |
2801 | bcm_kfree(psAdapter->psFlashCSInfo); | 2551 | kfree(psAdapter->psFlashCSInfo); |
2802 | bcm_kfree(psAdapter->psFlash2xCSInfo); | 2552 | kfree(psAdapter->psFlash2xCSInfo); |
2803 | bcm_kfree(psAdapter->psFlash2xVendorInfo); | 2553 | kfree(psAdapter->psFlash2xVendorInfo); |
2804 | return STATUS_SUCCESS ; | 2554 | return STATUS_SUCCESS ; |
2805 | } | 2555 | } |
2806 | 2556 | ||
@@ -2954,7 +2704,7 @@ static INT ConvertEndianOfCSStructure(PFLASH_CS_INFO psFlashCSInfo) | |||
2954 | return STATUS_SUCCESS; | 2704 | return STATUS_SUCCESS; |
2955 | } | 2705 | } |
2956 | 2706 | ||
2957 | INT IsSectionExistInVendorInfo(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section) | 2707 | static INT IsSectionExistInVendorInfo(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section) |
2958 | { | 2708 | { |
2959 | return ( Adapter->uiVendorExtnFlag && | 2709 | return ( Adapter->uiVendorExtnFlag && |
2960 | (Adapter->psFlash2xVendorInfo->VendorSection[section].AccessFlags & FLASH2X_SECTION_PRESENT) && | 2710 | (Adapter->psFlash2xVendorInfo->VendorSection[section].AccessFlags & FLASH2X_SECTION_PRESENT) && |
@@ -3052,7 +2802,7 @@ static VOID UpdateVendorInfo(PMINI_ADAPTER Adapter) | |||
3052 | // <VOID> | 2802 | // <VOID> |
3053 | //----------------------------------------------------------------------------- | 2803 | //----------------------------------------------------------------------------- |
3054 | 2804 | ||
3055 | INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) | 2805 | static INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) |
3056 | { | 2806 | { |
3057 | //FLASH_CS_INFO sFlashCsInfo = {0}; | 2807 | //FLASH_CS_INFO sFlashCsInfo = {0}; |
3058 | 2808 | ||
@@ -3070,7 +2820,6 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) | |||
3070 | memset(Adapter->psFlashCSInfo, 0 ,sizeof(FLASH_CS_INFO)); | 2820 | memset(Adapter->psFlashCSInfo, 0 ,sizeof(FLASH_CS_INFO)); |
3071 | memset(Adapter->psFlash2xCSInfo, 0 ,sizeof(FLASH2X_CS_INFO)); | 2821 | memset(Adapter->psFlash2xCSInfo, 0 ,sizeof(FLASH2X_CS_INFO)); |
3072 | 2822 | ||
3073 | #ifndef BCM_SHM_INTERFACE | ||
3074 | if(!Adapter->bDDRInitDone) | 2823 | if(!Adapter->bDDRInitDone) |
3075 | { | 2824 | { |
3076 | { | 2825 | { |
@@ -3079,7 +2828,6 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) | |||
3079 | } | 2828 | } |
3080 | } | 2829 | } |
3081 | 2830 | ||
3082 | #endif | ||
3083 | 2831 | ||
3084 | // Reading first 8 Bytes to get the Flash Layout | 2832 | // Reading first 8 Bytes to get the Flash Layout |
3085 | // MagicNumber(4 bytes) +FlashLayoutMinorVersion(2 Bytes) +FlashLayoutMajorVersion(2 Bytes) | 2833 | // MagicNumber(4 bytes) +FlashLayoutMinorVersion(2 Bytes) +FlashLayoutMajorVersion(2 Bytes) |
@@ -3147,9 +2895,7 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) | |||
3147 | return STATUS_FAILURE; | 2895 | return STATUS_FAILURE; |
3148 | } | 2896 | } |
3149 | ConvertEndianOf2XCSStructure(Adapter->psFlash2xCSInfo); | 2897 | ConvertEndianOf2XCSStructure(Adapter->psFlash2xCSInfo); |
3150 | #ifndef BCM_SHM_INTERFACE | ||
3151 | BcmDumpFlash2XCSStructure(Adapter->psFlash2xCSInfo,Adapter); | 2898 | BcmDumpFlash2XCSStructure(Adapter->psFlash2xCSInfo,Adapter); |
3152 | #endif | ||
3153 | if((FLASH_CONTROL_STRUCT_SIGNATURE == Adapter->psFlash2xCSInfo->MagicNumber) && | 2899 | if((FLASH_CONTROL_STRUCT_SIGNATURE == Adapter->psFlash2xCSInfo->MagicNumber) && |
3154 | (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlash2xCSInfo->SCSIFirmwareVersion)) && | 2900 | (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlash2xCSInfo->SCSIFirmwareVersion)) && |
3155 | (FLASH_SECTOR_SIZE_SIG == Adapter->psFlash2xCSInfo->FlashSectorSizeSig) && | 2901 | (FLASH_SECTOR_SIZE_SIG == Adapter->psFlash2xCSInfo->FlashSectorSizeSig) && |
@@ -3181,21 +2927,10 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) | |||
3181 | Concerns: what if CS sector size does not match with this sector size ??? | 2927 | Concerns: what if CS sector size does not match with this sector size ??? |
3182 | what is the indication of AccessBitMap in CS in flash 2.x ???? | 2928 | what is the indication of AccessBitMap in CS in flash 2.x ???? |
3183 | */ | 2929 | */ |
3184 | #ifndef BCM_SHM_INTERFACE | ||
3185 | Adapter->ulFlashID = BcmReadFlashRDID(Adapter); | 2930 | Adapter->ulFlashID = BcmReadFlashRDID(Adapter); |
3186 | #endif | ||
3187 | 2931 | ||
3188 | Adapter->uiFlashLayoutMajorVersion = uiFlashLayoutMajorVersion; | 2932 | Adapter->uiFlashLayoutMajorVersion = uiFlashLayoutMajorVersion; |
3189 | 2933 | ||
3190 | #if 0 | ||
3191 | if(FLASH_PART_SST25VF080B == Adapter->ulFlashID) | ||
3192 | { | ||
3193 | // | ||
3194 | // 1MB flash has been selected. we have to use 64K as sector size no matter what is kept in FLASH_CS. | ||
3195 | // | ||
3196 | Adapter->uiSectorSize = 0x10000; | ||
3197 | } | ||
3198 | #endif | ||
3199 | 2934 | ||
3200 | return STATUS_SUCCESS ; | 2935 | return STATUS_SUCCESS ; |
3201 | } | 2936 | } |
@@ -3214,7 +2949,7 @@ INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter) | |||
3214 | // | 2949 | // |
3215 | //----------------------------------------------------------------------------- | 2950 | //----------------------------------------------------------------------------- |
3216 | 2951 | ||
3217 | NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter) | 2952 | static NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter) |
3218 | { | 2953 | { |
3219 | UINT uiData = 0; | 2954 | UINT uiData = 0; |
3220 | 2955 | ||
@@ -3569,39 +3304,6 @@ INT BcmFlash2xBulkWrite( | |||
3569 | } | 3304 | } |
3570 | 3305 | ||
3571 | /** | 3306 | /** |
3572 | * ReadDSDHeader : Read the DSD map for the DSD Section val provided in Argument. | ||
3573 | * @Adapter : Beceem Private Data Structure | ||
3574 | * @psDSDHeader :Pointer of the buffer where header has to be read | ||
3575 | * @dsd :value of the Dyanmic DSD like DSD0 of DSD1 or DSD2 | ||
3576 | * | ||
3577 | * Return Value:- | ||
3578 | * if suceeds return STATUS_SUCCESS or negative error code. | ||
3579 | **/ | ||
3580 | INT ReadDSDHeader(PMINI_ADAPTER Adapter, PDSD_HEADER psDSDHeader, FLASH2X_SECTION_VAL dsd) | ||
3581 | { | ||
3582 | INT Status = STATUS_SUCCESS; | ||
3583 | |||
3584 | Status =BcmFlash2xBulkRead(Adapter, | ||
3585 | (PUINT)psDSDHeader, | ||
3586 | dsd, | ||
3587 | Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader, | ||
3588 | sizeof(DSD_HEADER)); | ||
3589 | if(Status == STATUS_SUCCESS) | ||
3590 | { | ||
3591 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSDImageMagicNumber :0X%x", ntohl(psDSDHeader->DSDImageMagicNumber)); | ||
3592 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSDImageSize :0X%x ",ntohl(psDSDHeader->DSDImageSize)); | ||
3593 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSDImageCRC :0X%x",ntohl(psDSDHeader->DSDImageCRC)); | ||
3594 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSDImagePriority :0X%x",ntohl(psDSDHeader->DSDImagePriority)); | ||
3595 | } | ||
3596 | else | ||
3597 | { | ||
3598 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"DSD Header read is failed with status :%d", Status); | ||
3599 | } | ||
3600 | |||
3601 | return Status; | ||
3602 | } | ||
3603 | |||
3604 | /** | ||
3605 | * BcmGetActiveDSD : Set the Active DSD in Adapter Structure which has to be dumped in DDR | 3307 | * BcmGetActiveDSD : Set the Active DSD in Adapter Structure which has to be dumped in DDR |
3606 | * @Adapter :-Drivers private Data Structure | 3308 | * @Adapter :-Drivers private Data Structure |
3607 | * | 3309 | * |
@@ -3609,7 +3311,7 @@ INT ReadDSDHeader(PMINI_ADAPTER Adapter, PDSD_HEADER psDSDHeader, FLASH2X_SECTIO | |||
3609 | * Return STATUS_SUCESS if get sucess in setting the right DSD else negaive error code | 3311 | * Return STATUS_SUCESS if get sucess in setting the right DSD else negaive error code |
3610 | * | 3312 | * |
3611 | **/ | 3313 | **/ |
3612 | INT BcmGetActiveDSD(PMINI_ADAPTER Adapter) | 3314 | static INT BcmGetActiveDSD(PMINI_ADAPTER Adapter) |
3613 | { | 3315 | { |
3614 | FLASH2X_SECTION_VAL uiHighestPriDSD = 0 ; | 3316 | FLASH2X_SECTION_VAL uiHighestPriDSD = 0 ; |
3615 | 3317 | ||
@@ -3647,39 +3349,6 @@ INT BcmGetActiveDSD(PMINI_ADAPTER Adapter) | |||
3647 | return STATUS_SUCCESS; | 3349 | return STATUS_SUCCESS; |
3648 | } | 3350 | } |
3649 | 3351 | ||
3650 | /** | ||
3651 | * ReadISOUnReservedBytes : Read the ISO map for the ISO Section val provided in Argument. | ||
3652 | * @Adapter : Driver Private Data Structure | ||
3653 | * @psISOHeader :Pointer of the location where header has to be read | ||
3654 | * @IsoImage :value of the Dyanmic ISO like ISO_IMAGE1 of ISO_IMAGE2 | ||
3655 | * | ||
3656 | * Return Value:- | ||
3657 | * if suceeds return STATUS_SUCCESS or negative error code. | ||
3658 | **/ | ||
3659 | |||
3660 | INT ReadISOHeader(PMINI_ADAPTER Adapter, PISO_HEADER psISOHeader, FLASH2X_SECTION_VAL IsoImage) | ||
3661 | { | ||
3662 | INT Status = STATUS_SUCCESS; | ||
3663 | |||
3664 | Status = BcmFlash2xBulkRead(Adapter, | ||
3665 | (PUINT)psISOHeader, | ||
3666 | IsoImage, | ||
3667 | 0, | ||
3668 | sizeof(ISO_HEADER)); | ||
3669 | |||
3670 | if(Status == STATUS_SUCCESS) | ||
3671 | { | ||
3672 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISOImageMagicNumber :0X%x", ntohl(psISOHeader->ISOImageMagicNumber)); | ||
3673 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISOImageSize :0X%x ",ntohl(psISOHeader->ISOImageSize)); | ||
3674 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISOImageCRC :0X%x",ntohl(psISOHeader->ISOImageCRC)); | ||
3675 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISOImagePriority :0X%x",ntohl(psISOHeader->ISOImagePriority)); | ||
3676 | } | ||
3677 | else | ||
3678 | { | ||
3679 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "ISO Header Read failed"); | ||
3680 | } | ||
3681 | return Status; | ||
3682 | } | ||
3683 | 3352 | ||
3684 | /** | 3353 | /** |
3685 | * BcmGetActiveISO :- Set the Active ISO in Adapter Data Structue | 3354 | * BcmGetActiveISO :- Set the Active ISO in Adapter Data Structue |
@@ -3691,7 +3360,7 @@ INT ReadISOHeader(PMINI_ADAPTER Adapter, PISO_HEADER psISOHeader, FLASH2X_SECTIO | |||
3691 | * | 3360 | * |
3692 | **/ | 3361 | **/ |
3693 | 3362 | ||
3694 | INT BcmGetActiveISO(PMINI_ADAPTER Adapter) | 3363 | static INT BcmGetActiveISO(PMINI_ADAPTER Adapter) |
3695 | { | 3364 | { |
3696 | 3365 | ||
3697 | INT HighestPriISO = 0 ; | 3366 | INT HighestPriISO = 0 ; |
@@ -4588,7 +4257,7 @@ INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut) | |||
4588 | 4257 | ||
4589 | } | 4258 | } |
4590 | 4259 | ||
4591 | bcm_kfree(Buff); | 4260 | kfree(Buff); |
4592 | 4261 | ||
4593 | return Status; | 4262 | return Status; |
4594 | } | 4263 | } |
@@ -4789,7 +4458,7 @@ Return Value:- | |||
4789 | Success :- Base Address of the Flash | 4458 | Success :- Base Address of the Flash |
4790 | **/ | 4459 | **/ |
4791 | 4460 | ||
4792 | INT GetFlashBaseAddr(PMINI_ADAPTER Adapter) | 4461 | static INT GetFlashBaseAddr(PMINI_ADAPTER Adapter) |
4793 | { | 4462 | { |
4794 | 4463 | ||
4795 | UINT uiBaseAddr = 0; | 4464 | UINT uiBaseAddr = 0; |
@@ -4866,20 +4535,6 @@ INT BcmCopySection(PMINI_ADAPTER Adapter, | |||
4866 | return -EINVAL; | 4535 | return -EINVAL; |
4867 | } | 4536 | } |
4868 | 4537 | ||
4869 | #if 0 | ||
4870 | else | ||
4871 | { | ||
4872 | if((SrcSection == VSA0) || (SrcSection == VSA1) || (SrcSection == VSA2)) | ||
4873 | { | ||
4874 | if((DstSection != VSA0) && (DstSection != VSA1) && (DstSection != VSA2)) | ||
4875 | { | ||
4876 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Source and Destion secton is not of same type"); | ||
4877 | return -EINVAL; | ||
4878 | } | ||
4879 | } | ||
4880 | |||
4881 | } | ||
4882 | #endif | ||
4883 | //if offset zero means have to copy complete secton | 4538 | //if offset zero means have to copy complete secton |
4884 | 4539 | ||
4885 | if(numOfBytes == 0) | 4540 | if(numOfBytes == 0) |
@@ -4954,7 +4609,7 @@ INT BcmCopySection(PMINI_ADAPTER Adapter, | |||
4954 | BytesToBeCopied = numOfBytes; | 4609 | BytesToBeCopied = numOfBytes; |
4955 | } | 4610 | } |
4956 | }while(numOfBytes > 0) ; | 4611 | }while(numOfBytes > 0) ; |
4957 | bcm_kfree(pBuff); | 4612 | kfree(pBuff); |
4958 | Adapter->bHeaderChangeAllowed = FALSE ; | 4613 | Adapter->bHeaderChangeAllowed = FALSE ; |
4959 | return Status; | 4614 | return Status; |
4960 | } | 4615 | } |
@@ -4979,14 +4634,6 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset) | |||
4979 | UINT uiSectAlignAddr = 0; | 4634 | UINT uiSectAlignAddr = 0; |
4980 | UINT sig = 0; | 4635 | UINT sig = 0; |
4981 | 4636 | ||
4982 | #if 0 | ||
4983 | //if Chenges in Header is allowed, Return back | ||
4984 | if(Adapter->bHeaderChangeAllowed == TRUE) | ||
4985 | { | ||
4986 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Header Change is allowed"); | ||
4987 | return STATUS_SUCCESS ; | ||
4988 | } | ||
4989 | #endif | ||
4990 | //making the offset sector alligned | 4637 | //making the offset sector alligned |
4991 | uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); | 4638 | uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); |
4992 | 4639 | ||
@@ -5024,7 +4671,7 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset) | |||
5024 | //Replace Buffer content with Header | 4671 | //Replace Buffer content with Header |
5025 | memcpy(pBuff +offsetToProtect,pTempBuff,HeaderSizeToProtect); | 4672 | memcpy(pBuff +offsetToProtect,pTempBuff,HeaderSizeToProtect); |
5026 | 4673 | ||
5027 | bcm_kfree(pTempBuff); | 4674 | kfree(pTempBuff); |
5028 | } | 4675 | } |
5029 | if(bHasHeader && Adapter->bSigCorrupted) | 4676 | if(bHasHeader && Adapter->bSigCorrupted) |
5030 | { | 4677 | { |
@@ -5044,29 +4691,7 @@ INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset) | |||
5044 | 4691 | ||
5045 | return STATUS_SUCCESS ; | 4692 | return STATUS_SUCCESS ; |
5046 | } | 4693 | } |
5047 | INT BcmMakeFlashCSActive(PMINI_ADAPTER Adapter, UINT offset) | ||
5048 | { | ||
5049 | UINT GPIOConfig = 0 ; | ||
5050 | |||
5051 | |||
5052 | if(Adapter->bFlashRawRead == FALSE) | ||
5053 | { | ||
5054 | //Applicable for Flash2.x | ||
5055 | if(IsFlash2x(Adapter) == FALSE) | ||
5056 | return STATUS_SUCCESS; | ||
5057 | } | ||
5058 | 4694 | ||
5059 | if(offset/FLASH_PART_SIZE) | ||
5060 | { | ||
5061 | //bit[14..12] -> will select make Active CS1, CS2 or CS3 | ||
5062 | // Select CS1, CS2 and CS3 (CS0 is dedicated pin) | ||
5063 | rdmalt(Adapter,FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4); | ||
5064 | GPIOConfig |= (7 << 12); | ||
5065 | wrmalt(Adapter,FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4); | ||
5066 | } | ||
5067 | |||
5068 | return STATUS_SUCCESS ; | ||
5069 | } | ||
5070 | /** | 4695 | /** |
5071 | BcmDoChipSelect : This will selcet the appropriate chip for writing. | 4696 | BcmDoChipSelect : This will selcet the appropriate chip for writing. |
5072 | @Adapater :- Bcm Driver Private Data Structure | 4697 | @Adapater :- Bcm Driver Private Data Structure |
@@ -5074,7 +4699,7 @@ BcmDoChipSelect : This will selcet the appropriate chip for writing. | |||
5074 | OutPut:- | 4699 | OutPut:- |
5075 | Select the Appropriate chip and retrn status Sucess | 4700 | Select the Appropriate chip and retrn status Sucess |
5076 | **/ | 4701 | **/ |
5077 | INT BcmDoChipSelect(PMINI_ADAPTER Adapter, UINT offset) | 4702 | static INT BcmDoChipSelect(PMINI_ADAPTER Adapter, UINT offset) |
5078 | { | 4703 | { |
5079 | UINT FlashConfig = 0; | 4704 | UINT FlashConfig = 0; |
5080 | INT ChipNum = 0; | 4705 | INT ChipNum = 0; |
@@ -5365,39 +4990,6 @@ INT WriteToFlashWithoutSectorErase(PMINI_ADAPTER Adapter, | |||
5365 | return Status; | 4990 | return Status; |
5366 | } | 4991 | } |
5367 | 4992 | ||
5368 | #if 0 | ||
5369 | UINT getNumOfSubSectionWithWRPermisson(PMINI_ADAPTER Adapter, SECTION_TYPE secType) | ||
5370 | { | ||
5371 | |||
5372 | UINT numOfWRSubSec = 0; | ||
5373 | switch(secType) | ||
5374 | { | ||
5375 | case ISO : | ||
5376 | if(IsSectionWritable(Adapter,ISO_IMAGE1)) | ||
5377 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5378 | if(IsSectionWritable(Adapter,ISO_IMAGE2)) | ||
5379 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5380 | break; | ||
5381 | |||
5382 | case DSD : | ||
5383 | if(IsSectionWritable(Adapter,DSD2)) | ||
5384 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5385 | if(IsSectionWritable(Adapter,DSD1)) | ||
5386 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5387 | if(IsSectionWritable(Adapter,DSD0)) | ||
5388 | numOfWRSubSec = numOfWRSubSec + 1; | ||
5389 | break ; | ||
5390 | |||
5391 | case VSA : | ||
5392 | //for VSA Add code Here | ||
5393 | default : | ||
5394 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Invalid secton<%d> is passed", secType);\ | ||
5395 | numOfWRSubSec = 0; | ||
5396 | |||
5397 | } | ||
5398 | return numOfWRSubSec; | ||
5399 | } | ||
5400 | #endif | ||
5401 | BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section) | 4993 | BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section) |
5402 | { | 4994 | { |
5403 | 4995 | ||
@@ -5479,7 +5071,7 @@ INT IsSectionWritable(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL Section) | |||
5479 | return Status ; | 5071 | return Status ; |
5480 | } | 5072 | } |
5481 | 5073 | ||
5482 | INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) | 5074 | static INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) |
5483 | { | 5075 | { |
5484 | 5076 | ||
5485 | PUCHAR pBuff = NULL; | 5077 | PUCHAR pBuff = NULL; |
@@ -5543,16 +5135,16 @@ INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) | |||
5543 | else | 5135 | else |
5544 | { | 5136 | { |
5545 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header"); | 5137 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header"); |
5546 | bcm_kfree(pBuff); | 5138 | kfree(pBuff); |
5547 | return STATUS_FAILURE; | 5139 | return STATUS_FAILURE; |
5548 | } | 5140 | } |
5549 | 5141 | ||
5550 | bcm_kfree(pBuff); | 5142 | kfree(pBuff); |
5551 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature"); | 5143 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature"); |
5552 | return STATUS_SUCCESS ; | 5144 | return STATUS_SUCCESS ; |
5553 | } | 5145 | } |
5554 | 5146 | ||
5555 | INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) | 5147 | static INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) |
5556 | { | 5148 | { |
5557 | 5149 | ||
5558 | PUCHAR pBuff = NULL; | 5150 | PUCHAR pBuff = NULL; |
@@ -5593,14 +5185,14 @@ INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal) | |||
5593 | else | 5185 | else |
5594 | { | 5186 | { |
5595 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header"); | 5187 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header"); |
5596 | bcm_kfree(pBuff); | 5188 | kfree(pBuff); |
5597 | return STATUS_FAILURE; | 5189 | return STATUS_FAILURE; |
5598 | } | 5190 | } |
5599 | 5191 | ||
5600 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature"); | 5192 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature"); |
5601 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,pBuff,MAX_RW_SIZE); | 5193 | BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,pBuff,MAX_RW_SIZE); |
5602 | 5194 | ||
5603 | bcm_kfree(pBuff); | 5195 | kfree(pBuff); |
5604 | return STATUS_SUCCESS ; | 5196 | return STATUS_SUCCESS ; |
5605 | } | 5197 | } |
5606 | 5198 | ||