2010-09-08 15:46:36 -06:00
# include "headers.h"
# define DWORD unsigned int
2010-11-01 10:24:00 -06:00
2014-07-20 07:14:09 -06:00
static int BcmDoChipSelect ( struct bcm_mini_adapter * Adapter ,
unsigned int offset ) ;
2012-06-19 18:14:52 -06:00
static int BcmGetActiveDSD ( struct bcm_mini_adapter * Adapter ) ;
static int BcmGetActiveISO ( struct bcm_mini_adapter * Adapter ) ;
2012-06-19 18:14:53 -06:00
static unsigned int BcmGetEEPROMSize ( struct bcm_mini_adapter * Adapter ) ;
2012-06-19 18:14:52 -06:00
static int BcmGetFlashCSInfo ( struct bcm_mini_adapter * Adapter ) ;
2014-07-20 07:14:09 -06:00
static unsigned int BcmGetFlashSectorSize ( struct bcm_mini_adapter * Adapter ,
unsigned int FlashSectorSizeSig ,
unsigned int FlashSectorSize ) ;
2012-05-26 10:05:12 -06:00
static VOID BcmValidateNvmType ( struct bcm_mini_adapter * Adapter ) ;
2012-06-19 18:14:52 -06:00
static int BcmGetNvmSize ( struct bcm_mini_adapter * Adapter ) ;
2012-06-19 18:14:53 -06:00
static unsigned int BcmGetFlashSize ( struct bcm_mini_adapter * Adapter ) ;
2012-12-21 13:10:36 -07:00
static enum bcm_nvm_type BcmGetNvmType ( struct bcm_mini_adapter * Adapter ) ;
2012-05-26 10:05:12 -06:00
2014-07-20 07:14:09 -06:00
static int BcmGetSectionValEndOffset ( struct bcm_mini_adapter * Adapter ,
enum bcm_flash2x_section_val eFlash2xSectionVal ) ;
static B_UINT8 IsOffsetWritable ( struct bcm_mini_adapter * Adapter ,
unsigned int uiOffset ) ;
static int IsSectionWritable ( struct bcm_mini_adapter * Adapter ,
enum bcm_flash2x_section_val Section ) ;
static int IsSectionExistInVendorInfo ( struct bcm_mini_adapter * Adapter ,
enum bcm_flash2x_section_val section ) ;
static int ReadDSDPriority ( struct bcm_mini_adapter * Adapter ,
enum bcm_flash2x_section_val dsd ) ;
static int ReadDSDSignature ( struct bcm_mini_adapter * Adapter ,
enum bcm_flash2x_section_val dsd ) ;
static int ReadISOPriority ( struct bcm_mini_adapter * Adapter ,
enum bcm_flash2x_section_val iso ) ;
static int ReadISOSignature ( struct bcm_mini_adapter * Adapter ,
enum bcm_flash2x_section_val iso ) ;
static int CorruptDSDSig ( struct bcm_mini_adapter * Adapter ,
enum bcm_flash2x_section_val eFlash2xSectionVal ) ;
static int CorruptISOSig ( struct bcm_mini_adapter * Adapter ,
enum bcm_flash2x_section_val eFlash2xSectionVal ) ;
static int SaveHeaderIfPresent ( struct bcm_mini_adapter * Adapter ,
PUCHAR pBuff ,
unsigned int uiSectAlignAddr ) ;
static int WriteToFlashWithoutSectorErase ( struct bcm_mini_adapter * Adapter ,
PUINT pBuff ,
enum bcm_flash2x_section_val eFlash2xSectionVal ,
unsigned int uiOffset ,
unsigned int uiNumBytes ) ;
2012-11-22 12:48:50 -07:00
static enum bcm_flash2x_section_val getHighestPriDSD ( struct bcm_mini_adapter * Adapter ) ;
static enum bcm_flash2x_section_val getHighestPriISO ( struct bcm_mini_adapter * Adapter ) ;
2010-11-01 10:24:00 -06:00
2012-06-19 18:14:52 -06:00
static int BeceemFlashBulkRead (
2012-05-26 10:05:12 -06:00
struct bcm_mini_adapter * Adapter ,
2010-11-01 10:24:00 -06:00
PUINT pBuffer ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
unsigned int uiNumBytes ) ;
2010-11-01 10:24:00 -06:00
2012-06-19 18:14:52 -06:00
static int BeceemFlashBulkWrite (
2012-05-26 10:05:12 -06:00
struct bcm_mini_adapter * Adapter ,
2010-11-01 10:24:00 -06:00
PUINT pBuffer ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
unsigned int uiNumBytes ,
2013-10-28 02:35:59 -06:00
bool bVerify ) ;
2010-11-01 10:24:00 -06:00
2012-06-19 18:14:52 -06:00
static int GetFlashBaseAddr ( struct bcm_mini_adapter * Adapter ) ;
2010-11-01 10:24:00 -06:00
2012-06-19 18:14:53 -06:00
static int ReadBeceemEEPROMBulk ( struct bcm_mini_adapter * Adapter , unsigned int dwAddress , unsigned int * pdwData , unsigned int dwNumData ) ;
2010-11-01 10:24:00 -06:00
2012-06-06 20:54:29 -06:00
/* Procedure: ReadEEPROMStatusRegister
*
* Description : Reads the standard EEPROM Status Register .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* Returns :
* OSAL_STATUS_CODE
*/
2012-06-06 20:54:27 -06:00
static UCHAR ReadEEPROMStatusRegister ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
UCHAR uiData = 0 ;
2012-06-06 20:54:27 -06:00
DWORD dwRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY ;
2012-06-19 18:14:53 -06:00
unsigned int uiStatus = 0 ;
unsigned int value = 0 ;
unsigned int value1 = 0 ;
2010-09-08 15:46:36 -06:00
/* Read the EEPROM status register */
2012-06-06 20:54:27 -06:00
value = EEPROM_READ_STATUS_REGISTER ;
wrmalt ( Adapter , EEPROM_CMDQ_SPI_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
while ( dwRetries ! = 0 ) {
2012-06-06 20:54:27 -06:00
value = 0 ;
uiStatus = 0 ;
2011-11-06 07:40:11 -07:00
rdmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & uiStatus , sizeof ( uiStatus ) ) ;
2012-06-06 20:54:28 -06:00
if ( Adapter - > device_removed = = TRUE ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Modem has got removed hence exiting.... " ) ;
2010-09-08 15:46:36 -06:00
break ;
}
/* Wait for Avail bit to be set. */
2012-06-06 20:54:28 -06:00
if ( ( uiStatus & EEPROM_READ_DATA_AVAIL ) ! = 0 ) {
2010-09-08 15:46:36 -06:00
/* Clear the Avail/Full bits - which ever is set. */
value = uiStatus & ( EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL ) ;
2012-06-06 20:54:27 -06:00
wrmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
value = 0 ;
2011-11-06 07:40:11 -07:00
rdmalt ( Adapter , EEPROM_READ_DATAQ_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
uiData = ( UCHAR ) value ;
break ;
}
2012-06-06 20:54:27 -06:00
dwRetries - - ;
2012-06-06 20:54:28 -06:00
if ( dwRetries = = 0 ) {
2012-06-06 20:54:27 -06:00
rdmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & value , sizeof ( value ) ) ;
rdmalt ( Adapter , EEPROM_SPI_Q_STATUS_REG , & value1 , sizeof ( value1 ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " 0x3004 = %x 0x3008 = %x, retries = %d failed. \n " , value , value1 , MAX_EEPROM_RETRIES * RETRIES_PER_DELAY ) ;
2010-09-08 15:46:36 -06:00
return uiData ;
}
2012-06-06 20:54:27 -06:00
if ( ! ( dwRetries % RETRIES_PER_DELAY ) )
2012-06-06 20:54:31 -06:00
udelay ( 1000 ) ;
2013-09-10 09:44:39 -06:00
uiStatus = 0 ;
2010-09-08 15:46:36 -06:00
}
return uiData ;
} /* ReadEEPROMStatusRegister */
2012-06-06 20:54:29 -06:00
/*
* Procedure : ReadBeceemEEPROMBulk
*
* Description : This routine reads 16 Byte data from EEPROM
*
* Arguments :
* Adapter - ptr to Adapter object instance
* dwAddress - EEPROM Offset to read the data from .
* pdwData - Pointer to double word where data needs to be stored in . // dwNumWords - Number of words. Valid values are 4 ONLY.
*
* Returns :
* OSAL_STATUS_CODE :
*/
2010-09-08 15:46:36 -06:00
2014-03-13 12:02:46 -06:00
static int ReadBeceemEEPROMBulk ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
DWORD dwAddress ,
DWORD * pdwData ,
DWORD dwNumWords )
2010-09-08 15:46:36 -06:00
{
DWORD dwIndex = 0 ;
2012-06-06 20:54:27 -06:00
DWORD dwRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY ;
2012-06-19 18:14:53 -06:00
unsigned int uiStatus = 0 ;
unsigned int value = 0 ;
unsigned int value1 = 0 ;
2010-09-08 15:46:36 -06:00
UCHAR * pvalue ;
/* Flush the read and cmd queue. */
2012-06-06 20:54:27 -06:00
value = ( EEPROM_READ_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH ) ;
wrmalt ( Adapter , SPI_FLUSH_REG , & value , sizeof ( value ) ) ;
value = 0 ;
wrmalt ( Adapter , SPI_FLUSH_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
/* Clear the Avail/Full bits. */
2012-06-06 20:54:27 -06:00
value = ( EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL ) ;
wrmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
value = dwAddress | ( ( dwNumWords = = 4 ) ? EEPROM_16_BYTE_PAGE_READ : EEPROM_4_BYTE_PAGE_READ ) ;
wrmalt ( Adapter , EEPROM_CMDQ_SPI_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
while ( dwRetries ! = 0 ) {
2010-09-08 15:46:36 -06:00
uiStatus = 0 ;
2011-11-06 07:40:11 -07:00
rdmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & uiStatus , sizeof ( uiStatus ) ) ;
2012-06-06 20:54:28 -06:00
if ( Adapter - > device_removed = = TRUE ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Modem has got Removed.hence exiting from loop... " ) ;
2010-09-08 15:46:36 -06:00
return - ENODEV ;
}
/* If we are reading 16 bytes we want to be sure that the queue
* is full before we read . In the other cases we are ok if the
2012-06-06 20:54:29 -06:00
* queue has data available
*/
2012-06-06 20:54:28 -06:00
if ( dwNumWords = = 4 ) {
if ( ( uiStatus & EEPROM_READ_DATA_FULL ) ! = 0 ) {
2010-09-08 15:46:36 -06:00
/* Clear the Avail/Full bits - which ever is set. */
2012-06-06 20:54:27 -06:00
value = ( uiStatus & ( EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL ) ) ;
wrmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
break ;
}
2012-06-06 20:54:28 -06:00
} else if ( dwNumWords = = 1 ) {
if ( ( uiStatus & EEPROM_READ_DATA_AVAIL ) ! = 0 ) {
2010-09-08 15:46:36 -06:00
/* We just got Avail and we have to read 32bits so we
2012-06-06 20:54:29 -06:00
* need this sleep for Cardbus kind of devices .
*/
2012-06-06 20:54:27 -06:00
if ( Adapter - > chip_id = = 0xBECE0210 )
udelay ( 800 ) ;
2010-09-08 15:46:36 -06:00
/* Clear the Avail/Full bits - which ever is set. */
2012-06-06 20:54:27 -06:00
value = ( uiStatus & ( EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL ) ) ;
wrmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
break ;
}
}
uiStatus = 0 ;
dwRetries - - ;
2012-06-06 20:54:28 -06:00
if ( dwRetries = = 0 ) {
2012-06-06 20:54:27 -06:00
value = 0 ;
value1 = 0 ;
2011-11-06 07:40:11 -07:00
rdmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & value , sizeof ( value ) ) ;
rdmalt ( Adapter , EEPROM_SPI_Q_STATUS_REG , & value1 , sizeof ( value1 ) ) ;
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " dwNumWords %d 0x3004 = %x 0x3008 = %x retries = %d failed. \n " ,
dwNumWords , value , value1 , MAX_EEPROM_RETRIES * RETRIES_PER_DELAY ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:27 -06:00
if ( ! ( dwRetries % RETRIES_PER_DELAY ) )
2012-06-06 20:54:31 -06:00
udelay ( 1000 ) ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:28 -06:00
for ( dwIndex = 0 ; dwIndex < dwNumWords ; dwIndex + + ) {
2010-09-08 15:46:36 -06:00
/* We get only a byte at a time - from LSB to MSB. We shift it into an integer. */
pvalue = ( PUCHAR ) ( pdwData + dwIndex ) ;
2012-06-06 20:54:27 -06:00
value = 0 ;
2011-11-06 07:40:11 -07:00
rdmalt ( Adapter , EEPROM_READ_DATAQ_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
pvalue [ 0 ] = value ;
value = 0 ;
2011-11-06 07:40:11 -07:00
rdmalt ( Adapter , EEPROM_READ_DATAQ_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
pvalue [ 1 ] = value ;
2012-06-06 20:54:27 -06:00
value = 0 ;
2011-11-06 07:40:11 -07:00
rdmalt ( Adapter , EEPROM_READ_DATAQ_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
pvalue [ 2 ] = value ;
value = 0 ;
2011-11-06 07:40:11 -07:00
rdmalt ( Adapter , EEPROM_READ_DATAQ_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
pvalue [ 3 ] = value ;
}
return STATUS_SUCCESS ;
} /* ReadBeceemEEPROMBulk() */
2012-06-06 20:54:29 -06:00
/*
* Procedure : ReadBeceemEEPROM
*
* Description : This routine reads 4 data from EEPROM . It uses 1 or 2 page
* reads to do this operation .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* uiOffset - EEPROM Offset to read the data from .
* pBuffer - Pointer to word where data needs to be stored in .
*
* Returns :
* OSAL_STATUS_CODE :
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
int ReadBeceemEEPROM ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
DWORD uiOffset ,
DWORD * pBuffer )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiData [ 8 ] = { 0 } ;
unsigned int uiByteOffset = 0 ;
unsigned int uiTempOffset = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " ====> " ) ;
2010-09-08 15:46:36 -06:00
uiTempOffset = uiOffset - ( uiOffset % MAX_RW_SIZE ) ;
uiByteOffset = uiOffset - uiTempOffset ;
ReadBeceemEEPROMBulk ( Adapter , uiTempOffset , ( PUINT ) & uiData [ 0 ] , 4 ) ;
/* A word can overlap at most over 2 pages. In that case we read the
2012-06-06 20:54:29 -06:00
* next page too .
*/
2012-06-06 20:54:27 -06:00
if ( uiByteOffset > 12 )
2010-09-08 15:46:36 -06:00
ReadBeceemEEPROMBulk ( Adapter , uiTempOffset + MAX_RW_SIZE , ( PUINT ) & uiData [ 4 ] , 4 ) ;
2012-06-06 20:54:27 -06:00
memcpy ( ( PUCHAR ) pBuffer , ( ( ( PUCHAR ) & uiData [ 0 ] ) + uiByteOffset ) , 4 ) ;
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
} /* ReadBeceemEEPROM() */
2012-06-19 18:14:52 -06:00
int ReadMacAddressFromNVM ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:52 -06:00
int Status ;
2010-11-01 12:06:24 -06:00
unsigned char puMacAddr [ 6 ] ;
2010-09-08 15:46:36 -06:00
Status = BeceemNVMRead ( Adapter ,
( PUINT ) & puMacAddr [ 0 ] ,
INIT_PARAMS_1_MACADDRESS_ADDRESS ,
MAC_ADDRESS_SIZE ) ;
2012-06-06 20:54:27 -06:00
if ( Status = = STATUS_SUCCESS )
2010-11-01 12:06:24 -06:00
memcpy ( Adapter - > dev - > dev_addr , puMacAddr , MAC_ADDRESS_SIZE ) ;
2010-09-08 15:46:36 -06:00
return Status ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BeceemEEPROMBulkRead
*
* Description : Reads the EEPROM and returns the Data .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* pBuffer - Buffer to store the data read from EEPROM
* uiOffset - Offset of EEPROM from where data should be read
* uiNumBytes - Number of bytes to be read from the EEPROM .
*
* Returns :
* OSAL_STATUS_SUCCESS - if EEPROM read is successful .
* < FAILURE > - if failed .
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
int BeceemEEPROMBulkRead ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
PUINT pBuffer ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
unsigned int uiNumBytes )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiData [ 4 ] = { 0 } ;
/* unsigned int uiAddress = 0; */
unsigned int uiBytesRemaining = uiNumBytes ;
unsigned int uiIndex = 0 ;
unsigned int uiTempOffset = 0 ;
unsigned int uiExtraBytes = 0 ;
unsigned int uiFailureRetries = 0 ;
2010-09-08 15:46:36 -06:00
PUCHAR pcBuff = ( PUCHAR ) pBuffer ;
2012-06-06 20:54:28 -06:00
if ( uiOffset % MAX_RW_SIZE & & uiBytesRemaining ) {
2012-06-06 20:54:27 -06:00
uiTempOffset = uiOffset - ( uiOffset % MAX_RW_SIZE ) ;
uiExtraBytes = uiOffset - uiTempOffset ;
ReadBeceemEEPROMBulk ( Adapter , uiTempOffset , ( PUINT ) & uiData [ 0 ] , 4 ) ;
2012-06-06 20:54:28 -06:00
if ( uiBytesRemaining > = ( MAX_RW_SIZE - uiExtraBytes ) ) {
2012-06-06 20:54:27 -06:00
memcpy ( pBuffer , ( ( ( PUCHAR ) & uiData [ 0 ] ) + uiExtraBytes ) , MAX_RW_SIZE - uiExtraBytes ) ;
2010-09-08 15:46:36 -06:00
uiBytesRemaining - = ( MAX_RW_SIZE - uiExtraBytes ) ;
uiIndex + = ( MAX_RW_SIZE - uiExtraBytes ) ;
uiOffset + = ( MAX_RW_SIZE - uiExtraBytes ) ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
memcpy ( pBuffer , ( ( ( PUCHAR ) & uiData [ 0 ] ) + uiExtraBytes ) , uiBytesRemaining ) ;
2010-09-08 15:46:36 -06:00
uiIndex + = uiBytesRemaining ;
uiOffset + = uiBytesRemaining ;
uiBytesRemaining = 0 ;
}
}
2012-06-06 20:54:28 -06:00
while ( uiBytesRemaining & & uiFailureRetries ! = 128 ) {
2012-06-06 20:54:27 -06:00
if ( Adapter - > device_removed )
2010-09-08 15:46:36 -06:00
return - 1 ;
2012-06-06 20:54:28 -06:00
if ( uiBytesRemaining > = MAX_RW_SIZE ) {
2010-09-08 15:46:36 -06:00
/* For the requests more than or equal to 16 bytes, use bulk
* read function to make the access faster .
2012-06-06 20:54:29 -06:00
* We read 4 Dwords of data
*/
2012-06-19 18:14:55 -06:00
if ( ReadBeceemEEPROMBulk ( Adapter , uiOffset , & uiData [ 0 ] , 4 ) = = 0 ) {
2012-06-06 20:54:27 -06:00
memcpy ( pcBuff + uiIndex , & uiData [ 0 ] , MAX_RW_SIZE ) ;
2010-09-08 15:46:36 -06:00
uiOffset + = MAX_RW_SIZE ;
uiBytesRemaining - = MAX_RW_SIZE ;
uiIndex + = MAX_RW_SIZE ;
2012-06-06 20:54:28 -06:00
} else {
2010-09-08 15:46:36 -06:00
uiFailureRetries + + ;
2012-06-06 20:54:29 -06:00
mdelay ( 3 ) ; /* sleep for a while before retry... */
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:28 -06:00
} else if ( uiBytesRemaining > = 4 ) {
2012-06-19 18:14:55 -06:00
if ( ReadBeceemEEPROM ( Adapter , uiOffset , & uiData [ 0 ] ) = = 0 ) {
2012-06-06 20:54:27 -06:00
memcpy ( pcBuff + uiIndex , & uiData [ 0 ] , 4 ) ;
2010-09-08 15:46:36 -06:00
uiOffset + = 4 ;
uiBytesRemaining - = 4 ;
2012-06-06 20:54:27 -06:00
uiIndex + = 4 ;
2012-06-06 20:54:28 -06:00
} else {
2010-09-08 15:46:36 -06:00
uiFailureRetries + + ;
2012-06-06 20:54:29 -06:00
mdelay ( 3 ) ; /* sleep for a while before retry... */
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:29 -06:00
/* Handle the reads less than 4 bytes... */
2010-09-08 15:46:36 -06:00
PUCHAR pCharBuff = ( PUCHAR ) pBuffer ;
2014-07-09 09:59:29 -06:00
2010-09-08 15:46:36 -06:00
pCharBuff + = uiIndex ;
2012-06-19 18:14:55 -06:00
if ( ReadBeceemEEPROM ( Adapter , uiOffset , & uiData [ 0 ] ) = = 0 ) {
2012-06-06 20:54:29 -06:00
memcpy ( pCharBuff , & uiData [ 0 ] , uiBytesRemaining ) ; /* copy only bytes requested. */
2010-09-08 15:46:36 -06:00
uiBytesRemaining = 0 ;
2012-06-06 20:54:28 -06:00
} else {
2010-09-08 15:46:36 -06:00
uiFailureRetries + + ;
2012-06-06 20:54:29 -06:00
mdelay ( 3 ) ; /* sleep for a while before retry... */
2010-09-08 15:46:36 -06:00
}
}
}
return 0 ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BeceemFlashBulkRead
*
* Description : Reads the FLASH and returns the Data .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* pBuffer - Buffer to store the data read from FLASH
* uiOffset - Offset of FLASH from where data should be read
* uiNumBytes - Number of bytes to be read from the FLASH .
*
* Returns :
* OSAL_STATUS_SUCCESS - if FLASH read is successful .
* < FAILURE > - if failed .
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int BeceemFlashBulkRead ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
PUINT pBuffer ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
unsigned int uiNumBytes )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiIndex = 0 ;
unsigned int uiBytesToRead = uiNumBytes ;
2012-06-19 18:14:52 -06:00
int Status = 0 ;
2012-06-19 18:14:53 -06:00
unsigned int uiPartOffset = 0 ;
2011-11-06 07:40:11 -07:00
int bytes ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( Adapter - > device_removed ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Device Got Removed " ) ;
2010-09-08 15:46:36 -06:00
return - ENODEV ;
}
2012-06-06 20:54:29 -06:00
/* Adding flash Base address
* uiOffset = uiOffset + GetFlashBaseAddr ( Adapter ) ;
*/
2012-06-06 20:54:27 -06:00
# if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
Status = bcmflash_raw_read ( ( uiOffset / FLASH_PART_SIZE ) , ( uiOffset % FLASH_PART_SIZE ) , ( unsigned char * ) pBuffer , uiNumBytes ) ;
return Status ;
# endif
2010-09-08 15:46:36 -06:00
Adapter - > SelectedChip = RESET_CHIP_SELECT ;
2012-06-06 20:54:28 -06:00
if ( uiOffset % MAX_RW_SIZE ) {
2012-06-06 20:54:27 -06:00
BcmDoChipSelect ( Adapter , uiOffset ) ;
2010-09-08 15:46:36 -06:00
uiPartOffset = ( uiOffset & ( FLASH_PART_SIZE - 1 ) ) + GetFlashBaseAddr ( Adapter ) ;
2012-06-06 20:54:27 -06:00
uiBytesToRead = MAX_RW_SIZE - ( uiOffset % MAX_RW_SIZE ) ;
uiBytesToRead = MIN ( uiNumBytes , uiBytesToRead ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
bytes = rdm ( Adapter , uiPartOffset , ( PCHAR ) pBuffer + uiIndex , uiBytesToRead ) ;
2011-11-06 07:40:11 -07:00
if ( bytes < 0 ) {
Status = bytes ;
2010-09-08 15:46:36 -06:00
Adapter - > SelectedChip = RESET_CHIP_SELECT ;
return Status ;
}
uiIndex + = uiBytesToRead ;
uiOffset + = uiBytesToRead ;
uiNumBytes - = uiBytesToRead ;
}
2012-06-06 20:54:28 -06:00
while ( uiNumBytes ) {
2012-06-06 20:54:27 -06:00
BcmDoChipSelect ( Adapter , uiOffset ) ;
2010-09-08 15:46:36 -06:00
uiPartOffset = ( uiOffset & ( FLASH_PART_SIZE - 1 ) ) + GetFlashBaseAddr ( Adapter ) ;
2012-06-06 20:54:27 -06:00
uiBytesToRead = MIN ( uiNumBytes , MAX_RW_SIZE ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
bytes = rdm ( Adapter , uiPartOffset , ( PCHAR ) pBuffer + uiIndex , uiBytesToRead ) ;
2011-11-06 07:40:11 -07:00
if ( bytes < 0 ) {
Status = bytes ;
2010-09-08 15:46:36 -06:00
break ;
}
uiIndex + = uiBytesToRead ;
uiOffset + = uiBytesToRead ;
uiNumBytes - = uiBytesToRead ;
}
Adapter - > SelectedChip = RESET_CHIP_SELECT ;
return Status ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BcmGetFlashSize
*
* Description : Finds the size of FLASH .
*
* Arguments :
* Adapter - ptr to Adapter object instance
*
* Returns :
2012-06-19 18:14:53 -06:00
* unsigned int - size of the FLASH Storage .
2012-06-06 20:54:29 -06:00
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:53 -06:00
static unsigned int BcmGetFlashSize ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-06 20:54:27 -06:00
if ( IsFlash2x ( Adapter ) )
2012-11-30 23:15:52 -07:00
return Adapter - > psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader + sizeof ( struct bcm_dsd_header ) ;
2010-09-08 15:46:36 -06:00
else
2012-06-06 20:54:27 -06:00
return 32 * 1024 ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BcmGetEEPROMSize
*
* Description : Finds the size of EEPROM .
*
* Arguments :
* Adapter - ptr to Adapter object instance
*
* Returns :
2012-06-19 18:14:53 -06:00
* unsigned int - size of the EEPROM Storage .
2012-06-06 20:54:29 -06:00
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:53 -06:00
static unsigned int BcmGetEEPROMSize ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiData = 0 ;
unsigned int uiIndex = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/*
* if EEPROM is present and already Calibrated , it will have
* ' BECM ' string at 0 th offset .
* To find the EEPROM size read the possible boundaries of the
* EEPROM like 4 K , 8 K etc . . accessing the EEPROM beyond its size will
* result in wrap around . So when we get the End of the EEPROM we will
* get ' BECM ' string which is indeed at offset 0.
*/
2012-06-06 20:54:27 -06:00
BeceemEEPROMBulkRead ( Adapter , & uiData , 0x0 , 4 ) ;
2012-06-06 20:54:28 -06:00
if ( uiData = = BECM ) {
for ( uiIndex = 2 ; uiIndex < = 256 ; uiIndex * = 2 ) {
2012-06-06 20:54:27 -06:00
BeceemEEPROMBulkRead ( Adapter , & uiData , uiIndex * 1024 , 4 ) ;
if ( uiData = = BECM )
return uiIndex * 1024 ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:29 -06:00
/*
* EEPROM may not be present or not programmed
*/
2012-06-06 20:54:27 -06:00
uiData = 0xBABEFACE ;
2012-06-19 18:14:55 -06:00
if ( BeceemEEPROMBulkWrite ( Adapter , ( PUCHAR ) & uiData , 0 , 4 , TRUE ) = = 0 ) {
2010-09-08 15:46:36 -06:00
uiData = 0 ;
2012-06-06 20:54:28 -06:00
for ( uiIndex = 2 ; uiIndex < = 256 ; uiIndex * = 2 ) {
2012-06-06 20:54:27 -06:00
BeceemEEPROMBulkRead ( Adapter , & uiData , uiIndex * 1024 , 4 ) ;
if ( uiData = = 0xBABEFACE )
return uiIndex * 1024 ;
2010-09-08 15:46:36 -06:00
}
}
}
return 0 ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : FlashSectorErase
*
* Description : Finds the sector size of the FLASH .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* addr - sector start address
* numOfSectors - number of sectors to be erased .
*
* Returns :
* OSAL_STATUS_CODE
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int FlashSectorErase ( struct bcm_mini_adapter * Adapter ,
2012-06-19 18:14:53 -06:00
unsigned int addr ,
unsigned int numOfSectors )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int iIndex = 0 , iRetries = 0 ;
unsigned int uiStatus = 0 ;
unsigned int value ;
2011-11-06 07:40:11 -07:00
int bytes ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
for ( iIndex = 0 ; iIndex < numOfSectors ; iIndex + + ) {
2010-09-08 15:46:36 -06:00
value = 0x06000000 ;
wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) ;
value = ( 0xd8000000 | ( addr & 0xFFFFFF ) ) ;
wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) ;
iRetries = 0 ;
2012-06-06 20:54:28 -06:00
do {
2010-09-08 15:46:36 -06:00
value = ( FLASH_CMD_STATUS_REG_READ < < 24 ) ;
2012-06-06 20:54:28 -06:00
if ( wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Programing of FLASH_SPI_CMDQ_REG fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2011-11-06 07:40:11 -07:00
bytes = rdmalt ( Adapter , FLASH_SPI_READQ_REG , & uiStatus , sizeof ( uiStatus ) ) ;
if ( bytes < 0 ) {
uiStatus = bytes ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Reading status of FLASH_SPI_READQ_REG fails " ) ;
return uiStatus ;
2010-09-08 15:46:36 -06:00
}
iRetries + + ;
2012-06-06 20:54:29 -06:00
/* After every try lets make the CPU free for 10 ms. generally time taken by the
* the sector erase cycle is 500 ms to 40000 msec . hence sleeping 10 ms
* won ' t hamper performance in any case .
*/
2012-09-13 22:37:33 -06:00
mdelay ( 10 ) ;
2012-06-06 20:54:27 -06:00
} while ( ( uiStatus & 0x1 ) & & ( iRetries < 400 ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiStatus & 0x1 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " iRetries crossing the limit of 80000 \n " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
addr + = Adapter - > uiSectorSize ;
}
return 0 ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : flashByteWrite
*
* Description : Performs Byte by Byte write to flash
*
* Arguments :
* Adapter - ptr to Adapter object instance
* uiOffset - Offset of the flash where data needs to be written to .
* pData - Address of Data to be written .
* Returns :
* OSAL_STATUS_CODE
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int flashByteWrite ( struct bcm_mini_adapter * Adapter ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
2012-06-06 20:54:27 -06:00
PVOID pData )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiStatus = 0 ;
2012-06-19 18:14:52 -06:00
int iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY ; /* 3 */
2012-06-19 18:14:53 -06:00
unsigned int value ;
2010-09-08 15:46:36 -06:00
ULONG ulData = * ( PUCHAR ) pData ;
2011-11-06 07:40:11 -07:00
int bytes ;
2012-06-06 20:54:29 -06:00
/*
* need not write 0xFF because write requires an erase and erase will
* make whole sector 0xFF .
*/
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( 0xFF = = ulData )
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
2012-06-06 20:54:29 -06:00
/* DumpDebug(NVM_RW,("flashWrite ====>\n")); */
2010-09-08 15:46:36 -06:00
value = ( FLASH_CMD_WRITE_ENABLE < < 24 ) ;
2012-06-06 20:54:28 -06:00
if ( wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Write enable in FLASH_SPI_CMDQ_REG register fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( wrm ( Adapter , FLASH_SPI_WRITEQ_REG , ( PCHAR ) & ulData , 4 ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " DATA Write on FLASH_SPI_WRITEQ_REG fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
value = ( 0x02000000 | ( uiOffset & 0xFFFFFF ) ) ;
2012-06-06 20:54:28 -06:00
if ( wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Programming of FLASH_SPI_CMDQ_REG fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:29 -06:00
/* __udelay(950); */
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
do {
2010-09-08 15:46:36 -06:00
value = ( FLASH_CMD_STATUS_REG_READ < < 24 ) ;
2012-06-06 20:54:28 -06:00
if ( wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Programing of FLASH_SPI_CMDQ_REG fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
2012-06-06 20:54:27 -06:00
}
2012-06-06 20:54:29 -06:00
/* __udelay(1); */
2011-11-06 07:40:11 -07:00
bytes = rdmalt ( Adapter , FLASH_SPI_READQ_REG , & uiStatus , sizeof ( uiStatus ) ) ;
if ( bytes < 0 ) {
uiStatus = bytes ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Reading status of FLASH_SPI_READQ_REG fails " ) ;
return uiStatus ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
iRetries - - ;
if ( iRetries & & ( ( iRetries % FLASH_PER_RETRIES_DELAY ) = = 0 ) )
2012-06-06 20:54:31 -06:00
udelay ( 1000 ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
} while ( ( uiStatus & 0x1 ) & & ( iRetries > 0 ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiStatus & 0x1 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Flash Write fails even after checking status for 200 times. " ) ;
return STATUS_FAILURE ;
2010-09-08 15:46:36 -06:00
}
return STATUS_SUCCESS ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : flashWrite
*
* Description : Performs write to flash
*
* Arguments :
* Adapter - ptr to Adapter object instance
* uiOffset - Offset of the flash where data needs to be written to .
* pData - Address of Data to be written .
* Returns :
* OSAL_STATUS_CODE
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int flashWrite ( struct bcm_mini_adapter * Adapter ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
2012-06-06 20:54:27 -06:00
PVOID pData )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
/* unsigned int uiStatus = 0;
2012-06-19 18:14:52 -06:00
* int iRetries = 0 ;
2012-06-19 18:14:53 -06:00
* unsigned int uiReadBack = 0 ;
2012-06-06 20:54:29 -06:00
*/
2012-06-19 18:14:53 -06:00
unsigned int uiStatus = 0 ;
2012-06-19 18:14:52 -06:00
int iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY ; /* 3 */
2012-06-19 18:14:53 -06:00
unsigned int value ;
unsigned int uiErasePattern [ 4 ] = { 0xFFFFFFFF , 0xFFFFFFFF , 0xFFFFFFFF , 0xFFFFFFFF } ;
2011-11-06 07:40:11 -07:00
int bytes ;
2012-06-06 20:54:29 -06:00
/*
* need not write 0xFFFFFFFF because write requires an erase and erase will
* make whole sector 0xFFFFFFFF .
*/
2010-11-01 07:35:21 -06:00
if ( ! memcmp ( pData , uiErasePattern , MAX_RW_SIZE ) )
2010-09-08 15:46:36 -06:00
return 0 ;
value = ( FLASH_CMD_WRITE_ENABLE < < 24 ) ;
2012-06-06 20:54:28 -06:00
if ( wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Write Enable of FLASH_SPI_CMDQ_REG fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( wrm ( Adapter , uiOffset , ( PCHAR ) pData , MAX_RW_SIZE ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Data write fails... " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:29 -06:00
/* __udelay(950); */
2012-06-06 20:54:28 -06:00
do {
2010-09-08 15:46:36 -06:00
value = ( FLASH_CMD_STATUS_REG_READ < < 24 ) ;
2012-06-06 20:54:28 -06:00
if ( wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Programing of FLASH_SPI_CMDQ_REG fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
2012-06-06 20:54:27 -06:00
}
2012-06-06 20:54:29 -06:00
/* __udelay(1); */
2011-11-06 07:40:11 -07:00
bytes = rdmalt ( Adapter , FLASH_SPI_READQ_REG , & uiStatus , sizeof ( uiStatus ) ) ;
if ( bytes < 0 ) {
uiStatus = bytes ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Reading status of FLASH_SPI_READQ_REG fails " ) ;
return uiStatus ;
2010-09-08 15:46:36 -06:00
}
iRetries - - ;
2012-06-06 20:54:29 -06:00
/* this will ensure that in there will be no changes in the current path.
* currently one rdm / wrm takes 125 us .
* Hence 125 * 2 * FLASH_PER_RETRIES_DELAY > 3 ms ( worst case delay )
* Hence current implementation cycle will intoduce no delay in current path
*/
2012-06-06 20:54:27 -06:00
if ( iRetries & & ( ( iRetries % FLASH_PER_RETRIES_DELAY ) = = 0 ) )
2012-06-06 20:54:31 -06:00
udelay ( 1000 ) ;
2012-06-06 20:54:27 -06:00
} while ( ( uiStatus & 0x1 ) & & ( iRetries > 0 ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiStatus & 0x1 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Flash Write fails even after checking status for 200 times. " ) ;
return STATUS_FAILURE ;
2010-09-08 15:46:36 -06:00
}
return STATUS_SUCCESS ;
}
2012-06-06 20:54:29 -06:00
/*-----------------------------------------------------------------------------
* Procedure : flashByteWriteStatus
*
* Description : Performs byte by byte write to flash with write done status check
*
* Arguments :
* Adapter - ptr to Adapter object instance
* uiOffset - Offset of the flash where data needs to be written to .
* pData - Address of the Data to be written .
* Returns :
* OSAL_STATUS_CODE
*
*/
2012-06-19 18:14:52 -06:00
static int flashByteWriteStatus ( struct bcm_mini_adapter * Adapter ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
2012-06-06 20:54:27 -06:00
PVOID pData )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiStatus = 0 ;
2012-06-19 18:14:52 -06:00
int iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY ; /* 3 */
2010-09-08 15:46:36 -06:00
ULONG ulData = * ( PUCHAR ) pData ;
2012-06-19 18:14:53 -06:00
unsigned int value ;
2011-11-06 07:40:11 -07:00
int bytes ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/*
* need not write 0xFFFFFFFF because write requires an erase and erase will
* make whole sector 0xFFFFFFFF .
*/
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( 0xFF = = ulData )
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
2012-06-06 20:54:29 -06:00
/* DumpDebug(NVM_RW,("flashWrite ====>\n")); */
2010-09-08 15:46:36 -06:00
value = ( FLASH_CMD_WRITE_ENABLE < < 24 ) ;
2012-06-06 20:54:28 -06:00
if ( wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Write enable in FLASH_SPI_CMDQ_REG register fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
}
2012-06-06 20:54:28 -06:00
if ( wrm ( Adapter , FLASH_SPI_WRITEQ_REG , ( PCHAR ) & ulData , 4 ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " DATA Write on FLASH_SPI_WRITEQ_REG fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
value = ( 0x02000000 | ( uiOffset & 0xFFFFFF ) ) ;
2012-06-06 20:54:28 -06:00
if ( wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Programming of FLASH_SPI_CMDQ_REG fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:29 -06:00
/* msleep(1); */
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
do {
2010-09-08 15:46:36 -06:00
value = ( FLASH_CMD_STATUS_REG_READ < < 24 ) ;
2012-06-06 20:54:28 -06:00
if ( wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Programing of FLASH_SPI_CMDQ_REG fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:29 -06:00
/* __udelay(1); */
2011-11-06 07:40:11 -07:00
bytes = rdmalt ( Adapter , FLASH_SPI_READQ_REG , & uiStatus , sizeof ( uiStatus ) ) ;
if ( bytes < 0 ) {
uiStatus = bytes ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Reading status of FLASH_SPI_READQ_REG fails " ) ;
return uiStatus ;
2010-09-08 15:46:36 -06:00
}
iRetries - - ;
2012-06-06 20:54:27 -06:00
if ( iRetries & & ( ( iRetries % FLASH_PER_RETRIES_DELAY ) = = 0 ) )
2012-06-06 20:54:31 -06:00
udelay ( 1000 ) ;
2012-06-06 20:54:27 -06:00
} while ( ( uiStatus & 0x1 ) & & ( iRetries > 0 ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiStatus & 0x1 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Flash Write fails even after checking status for 200 times. " ) ;
return STATUS_FAILURE ;
2010-09-08 15:46:36 -06:00
}
return STATUS_SUCCESS ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : flashWriteStatus
*
* Description : Performs write to flash with write done status check
*
* Arguments :
* Adapter - ptr to Adapter object instance
* uiOffset - Offset of the flash where data needs to be written to .
* pData - Address of the Data to be written .
* Returns :
* OSAL_STATUS_CODE
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int flashWriteStatus ( struct bcm_mini_adapter * Adapter ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
2012-06-06 20:54:27 -06:00
PVOID pData )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiStatus = 0 ;
2012-06-19 18:14:52 -06:00
int iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY ; /* 3 */
2012-06-19 18:14:53 -06:00
/* unsigned int uiReadBack = 0; */
unsigned int value ;
unsigned int uiErasePattern [ 4 ] = { 0xFFFFFFFF , 0xFFFFFFFF , 0xFFFFFFFF , 0xFFFFFFFF } ;
2011-11-06 07:40:11 -07:00
int bytes ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/*
* need not write 0xFFFFFFFF because write requires an erase and erase will
* make whole sector 0xFFFFFFFF .
*/
2012-06-06 20:54:27 -06:00
if ( ! memcmp ( pData , uiErasePattern , MAX_RW_SIZE ) )
2010-09-08 15:46:36 -06:00
return 0 ;
value = ( FLASH_CMD_WRITE_ENABLE < < 24 ) ;
2012-06-06 20:54:28 -06:00
if ( wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Write Enable of FLASH_SPI_CMDQ_REG fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( wrm ( Adapter , uiOffset , ( PCHAR ) pData , MAX_RW_SIZE ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Data write fails... " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:29 -06:00
/* __udelay(1); */
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
do {
2010-09-08 15:46:36 -06:00
value = ( FLASH_CMD_STATUS_REG_READ < < 24 ) ;
2012-06-06 20:54:28 -06:00
if ( wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) < 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Programing of FLASH_SPI_CMDQ_REG fails " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
2012-06-06 20:54:27 -06:00
}
2012-06-06 20:54:29 -06:00
/* __udelay(1); */
2011-11-06 07:40:11 -07:00
bytes = rdmalt ( Adapter , FLASH_SPI_READQ_REG , & uiStatus , sizeof ( uiStatus ) ) ;
if ( bytes < 0 ) {
uiStatus = bytes ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Reading status of FLASH_SPI_READQ_REG fails " ) ;
return uiStatus ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
iRetries - - ;
2012-06-06 20:54:29 -06:00
/* this will ensure that in there will be no changes in the current path.
* currently one rdm / wrm takes 125 us .
* Hence 125 * 2 * FLASH_PER_RETRIES_DELAY > 3 ms ( worst case delay )
* Hence current implementation cycle will intoduce no delay in current path
*/
2012-06-06 20:54:27 -06:00
if ( iRetries & & ( ( iRetries % FLASH_PER_RETRIES_DELAY ) = = 0 ) )
2012-06-06 20:54:31 -06:00
udelay ( 1000 ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
} while ( ( uiStatus & 0x1 ) & & ( iRetries > 0 ) ) ;
2012-06-06 20:54:28 -06:00
if ( uiStatus & 0x1 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Flash Write fails even after checking status for 200 times. " ) ;
return STATUS_FAILURE ;
2010-09-08 15:46:36 -06:00
}
return STATUS_SUCCESS ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BcmRestoreBlockProtectStatus
*
* Description : Restores the original block protection status .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* ulWriteStatus - Original status
* Returns :
* < VOID >
*
*/
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
static VOID BcmRestoreBlockProtectStatus ( struct bcm_mini_adapter * Adapter , ULONG ulWriteStatus )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int value ;
2014-07-09 09:59:29 -06:00
2012-06-06 20:54:27 -06:00
value = ( FLASH_CMD_WRITE_ENABLE < < 24 ) ;
2010-09-08 15:46:36 -06:00
wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) ;
udelay ( 20 ) ;
2012-06-06 20:54:27 -06:00
value = ( FLASH_CMD_STATUS_REG_WRITE < < 24 ) | ( ulWriteStatus < < 16 ) ;
2010-09-08 15:46:36 -06:00
wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) ;
udelay ( 20 ) ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:29 -06:00
/*
* Procedure : BcmFlashUnProtectBlock
*
* Description : UnProtects appropriate blocks for writing .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* uiOffset - Offset of the flash where data needs to be written to . This should be Sector aligned .
* Returns :
* ULONG - Status value before UnProtect .
*
*/
2012-06-06 20:54:27 -06:00
2012-06-19 18:14:53 -06:00
static ULONG BcmFlashUnProtectBlock ( struct bcm_mini_adapter * Adapter , unsigned int uiOffset , unsigned int uiLength )
2010-09-08 15:46:36 -06:00
{
2012-06-06 20:54:27 -06:00
ULONG ulStatus = 0 ;
ULONG ulWriteStatus = 0 ;
2012-06-19 18:14:53 -06:00
unsigned int value ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
uiOffset = uiOffset & 0x000FFFFF ;
2012-06-06 20:54:29 -06:00
/*
* Implemented only for 1 MB Flash parts .
*/
2012-06-06 20:54:28 -06:00
if ( FLASH_PART_SST25VF080B = = Adapter - > ulFlashID ) {
2012-06-06 20:54:29 -06:00
/*
* Get Current BP status .
*/
2010-09-08 15:46:36 -06:00
value = ( FLASH_CMD_STATUS_REG_READ < < 24 ) ;
wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) ;
udelay ( 10 ) ;
2012-06-06 20:54:29 -06:00
/*
* Read status will be WWXXYYZZ . We have to take only WW .
*/
2010-09-08 15:46:36 -06:00
rdmalt ( Adapter , FLASH_SPI_READQ_REG , ( PUINT ) & ulStatus , sizeof ( ulStatus ) ) ;
ulStatus > > = 24 ;
ulWriteStatus = ulStatus ;
2012-06-06 20:54:29 -06:00
/*
* Bits [ 5 - 2 ] give current block level protection status .
* Bit5 : BP3 - DONT CARE
* BP2 - BP0 : 0 - NO PROTECTION , 1 - UPPER 1 / 16 , 2 - UPPER 1 / 8 , 3 - UPPER 1 / 4
* 4 - UPPER 1 / 2. 5 to 7 - ALL BLOCKS
*/
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( ulStatus ) {
if ( ( uiOffset + uiLength ) < = 0x80000 ) {
2012-06-06 20:54:29 -06:00
/*
* Offset comes in lower half of 1 MB . Protect the upper half .
* Clear BP1 and BP0 and set BP2 .
*/
2010-09-08 15:46:36 -06:00
ulWriteStatus | = ( 0x4 < < 2 ) ;
ulWriteStatus & = ~ ( 0x3 < < 2 ) ;
2012-06-06 20:54:28 -06:00
} else if ( ( uiOffset + uiLength ) < = 0xC0000 ) {
2012-06-06 20:54:29 -06:00
/*
* Offset comes below Upper 1 / 4. Upper 1 / 4 can be protected .
* Clear BP2 and set BP1 and BP0 .
*/
2010-09-08 15:46:36 -06:00
ulWriteStatus | = ( 0x3 < < 2 ) ;
ulWriteStatus & = ~ ( 0x1 < < 4 ) ;
2012-06-06 20:54:28 -06:00
} else if ( ( uiOffset + uiLength ) < = 0xE0000 ) {
2012-06-06 20:54:29 -06:00
/*
* Offset comes below Upper 1 / 8. Upper 1 / 8 can be protected .
* Clear BP2 and BP0 and set BP1
*/
2012-06-06 20:54:27 -06:00
ulWriteStatus | = ( 0x1 < < 3 ) ;
ulWriteStatus & = ~ ( 0x5 < < 2 ) ;
2012-06-06 20:54:28 -06:00
} else if ( ( uiOffset + uiLength ) < = 0xF0000 ) {
2012-06-06 20:54:29 -06:00
/*
* Offset comes below Upper 1 / 16. Only upper 1 / 16 can be protected .
* Set BP0 and Clear BP2 , BP1 .
*/
2012-06-06 20:54:27 -06:00
ulWriteStatus | = ( 0x1 < < 2 ) ;
ulWriteStatus & = ~ ( 0x3 < < 3 ) ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:29 -06:00
/*
* Unblock all .
* Clear BP2 , BP1 and BP0 .
*/
2012-06-06 20:54:27 -06:00
ulWriteStatus & = ~ ( 0x7 < < 2 ) ;
}
value = ( FLASH_CMD_WRITE_ENABLE < < 24 ) ;
2010-09-08 15:46:36 -06:00
wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) ;
udelay ( 20 ) ;
2012-06-06 20:54:27 -06:00
value = ( FLASH_CMD_STATUS_REG_WRITE < < 24 ) | ( ulWriteStatus < < 16 ) ;
2010-09-08 15:46:36 -06:00
wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) ;
udelay ( 20 ) ;
}
}
return ulStatus ;
}
2012-06-06 20:54:27 -06:00
2014-07-20 07:14:10 -06:00
static int bulk_read_complete_sector ( struct bcm_mini_adapter * ad ,
UCHAR read_bk [ ] ,
PCHAR tmpbuff ,
unsigned int offset ,
2014-07-23 05:31:00 -06:00
unsigned int partoff )
2014-07-20 07:14:10 -06:00
{
2014-07-23 05:31:00 -06:00
unsigned int i ;
2014-07-23 05:30:59 -06:00
int j ;
2014-07-20 07:14:10 -06:00
int bulk_read_stat ;
2014-07-20 07:14:13 -06:00
FP_FLASH_WRITE_STATUS writef =
ad - > fpFlashWriteWithStatusCheck ;
2014-07-20 07:14:10 -06:00
for ( i = 0 ; i < ad - > uiSectorSize ; i + = MAX_RW_SIZE ) {
bulk_read_stat = BeceemFlashBulkRead ( ad ,
( PUINT ) read_bk ,
offset + i ,
MAX_RW_SIZE ) ;
2014-07-20 07:14:11 -06:00
if ( bulk_read_stat ! = STATUS_SUCCESS )
continue ;
if ( ad - > ulFlashWriteSize = = 1 ) {
for ( j = 0 ; j < 16 ; j + + ) {
2014-07-20 07:14:13 -06:00
if ( ( read_bk [ j ] ! = tmpbuff [ i + j ] ) & &
( STATUS_SUCCESS ! = ( * writef ) ( ad , partoff + i + j , & tmpbuff [ i + j ] ) ) ) {
2014-07-20 07:14:12 -06:00
return STATUS_FAILURE ;
2014-07-20 07:14:10 -06:00
}
}
2014-07-20 07:14:11 -06:00
} else {
2014-07-20 07:14:12 -06:00
if ( ( memcmp ( read_bk , & tmpbuff [ i ] , MAX_RW_SIZE ) ) & &
2014-07-20 07:14:13 -06:00
( STATUS_SUCCESS ! = ( * writef ) ( ad , partoff + i , & tmpbuff [ i ] ) ) ) {
2014-07-20 07:14:12 -06:00
return STATUS_FAILURE ;
2014-07-20 07:14:11 -06:00
}
2014-07-20 07:14:10 -06:00
}
}
return STATUS_SUCCESS ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BeceemFlashBulkWrite
*
* Description : Performs write to the flash
*
* Arguments :
* Adapter - ptr to Adapter object instance
* pBuffer - Data to be written .
* uiOffset - Offset of the flash where data needs to be written to .
* uiNumBytes - Number of bytes to be written .
* bVerify - read verify flag .
* Returns :
* OSAL_STATUS_CODE
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int BeceemFlashBulkWrite ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
PUINT pBuffer ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
unsigned int uiNumBytes ,
2013-10-28 02:35:59 -06:00
bool bVerify )
2010-09-08 15:46:36 -06:00
{
2012-06-06 20:54:27 -06:00
PCHAR pTempBuff = NULL ;
PUCHAR pcBuffer = ( PUCHAR ) pBuffer ;
2012-06-19 18:14:53 -06:00
unsigned int uiIndex = 0 ;
unsigned int uiOffsetFromSectStart = 0 ;
unsigned int uiSectAlignAddr = 0 ;
unsigned int uiCurrSectOffsetAddr = 0 ;
unsigned int uiSectBoundary = 0 ;
unsigned int uiNumSectTobeRead = 0 ;
2012-06-06 20:54:27 -06:00
UCHAR ucReadBk [ 16 ] = { 0 } ;
ULONG ulStatus = 0 ;
2012-06-19 18:14:52 -06:00
int Status = STATUS_SUCCESS ;
2012-06-19 18:14:53 -06:00
unsigned int uiTemp = 0 ;
unsigned int index = 0 ;
unsigned int uiPartOffset = 0 ;
2012-06-06 20:54:27 -06:00
# if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
Status = bcmflash_raw_write ( ( uiOffset / FLASH_PART_SIZE ) , ( uiOffset % FLASH_PART_SIZE ) , ( unsigned char * ) pBuffer , uiNumBytes ) ;
return Status ;
# endif
uiOffsetFromSectStart = uiOffset & ~ ( Adapter - > uiSectorSize - 1 ) ;
2012-06-06 20:54:29 -06:00
/* Adding flash Base address
* uiOffset = uiOffset + GetFlashBaseAddr ( Adapter ) ;
*/
2012-06-06 20:54:27 -06:00
uiSectAlignAddr = uiOffset & ~ ( Adapter - > uiSectorSize - 1 ) ;
uiCurrSectOffsetAddr = uiOffset & ( Adapter - > uiSectorSize - 1 ) ;
uiSectBoundary = uiSectAlignAddr + Adapter - > uiSectorSize ;
2010-09-08 15:46:36 -06:00
2010-11-01 07:35:21 -06:00
pTempBuff = kmalloc ( Adapter - > uiSectorSize , GFP_KERNEL ) ;
2012-06-19 18:14:54 -06:00
if ( ! pTempBuff )
2010-09-08 15:46:36 -06:00
goto BeceemFlashBulkWrite_EXIT ;
2012-06-06 20:54:29 -06:00
/*
* check if the data to be written is overlapped across sectors
*/
2012-06-06 20:54:28 -06:00
if ( uiOffset + uiNumBytes < uiSectBoundary ) {
2010-09-08 15:46:36 -06:00
uiNumSectTobeRead = 1 ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:29 -06:00
/* Number of sectors = Last sector start address/First sector start address */
2012-06-06 20:54:27 -06:00
uiNumSectTobeRead = ( uiCurrSectOffsetAddr + uiNumBytes ) / Adapter - > uiSectorSize ;
if ( ( uiCurrSectOffsetAddr + uiNumBytes ) % Adapter - > uiSectorSize )
2010-09-08 15:46:36 -06:00
uiNumSectTobeRead + + ;
}
2012-06-06 20:54:29 -06:00
/* Check whether Requested sector is writable or not in case of flash2x write. But if write call is
* for DSD calibration , allow it without checking of sector permission
*/
2010-09-08 15:46:36 -06:00
2013-10-28 02:36:19 -06:00
if ( IsFlash2x ( Adapter ) & & ( Adapter - > bAllDSDWriteAllow = = false ) ) {
2010-09-08 15:46:36 -06:00
index = 0 ;
2012-06-06 20:54:27 -06:00
uiTemp = uiNumSectTobeRead ;
2012-06-06 20:54:28 -06:00
while ( uiTemp ) {
2013-10-28 02:36:19 -06:00
if ( IsOffsetWritable ( Adapter , uiOffsetFromSectStart + index * Adapter - > uiSectorSize ) = = false ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Sector Starting at offset <0X%X> is not writable " ,
( uiOffsetFromSectStart + index * Adapter - > uiSectorSize ) ) ;
2010-09-08 15:46:36 -06:00
Status = SECTOR_IS_NOT_WRITABLE ;
goto BeceemFlashBulkWrite_EXIT ;
2012-06-06 20:54:27 -06:00
}
uiTemp = uiTemp - 1 ;
2013-09-10 09:44:39 -06:00
index = index + 1 ;
2010-09-08 15:46:36 -06:00
}
}
Adapter - > SelectedChip = RESET_CHIP_SELECT ;
2012-06-06 20:54:28 -06:00
while ( uiNumSectTobeRead ) {
2012-06-06 20:54:29 -06:00
/* do_gettimeofday(&tv1);
* BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " \n Time In start of write :%ld ms \n " , ( tv1 . tv_sec * 1000 + tv1 . tv_usec / 1000 ) ) ;
*/
2010-09-08 15:46:36 -06:00
uiPartOffset = ( uiSectAlignAddr & ( FLASH_PART_SIZE - 1 ) ) + GetFlashBaseAddr ( Adapter ) ;
2012-06-06 20:54:27 -06:00
BcmDoChipSelect ( Adapter , uiSectAlignAddr ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( 0 ! = BeceemFlashBulkRead ( Adapter ,
2010-09-08 15:46:36 -06:00
( PUINT ) pTempBuff ,
uiOffsetFromSectStart ,
2012-06-06 20:54:28 -06:00
Adapter - > uiSectorSize ) ) {
2010-09-08 15:46:36 -06:00
Status = - 1 ;
goto BeceemFlashBulkWrite_EXIT ;
}
2012-06-06 20:54:29 -06:00
/* do_gettimeofday(&tr);
* BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Total time taken by Read :%ld ms \n " , ( tr . tv_sec * 1000 + tr . tv_usec / 1000 ) - ( tv1 . tv_sec * 1000 + tv1 . tv_usec / 1000 ) ) ;
*/
2012-06-06 20:54:27 -06:00
ulStatus = BcmFlashUnProtectBlock ( Adapter , uiSectAlignAddr , Adapter - > uiSectorSize ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiNumSectTobeRead > 1 ) {
2012-06-06 20:54:27 -06:00
memcpy ( & pTempBuff [ uiCurrSectOffsetAddr ] , pcBuffer , uiSectBoundary - ( uiSectAlignAddr + uiCurrSectOffsetAddr ) ) ;
pcBuffer + = ( ( uiSectBoundary - ( uiSectAlignAddr + uiCurrSectOffsetAddr ) ) ) ;
uiNumBytes - = ( uiSectBoundary - ( uiSectAlignAddr + uiCurrSectOffsetAddr ) ) ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
memcpy ( & pTempBuff [ uiCurrSectOffsetAddr ] , pcBuffer , uiNumBytes ) ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
if ( IsFlash2x ( Adapter ) )
SaveHeaderIfPresent ( Adapter , ( PUCHAR ) pTempBuff , uiOffsetFromSectStart ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
FlashSectorErase ( Adapter , uiPartOffset , 1 ) ;
2012-06-06 20:54:29 -06:00
/* do_gettimeofday(&te);
* BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Total time taken by Erase :%ld ms \n " , ( te . tv_sec * 1000 + te . tv_usec / 1000 ) - ( tr . tv_sec * 1000 + tr . tv_usec / 1000 ) ) ;
*/
2012-06-06 20:54:28 -06:00
for ( uiIndex = 0 ; uiIndex < Adapter - > uiSectorSize ; uiIndex + = Adapter - > ulFlashWriteSize ) {
if ( Adapter - > device_removed ) {
2010-09-08 15:46:36 -06:00
Status = - 1 ;
goto BeceemFlashBulkWrite_EXIT ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( STATUS_SUCCESS ! = ( * Adapter - > fpFlashWrite ) ( Adapter , uiPartOffset + uiIndex , ( & pTempBuff [ uiIndex ] ) ) ) {
2010-09-08 15:46:36 -06:00
Status = - 1 ;
goto BeceemFlashBulkWrite_EXIT ;
}
}
2012-06-06 20:54:29 -06:00
/* do_gettimeofday(&tw);
* BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Total time taken in Write to Flash :%ld ms \n " , ( tw . tv_sec * 1000 + tw . tv_usec / 1000 ) - ( te . tv_sec * 1000 + te . tv_usec / 1000 ) ) ;
*/
2014-07-20 07:14:10 -06:00
if ( STATUS_FAILURE = = bulk_read_complete_sector ( Adapter ,
ucReadBk ,
pTempBuff ,
uiOffsetFromSectStart ,
2014-07-23 05:31:00 -06:00
uiPartOffset ) ) {
2014-07-20 07:14:10 -06:00
Status = STATUS_FAILURE ;
goto BeceemFlashBulkWrite_EXIT ;
2010-09-08 15:46:36 -06:00
}
2014-07-20 07:14:10 -06:00
2012-06-06 20:54:29 -06:00
/* do_gettimeofday(&twv);
* BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Total time taken in Write to Flash verification :%ld ms \n " , ( twv . tv_sec * 1000 + twv . tv_usec / 1000 ) - ( tw . tv_sec * 1000 + tw . tv_usec / 1000 ) ) ;
*/
2012-06-06 20:54:28 -06:00
if ( ulStatus ) {
2012-06-06 20:54:27 -06:00
BcmRestoreBlockProtectStatus ( Adapter , ulStatus ) ;
2010-09-08 15:46:36 -06:00
ulStatus = 0 ;
}
uiCurrSectOffsetAddr = 0 ;
uiSectAlignAddr = uiSectBoundary ;
uiSectBoundary + = Adapter - > uiSectorSize ;
uiOffsetFromSectStart + = Adapter - > uiSectorSize ;
uiNumSectTobeRead - - ;
}
2012-06-06 20:54:29 -06:00
/* do_gettimeofday(&tv2);
* BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Time after Write :%ld ms \n " , ( tv2 . tv_sec * 1000 + tv2 . tv_usec / 1000 ) ) ;
* BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Total time taken by in Write is :%ld ms \n " , ( tv2 . tv_sec * 1000 + tv2 . tv_usec / 1000 ) - ( tv1 . tv_sec * 1000 + tv1 . tv_usec / 1000 ) ) ;
*
* Cleanup .
*/
BeceemFlashBulkWrite_EXIT :
2012-06-06 20:54:27 -06:00
if ( ulStatus )
BcmRestoreBlockProtectStatus ( Adapter , ulStatus ) ;
2010-11-01 07:35:21 -06:00
kfree ( pTempBuff ) ;
2010-09-08 15:46:36 -06:00
Adapter - > SelectedChip = RESET_CHIP_SELECT ;
return Status ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BeceemFlashBulkWriteStatus
*
* Description : Writes to Flash . Checks the SPI status after each write .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* pBuffer - Data to be written .
* uiOffset - Offset of the flash where data needs to be written to .
* uiNumBytes - Number of bytes to be written .
* bVerify - read verify flag .
* Returns :
* OSAL_STATUS_CODE
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int BeceemFlashBulkWriteStatus ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
PUINT pBuffer ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
unsigned int uiNumBytes ,
2013-10-28 02:35:59 -06:00
bool bVerify )
2010-09-08 15:46:36 -06:00
{
2012-06-06 20:54:27 -06:00
PCHAR pTempBuff = NULL ;
PUCHAR pcBuffer = ( PUCHAR ) pBuffer ;
2012-06-19 18:14:53 -06:00
unsigned int uiIndex = 0 ;
unsigned int uiOffsetFromSectStart = 0 ;
unsigned int uiSectAlignAddr = 0 ;
unsigned int uiCurrSectOffsetAddr = 0 ;
unsigned int uiSectBoundary = 0 ;
unsigned int uiNumSectTobeRead = 0 ;
2012-06-06 20:54:27 -06:00
UCHAR ucReadBk [ 16 ] = { 0 } ;
ULONG ulStatus = 0 ;
2012-06-19 18:14:53 -06:00
unsigned int Status = STATUS_SUCCESS ;
unsigned int uiTemp = 0 ;
unsigned int index = 0 ;
unsigned int uiPartOffset = 0 ;
2012-06-06 20:54:27 -06:00
uiOffsetFromSectStart = uiOffset & ~ ( Adapter - > uiSectorSize - 1 ) ;
2012-06-06 20:54:29 -06:00
/* uiOffset += Adapter->ulFlashCalStart;
* Adding flash Base address
* uiOffset = uiOffset + GetFlashBaseAddr ( Adapter ) ;
*/
2012-06-06 20:54:27 -06:00
uiSectAlignAddr = uiOffset & ~ ( Adapter - > uiSectorSize - 1 ) ;
uiCurrSectOffsetAddr = uiOffset & ( Adapter - > uiSectorSize - 1 ) ;
uiSectBoundary = uiSectAlignAddr + Adapter - > uiSectorSize ;
2010-09-08 15:46:36 -06:00
2010-11-01 07:35:21 -06:00
pTempBuff = kmalloc ( Adapter - > uiSectorSize , GFP_KERNEL ) ;
2012-06-19 18:14:54 -06:00
if ( ! pTempBuff )
2010-09-08 15:46:36 -06:00
goto BeceemFlashBulkWriteStatus_EXIT ;
2010-11-01 07:35:21 -06:00
2012-06-06 20:54:29 -06:00
/*
* check if the data to be written is overlapped across sectors
*/
2012-06-06 20:54:28 -06:00
if ( uiOffset + uiNumBytes < uiSectBoundary ) {
2010-09-08 15:46:36 -06:00
uiNumSectTobeRead = 1 ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:29 -06:00
/* Number of sectors = Last sector start address/First sector start address */
2012-06-06 20:54:27 -06:00
uiNumSectTobeRead = ( uiCurrSectOffsetAddr + uiNumBytes ) / Adapter - > uiSectorSize ;
if ( ( uiCurrSectOffsetAddr + uiNumBytes ) % Adapter - > uiSectorSize )
2010-09-08 15:46:36 -06:00
uiNumSectTobeRead + + ;
}
2013-10-28 02:36:19 -06:00
if ( IsFlash2x ( Adapter ) & & ( Adapter - > bAllDSDWriteAllow = = false ) ) {
2010-09-08 15:46:36 -06:00
index = 0 ;
2012-06-06 20:54:27 -06:00
uiTemp = uiNumSectTobeRead ;
2012-06-06 20:54:28 -06:00
while ( uiTemp ) {
2013-10-28 02:36:19 -06:00
if ( IsOffsetWritable ( Adapter , uiOffsetFromSectStart + index * Adapter - > uiSectorSize ) = = false ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Sector Starting at offset <0X%x> is not writable " ,
( uiOffsetFromSectStart + index * Adapter - > uiSectorSize ) ) ;
2010-09-08 15:46:36 -06:00
Status = SECTOR_IS_NOT_WRITABLE ;
goto BeceemFlashBulkWriteStatus_EXIT ;
2012-06-06 20:54:27 -06:00
}
uiTemp = uiTemp - 1 ;
2013-09-10 09:44:39 -06:00
index = index + 1 ;
2010-09-08 15:46:36 -06:00
}
}
Adapter - > SelectedChip = RESET_CHIP_SELECT ;
2012-06-06 20:54:28 -06:00
while ( uiNumSectTobeRead ) {
2010-09-08 15:46:36 -06:00
uiPartOffset = ( uiSectAlignAddr & ( FLASH_PART_SIZE - 1 ) ) + GetFlashBaseAddr ( Adapter ) ;
2012-06-06 20:54:27 -06:00
BcmDoChipSelect ( Adapter , uiSectAlignAddr ) ;
if ( 0 ! = BeceemFlashBulkRead ( Adapter ,
2010-09-08 15:46:36 -06:00
( PUINT ) pTempBuff ,
uiOffsetFromSectStart ,
2012-06-06 20:54:28 -06:00
Adapter - > uiSectorSize ) ) {
2010-09-08 15:46:36 -06:00
Status = - 1 ;
goto BeceemFlashBulkWriteStatus_EXIT ;
}
2012-06-06 20:54:27 -06:00
ulStatus = BcmFlashUnProtectBlock ( Adapter , uiOffsetFromSectStart , Adapter - > uiSectorSize ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiNumSectTobeRead > 1 ) {
2012-06-06 20:54:27 -06:00
memcpy ( & pTempBuff [ uiCurrSectOffsetAddr ] , pcBuffer , uiSectBoundary - ( uiSectAlignAddr + uiCurrSectOffsetAddr ) ) ;
pcBuffer + = ( ( uiSectBoundary - ( uiSectAlignAddr + uiCurrSectOffsetAddr ) ) ) ;
uiNumBytes - = ( uiSectBoundary - ( uiSectAlignAddr + uiCurrSectOffsetAddr ) ) ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
memcpy ( & pTempBuff [ uiCurrSectOffsetAddr ] , pcBuffer , uiNumBytes ) ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
if ( IsFlash2x ( Adapter ) )
SaveHeaderIfPresent ( Adapter , ( PUCHAR ) pTempBuff , uiOffsetFromSectStart ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
FlashSectorErase ( Adapter , uiPartOffset , 1 ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
for ( uiIndex = 0 ; uiIndex < Adapter - > uiSectorSize ; uiIndex + = Adapter - > ulFlashWriteSize ) {
if ( Adapter - > device_removed ) {
2010-09-08 15:46:36 -06:00
Status = - 1 ;
goto BeceemFlashBulkWriteStatus_EXIT ;
}
2012-06-06 20:54:28 -06:00
if ( STATUS_SUCCESS ! = ( * Adapter - > fpFlashWriteWithStatusCheck ) ( Adapter , uiPartOffset + uiIndex , & pTempBuff [ uiIndex ] ) ) {
2010-09-08 15:46:36 -06:00
Status = - 1 ;
goto BeceemFlashBulkWriteStatus_EXIT ;
}
}
2012-06-06 20:54:28 -06:00
if ( bVerify ) {
for ( uiIndex = 0 ; uiIndex < Adapter - > uiSectorSize ; uiIndex + = MAX_RW_SIZE ) {
if ( STATUS_SUCCESS = = BeceemFlashBulkRead ( Adapter , ( PUINT ) ucReadBk , uiOffsetFromSectStart + uiIndex , MAX_RW_SIZE ) ) {
if ( memcmp ( ucReadBk , & pTempBuff [ uiIndex ] , MAX_RW_SIZE ) ) {
2010-09-08 15:46:36 -06:00
Status = STATUS_FAILURE ;
goto BeceemFlashBulkWriteStatus_EXIT ;
}
}
}
}
2012-06-06 20:54:28 -06:00
if ( ulStatus ) {
2012-06-06 20:54:27 -06:00
BcmRestoreBlockProtectStatus ( Adapter , ulStatus ) ;
2010-09-08 15:46:36 -06:00
ulStatus = 0 ;
}
uiCurrSectOffsetAddr = 0 ;
uiSectAlignAddr = uiSectBoundary ;
uiSectBoundary + = Adapter - > uiSectorSize ;
uiOffsetFromSectStart + = Adapter - > uiSectorSize ;
uiNumSectTobeRead - - ;
}
2012-06-06 20:54:29 -06:00
/*
* Cleanup .
*/
BeceemFlashBulkWriteStatus_EXIT :
2012-06-06 20:54:27 -06:00
if ( ulStatus )
BcmRestoreBlockProtectStatus ( Adapter , ulStatus ) ;
2010-11-01 07:35:21 -06:00
kfree ( pTempBuff ) ;
2010-09-08 15:46:36 -06:00
Adapter - > SelectedChip = RESET_CHIP_SELECT ;
return Status ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : PropagateCalParamsFromFlashToMemory
*
* Description : Dumps the calibration section of EEPROM to DDR .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* Returns :
* OSAL_STATUS_CODE
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
int PropagateCalParamsFromFlashToMemory ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
PCHAR pBuff , pPtr ;
2012-06-19 18:14:53 -06:00
unsigned int uiEepromSize = 0 ;
unsigned int uiBytesToCopy = 0 ;
/* unsigned int uiIndex = 0; */
unsigned int uiCalStartAddr = EEPROM_CALPARAM_START ;
unsigned int uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC ;
unsigned int value ;
2012-06-19 18:14:52 -06:00
int Status = 0 ;
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:29 -06:00
/*
* Write the signature first . This will ensure firmware does not access EEPROM .
*/
2010-09-08 15:46:36 -06:00
value = 0xbeadbead ;
wrmalt ( Adapter , EEPROM_CAL_DATA_INTERNAL_LOC - 4 , & value , sizeof ( value ) ) ;
value = 0xbeadbead ;
wrmalt ( Adapter , EEPROM_CAL_DATA_INTERNAL_LOC - 8 , & value , sizeof ( value ) ) ;
2012-06-06 20:54:27 -06:00
if ( 0 ! = BeceemNVMRead ( Adapter , & uiEepromSize , EEPROM_SIZE_OFFSET , 4 ) )
2010-09-08 15:46:36 -06:00
return - 1 ;
2012-06-06 20:54:28 -06:00
2010-09-08 15:46:36 -06:00
uiEepromSize = ntohl ( uiEepromSize ) ;
uiEepromSize > > = 16 ;
2012-06-06 20:54:29 -06:00
/*
* subtract the auto init section size
*/
2010-09-08 15:46:36 -06:00
uiEepromSize - = EEPROM_CALPARAM_START ;
2012-06-06 20:54:27 -06:00
if ( uiEepromSize > 1024 * 1024 )
2010-09-08 15:46:36 -06:00
return - 1 ;
2010-11-01 07:35:21 -06:00
pBuff = kmalloc ( uiEepromSize , GFP_KERNEL ) ;
2012-06-06 20:54:27 -06:00
if ( pBuff = = NULL )
2012-06-07 21:52:42 -06:00
return - ENOMEM ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( 0 ! = BeceemNVMRead ( Adapter , ( PUINT ) pBuff , uiCalStartAddr , uiEepromSize ) ) {
2010-11-01 07:35:21 -06:00
kfree ( pBuff ) ;
2010-09-08 15:46:36 -06:00
return - 1 ;
}
pPtr = pBuff ;
2012-06-06 20:54:27 -06:00
uiBytesToCopy = MIN ( BUFFER_4K , uiEepromSize ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
while ( uiBytesToCopy ) {
2012-06-06 20:54:27 -06:00
Status = wrm ( Adapter , uiMemoryLoc , ( PCHAR ) pPtr , uiBytesToCopy ) ;
2012-06-06 20:54:28 -06:00
if ( Status ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " wrm failed with status :%d " , Status ) ;
2010-09-08 15:46:36 -06:00
break ;
}
pPtr + = uiBytesToCopy ;
uiEepromSize - = uiBytesToCopy ;
uiMemoryLoc + = uiBytesToCopy ;
2012-06-06 20:54:27 -06:00
uiBytesToCopy = MIN ( BUFFER_4K , uiEepromSize ) ;
2010-09-08 15:46:36 -06:00
}
2010-11-01 07:35:21 -06:00
kfree ( pBuff ) ;
2010-09-08 15:46:36 -06:00
return Status ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BeceemEEPROMReadBackandVerify
*
* Description : Read back the data written and verifies .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* pBuffer - Data to be written .
* uiOffset - Offset of the flash where data needs to be written to .
* uiNumBytes - Number of bytes to be written .
* Returns :
* OSAL_STATUS_CODE
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int BeceemEEPROMReadBackandVerify ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
PUINT pBuffer ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
unsigned int uiNumBytes )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiRdbk = 0 ;
unsigned int uiIndex = 0 ;
unsigned int uiData = 0 ;
unsigned int auiData [ 4 ] = { 0 } ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
while ( uiNumBytes ) {
2012-06-06 20:54:27 -06:00
if ( Adapter - > device_removed )
2010-09-08 15:46:36 -06:00
return - 1 ;
2012-06-06 20:54:28 -06:00
if ( uiNumBytes > = MAX_RW_SIZE ) {
2012-06-06 20:54:29 -06:00
/* for the requests more than or equal to MAX_RW_SIZE bytes, use bulk read function to make the access faster. */
2012-06-06 20:54:27 -06:00
BeceemEEPROMBulkRead ( Adapter , & auiData [ 0 ] , uiOffset , MAX_RW_SIZE ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( memcmp ( & pBuffer [ uiIndex ] , & auiData [ 0 ] , MAX_RW_SIZE ) ) {
2012-06-06 20:54:29 -06:00
/* re-write */
2013-10-28 02:36:19 -06:00
BeceemEEPROMBulkWrite ( Adapter , ( PUCHAR ) ( pBuffer + uiIndex ) , uiOffset , MAX_RW_SIZE , false ) ;
2010-09-08 15:46:36 -06:00
mdelay ( 3 ) ;
2012-06-06 20:54:27 -06:00
BeceemEEPROMBulkRead ( Adapter , & auiData [ 0 ] , uiOffset , MAX_RW_SIZE ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( memcmp ( & pBuffer [ uiIndex ] , & auiData [ 0 ] , MAX_RW_SIZE ) )
2010-09-08 15:46:36 -06:00
return - 1 ;
}
uiOffset + = MAX_RW_SIZE ;
uiNumBytes - = MAX_RW_SIZE ;
uiIndex + = 4 ;
2012-06-06 20:54:28 -06:00
} else if ( uiNumBytes > = 4 ) {
2012-06-06 20:54:27 -06:00
BeceemEEPROMBulkRead ( Adapter , & uiData , uiOffset , 4 ) ;
2012-06-06 20:54:28 -06:00
if ( uiData ! = pBuffer [ uiIndex ] ) {
2012-06-06 20:54:29 -06:00
/* re-write */
2013-10-28 02:36:19 -06:00
BeceemEEPROMBulkWrite ( Adapter , ( PUCHAR ) ( pBuffer + uiIndex ) , uiOffset , 4 , false ) ;
2010-09-08 15:46:36 -06:00
mdelay ( 3 ) ;
2012-06-06 20:54:27 -06:00
BeceemEEPROMBulkRead ( Adapter , & uiData , uiOffset , 4 ) ;
if ( uiData ! = pBuffer [ uiIndex ] )
2010-09-08 15:46:36 -06:00
return - 1 ;
}
uiOffset + = 4 ;
uiNumBytes - = 4 ;
uiIndex + + ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:29 -06:00
/* Handle the reads less than 4 bytes... */
2010-09-08 15:46:36 -06:00
uiData = 0 ;
2012-06-19 18:14:53 -06:00
memcpy ( & uiData , ( ( PUCHAR ) pBuffer ) + ( uiIndex * sizeof ( unsigned int ) ) , uiNumBytes ) ;
2012-06-06 20:54:27 -06:00
BeceemEEPROMBulkRead ( Adapter , & uiRdbk , uiOffset , 4 ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( memcmp ( & uiData , & uiRdbk , uiNumBytes ) )
2010-09-08 15:46:36 -06:00
return - 1 ;
uiNumBytes = 0 ;
}
}
return 0 ;
}
2012-06-19 18:14:53 -06:00
static VOID BcmSwapWord ( unsigned int * ptr1 )
2012-06-06 20:54:28 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int tempval = ( unsigned int ) * ptr1 ;
2010-09-08 15:46:36 -06:00
char * ptr2 = ( char * ) & tempval ;
char * ptr = ( char * ) ptr1 ;
ptr [ 0 ] = ptr2 [ 3 ] ;
ptr [ 1 ] = ptr2 [ 2 ] ;
ptr [ 2 ] = ptr2 [ 1 ] ;
ptr [ 3 ] = ptr2 [ 0 ] ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BeceemEEPROMWritePage
*
* Description : Performs page write ( 16 bytes ) to the EEPROM
*
* Arguments :
* Adapter - ptr to Adapter object instance
* uiData - Data to be written .
* uiOffset - Offset of the EEPROM where data needs to be written to .
* Returns :
* OSAL_STATUS_CODE
*
*/
2012-06-06 20:54:27 -06:00
2012-06-19 18:14:53 -06:00
static int BeceemEEPROMWritePage ( struct bcm_mini_adapter * Adapter , unsigned int uiData [ ] , unsigned int uiOffset )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY ;
unsigned int uiStatus = 0 ;
2010-09-08 15:46:36 -06:00
UCHAR uiEpromStatus = 0 ;
2012-06-19 18:14:53 -06:00
unsigned int value = 0 ;
2010-09-08 15:46:36 -06:00
/* Flush the Write/Read/Cmd queues. */
2012-06-06 20:54:27 -06:00
value = ( EEPROM_WRITE_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH | EEPROM_READ_QUEUE_FLUSH ) ;
wrmalt ( Adapter , SPI_FLUSH_REG , & value , sizeof ( value ) ) ;
value = 0 ;
wrmalt ( Adapter , SPI_FLUSH_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
/* Clear the Empty/Avail/Full bits. After this it has been confirmed
* that the bit was cleared by reading back the register . See NOTE below .
* We also clear the Read queues as we do a EEPROM status register read
2012-06-06 20:54:29 -06:00
* later .
*/
2012-06-06 20:54:27 -06:00
value = ( EEPROM_WRITE_QUEUE_EMPTY | EEPROM_WRITE_QUEUE_AVAIL | EEPROM_WRITE_QUEUE_FULL | EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL ) ;
wrmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
/* Enable write */
2012-06-06 20:54:27 -06:00
value = EEPROM_WRITE_ENABLE ;
wrmalt ( Adapter , EEPROM_CMDQ_SPI_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
/* We can write back to back 8bits * 16 into the queue and as we have
2012-06-06 20:54:29 -06:00
* checked for the queue to be empty we can write in a burst .
*/
2010-09-08 15:46:36 -06:00
value = uiData [ 0 ] ;
BcmSwapWord ( & value ) ;
2012-06-06 20:54:27 -06:00
wrm ( Adapter , EEPROM_WRITE_DATAQ_REG , ( PUCHAR ) & value , 4 ) ;
2010-09-08 15:46:36 -06:00
value = uiData [ 1 ] ;
BcmSwapWord ( & value ) ;
2012-06-06 20:54:27 -06:00
wrm ( Adapter , EEPROM_WRITE_DATAQ_REG , ( PUCHAR ) & value , 4 ) ;
2010-09-08 15:46:36 -06:00
value = uiData [ 2 ] ;
BcmSwapWord ( & value ) ;
2012-06-06 20:54:27 -06:00
wrm ( Adapter , EEPROM_WRITE_DATAQ_REG , ( PUCHAR ) & value , 4 ) ;
2010-09-08 15:46:36 -06:00
value = uiData [ 3 ] ;
BcmSwapWord ( & value ) ;
2012-06-06 20:54:27 -06:00
wrm ( Adapter , EEPROM_WRITE_DATAQ_REG , ( PUCHAR ) & value , 4 ) ;
2010-09-08 15:46:36 -06:00
/* NOTE : After this write, on readback of EEPROM_SPI_Q_STATUS1_REG
* shows that we see 7 for the EEPROM data write . Which means that
* queue got full , also space is available as well as the queue is empty .
2012-06-06 20:54:29 -06:00
* This may happen in sequence .
*/
2012-06-06 20:54:27 -06:00
value = EEPROM_16_BYTE_PAGE_WRITE | uiOffset ;
wrmalt ( Adapter , EEPROM_CMDQ_SPI_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
/* Ideally we should loop here without tries and eventually succeed.
* What we are checking if the previous write has completed , and this
2012-06-06 20:54:29 -06:00
* may take time . We should wait till the Empty bit is set .
*/
2010-09-08 15:46:36 -06:00
uiStatus = 0 ;
2011-11-06 07:40:11 -07:00
rdmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & uiStatus , sizeof ( uiStatus ) ) ;
2012-06-06 20:54:28 -06:00
while ( ( uiStatus & EEPROM_WRITE_QUEUE_EMPTY ) = = 0 ) {
2010-09-08 15:46:36 -06:00
uiRetries - - ;
2012-06-06 20:54:28 -06:00
if ( uiRetries = = 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " 0x0f003004 = %x, %d retries failed. \n " , uiStatus , MAX_EEPROM_RETRIES * RETRIES_PER_DELAY ) ;
return STATUS_FAILURE ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
if ( ! ( uiRetries % RETRIES_PER_DELAY ) )
2012-06-06 20:54:31 -06:00
udelay ( 1000 ) ;
2010-09-08 15:46:36 -06:00
uiStatus = 0 ;
2011-11-06 07:40:11 -07:00
rdmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & uiStatus , sizeof ( uiStatus ) ) ;
2012-06-06 20:54:28 -06:00
if ( Adapter - > device_removed = = TRUE ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Modem got removed hence exiting from loop.... " ) ;
2010-09-08 15:46:36 -06:00
return - ENODEV ;
}
}
2012-06-06 20:54:28 -06:00
if ( uiRetries ! = 0 ) {
2010-09-08 15:46:36 -06:00
/* Clear the ones that are set - either, Empty/Full/Avail bits */
2012-06-06 20:54:27 -06:00
value = ( uiStatus & ( EEPROM_WRITE_QUEUE_EMPTY | EEPROM_WRITE_QUEUE_AVAIL | EEPROM_WRITE_QUEUE_FULL ) ) ;
wrmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
}
/* Here we should check if the EEPROM status register is correct before
* proceeding . Bit 0 in the EEPROM Status register should be 0 before
* we proceed further . A 1 at Bit 0 indicates that the EEPROM is busy
* with the previous write . Note also that issuing this read finally
2012-06-06 20:54:29 -06:00
* means the previous write to the EEPROM has completed .
*/
2012-06-06 20:54:27 -06:00
uiRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY ;
2010-09-08 15:46:36 -06:00
uiEpromStatus = 0 ;
2012-06-06 20:54:28 -06:00
while ( uiRetries ! = 0 ) {
2012-06-06 20:54:27 -06:00
uiEpromStatus = ReadEEPROMStatusRegister ( Adapter ) ;
2012-06-06 20:54:28 -06:00
if ( Adapter - > device_removed = = TRUE ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Modem has got removed hence exiting from loop... " ) ;
2010-09-08 15:46:36 -06:00
return - ENODEV ;
}
2012-06-06 20:54:28 -06:00
if ( ( EEPROM_STATUS_REG_WRITE_BUSY & uiEpromStatus ) = = 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " EEPROM status register = %x tries = %d \n " , uiEpromStatus , ( MAX_EEPROM_RETRIES * RETRIES_PER_DELAY - uiRetries ) ) ;
return STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
}
uiRetries - - ;
2012-06-06 20:54:28 -06:00
if ( uiRetries = = 0 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " 0x0f003004 = %x, for EEPROM status read %d retries failed. \n " , uiEpromStatus , MAX_EEPROM_RETRIES * RETRIES_PER_DELAY ) ;
return STATUS_FAILURE ;
2010-09-08 15:46:36 -06:00
}
uiEpromStatus = 0 ;
2012-06-06 20:54:27 -06:00
if ( ! ( uiRetries % RETRIES_PER_DELAY ) )
2012-06-06 20:54:31 -06:00
udelay ( 1000 ) ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
return STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
} /* BeceemEEPROMWritePage */
2012-06-06 20:54:29 -06:00
/*
* Procedure : BeceemEEPROMBulkWrite
*
* Description : Performs write to the EEPROM
*
* Arguments :
* Adapter - ptr to Adapter object instance
* pBuffer - Data to be written .
* uiOffset - Offset of the EEPROM where data needs to be written to .
* uiNumBytes - Number of bytes to be written .
* bVerify - read verify flag .
* Returns :
* OSAL_STATUS_CODE
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
int BeceemEEPROMBulkWrite ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
PUCHAR pBuffer ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
unsigned int uiNumBytes ,
2013-10-28 02:35:59 -06:00
bool bVerify )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiBytesToCopy = uiNumBytes ;
/* unsigned int uiRdbk = 0; */
unsigned int uiData [ 4 ] = { 0 } ;
unsigned int uiIndex = 0 ;
unsigned int uiTempOffset = 0 ;
unsigned int uiExtraBytes = 0 ;
2012-06-06 20:54:29 -06:00
/* PUINT puiBuffer = (PUINT)pBuffer;
2012-06-19 18:14:52 -06:00
* int value ;
2012-06-06 20:54:29 -06:00
*/
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiOffset % MAX_RW_SIZE & & uiBytesToCopy ) {
2012-06-06 20:54:27 -06:00
uiTempOffset = uiOffset - ( uiOffset % MAX_RW_SIZE ) ;
uiExtraBytes = uiOffset - uiTempOffset ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
BeceemEEPROMBulkRead ( Adapter , & uiData [ 0 ] , uiTempOffset , MAX_RW_SIZE ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiBytesToCopy > = ( 16 - uiExtraBytes ) ) {
2012-06-06 20:54:27 -06:00
memcpy ( ( ( ( PUCHAR ) & uiData [ 0 ] ) + uiExtraBytes ) , pBuffer , MAX_RW_SIZE - uiExtraBytes ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( STATUS_FAILURE = = BeceemEEPROMWritePage ( Adapter , uiData , uiTempOffset ) )
return STATUS_FAILURE ;
2010-09-08 15:46:36 -06:00
uiBytesToCopy - = ( MAX_RW_SIZE - uiExtraBytes ) ;
uiIndex + = ( MAX_RW_SIZE - uiExtraBytes ) ;
uiOffset + = ( MAX_RW_SIZE - uiExtraBytes ) ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
memcpy ( ( ( ( PUCHAR ) & uiData [ 0 ] ) + uiExtraBytes ) , pBuffer , uiBytesToCopy ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( STATUS_FAILURE = = BeceemEEPROMWritePage ( Adapter , uiData , uiTempOffset ) )
return STATUS_FAILURE ;
2010-09-08 15:46:36 -06:00
uiIndex + = uiBytesToCopy ;
uiOffset + = uiBytesToCopy ;
uiBytesToCopy = 0 ;
}
}
2012-06-06 20:54:28 -06:00
while ( uiBytesToCopy ) {
2012-06-06 20:54:27 -06:00
if ( Adapter - > device_removed )
2010-09-08 15:46:36 -06:00
return - 1 ;
2012-06-06 20:54:28 -06:00
if ( uiBytesToCopy > = MAX_RW_SIZE ) {
2012-06-06 20:54:27 -06:00
if ( STATUS_FAILURE = = BeceemEEPROMWritePage ( Adapter , ( PUINT ) & pBuffer [ uiIndex ] , uiOffset ) )
return STATUS_FAILURE ;
2010-09-08 15:46:36 -06:00
uiIndex + = MAX_RW_SIZE ;
uiOffset + = MAX_RW_SIZE ;
2012-06-06 20:54:27 -06:00
uiBytesToCopy - = MAX_RW_SIZE ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:29 -06:00
/*
* To program non 16 byte aligned data , read 16 byte and then update .
*/
2012-06-06 20:54:27 -06:00
BeceemEEPROMBulkRead ( Adapter , & uiData [ 0 ] , uiOffset , 16 ) ;
memcpy ( & uiData [ 0 ] , pBuffer + uiIndex , uiBytesToCopy ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( STATUS_FAILURE = = BeceemEEPROMWritePage ( Adapter , uiData , uiOffset ) )
return STATUS_FAILURE ;
2010-09-08 15:46:36 -06:00
uiBytesToCopy = 0 ;
}
}
return 0 ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BeceemNVMRead
*
* Description : Reads n number of bytes from NVM .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* pBuffer - Buffer to store the data read from NVM
* uiOffset - Offset of NVM from where data should be read
* uiNumBytes - Number of bytes to be read from the NVM .
*
* Returns :
* OSAL_STATUS_SUCCESS - if NVM read is successful .
* < FAILURE > - if failed .
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
int BeceemNVMRead ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
PUINT pBuffer ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
unsigned int uiNumBytes )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:52 -06:00
int Status = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
# if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
2012-06-19 18:14:53 -06:00
unsigned int uiTemp = 0 , value ;
2012-06-06 20:54:27 -06:00
# endif
2012-06-06 20:54:28 -06:00
if ( Adapter - > eNVMType = = NVM_FLASH ) {
2013-10-28 02:36:19 -06:00
if ( Adapter - > bFlashRawRead = = false ) {
2012-06-06 20:54:27 -06:00
if ( IsSectionExistInVendorInfo ( Adapter , Adapter - > eActiveDSD ) )
return vendorextnReadSection ( Adapter , ( PUCHAR ) pBuffer , Adapter - > eActiveDSD , uiOffset , uiNumBytes ) ;
uiOffset = uiOffset + Adapter - > ulFlashCalStart ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
# if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
Status = bcmflash_raw_read ( ( uiOffset / FLASH_PART_SIZE ) , ( uiOffset % FLASH_PART_SIZE ) , ( unsigned char * ) pBuffer , uiNumBytes ) ;
# else
rdmalt ( Adapter , 0x0f000C80 , & uiTemp , sizeof ( uiTemp ) ) ;
value = 0 ;
wrmalt ( Adapter , 0x0f000C80 , & value , sizeof ( value ) ) ;
Status = BeceemFlashBulkRead ( Adapter ,
2010-09-08 15:46:36 -06:00
pBuffer ,
uiOffset ,
uiNumBytes ) ;
2012-06-06 20:54:27 -06:00
wrmalt ( Adapter , 0x0f000C80 , & uiTemp , sizeof ( uiTemp ) ) ;
# endif
2012-06-06 20:54:28 -06:00
} else if ( Adapter - > eNVMType = = NVM_EEPROM ) {
2010-09-08 15:46:36 -06:00
Status = BeceemEEPROMBulkRead ( Adapter ,
pBuffer ,
uiOffset ,
uiNumBytes ) ;
2012-06-06 20:54:28 -06:00
} else {
2010-09-08 15:46:36 -06:00
Status = - 1 ;
}
2012-06-06 20:54:27 -06:00
2010-09-08 15:46:36 -06:00
return Status ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BeceemNVMWrite
*
* Description : Writes n number of bytes to NVM .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* pBuffer - Buffer contains the data to be written .
* uiOffset - Offset of NVM where data to be written to .
* uiNumBytes - Number of bytes to be written . .
*
* Returns :
* OSAL_STATUS_SUCCESS - if NVM write is successful .
* < FAILURE > - if failed .
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
int BeceemNVMWrite ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
PUINT pBuffer ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
unsigned int uiNumBytes ,
2013-10-28 02:35:59 -06:00
bool bVerify )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:52 -06:00
int Status = 0 ;
2012-06-19 18:14:53 -06:00
unsigned int uiTemp = 0 ;
unsigned int uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC ;
unsigned int uiIndex = 0 ;
2012-06-06 20:54:27 -06:00
# if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
2012-06-19 18:14:53 -06:00
unsigned int value ;
2012-06-06 20:54:27 -06:00
# endif
2012-06-19 18:14:53 -06:00
unsigned int uiFlashOffset = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( Adapter - > eNVMType = = NVM_FLASH ) {
2012-06-06 20:54:27 -06:00
if ( IsSectionExistInVendorInfo ( Adapter , Adapter - > eActiveDSD ) )
Status = vendorextnWriteSection ( Adapter , ( PUCHAR ) pBuffer , Adapter - > eActiveDSD , uiOffset , uiNumBytes , bVerify ) ;
2012-06-06 20:54:28 -06:00
else {
2010-09-08 15:46:36 -06:00
uiFlashOffset = uiOffset + Adapter - > ulFlashCalStart ;
2012-06-06 20:54:27 -06:00
# if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
Status = bcmflash_raw_write ( ( uiFlashOffset / FLASH_PART_SIZE ) , ( uiFlashOffset % FLASH_PART_SIZE ) , ( unsigned char * ) pBuffer , uiNumBytes ) ;
# else
rdmalt ( Adapter , 0x0f000C80 , & uiTemp , sizeof ( uiTemp ) ) ;
value = 0 ;
wrmalt ( Adapter , 0x0f000C80 , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( Adapter - > bStatusWrite = = TRUE )
Status = BeceemFlashBulkWriteStatus ( Adapter ,
pBuffer ,
uiFlashOffset ,
uiNumBytes ,
bVerify ) ;
else
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
Status = BeceemFlashBulkWrite ( Adapter ,
pBuffer ,
uiFlashOffset ,
uiNumBytes ,
bVerify ) ;
# endif
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:28 -06:00
if ( uiOffset > = EEPROM_CALPARAM_START ) {
2010-09-08 15:46:36 -06:00
uiMemoryLoc + = ( uiOffset - EEPROM_CALPARAM_START ) ;
2012-06-06 20:54:28 -06:00
while ( uiNumBytes ) {
if ( uiNumBytes > BUFFER_4K ) {
2012-06-06 20:54:27 -06:00
wrm ( Adapter , ( uiMemoryLoc + uiIndex ) , ( PCHAR ) ( pBuffer + ( uiIndex / 4 ) ) , BUFFER_4K ) ;
2010-09-08 15:46:36 -06:00
uiNumBytes - = BUFFER_4K ;
uiIndex + = BUFFER_4K ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
wrm ( Adapter , uiMemoryLoc + uiIndex , ( PCHAR ) ( pBuffer + ( uiIndex / 4 ) ) , uiNumBytes ) ;
2010-09-08 15:46:36 -06:00
uiNumBytes = 0 ;
break ;
}
}
2012-06-06 20:54:28 -06:00
} else {
if ( ( uiOffset + uiNumBytes ) > EEPROM_CALPARAM_START ) {
2010-09-08 15:46:36 -06:00
ULONG ulBytesTobeSkipped = 0 ;
2012-06-06 20:54:29 -06:00
PUCHAR pcBuffer = ( PUCHAR ) pBuffer ; /* char pointer to take care of odd byte cases. */
2014-07-09 09:59:29 -06:00
2010-09-08 15:46:36 -06:00
uiNumBytes - = ( EEPROM_CALPARAM_START - uiOffset ) ;
ulBytesTobeSkipped + = ( EEPROM_CALPARAM_START - uiOffset ) ;
uiOffset + = ( EEPROM_CALPARAM_START - uiOffset ) ;
2012-06-06 20:54:28 -06:00
while ( uiNumBytes ) {
if ( uiNumBytes > BUFFER_4K ) {
2012-06-06 20:54:27 -06:00
wrm ( Adapter , uiMemoryLoc + uiIndex , ( PCHAR ) & pcBuffer [ ulBytesTobeSkipped + uiIndex ] , BUFFER_4K ) ;
2010-09-08 15:46:36 -06:00
uiNumBytes - = BUFFER_4K ;
uiIndex + = BUFFER_4K ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
wrm ( Adapter , uiMemoryLoc + uiIndex , ( PCHAR ) & pcBuffer [ ulBytesTobeSkipped + uiIndex ] , uiNumBytes ) ;
2010-09-08 15:46:36 -06:00
uiNumBytes = 0 ;
break ;
}
}
}
}
2012-06-06 20:54:29 -06:00
/* restore the values. */
2012-06-06 20:54:27 -06:00
wrmalt ( Adapter , 0x0f000C80 , & uiTemp , sizeof ( uiTemp ) ) ;
2012-06-06 20:54:28 -06:00
} else if ( Adapter - > eNVMType = = NVM_EEPROM ) {
2010-09-08 15:46:36 -06:00
Status = BeceemEEPROMBulkWrite ( Adapter ,
( PUCHAR ) pBuffer ,
uiOffset ,
uiNumBytes ,
bVerify ) ;
2012-06-06 20:54:27 -06:00
if ( bVerify )
Status = BeceemEEPROMReadBackandVerify ( Adapter , ( PUINT ) pBuffer , uiOffset , uiNumBytes ) ;
2012-06-06 20:54:28 -06:00
} else {
2010-09-08 15:46:36 -06:00
Status = - 1 ;
}
return Status ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BcmUpdateSectorSize
*
* Description : Updates the sector size to FLASH .
*
* Arguments :
* Adapter - ptr to Adapter object instance
* uiSectorSize - sector size
*
* Returns :
* OSAL_STATUS_SUCCESS - if NVM write is successful .
* < FAILURE > - if failed .
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:53 -06:00
int BcmUpdateSectorSize ( struct bcm_mini_adapter * Adapter , unsigned int uiSectorSize )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:52 -06:00
int Status = - 1 ;
2012-11-30 23:15:56 -07:00
struct bcm_flash_cs_info sFlashCsInfo = { 0 } ;
2012-06-19 18:14:53 -06:00
unsigned int uiTemp = 0 ;
unsigned int uiSectorSig = 0 ;
unsigned int uiCurrentSectorSize = 0 ;
unsigned int value ;
2010-09-08 15:46:36 -06:00
rdmalt ( Adapter , 0x0f000C80 , & uiTemp , sizeof ( uiTemp ) ) ;
value = 0 ;
2012-06-06 20:54:27 -06:00
wrmalt ( Adapter , 0x0f000C80 , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/*
* Before updating the sector size in the reserved area , check if already present .
*/
2012-06-06 20:54:27 -06:00
BeceemFlashBulkRead ( Adapter , ( PUINT ) & sFlashCsInfo , Adapter - > ulFlashControlSectionStart , sizeof ( sFlashCsInfo ) ) ;
2010-09-08 15:46:36 -06:00
uiSectorSig = ntohl ( sFlashCsInfo . FlashSectorSizeSig ) ;
uiCurrentSectorSize = ntohl ( sFlashCsInfo . FlashSectorSize ) ;
2012-06-06 20:54:28 -06:00
if ( uiSectorSig = = FLASH_SECTOR_SIZE_SIG ) {
if ( ( uiCurrentSectorSize < = MAX_SECTOR_SIZE ) & & ( uiCurrentSectorSize > = MIN_SECTOR_SIZE ) ) {
if ( uiSectorSize = = uiCurrentSectorSize ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Provided sector size is same as programmed in Flash " ) ;
2010-09-08 15:46:36 -06:00
Status = STATUS_SUCCESS ;
2012-06-06 20:54:27 -06:00
goto Restore ;
2010-09-08 15:46:36 -06:00
}
}
}
2012-06-06 20:54:28 -06:00
if ( ( uiSectorSize < = MAX_SECTOR_SIZE ) & & ( uiSectorSize > = MIN_SECTOR_SIZE ) ) {
2010-09-08 15:46:36 -06:00
sFlashCsInfo . FlashSectorSize = htonl ( uiSectorSize ) ;
sFlashCsInfo . FlashSectorSizeSig = htonl ( FLASH_SECTOR_SIZE_SIG ) ;
Status = BeceemFlashBulkWrite ( Adapter ,
( PUINT ) & sFlashCsInfo ,
Adapter - > ulFlashControlSectionStart ,
sizeof ( sFlashCsInfo ) ,
TRUE ) ;
}
2012-06-06 20:54:27 -06:00
Restore :
2012-06-06 20:54:29 -06:00
/* restore the values. */
2012-06-06 20:54:27 -06:00
wrmalt ( Adapter , 0x0f000C80 , & uiTemp , sizeof ( uiTemp ) ) ;
2010-09-08 15:46:36 -06:00
return Status ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BcmGetFlashSectorSize
*
* Description : Finds the sector size of the FLASH .
*
* Arguments :
* Adapter - ptr to Adapter object instance
*
* Returns :
2012-06-19 18:14:53 -06:00
* unsigned int - sector size .
2012-06-06 20:54:29 -06:00
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:53 -06:00
static unsigned int BcmGetFlashSectorSize ( struct bcm_mini_adapter * Adapter , unsigned int FlashSectorSizeSig , unsigned int FlashSectorSize )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiSectorSize = 0 ;
unsigned int uiSectorSig = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( Adapter - > bSectorSizeOverride & &
2010-09-08 15:46:36 -06:00
( Adapter - > uiSectorSizeInCFG < = MAX_SECTOR_SIZE & &
2012-06-06 20:54:28 -06:00
Adapter - > uiSectorSizeInCFG > = MIN_SECTOR_SIZE ) ) {
2010-09-08 15:46:36 -06:00
Adapter - > uiSectorSize = Adapter - > uiSectorSizeInCFG ;
2012-06-06 20:54:28 -06:00
} else {
2010-09-08 15:46:36 -06:00
uiSectorSig = FlashSectorSizeSig ;
2012-06-06 20:54:28 -06:00
if ( uiSectorSig = = FLASH_SECTOR_SIZE_SIG ) {
2010-09-08 15:46:36 -06:00
uiSectorSize = FlashSectorSize ;
2012-06-06 20:54:29 -06:00
/*
* If the sector size stored in the FLASH makes sense then use it .
*/
2012-06-06 20:54:28 -06:00
if ( uiSectorSize < = MAX_SECTOR_SIZE & & uiSectorSize > = MIN_SECTOR_SIZE ) {
2010-09-08 15:46:36 -06:00
Adapter - > uiSectorSize = uiSectorSize ;
2012-06-06 20:54:28 -06:00
} else if ( Adapter - > uiSectorSizeInCFG < = MAX_SECTOR_SIZE & &
Adapter - > uiSectorSizeInCFG > = MIN_SECTOR_SIZE ) {
2012-06-06 20:54:29 -06:00
/* No valid size in FLASH, check if Config file has it. */
2010-09-08 15:46:36 -06:00
Adapter - > uiSectorSize = Adapter - > uiSectorSizeInCFG ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:29 -06:00
/* Init to Default, if none of the above works. */
2010-09-08 15:46:36 -06:00
Adapter - > uiSectorSize = DEFAULT_SECTOR_SIZE ;
}
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
if ( Adapter - > uiSectorSizeInCFG < = MAX_SECTOR_SIZE & &
Adapter - > uiSectorSizeInCFG > = MIN_SECTOR_SIZE )
2010-09-08 15:46:36 -06:00
Adapter - > uiSectorSize = Adapter - > uiSectorSizeInCFG ;
else
Adapter - > uiSectorSize = DEFAULT_SECTOR_SIZE ;
}
}
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Sector size :%x \n " , Adapter - > uiSectorSize ) ;
2010-09-08 15:46:36 -06:00
return Adapter - > uiSectorSize ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BcmInitEEPROMQueues
*
* Description : Initialization of EEPROM queues .
*
* Arguments :
* Adapter - ptr to Adapter object instance
*
* Returns :
* < OSAL_STATUS_CODE >
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int BcmInitEEPROMQueues ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int value = 0 ;
2010-09-08 15:46:36 -06:00
/* CHIP Bug : Clear the Avail bits on the Read queue. The default
* value on this register is supposed to be 0x00001102 .
2012-06-06 20:54:29 -06:00
* But we get 0x00001122 .
*/
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Fixing reset value on 0x0f003004 register \n " ) ;
2010-09-08 15:46:36 -06:00
value = EEPROM_READ_DATA_AVAIL ;
2012-06-06 20:54:27 -06:00
wrmalt ( Adapter , EEPROM_SPI_Q_STATUS1_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
/* Flush the all the EEPROM queues. */
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Flushing the queues \n " ) ;
value = EEPROM_ALL_QUEUE_FLUSH ;
wrmalt ( Adapter , SPI_FLUSH_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
value = 0 ;
2012-06-06 20:54:27 -06:00
wrmalt ( Adapter , SPI_FLUSH_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
/* Read the EEPROM Status Register. Just to see, no real purpose. */
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " EEPROM Status register value = %x \n " , ReadEEPROMStatusRegister ( Adapter ) ) ;
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
} /* BcmInitEEPROMQueues() */
2012-06-06 20:54:29 -06:00
/*
* Procedure : BcmInitNVM
*
* Description : Initialization of NVM , EEPROM size , FLASH size , sector size etc .
*
* Arguments :
* Adapter - ptr to Adapter object instance
*
* Returns :
* < OSAL_STATUS_CODE >
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
int BcmInitNVM ( struct bcm_mini_adapter * ps_adapter )
2010-09-08 15:46:36 -06:00
{
BcmValidateNvmType ( ps_adapter ) ;
BcmInitEEPROMQueues ( ps_adapter ) ;
2012-06-06 20:54:28 -06:00
if ( ps_adapter - > eNVMType = = NVM_AUTODETECT ) {
2010-09-08 15:46:36 -06:00
ps_adapter - > eNVMType = BcmGetNvmType ( ps_adapter ) ;
2012-06-06 20:54:27 -06:00
if ( ps_adapter - > eNVMType = = NVM_UNKNOWN )
BCM_DEBUG_PRINT ( ps_adapter , DBG_TYPE_PRINTK , 0 , 0 , " NVM Type is unknown!! \n " ) ;
2012-06-06 20:54:28 -06:00
} else if ( ps_adapter - > eNVMType = = NVM_FLASH ) {
2010-09-08 15:46:36 -06:00
BcmGetFlashCSInfo ( ps_adapter ) ;
}
BcmGetNvmSize ( ps_adapter ) ;
return STATUS_SUCCESS ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:29 -06:00
/* BcmGetNvmSize : set the EEPROM or flash size in Adapter.
*
* Input Parameter :
* Adapter data structure
* Return Value :
* 0. means success ;
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int BcmGetNvmSize ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-06 20:54:27 -06:00
if ( Adapter - > eNVMType = = NVM_EEPROM )
2010-09-08 15:46:36 -06:00
Adapter - > uiNVMDSDSize = BcmGetEEPROMSize ( Adapter ) ;
2012-06-06 20:54:27 -06:00
else if ( Adapter - > eNVMType = = NVM_FLASH )
2010-09-08 15:46:36 -06:00
Adapter - > uiNVMDSDSize = BcmGetFlashSize ( Adapter ) ;
2012-06-06 20:54:28 -06:00
2010-09-08 15:46:36 -06:00
return 0 ;
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BcmValidateNvm
*
* Description : Validates the NVM Type option selected against the device
*
* Arguments :
* Adapter - ptr to Adapter object instance
*
* Returns :
* < VOID >
*/
2012-06-06 20:54:27 -06:00
2012-05-26 10:05:12 -06:00
static VOID BcmValidateNvmType ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-06 20:54:29 -06:00
/*
* if forcing the FLASH through CFG file , we should ensure device really has a FLASH .
* Accessing the FLASH address without the FLASH being present can cause hang / freeze etc .
* So if NVM_FLASH is selected for older chipsets , change it to AUTODETECT where EEPROM is 1 st choice .
*/
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( Adapter - > eNVMType = = NVM_FLASH & &
2010-09-08 15:46:36 -06:00
Adapter - > chip_id < 0xBECE3300 )
Adapter - > eNVMType = NVM_AUTODETECT ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:29 -06:00
/*
* Procedure : BcmReadFlashRDID
*
* Description : Reads ID from Serial Flash
*
* Arguments :
* Adapter - ptr to Adapter object instance
*
* Returns :
* Flash ID
*/
2012-06-06 20:54:27 -06:00
2012-05-26 10:05:12 -06:00
static ULONG BcmReadFlashRDID ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
ULONG ulRDID = 0 ;
2012-06-19 18:14:53 -06:00
unsigned int value ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/*
* Read ID Instruction .
*/
2012-06-06 20:54:27 -06:00
value = ( FLASH_CMD_READ_ID < < 24 ) ;
wrmalt ( Adapter , FLASH_SPI_CMDQ_REG , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* Delay */
2012-06-06 20:54:27 -06:00
udelay ( 10 ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/*
* Read SPI READQ REG . The output will be WWXXYYZZ .
* The ID is 3 Bytes long and is WWXXYY . ZZ needs to be Ignored .
*/
2012-06-06 20:54:27 -06:00
rdmalt ( Adapter , FLASH_SPI_READQ_REG , ( PUINT ) & ulRDID , sizeof ( ulRDID ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:30 -06:00
return ulRDID > > 8 ;
2010-09-08 15:46:36 -06:00
}
2012-06-19 18:14:52 -06:00
int BcmAllocFlashCSStructure ( struct bcm_mini_adapter * psAdapter )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:54 -06:00
if ( ! psAdapter ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_PRINTK , 0 , 0 , " Adapter structure point is NULL " ) ;
2010-09-08 15:46:36 -06:00
return - EINVAL ;
}
2013-03-10 06:48:27 -06:00
psAdapter - > psFlashCSInfo = kzalloc ( sizeof ( struct bcm_flash_cs_info ) , GFP_KERNEL ) ;
2012-06-06 20:54:28 -06:00
if ( psAdapter - > psFlashCSInfo = = NULL ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_PRINTK , 0 , 0 , " Can't Allocate memory for Flash 1.x " ) ;
2010-09-08 15:46:36 -06:00
return - ENOMEM ;
}
2013-03-10 06:48:27 -06:00
psAdapter - > psFlash2xCSInfo = kzalloc ( sizeof ( struct bcm_flash2x_cs_info ) , GFP_KERNEL ) ;
2012-06-19 18:14:54 -06:00
if ( ! psAdapter - > psFlash2xCSInfo ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_PRINTK , 0 , 0 , " Can't Allocate memory for Flash 2.x " ) ;
2010-11-01 07:35:21 -06:00
kfree ( psAdapter - > psFlashCSInfo ) ;
2010-09-08 15:46:36 -06:00
return - ENOMEM ;
}
2013-03-10 06:48:27 -06:00
psAdapter - > psFlash2xVendorInfo = kzalloc ( sizeof ( struct bcm_flash2x_vendor_info ) , GFP_KERNEL ) ;
2012-06-19 18:14:54 -06:00
if ( ! psAdapter - > psFlash2xVendorInfo ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_PRINTK , 0 , 0 , " Can't Allocate Vendor Info Memory for Flash 2.x " ) ;
2010-11-01 07:35:21 -06:00
kfree ( psAdapter - > psFlashCSInfo ) ;
kfree ( psAdapter - > psFlash2xCSInfo ) ;
2010-09-08 15:46:36 -06:00
return - ENOMEM ;
}
return STATUS_SUCCESS ;
}
2012-06-19 18:14:52 -06:00
int BcmDeAllocFlashCSStructure ( struct bcm_mini_adapter * psAdapter )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:54 -06:00
if ( ! psAdapter ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_PRINTK , 0 , 0 , " Adapter structure point is NULL " ) ;
2010-09-08 15:46:36 -06:00
return - EINVAL ;
}
2010-11-01 07:35:21 -06:00
kfree ( psAdapter - > psFlashCSInfo ) ;
kfree ( psAdapter - > psFlash2xCSInfo ) ;
kfree ( psAdapter - > psFlash2xVendorInfo ) ;
2012-06-06 20:54:27 -06:00
return STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
}
2012-11-30 23:15:55 -07:00
static int BcmDumpFlash2XCSStructure ( struct bcm_flash2x_cs_info * psFlash2xCSInfo , struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int Index = 0 ;
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " **********************FLASH2X CS Structure ******************* " ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Signature is :%x " , ( psFlash2xCSInfo - > MagicNumber ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Flash Major Version :%d " , MAJOR_VERSION ( psFlash2xCSInfo - > FlashLayoutVersion ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Flash Minor Version :%d " , MINOR_VERSION ( psFlash2xCSInfo - > FlashLayoutVersion ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " ISOImageMajorVersion:0x%x " , ( psFlash2xCSInfo - > ISOImageVersion ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " SCSIFirmwareMajorVersion :0x%x " , ( psFlash2xCSInfo - > SCSIFirmwareVersion ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForPart1ISOImage :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForPart1ISOImage ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForScsiFirmware :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForScsiFirmware ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " SizeOfScsiFirmware :0x%x " , ( psFlash2xCSInfo - > SizeOfScsiFirmware ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForPart2ISOImage :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForPart2ISOImage ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForDSDStart :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForDSDStart ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForDSDEnd :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForDSDEnd ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForVSAStart :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForVSAStart ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForVSAEnd :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForVSAEnd ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForControlSectionStart :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForControlSectionStart ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForControlSectionData :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForControlSectionData ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " CDLessInactivityTimeout :0x%x " , ( psFlash2xCSInfo - > CDLessInactivityTimeout ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " NewImageSignature :0x%x " , ( psFlash2xCSInfo - > NewImageSignature ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " FlashSectorSizeSig :0x%x " , ( psFlash2xCSInfo - > FlashSectorSizeSig ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " FlashSectorSize :0x%x " , ( psFlash2xCSInfo - > FlashSectorSize ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " FlashWriteSupportSize :0x%x " , ( psFlash2xCSInfo - > FlashWriteSupportSize ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " TotalFlashSize :0x%X " , ( psFlash2xCSInfo - > TotalFlashSize ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " FlashBaseAddr :0x%x " , ( psFlash2xCSInfo - > FlashBaseAddr ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " FlashPartMaxSize :0x%x " , ( psFlash2xCSInfo - > FlashPartMaxSize ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " IsCDLessDeviceBootSig :0x%x " , ( psFlash2xCSInfo - > IsCDLessDeviceBootSig ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " MassStorageTimeout :0x%x " , ( psFlash2xCSInfo - > MassStorageTimeout ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetISOImage1Part1Start :0x%x " , ( psFlash2xCSInfo - > OffsetISOImage1Part1Start ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetISOImage1Part1End :0x%x " , ( psFlash2xCSInfo - > OffsetISOImage1Part1End ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetISOImage1Part2Start :0x%x " , ( psFlash2xCSInfo - > OffsetISOImage1Part2Start ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetISOImage1Part2End :0x%x " , ( psFlash2xCSInfo - > OffsetISOImage1Part2End ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetISOImage1Part3Start :0x%x " , ( psFlash2xCSInfo - > OffsetISOImage1Part3Start ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetISOImage1Part3End :0x%x " , ( psFlash2xCSInfo - > OffsetISOImage1Part3End ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetISOImage2Part1Start :0x%x " , ( psFlash2xCSInfo - > OffsetISOImage2Part1Start ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetISOImage2Part1End :0x%x " , ( psFlash2xCSInfo - > OffsetISOImage2Part1End ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetISOImage2Part2Start :0x%x " , ( psFlash2xCSInfo - > OffsetISOImage2Part2Start ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetISOImage2Part2End :0x%x " , ( psFlash2xCSInfo - > OffsetISOImage2Part2End ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetISOImage2Part3Start :0x%x " , ( psFlash2xCSInfo - > OffsetISOImage2Part3Start ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetISOImage2Part3End :0x%x " , ( psFlash2xCSInfo - > OffsetISOImage2Part3End ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromDSDStartForDSDHeader :0x%x " , ( psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForDSD1Start :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForDSD1Start ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForDSD1End :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForDSD1End ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForDSD2Start :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForDSD2Start ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForDSD2End :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForDSD2End ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForVSA1Start :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForVSA1Start ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForVSA1End :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForVSA1End ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForVSA2Start :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForVSA2Start ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " OffsetFromZeroForVSA2End :0x%x " , ( psFlash2xCSInfo - > OffsetFromZeroForVSA2End ) ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Sector Access Bit Map is Defined as : " ) ;
for ( Index = 0 ; Index < ( FLASH2X_TOTAL_SIZE / ( DEFAULT_SECTOR_SIZE * 16 ) ) ; Index + + )
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " SectorAccessBitMap[%d] :0x%x " , Index ,
2010-09-08 15:46:36 -06:00
( psFlash2xCSInfo - > SectorAccessBitMap [ Index ] ) ) ;
return STATUS_SUCCESS ;
}
2012-11-30 23:15:55 -07:00
static int ConvertEndianOf2XCSStructure ( struct bcm_flash2x_cs_info * psFlash2xCSInfo )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int Index = 0 ;
2012-06-06 20:54:27 -06:00
2010-09-08 15:46:36 -06:00
psFlash2xCSInfo - > MagicNumber = ntohl ( psFlash2xCSInfo - > MagicNumber ) ;
2012-06-06 20:54:27 -06:00
psFlash2xCSInfo - > FlashLayoutVersion = ntohl ( psFlash2xCSInfo - > FlashLayoutVersion ) ;
2012-06-06 20:54:29 -06:00
/* psFlash2xCSInfo->FlashLayoutMinorVersion = ntohs(psFlash2xCSInfo->FlashLayoutMinorVersion); */
2010-09-08 15:46:36 -06:00
psFlash2xCSInfo - > ISOImageVersion = ntohl ( psFlash2xCSInfo - > ISOImageVersion ) ;
2012-06-06 20:54:27 -06:00
psFlash2xCSInfo - > SCSIFirmwareVersion = ntohl ( psFlash2xCSInfo - > SCSIFirmwareVersion ) ;
2010-09-08 15:46:36 -06:00
psFlash2xCSInfo - > OffsetFromZeroForPart1ISOImage = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForPart1ISOImage ) ;
psFlash2xCSInfo - > OffsetFromZeroForScsiFirmware = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForScsiFirmware ) ;
2012-06-06 20:54:27 -06:00
psFlash2xCSInfo - > SizeOfScsiFirmware = ntohl ( psFlash2xCSInfo - > SizeOfScsiFirmware ) ;
2010-09-08 15:46:36 -06:00
psFlash2xCSInfo - > OffsetFromZeroForPart2ISOImage = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForPart2ISOImage ) ;
psFlash2xCSInfo - > OffsetFromZeroForDSDStart = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForDSDStart ) ;
psFlash2xCSInfo - > OffsetFromZeroForDSDEnd = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForDSDEnd ) ;
psFlash2xCSInfo - > OffsetFromZeroForVSAStart = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForVSAStart ) ;
psFlash2xCSInfo - > OffsetFromZeroForVSAEnd = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForVSAEnd ) ;
psFlash2xCSInfo - > OffsetFromZeroForControlSectionStart = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForControlSectionStart ) ;
psFlash2xCSInfo - > OffsetFromZeroForControlSectionData = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForControlSectionData ) ;
psFlash2xCSInfo - > CDLessInactivityTimeout = ntohl ( psFlash2xCSInfo - > CDLessInactivityTimeout ) ;
psFlash2xCSInfo - > NewImageSignature = ntohl ( psFlash2xCSInfo - > NewImageSignature ) ;
psFlash2xCSInfo - > FlashSectorSizeSig = ntohl ( psFlash2xCSInfo - > FlashSectorSizeSig ) ;
psFlash2xCSInfo - > FlashSectorSize = ntohl ( psFlash2xCSInfo - > FlashSectorSize ) ;
psFlash2xCSInfo - > FlashWriteSupportSize = ntohl ( psFlash2xCSInfo - > FlashWriteSupportSize ) ;
psFlash2xCSInfo - > TotalFlashSize = ntohl ( psFlash2xCSInfo - > TotalFlashSize ) ;
psFlash2xCSInfo - > FlashBaseAddr = ntohl ( psFlash2xCSInfo - > FlashBaseAddr ) ;
psFlash2xCSInfo - > FlashPartMaxSize = ntohl ( psFlash2xCSInfo - > FlashPartMaxSize ) ;
psFlash2xCSInfo - > IsCDLessDeviceBootSig = ntohl ( psFlash2xCSInfo - > IsCDLessDeviceBootSig ) ;
psFlash2xCSInfo - > MassStorageTimeout = ntohl ( psFlash2xCSInfo - > MassStorageTimeout ) ;
psFlash2xCSInfo - > OffsetISOImage1Part1Start = ntohl ( psFlash2xCSInfo - > OffsetISOImage1Part1Start ) ;
psFlash2xCSInfo - > OffsetISOImage1Part1End = ntohl ( psFlash2xCSInfo - > OffsetISOImage1Part1End ) ;
psFlash2xCSInfo - > OffsetISOImage1Part2Start = ntohl ( psFlash2xCSInfo - > OffsetISOImage1Part2Start ) ;
psFlash2xCSInfo - > OffsetISOImage1Part2End = ntohl ( psFlash2xCSInfo - > OffsetISOImage1Part2End ) ;
psFlash2xCSInfo - > OffsetISOImage1Part3Start = ntohl ( psFlash2xCSInfo - > OffsetISOImage1Part3Start ) ;
psFlash2xCSInfo - > OffsetISOImage1Part3End = ntohl ( psFlash2xCSInfo - > OffsetISOImage1Part3End ) ;
psFlash2xCSInfo - > OffsetISOImage2Part1Start = ntohl ( psFlash2xCSInfo - > OffsetISOImage2Part1Start ) ;
psFlash2xCSInfo - > OffsetISOImage2Part1End = ntohl ( psFlash2xCSInfo - > OffsetISOImage2Part1End ) ;
psFlash2xCSInfo - > OffsetISOImage2Part2Start = ntohl ( psFlash2xCSInfo - > OffsetISOImage2Part2Start ) ;
psFlash2xCSInfo - > OffsetISOImage2Part2End = ntohl ( psFlash2xCSInfo - > OffsetISOImage2Part2End ) ;
psFlash2xCSInfo - > OffsetISOImage2Part3Start = ntohl ( psFlash2xCSInfo - > OffsetISOImage2Part3Start ) ;
psFlash2xCSInfo - > OffsetISOImage2Part3End = ntohl ( psFlash2xCSInfo - > OffsetISOImage2Part3End ) ;
psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader = ntohl ( psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader ) ;
psFlash2xCSInfo - > OffsetFromZeroForDSD1Start = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForDSD1Start ) ;
psFlash2xCSInfo - > OffsetFromZeroForDSD1End = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForDSD1End ) ;
psFlash2xCSInfo - > OffsetFromZeroForDSD2Start = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForDSD2Start ) ;
psFlash2xCSInfo - > OffsetFromZeroForDSD2End = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForDSD2End ) ;
psFlash2xCSInfo - > OffsetFromZeroForVSA1Start = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForVSA1Start ) ;
psFlash2xCSInfo - > OffsetFromZeroForVSA1End = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForVSA1End ) ;
psFlash2xCSInfo - > OffsetFromZeroForVSA2Start = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForVSA2Start ) ;
psFlash2xCSInfo - > OffsetFromZeroForVSA2End = ntohl ( psFlash2xCSInfo - > OffsetFromZeroForVSA2End ) ;
2012-06-06 20:54:27 -06:00
for ( Index = 0 ; Index < ( FLASH2X_TOTAL_SIZE / ( DEFAULT_SECTOR_SIZE * 16 ) ) ; Index + + )
psFlash2xCSInfo - > SectorAccessBitMap [ Index ] = ntohl ( psFlash2xCSInfo - > SectorAccessBitMap [ Index ] ) ;
2012-06-06 20:54:28 -06:00
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
}
2012-11-30 23:15:56 -07:00
static int ConvertEndianOfCSStructure ( struct bcm_flash_cs_info * psFlashCSInfo )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
/* unsigned int Index = 0; */
2012-06-06 20:54:27 -06:00
psFlashCSInfo - > MagicNumber = ntohl ( psFlashCSInfo - > MagicNumber ) ;
psFlashCSInfo - > FlashLayoutVersion = ntohl ( psFlashCSInfo - > FlashLayoutVersion ) ;
psFlashCSInfo - > ISOImageVersion = ntohl ( psFlashCSInfo - > ISOImageVersion ) ;
2012-06-06 20:54:29 -06:00
/* won't convert according to old assumption */
2012-06-06 20:54:27 -06:00
psFlashCSInfo - > SCSIFirmwareVersion = ( psFlashCSInfo - > SCSIFirmwareVersion ) ;
psFlashCSInfo - > OffsetFromZeroForPart1ISOImage = ntohl ( psFlashCSInfo - > OffsetFromZeroForPart1ISOImage ) ;
psFlashCSInfo - > OffsetFromZeroForScsiFirmware = ntohl ( psFlashCSInfo - > OffsetFromZeroForScsiFirmware ) ;
psFlashCSInfo - > SizeOfScsiFirmware = ntohl ( psFlashCSInfo - > SizeOfScsiFirmware ) ;
psFlashCSInfo - > OffsetFromZeroForPart2ISOImage = ntohl ( psFlashCSInfo - > OffsetFromZeroForPart2ISOImage ) ;
psFlashCSInfo - > OffsetFromZeroForCalibrationStart = ntohl ( psFlashCSInfo - > OffsetFromZeroForCalibrationStart ) ;
psFlashCSInfo - > OffsetFromZeroForCalibrationEnd = ntohl ( psFlashCSInfo - > OffsetFromZeroForCalibrationEnd ) ;
psFlashCSInfo - > OffsetFromZeroForVSAStart = ntohl ( psFlashCSInfo - > OffsetFromZeroForVSAStart ) ;
psFlashCSInfo - > OffsetFromZeroForVSAEnd = ntohl ( psFlashCSInfo - > OffsetFromZeroForVSAEnd ) ;
psFlashCSInfo - > OffsetFromZeroForControlSectionStart = ntohl ( psFlashCSInfo - > OffsetFromZeroForControlSectionStart ) ;
psFlashCSInfo - > OffsetFromZeroForControlSectionData = ntohl ( psFlashCSInfo - > OffsetFromZeroForControlSectionData ) ;
psFlashCSInfo - > CDLessInactivityTimeout = ntohl ( psFlashCSInfo - > CDLessInactivityTimeout ) ;
psFlashCSInfo - > NewImageSignature = ntohl ( psFlashCSInfo - > NewImageSignature ) ;
psFlashCSInfo - > FlashSectorSizeSig = ntohl ( psFlashCSInfo - > FlashSectorSizeSig ) ;
psFlashCSInfo - > FlashSectorSize = ntohl ( psFlashCSInfo - > FlashSectorSize ) ;
psFlashCSInfo - > FlashWriteSupportSize = ntohl ( psFlashCSInfo - > FlashWriteSupportSize ) ;
psFlashCSInfo - > TotalFlashSize = ntohl ( psFlashCSInfo - > TotalFlashSize ) ;
psFlashCSInfo - > FlashBaseAddr = ntohl ( psFlashCSInfo - > FlashBaseAddr ) ;
psFlashCSInfo - > FlashPartMaxSize = ntohl ( psFlashCSInfo - > FlashPartMaxSize ) ;
psFlashCSInfo - > IsCDLessDeviceBootSig = ntohl ( psFlashCSInfo - > IsCDLessDeviceBootSig ) ;
psFlashCSInfo - > MassStorageTimeout = ntohl ( psFlashCSInfo - > MassStorageTimeout ) ;
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
}
2012-11-22 12:48:50 -07:00
static int IsSectionExistInVendorInfo ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val section )
2010-09-08 15:46:36 -06:00
{
2012-06-06 20:54:27 -06:00
return ( Adapter - > uiVendorExtnFlag & &
( Adapter - > psFlash2xVendorInfo - > VendorSection [ section ] . AccessFlags & FLASH2X_SECTION_PRESENT ) & &
( Adapter - > psFlash2xVendorInfo - > VendorSection [ section ] . OffsetFromZeroForSectionStart ! = UNINIT_PTR_IN_CS ) ) ;
2010-09-08 15:46:36 -06:00
}
2012-05-26 10:05:12 -06:00
static VOID UpdateVendorInfo ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
B_UINT32 i = 0 ;
2012-06-19 18:14:53 -06:00
unsigned int uiSizeSection = 0 ;
2010-09-08 15:46:36 -06:00
2013-10-28 02:36:19 -06:00
Adapter - > uiVendorExtnFlag = false ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
for ( i = 0 ; i < TOTAL_SECTIONS ; i + + )
2010-09-08 15:46:36 -06:00
Adapter - > psFlash2xVendorInfo - > VendorSection [ i ] . OffsetFromZeroForSectionStart = UNINIT_PTR_IN_CS ;
2012-06-06 20:54:27 -06:00
if ( STATUS_SUCCESS ! = vendorextnGetSectionInfo ( Adapter , Adapter - > psFlash2xVendorInfo ) )
2010-09-08 15:46:36 -06:00
return ;
i = 0 ;
2012-06-06 20:54:28 -06:00
while ( i < TOTAL_SECTIONS ) {
if ( ! ( Adapter - > psFlash2xVendorInfo - > VendorSection [ i ] . AccessFlags & FLASH2X_SECTION_PRESENT ) ) {
2010-09-08 15:46:36 -06:00
i + + ;
continue ;
}
Adapter - > uiVendorExtnFlag = TRUE ;
uiSizeSection = ( Adapter - > psFlash2xVendorInfo - > VendorSection [ i ] . OffsetFromZeroForSectionEnd -
2012-06-06 20:54:27 -06:00
Adapter - > psFlash2xVendorInfo - > VendorSection [ i ] . OffsetFromZeroForSectionStart ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
switch ( i ) {
case DSD0 :
2012-11-30 23:15:52 -07:00
if ( ( uiSizeSection > = ( Adapter - > psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader + sizeof ( struct bcm_dsd_header ) ) ) & &
2012-06-06 20:54:28 -06:00
( UNINIT_PTR_IN_CS ! = Adapter - > psFlash2xVendorInfo - > VendorSection [ i ] . OffsetFromZeroForSectionStart ) )
Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSDStart = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSDEnd = VENDOR_PTR_IN_CS ;
else
Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSDStart = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSDEnd = UNINIT_PTR_IN_CS ;
break ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
case DSD1 :
2012-11-30 23:15:52 -07:00
if ( ( uiSizeSection > = ( Adapter - > psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader + sizeof ( struct bcm_dsd_header ) ) ) & &
2012-06-06 20:54:28 -06:00
( UNINIT_PTR_IN_CS ! = Adapter - > psFlash2xVendorInfo - > VendorSection [ i ] . OffsetFromZeroForSectionStart ) )
Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD1Start = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD1End = VENDOR_PTR_IN_CS ;
else
Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD1Start = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD1End = UNINIT_PTR_IN_CS ;
break ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
case DSD2 :
2012-11-30 23:15:52 -07:00
if ( ( uiSizeSection > = ( Adapter - > psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader + sizeof ( struct bcm_dsd_header ) ) ) & &
2012-06-06 20:54:28 -06:00
( UNINIT_PTR_IN_CS ! = Adapter - > psFlash2xVendorInfo - > VendorSection [ i ] . OffsetFromZeroForSectionStart ) )
Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD2Start = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD2End = VENDOR_PTR_IN_CS ;
else
Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD2Start = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD2End = UNINIT_PTR_IN_CS ;
break ;
case VSA0 :
if ( UNINIT_PTR_IN_CS ! = Adapter - > psFlash2xVendorInfo - > VendorSection [ i ] . OffsetFromZeroForSectionStart )
Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSAStart = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSAEnd = VENDOR_PTR_IN_CS ;
else
Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSAStart = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSAEnd = UNINIT_PTR_IN_CS ;
break ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
case VSA1 :
if ( UNINIT_PTR_IN_CS ! = Adapter - > psFlash2xVendorInfo - > VendorSection [ i ] . OffsetFromZeroForSectionStart )
Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA1Start = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA1End = VENDOR_PTR_IN_CS ;
else
Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA1Start = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA1End = UNINIT_PTR_IN_CS ;
break ;
case VSA2 :
if ( UNINIT_PTR_IN_CS ! = Adapter - > psFlash2xVendorInfo - > VendorSection [ i ] . OffsetFromZeroForSectionStart )
Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA2Start = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA2End = VENDOR_PTR_IN_CS ;
else
Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA2Start = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA2End = UNINIT_PTR_IN_CS ;
break ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
default :
break ;
2010-09-08 15:46:36 -06:00
}
i + + ;
}
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BcmGetFlashCSInfo
*
* Description : Reads control structure and gets Cal section addresses .
*
* Arguments :
* Adapter - ptr to Adapter object instance
*
* Returns :
* < VOID >
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int BcmGetFlashCSInfo ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-11-30 23:15:56 -07:00
/* struct bcm_flash_cs_info sFlashCsInfo = {0}; */
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
# if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
2012-06-19 18:14:53 -06:00
unsigned int value ;
2012-06-06 20:54:27 -06:00
# endif
2012-06-19 18:14:53 -06:00
unsigned int uiFlashLayoutMajorVersion ;
2014-07-09 09:59:29 -06:00
2010-09-08 15:46:36 -06:00
Adapter - > uiFlashLayoutMinorVersion = 0 ;
Adapter - > uiFlashLayoutMajorVersion = 0 ;
Adapter - > ulFlashControlSectionStart = FLASH_CS_INFO_START_ADDR ;
Adapter - > uiFlashBaseAdd = 0 ;
Adapter - > ulFlashCalStart = 0 ;
2012-11-30 23:15:56 -07:00
memset ( Adapter - > psFlashCSInfo , 0 , sizeof ( struct bcm_flash_cs_info ) ) ;
2012-11-30 23:15:55 -07:00
memset ( Adapter - > psFlash2xCSInfo , 0 , sizeof ( struct bcm_flash2x_cs_info ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( ! Adapter - > bDDRInitDone ) {
value = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT ;
wrmalt ( Adapter , 0xAF00A080 , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:29 -06:00
/* Reading first 8 Bytes to get the Flash Layout
* MagicNumber ( 4 bytes ) + FlashLayoutMinorVersion ( 2 Bytes ) + FlashLayoutMajorVersion ( 2 Bytes )
*/
2012-06-06 20:54:27 -06:00
BeceemFlashBulkRead ( Adapter , ( PUINT ) Adapter - > psFlashCSInfo , Adapter - > ulFlashControlSectionStart , 8 ) ;
2010-09-08 15:46:36 -06:00
Adapter - > psFlashCSInfo - > FlashLayoutVersion = ntohl ( Adapter - > psFlashCSInfo - > FlashLayoutVersion ) ;
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Flash Layout Version :%X " , ( Adapter - > psFlashCSInfo - > FlashLayoutVersion ) ) ;
2012-06-06 20:54:29 -06:00
/* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Layout Minor Version :%d\n", ntohs(sFlashCsInfo.FlashLayoutMinorVersion)); */
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Signature is :%x \n " , ntohl ( Adapter - > psFlashCSInfo - > MagicNumber ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( FLASH_CONTROL_STRUCT_SIGNATURE = = ntohl ( Adapter - > psFlashCSInfo - > MagicNumber ) ) {
2010-09-08 15:46:36 -06:00
uiFlashLayoutMajorVersion = MAJOR_VERSION ( ( Adapter - > psFlashCSInfo - > FlashLayoutVersion ) ) ;
Adapter - > uiFlashLayoutMinorVersion = MINOR_VERSION ( ( Adapter - > psFlashCSInfo - > FlashLayoutVersion ) ) ;
2012-06-06 20:54:28 -06:00
} else {
2010-09-08 15:46:36 -06:00
Adapter - > uiFlashLayoutMinorVersion = 0 ;
uiFlashLayoutMajorVersion = 0 ;
}
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " FLASH LAYOUT MAJOR VERSION :%X " , uiFlashLayoutMajorVersion ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiFlashLayoutMajorVersion < FLASH_2X_MAJOR_NUMBER ) {
2012-11-30 23:15:56 -07:00
BeceemFlashBulkRead ( Adapter , ( PUINT ) Adapter - > psFlashCSInfo , Adapter - > ulFlashControlSectionStart , sizeof ( struct bcm_flash_cs_info ) ) ;
2010-09-08 15:46:36 -06:00
ConvertEndianOfCSStructure ( Adapter - > psFlashCSInfo ) ;
Adapter - > ulFlashCalStart = ( Adapter - > psFlashCSInfo - > OffsetFromZeroForCalibrationStart ) ;
2012-06-06 20:54:27 -06:00
if ( ! ( ( Adapter - > uiFlashLayoutMajorVersion = = 1 ) & & ( Adapter - > uiFlashLayoutMinorVersion = = 1 ) ) )
2010-09-08 15:46:36 -06:00
Adapter - > ulFlashControlSectionStart = Adapter - > psFlashCSInfo - > OffsetFromZeroForControlSectionStart ;
2012-06-06 20:54:27 -06:00
if ( ( FLASH_CONTROL_STRUCT_SIGNATURE = = ( Adapter - > psFlashCSInfo - > MagicNumber ) ) & &
( SCSI_FIRMWARE_MINOR_VERSION < = MINOR_VERSION ( Adapter - > psFlashCSInfo - > SCSIFirmwareVersion ) ) & &
( FLASH_SECTOR_SIZE_SIG = = ( Adapter - > psFlashCSInfo - > FlashSectorSizeSig ) ) & &
2012-06-06 20:54:28 -06:00
( BYTE_WRITE_SUPPORT = = ( Adapter - > psFlashCSInfo - > FlashWriteSupportSize ) ) ) {
2010-09-08 15:46:36 -06:00
Adapter - > ulFlashWriteSize = ( Adapter - > psFlashCSInfo - > FlashWriteSupportSize ) ;
2012-06-06 20:54:27 -06:00
Adapter - > fpFlashWrite = flashByteWrite ;
Adapter - > fpFlashWriteWithStatusCheck = flashByteWriteStatus ;
2012-06-06 20:54:28 -06:00
} else {
2010-09-08 15:46:36 -06:00
Adapter - > ulFlashWriteSize = MAX_RW_SIZE ;
Adapter - > fpFlashWrite = flashWrite ;
2012-06-06 20:54:27 -06:00
Adapter - > fpFlashWriteWithStatusCheck = flashWriteStatus ;
2010-09-08 15:46:36 -06:00
}
BcmGetFlashSectorSize ( Adapter , ( Adapter - > psFlashCSInfo - > FlashSectorSizeSig ) ,
2012-06-06 20:54:27 -06:00
( Adapter - > psFlashCSInfo - > FlashSectorSize ) ) ;
2010-09-08 15:46:36 -06:00
Adapter - > uiFlashBaseAdd = Adapter - > psFlashCSInfo - > FlashBaseAddr & 0xFCFFFFFF ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
if ( BcmFlash2xBulkRead ( Adapter , ( PUINT ) Adapter - > psFlash2xCSInfo , NO_SECTION_VAL ,
2012-11-30 23:15:55 -07:00
Adapter - > ulFlashControlSectionStart , sizeof ( struct bcm_flash2x_cs_info ) ) ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Unable to read CS structure \n " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:27 -06:00
2010-09-08 15:46:36 -06:00
ConvertEndianOf2XCSStructure ( Adapter - > psFlash2xCSInfo ) ;
2012-06-06 20:54:27 -06:00
BcmDumpFlash2XCSStructure ( Adapter - > psFlash2xCSInfo , Adapter ) ;
if ( ( FLASH_CONTROL_STRUCT_SIGNATURE = = Adapter - > psFlash2xCSInfo - > MagicNumber ) & &
( SCSI_FIRMWARE_MINOR_VERSION < = MINOR_VERSION ( Adapter - > psFlash2xCSInfo - > SCSIFirmwareVersion ) ) & &
( FLASH_SECTOR_SIZE_SIG = = Adapter - > psFlash2xCSInfo - > FlashSectorSizeSig ) & &
2012-06-06 20:54:28 -06:00
( BYTE_WRITE_SUPPORT = = Adapter - > psFlash2xCSInfo - > FlashWriteSupportSize ) ) {
2010-09-08 15:46:36 -06:00
Adapter - > ulFlashWriteSize = Adapter - > psFlash2xCSInfo - > FlashWriteSupportSize ;
2012-06-06 20:54:27 -06:00
Adapter - > fpFlashWrite = flashByteWrite ;
Adapter - > fpFlashWriteWithStatusCheck = flashByteWriteStatus ;
2012-06-06 20:54:28 -06:00
} else {
2010-09-08 15:46:36 -06:00
Adapter - > ulFlashWriteSize = MAX_RW_SIZE ;
Adapter - > fpFlashWrite = flashWrite ;
2012-06-06 20:54:27 -06:00
Adapter - > fpFlashWriteWithStatusCheck = flashWriteStatus ;
2010-09-08 15:46:36 -06:00
}
BcmGetFlashSectorSize ( Adapter , Adapter - > psFlash2xCSInfo - > FlashSectorSizeSig ,
2012-06-06 20:54:27 -06:00
Adapter - > psFlash2xCSInfo - > FlashSectorSize ) ;
2010-09-08 15:46:36 -06:00
UpdateVendorInfo ( Adapter ) ;
BcmGetActiveDSD ( Adapter ) ;
BcmGetActiveISO ( Adapter ) ;
Adapter - > uiFlashBaseAdd = Adapter - > psFlash2xCSInfo - > FlashBaseAddr & 0xFCFFFFFF ;
Adapter - > ulFlashControlSectionStart = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForControlSectionStart ;
}
/*
2012-06-06 20:54:29 -06:00
* Concerns : what if CS sector size does not match with this sector size ? ? ?
* what is the indication of AccessBitMap in CS in flash 2. x ? ? ? ?
*/
2010-09-08 15:46:36 -06:00
Adapter - > ulFlashID = BcmReadFlashRDID ( Adapter ) ;
Adapter - > uiFlashLayoutMajorVersion = uiFlashLayoutMajorVersion ;
2012-06-06 20:54:27 -06:00
return STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:29 -06:00
/*
* Procedure : BcmGetNvmType
*
* Description : Finds the type of NVM used .
*
* Arguments :
* Adapter - ptr to Adapter object instance
*
* Returns :
* NVM_TYPE
*
*/
2010-09-08 15:46:36 -06:00
2012-12-21 13:10:36 -07:00
static enum bcm_nvm_type BcmGetNvmType ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiData = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
BeceemEEPROMBulkRead ( Adapter , & uiData , 0x0 , 4 ) ;
if ( uiData = = BECM )
2010-09-08 15:46:36 -06:00
return NVM_EEPROM ;
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:29 -06:00
/*
* Read control struct and get cal addresses before accessing the flash
*/
2010-09-08 15:46:36 -06:00
BcmGetFlashCSInfo ( Adapter ) ;
2012-06-06 20:54:27 -06:00
BeceemFlashBulkRead ( Adapter , & uiData , 0x0 + Adapter - > ulFlashCalStart , 4 ) ;
if ( uiData = = BECM )
2010-09-08 15:46:36 -06:00
return NVM_FLASH ;
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:29 -06:00
/*
* even if there is no valid signature on EEPROM / FLASH find out if they really exist .
* if exist select it .
*/
2012-06-06 20:54:27 -06:00
if ( BcmGetEEPROMSize ( Adapter ) )
2010-09-08 15:46:36 -06:00
return NVM_EEPROM ;
2012-06-06 20:54:29 -06:00
/* TBD for Flash. */
2010-09-08 15:46:36 -06:00
return NVM_UNKNOWN ;
}
2012-06-06 20:54:29 -06:00
/*
* BcmGetSectionValStartOffset - this will calculate the section ' s starting offset if section val is given
* @ Adapter : Drivers Private Data structure
2012-11-22 12:48:50 -07:00
* @ eFlashSectionVal : Flash secion value defined in enum bcm_flash2x_section_val
2012-06-06 20:54:29 -06:00
*
* Return value : -
* On success it return the start offset of the provided section val
* On Failure - returns STATUS_FAILURE
*/
2010-09-08 15:46:36 -06:00
2012-11-22 12:48:50 -07:00
int BcmGetSectionValStartOffset ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val eFlashSectionVal )
2010-09-08 15:46:36 -06:00
{
/*
2012-06-06 20:54:27 -06:00
* Considering all the section for which end offset can be calculated or directly given
* in CS Structure . if matching case does not exist , return STATUS_FAILURE indicating section
* endoffset can ' t be calculated or given in CS Structure .
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
int SectStartOffset = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
SectStartOffset = INVALID_OFFSET ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( IsSectionExistInVendorInfo ( Adapter , eFlashSectionVal ) )
2010-09-08 15:46:36 -06:00
return Adapter - > psFlash2xVendorInfo - > VendorSection [ eFlashSectionVal ] . OffsetFromZeroForSectionStart ;
2012-06-06 20:54:28 -06:00
switch ( eFlashSectionVal ) {
case ISO_IMAGE1 :
if ( ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1Start ! = UNINIT_PTR_IN_CS ) & &
2013-10-28 02:36:19 -06:00
( IsNonCDLessDevice ( Adapter ) = = false ) )
2012-06-06 20:54:28 -06:00
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1Start ) ;
break ;
case ISO_IMAGE2 :
if ( ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1Start ! = UNINIT_PTR_IN_CS ) & &
2013-10-28 02:36:19 -06:00
( IsNonCDLessDevice ( Adapter ) = = false ) )
2012-06-06 20:54:28 -06:00
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1Start ) ;
break ;
case DSD0 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSDStart ! = UNINIT_PTR_IN_CS )
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSDStart ) ;
break ;
case DSD1 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD1Start ! = UNINIT_PTR_IN_CS )
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD1Start ) ;
break ;
case DSD2 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD2Start ! = UNINIT_PTR_IN_CS )
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD2Start ) ;
break ;
case VSA0 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSAStart ! = UNINIT_PTR_IN_CS )
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSAStart ) ;
break ;
case VSA1 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA1Start ! = UNINIT_PTR_IN_CS )
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA1Start ) ;
break ;
case VSA2 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA2Start ! = UNINIT_PTR_IN_CS )
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA2Start ) ;
break ;
case SCSI :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForScsiFirmware ! = UNINIT_PTR_IN_CS )
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForScsiFirmware ) ;
break ;
case CONTROL_SECTION :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForControlSectionStart ! = UNINIT_PTR_IN_CS )
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForControlSectionStart ) ;
break ;
case ISO_IMAGE1_PART2 :
if ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part2Start ! = UNINIT_PTR_IN_CS )
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part2Start ) ;
break ;
case ISO_IMAGE1_PART3 :
if ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part3Start ! = UNINIT_PTR_IN_CS )
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part3Start ) ;
break ;
case ISO_IMAGE2_PART2 :
if ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part2Start ! = UNINIT_PTR_IN_CS )
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part2Start ) ;
break ;
case ISO_IMAGE2_PART3 :
if ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part3Start ! = UNINIT_PTR_IN_CS )
SectStartOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part3Start ) ;
break ;
default :
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Section Does not exist in Flash 2.x " ) ;
SectStartOffset = INVALID_OFFSET ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2010-09-08 15:46:36 -06:00
return SectStartOffset ;
}
2012-06-06 20:54:29 -06:00
/*
* BcmGetSectionValEndOffset - this will calculate the section ' s Ending offset if section val is given
* @ Adapter : Drivers Private Data structure
2012-11-22 12:48:50 -07:00
* @ eFlashSectionVal : Flash secion value defined in enum bcm_flash2x_section_val
2012-06-06 20:54:29 -06:00
*
* Return value : -
* On success it return the end offset of the provided section val
* On Failure - returns STATUS_FAILURE
*/
2010-09-08 15:46:36 -06:00
2014-03-13 12:02:46 -06:00
static int BcmGetSectionValEndOffset ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val eFlash2xSectionVal )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:52 -06:00
int SectEndOffset = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
SectEndOffset = INVALID_OFFSET ;
if ( IsSectionExistInVendorInfo ( Adapter , eFlash2xSectionVal ) )
2010-09-08 15:46:36 -06:00
return Adapter - > psFlash2xVendorInfo - > VendorSection [ eFlash2xSectionVal ] . OffsetFromZeroForSectionEnd ;
2012-06-06 20:54:28 -06:00
switch ( eFlash2xSectionVal ) {
case ISO_IMAGE1 :
if ( ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1End ! = UNINIT_PTR_IN_CS ) & &
2013-10-28 02:36:19 -06:00
( IsNonCDLessDevice ( Adapter ) = = false ) )
2012-06-06 20:54:28 -06:00
SectEndOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1End ) ;
break ;
case ISO_IMAGE2 :
if ( ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1End ! = UNINIT_PTR_IN_CS ) & &
2013-10-28 02:36:19 -06:00
( IsNonCDLessDevice ( Adapter ) = = false ) )
2012-06-06 20:54:28 -06:00
SectEndOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1End ) ;
break ;
case DSD0 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSDEnd ! = UNINIT_PTR_IN_CS )
SectEndOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSDEnd ) ;
break ;
case DSD1 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD1End ! = UNINIT_PTR_IN_CS )
SectEndOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD1End ) ;
break ;
case DSD2 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD2End ! = UNINIT_PTR_IN_CS )
SectEndOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD2End ) ;
break ;
case VSA0 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSAEnd ! = UNINIT_PTR_IN_CS )
SectEndOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSAEnd ) ;
break ;
case VSA1 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA1End ! = UNINIT_PTR_IN_CS )
SectEndOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA1End ) ;
break ;
case VSA2 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA2End ! = UNINIT_PTR_IN_CS )
SectEndOffset = ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA2End ) ;
break ;
case SCSI :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForScsiFirmware ! = UNINIT_PTR_IN_CS )
SectEndOffset = ( ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForScsiFirmware ) +
( Adapter - > psFlash2xCSInfo - > SizeOfScsiFirmware ) ) ;
break ;
case CONTROL_SECTION :
2012-06-06 20:54:29 -06:00
/* Not Clear So Putting failure. confirm and fix it. */
2012-06-06 20:54:28 -06:00
SectEndOffset = STATUS_FAILURE ;
2013-01-10 23:55:18 -07:00
break ;
2012-06-06 20:54:28 -06:00
case ISO_IMAGE1_PART2 :
if ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part2End ! = UNINIT_PTR_IN_CS )
SectEndOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part2End ) ;
break ;
case ISO_IMAGE1_PART3 :
if ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part3End ! = UNINIT_PTR_IN_CS )
SectEndOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part3End ) ;
break ;
case ISO_IMAGE2_PART2 :
if ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part2End ! = UNINIT_PTR_IN_CS )
SectEndOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part2End ) ;
break ;
case ISO_IMAGE2_PART3 :
if ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part3End ! = UNINIT_PTR_IN_CS )
SectEndOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part3End ) ;
break ;
default :
SectEndOffset = INVALID_OFFSET ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2013-09-10 09:44:39 -06:00
return SectEndOffset ;
2010-09-08 15:46:36 -06:00
}
/*
2012-06-06 20:54:29 -06:00
* BcmFlash2xBulkRead : - Read API for Flash Map 2. x .
* @ Adapter : Driver Private Data Structure
* @ pBuffer : Buffer where data has to be put after reading
2012-11-22 12:48:50 -07:00
* @ eFlashSectionVal : Flash Section Val defined in enum bcm_flash2x_section_val
2012-06-06 20:54:29 -06:00
* @ uiOffsetWithinSectionVal : - Offset with in provided section
* @ uiNumBytes : Number of Bytes for Read
*
* Return value : -
* return true on success and STATUS_FAILURE on fail .
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
int BcmFlash2xBulkRead ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
PUINT pBuffer ,
2012-11-22 12:48:50 -07:00
enum bcm_flash2x_section_val eFlash2xSectionVal ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffsetWithinSectionVal ,
unsigned int uiNumBytes )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:52 -06:00
int Status = STATUS_SUCCESS ;
int SectionStartOffset = 0 ;
2012-06-19 18:14:53 -06:00
unsigned int uiAbsoluteOffset = 0 ;
unsigned int uiTemp = 0 , value = 0 ;
2012-06-06 20:54:27 -06:00
2012-06-19 18:14:54 -06:00
if ( ! Adapter ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Adapter structure is NULL " ) ;
2010-09-08 15:46:36 -06:00
return - EINVAL ;
}
2012-06-06 20:54:28 -06:00
if ( Adapter - > device_removed ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Device has been removed " ) ;
2010-09-08 15:46:36 -06:00
return - ENODEV ;
}
2012-06-06 20:54:29 -06:00
/* NO_SECTION_VAL means absolute offset is given. */
2012-06-06 20:54:27 -06:00
if ( eFlash2xSectionVal = = NO_SECTION_VAL )
2010-09-08 15:46:36 -06:00
SectionStartOffset = 0 ;
else
2012-06-06 20:54:27 -06:00
SectionStartOffset = BcmGetSectionValStartOffset ( Adapter , eFlash2xSectionVal ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( SectionStartOffset = = STATUS_FAILURE ) {
2014-01-10 19:26:27 -07:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " This Section<%d> does not exist in Flash 2.x Map " , eFlash2xSectionVal ) ;
2010-09-08 15:46:36 -06:00
return - EINVAL ;
}
2012-06-06 20:54:27 -06:00
if ( IsSectionExistInVendorInfo ( Adapter , eFlash2xSectionVal ) )
return vendorextnReadSection ( Adapter , ( PUCHAR ) pBuffer , eFlash2xSectionVal , uiOffsetWithinSectionVal , uiNumBytes ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* calculating the absolute offset from FLASH; */
2010-09-08 15:46:36 -06:00
uiAbsoluteOffset = uiOffsetWithinSectionVal + SectionStartOffset ;
rdmalt ( Adapter , 0x0f000C80 , & uiTemp , sizeof ( uiTemp ) ) ;
value = 0 ;
2012-06-06 20:54:27 -06:00
wrmalt ( Adapter , 0x0f000C80 , & value , sizeof ( value ) ) ;
Status = BeceemFlashBulkRead ( Adapter , pBuffer , uiAbsoluteOffset , uiNumBytes ) ;
2010-09-08 15:46:36 -06:00
wrmalt ( Adapter , 0x0f000C80 , & uiTemp , sizeof ( uiTemp ) ) ;
2012-06-06 20:54:28 -06:00
if ( Status ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Flash Read Failed with Status :%d " , Status ) ;
return Status ;
2010-09-08 15:46:36 -06:00
}
return Status ;
}
/*
2012-06-06 20:54:29 -06:00
* BcmFlash2xBulkWrite : - API for Writing on the Flash Map 2. x .
* @ Adapter : Driver Private Data Structure
* @ pBuffer : Buffer From where data has to taken for writing
2012-11-22 12:48:50 -07:00
* @ eFlashSectionVal : Flash Section Val defined in enum bcm_flash2x_section_val
2012-06-06 20:54:29 -06:00
* @ uiOffsetWithinSectionVal : - Offset with in provided section
* @ uiNumBytes : Number of Bytes for Write
*
* Return value : -
* return true on success and STATUS_FAILURE on fail .
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
int BcmFlash2xBulkWrite ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
PUINT pBuffer ,
2012-11-22 12:48:50 -07:00
enum bcm_flash2x_section_val eFlash2xSectVal ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
unsigned int uiNumBytes ,
unsigned int bVerify )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:52 -06:00
int Status = STATUS_SUCCESS ;
2012-06-19 18:14:53 -06:00
unsigned int FlashSectValStartOffset = 0 ;
unsigned int uiTemp = 0 , value = 0 ;
2012-06-06 20:54:27 -06:00
2012-06-19 18:14:54 -06:00
if ( ! Adapter ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Adapter structure is NULL " ) ;
2010-09-08 15:46:36 -06:00
return - EINVAL ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( Adapter - > device_removed ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Device has been removed " ) ;
2010-09-08 15:46:36 -06:00
return - ENODEV ;
}
2012-06-06 20:54:29 -06:00
/* NO_SECTION_VAL means absolute offset is given. */
2012-06-06 20:54:27 -06:00
if ( eFlash2xSectVal = = NO_SECTION_VAL )
2010-09-08 15:46:36 -06:00
FlashSectValStartOffset = 0 ;
else
2012-06-06 20:54:27 -06:00
FlashSectValStartOffset = BcmGetSectionValStartOffset ( Adapter , eFlash2xSectVal ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( FlashSectValStartOffset = = STATUS_FAILURE ) {
2014-01-10 19:26:27 -07:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " This Section<%d> does not exist in Flash Map 2.x " , eFlash2xSectVal ) ;
2010-09-08 15:46:36 -06:00
return - EINVAL ;
}
2012-06-06 20:54:27 -06:00
if ( IsSectionExistInVendorInfo ( Adapter , eFlash2xSectVal ) )
2010-09-08 15:46:36 -06:00
return vendorextnWriteSection ( Adapter , ( PUCHAR ) pBuffer , eFlash2xSectVal , uiOffset , uiNumBytes , bVerify ) ;
2012-06-06 20:54:29 -06:00
/* calculating the absolute offset from FLASH; */
2010-09-08 15:46:36 -06:00
uiOffset = uiOffset + FlashSectValStartOffset ;
rdmalt ( Adapter , 0x0f000C80 , & uiTemp , sizeof ( uiTemp ) ) ;
value = 0 ;
2012-06-06 20:54:27 -06:00
wrmalt ( Adapter , 0x0f000C80 , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
Status = BeceemFlashBulkWrite ( Adapter , pBuffer , uiOffset , uiNumBytes , bVerify ) ;
2010-09-08 15:46:36 -06:00
wrmalt ( Adapter , 0x0f000C80 , & uiTemp , sizeof ( uiTemp ) ) ;
2012-06-06 20:54:28 -06:00
if ( Status ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Flash Write failed with Status :%d " , Status ) ;
return Status ;
2010-09-08 15:46:36 -06:00
}
return Status ;
}
2012-06-06 20:54:29 -06:00
/*
* BcmGetActiveDSD : Set the Active DSD in Adapter Structure which has to be dumped in DDR
* @ Adapter : - Drivers private Data Structure
*
* Return Value : -
2013-08-23 07:55:31 -06:00
* Return STATUS_SUCESS if get success in setting the right DSD else negative error code
2012-06-06 20:54:29 -06:00
*
*/
2012-06-06 20:54:27 -06:00
2012-06-19 18:14:52 -06:00
static int BcmGetActiveDSD ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-11-22 12:48:50 -07:00
enum bcm_flash2x_section_val uiHighestPriDSD = 0 ;
2010-09-08 15:46:36 -06:00
uiHighestPriDSD = getHighestPriDSD ( Adapter ) ;
Adapter - > eActiveDSD = uiHighestPriDSD ;
2012-06-06 20:54:27 -06:00
if ( DSD0 = = uiHighestPriDSD )
2010-09-08 15:46:36 -06:00
Adapter - > ulFlashCalStart = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSDStart ;
2012-06-06 20:54:27 -06:00
if ( DSD1 = = uiHighestPriDSD )
2010-09-08 15:46:36 -06:00
Adapter - > ulFlashCalStart = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD1Start ;
2012-06-06 20:54:27 -06:00
if ( DSD2 = = uiHighestPriDSD )
2010-09-08 15:46:36 -06:00
Adapter - > ulFlashCalStart = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD2Start ;
2012-06-06 20:54:27 -06:00
if ( Adapter - > eActiveDSD )
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Active DSD :%d " , Adapter - > eActiveDSD ) ;
2012-06-06 20:54:28 -06:00
if ( Adapter - > eActiveDSD = = 0 ) {
2012-06-06 20:54:29 -06:00
/* if No DSD gets Active, Make Active the DSD with WR permission */
2012-06-06 20:54:28 -06:00
if ( IsSectionWritable ( Adapter , DSD2 ) ) {
2010-09-08 15:46:36 -06:00
Adapter - > eActiveDSD = DSD2 ;
Adapter - > ulFlashCalStart = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD2Start ;
2012-06-06 20:54:28 -06:00
} else if ( IsSectionWritable ( Adapter , DSD1 ) ) {
2010-09-08 15:46:36 -06:00
Adapter - > eActiveDSD = DSD1 ;
Adapter - > ulFlashCalStart = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD1Start ;
2012-06-06 20:54:28 -06:00
} else if ( IsSectionWritable ( Adapter , DSD0 ) ) {
2010-09-08 15:46:36 -06:00
Adapter - > eActiveDSD = DSD0 ;
Adapter - > ulFlashCalStart = Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSDStart ;
}
}
return STATUS_SUCCESS ;
}
2012-06-06 20:54:29 -06:00
/*
* BcmGetActiveISO : - Set the Active ISO in Adapter Data Structue
* @ Adapter : Driver private Data Structure
*
* Return Value : -
* Sucsess : - STATUS_SUCESS
* Failure - : negative erro code
*
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int BcmGetActiveISO ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:52 -06:00
int HighestPriISO = 0 ;
2010-09-08 15:46:36 -06:00
HighestPriISO = getHighestPriISO ( Adapter ) ;
2012-06-06 20:54:27 -06:00
Adapter - > eActiveISO = HighestPriISO ;
if ( Adapter - > eActiveISO = = ISO_IMAGE2 )
2010-09-08 15:46:36 -06:00
Adapter - > uiActiveISOOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1Start ) ;
2012-06-06 20:54:27 -06:00
else if ( Adapter - > eActiveISO = = ISO_IMAGE1 )
2010-09-08 15:46:36 -06:00
Adapter - > uiActiveISOOffset = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1Start ) ;
2012-06-06 20:54:27 -06:00
if ( Adapter - > eActiveISO )
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Active ISO :%x " , Adapter - > eActiveISO ) ;
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
}
2012-06-06 20:54:29 -06:00
/*
* IsOffsetWritable : - it will tell the access permission of the sector having passed offset
* @ Adapter : Drivers Private Data Structure
* @ uiOffset : Offset provided in the Flash
*
* Return Value : -
* Success : - TRUE , offset is writable
2013-10-28 02:36:19 -06:00
* Failure : - false , offset is RO
2012-06-06 20:54:29 -06:00
*
*/
2012-06-06 20:54:27 -06:00
2014-03-13 12:02:46 -06:00
static B_UINT8 IsOffsetWritable ( struct bcm_mini_adapter * Adapter , unsigned int uiOffset )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiSectorNum = 0 ;
unsigned int uiWordOfSectorPermission = 0 ;
unsigned int uiBitofSectorePermission = 0 ;
2010-09-08 15:46:36 -06:00
B_UINT32 permissionBits = 0 ;
2012-06-06 20:54:27 -06:00
2010-09-08 15:46:36 -06:00
uiSectorNum = uiOffset / Adapter - > uiSectorSize ;
2012-06-06 20:54:29 -06:00
/* calculating the word having this Sector Access permission from SectorAccessBitMap Array */
2012-06-06 20:54:27 -06:00
uiWordOfSectorPermission = Adapter - > psFlash2xCSInfo - > SectorAccessBitMap [ uiSectorNum / 16 ] ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* calculating the bit index inside the word for this sector */
2012-06-06 20:54:27 -06:00
uiBitofSectorePermission = 2 * ( 15 - uiSectorNum % 16 ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* Setting Access permission */
2012-06-06 20:54:27 -06:00
permissionBits = uiWordOfSectorPermission & ( 0x3 < < uiBitofSectorePermission ) ;
2010-09-08 15:46:36 -06:00
permissionBits = ( permissionBits > > uiBitofSectorePermission ) & 0x3 ;
2012-06-06 20:54:27 -06:00
if ( permissionBits = = SECTOR_READWRITE_PERMISSION )
return TRUE ;
2010-09-08 15:46:36 -06:00
else
2013-10-28 02:36:19 -06:00
return false ;
2010-09-08 15:46:36 -06:00
}
2012-11-22 12:48:42 -07:00
static int BcmDumpFlash2xSectionBitMap ( struct bcm_flash2x_bitmap * psFlash2xBitMap )
2010-09-08 15:46:36 -06:00
{
2012-05-26 10:05:12 -06:00
struct bcm_mini_adapter * Adapter = GET_BCM_ADAPTER ( gblpnetdev ) ;
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " ***************Flash 2.x Section Bitmap*************** " ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " ISO_IMAGE1 :0X%x " , psFlash2xBitMap - > ISO_IMAGE1 ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " ISO_IMAGE2 :0X%x " , psFlash2xBitMap - > ISO_IMAGE2 ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " DSD0 :0X%x " , psFlash2xBitMap - > DSD0 ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " DSD1 :0X%x " , psFlash2xBitMap - > DSD1 ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " DSD2 :0X%x " , psFlash2xBitMap - > DSD2 ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " VSA0 :0X%x " , psFlash2xBitMap - > VSA0 ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " VSA1 :0X%x " , psFlash2xBitMap - > VSA1 ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " VSA2 :0X%x " , psFlash2xBitMap - > VSA2 ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " SCSI :0X%x " , psFlash2xBitMap - > SCSI ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " CONTROL_SECTION :0X%x " , psFlash2xBitMap - > CONTROL_SECTION ) ;
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
}
2012-06-06 20:54:29 -06:00
/*
* BcmGetFlash2xSectionalBitMap : - It will provide the bit map of all the section present in Flash
* 8 bit has been assigned to every section .
* bit [ 0 ] : Section present or not
* bit [ 1 ] : section is valid or not
* bit [ 2 ] : Secton is read only or has write permission too .
* bit [ 3 ] : Active Section -
* bit [ 7. . .4 ] = Reserved .
*
* @ Adapter : - Driver private Data Structure
*
* Return value : -
* Success : - STATUS_SUCESS
* Failure : - negative error code
*/
2010-09-08 15:46:36 -06:00
2012-11-22 12:48:42 -07:00
int BcmGetFlash2xSectionalBitMap ( struct bcm_mini_adapter * Adapter , struct bcm_flash2x_bitmap * psFlash2xBitMap )
2010-09-08 15:46:36 -06:00
{
2012-11-30 23:15:55 -07:00
struct bcm_flash2x_cs_info * psFlash2xCSInfo = Adapter - > psFlash2xCSInfo ;
2012-11-22 12:48:50 -07:00
enum bcm_flash2x_section_val uiHighestPriDSD = 0 ;
enum bcm_flash2x_section_val uiHighestPriISO = 0 ;
2013-10-28 02:36:19 -06:00
bool SetActiveDSDDone = false ;
bool SetActiveISODone = false ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* For 1.x map all the section except DSD0 will be shown as not present
* This part will be used by calibration tool to detect the number of DSD present in Flash .
*/
2013-10-28 02:36:19 -06:00
if ( IsFlash2x ( Adapter ) = = false ) {
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > ISO_IMAGE2 = 0 ;
psFlash2xBitMap - > ISO_IMAGE1 = 0 ;
2012-06-06 20:54:29 -06:00
psFlash2xBitMap - > DSD0 = FLASH2X_SECTION_VALID | FLASH2X_SECTION_ACT | FLASH2X_SECTION_PRESENT ; /* 0xF; 0000(Reseved)1(Active)0(RW)1(valid)1(present) */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > DSD1 = 0 ;
psFlash2xBitMap - > DSD2 = 0 ;
psFlash2xBitMap - > VSA0 = 0 ;
psFlash2xBitMap - > VSA1 = 0 ;
psFlash2xBitMap - > VSA2 = 0 ;
psFlash2xBitMap - > CONTROL_SECTION = 0 ;
psFlash2xBitMap - > SCSI = 0 ;
psFlash2xBitMap - > Reserved0 = 0 ;
psFlash2xBitMap - > Reserved1 = 0 ;
psFlash2xBitMap - > Reserved2 = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
return STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
}
uiHighestPriDSD = getHighestPriDSD ( Adapter ) ;
uiHighestPriISO = getHighestPriISO ( Adapter ) ;
2012-06-06 20:54:29 -06:00
/*
* IS0 IMAGE 2
*/
2012-06-06 20:54:28 -06:00
if ( ( psFlash2xCSInfo - > OffsetISOImage2Part1Start ) ! = UNINIT_PTR_IN_CS ) {
2012-06-06 20:54:29 -06:00
/* Setting the 0th Bit representing the Section is present or not. */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > ISO_IMAGE2 = psFlash2xBitMap - > ISO_IMAGE2 | FLASH2X_SECTION_PRESENT ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( ReadISOSignature ( Adapter , ISO_IMAGE2 ) = = ISO_IMAGE_MAGIC_NUMBER )
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > ISO_IMAGE2 | = FLASH2X_SECTION_VALID ;
2012-06-06 20:54:29 -06:00
/* Calculation for extrating the Access permission */
2013-10-28 02:36:19 -06:00
if ( IsSectionWritable ( Adapter , ISO_IMAGE2 ) = = false )
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > ISO_IMAGE2 | = FLASH2X_SECTION_RO ;
2013-10-28 02:36:19 -06:00
if ( SetActiveISODone = = false & & uiHighestPriISO = = ISO_IMAGE2 ) {
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > ISO_IMAGE2 | = FLASH2X_SECTION_ACT ;
2010-09-08 15:46:36 -06:00
SetActiveISODone = TRUE ;
}
}
2012-06-06 20:54:29 -06:00
/*
* IS0 IMAGE 1
*/
2012-06-06 20:54:28 -06:00
if ( ( psFlash2xCSInfo - > OffsetISOImage1Part1Start ) ! = UNINIT_PTR_IN_CS ) {
2012-06-06 20:54:29 -06:00
/* Setting the 0th Bit representing the Section is present or not. */
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > ISO_IMAGE1 = psFlash2xBitMap - > ISO_IMAGE1 | FLASH2X_SECTION_PRESENT ;
2012-06-06 20:54:27 -06:00
if ( ReadISOSignature ( Adapter , ISO_IMAGE1 ) = = ISO_IMAGE_MAGIC_NUMBER )
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > ISO_IMAGE1 | = FLASH2X_SECTION_VALID ;
2012-06-06 20:54:29 -06:00
/* Calculation for extrating the Access permission */
2013-10-28 02:36:19 -06:00
if ( IsSectionWritable ( Adapter , ISO_IMAGE1 ) = = false )
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > ISO_IMAGE1 | = FLASH2X_SECTION_RO ;
2013-10-28 02:36:19 -06:00
if ( SetActiveISODone = = false & & uiHighestPriISO = = ISO_IMAGE1 ) {
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > ISO_IMAGE1 | = FLASH2X_SECTION_ACT ;
2010-09-08 15:46:36 -06:00
SetActiveISODone = TRUE ;
}
}
2012-06-06 20:54:29 -06:00
/*
* DSD2
*/
2012-06-06 20:54:28 -06:00
if ( ( psFlash2xCSInfo - > OffsetFromZeroForDSD2Start ) ! = UNINIT_PTR_IN_CS ) {
2012-06-06 20:54:29 -06:00
/* Setting the 0th Bit representing the Section is present or not. */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > DSD2 = psFlash2xBitMap - > DSD2 | FLASH2X_SECTION_PRESENT ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( ReadDSDSignature ( Adapter , DSD2 ) = = DSD_IMAGE_MAGIC_NUMBER )
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > DSD2 | = FLASH2X_SECTION_VALID ;
2012-06-06 20:54:29 -06:00
/* Calculation for extrating the Access permission */
2013-10-28 02:36:19 -06:00
if ( IsSectionWritable ( Adapter , DSD2 ) = = false ) {
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > DSD2 | = FLASH2X_SECTION_RO ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:29 -06:00
/* Means section is writable */
2013-10-28 02:36:19 -06:00
if ( ( SetActiveDSDDone = = false ) & & ( uiHighestPriDSD = = DSD2 ) ) {
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > DSD2 | = FLASH2X_SECTION_ACT ;
SetActiveDSDDone = TRUE ;
2010-09-08 15:46:36 -06:00
}
}
}
2012-06-06 20:54:29 -06:00
/*
* DSD 1
*/
2012-06-06 20:54:28 -06:00
if ( ( psFlash2xCSInfo - > OffsetFromZeroForDSD1Start ) ! = UNINIT_PTR_IN_CS ) {
2012-06-06 20:54:29 -06:00
/* Setting the 0th Bit representing the Section is present or not. */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > DSD1 = psFlash2xBitMap - > DSD1 | FLASH2X_SECTION_PRESENT ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( ReadDSDSignature ( Adapter , DSD1 ) = = DSD_IMAGE_MAGIC_NUMBER )
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > DSD1 | = FLASH2X_SECTION_VALID ;
2012-06-06 20:54:29 -06:00
/* Calculation for extrating the Access permission */
2013-10-28 02:36:19 -06:00
if ( IsSectionWritable ( Adapter , DSD1 ) = = false ) {
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > DSD1 | = FLASH2X_SECTION_RO ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:29 -06:00
/* Means section is writable */
2013-10-28 02:36:19 -06:00
if ( ( SetActiveDSDDone = = false ) & & ( uiHighestPriDSD = = DSD1 ) ) {
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > DSD1 | = FLASH2X_SECTION_ACT ;
SetActiveDSDDone = TRUE ;
2010-09-08 15:46:36 -06:00
}
}
}
2012-06-06 20:54:29 -06:00
/*
* For DSD 0
*/
2012-06-06 20:54:28 -06:00
if ( ( psFlash2xCSInfo - > OffsetFromZeroForDSDStart ) ! = UNINIT_PTR_IN_CS ) {
2012-06-06 20:54:29 -06:00
/* Setting the 0th Bit representing the Section is present or not. */
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > DSD0 = psFlash2xBitMap - > DSD0 | FLASH2X_SECTION_PRESENT ;
2012-06-06 20:54:27 -06:00
if ( ReadDSDSignature ( Adapter , DSD0 ) = = DSD_IMAGE_MAGIC_NUMBER )
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > DSD0 | = FLASH2X_SECTION_VALID ;
2012-06-06 20:54:29 -06:00
/* Setting Access permission */
2013-10-28 02:36:19 -06:00
if ( IsSectionWritable ( Adapter , DSD0 ) = = false ) {
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > DSD0 | = FLASH2X_SECTION_RO ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:29 -06:00
/* Means section is writable */
2013-10-28 02:36:19 -06:00
if ( ( SetActiveDSDDone = = false ) & & ( uiHighestPriDSD = = DSD0 ) ) {
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > DSD0 | = FLASH2X_SECTION_ACT ;
SetActiveDSDDone = TRUE ;
2010-09-08 15:46:36 -06:00
}
}
}
2012-06-06 20:54:29 -06:00
/*
* VSA 0
*/
2012-06-06 20:54:28 -06:00
if ( ( psFlash2xCSInfo - > OffsetFromZeroForVSAStart ) ! = UNINIT_PTR_IN_CS ) {
2012-06-06 20:54:29 -06:00
/* Setting the 0th Bit representing the Section is present or not. */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > VSA0 = psFlash2xBitMap - > VSA0 | FLASH2X_SECTION_PRESENT ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* Setting the Access Bit. Map is not defined hece setting it always valid */
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > VSA0 | = FLASH2X_SECTION_VALID ;
2012-06-06 20:54:29 -06:00
/* Calculation for extrating the Access permission */
2013-10-28 02:36:19 -06:00
if ( IsSectionWritable ( Adapter , VSA0 ) = = false )
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > VSA0 | = FLASH2X_SECTION_RO ;
2012-06-06 20:54:29 -06:00
/* By Default section is Active */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > VSA0 | = FLASH2X_SECTION_ACT ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:29 -06:00
/*
* VSA 1
*/
2012-06-06 20:54:28 -06:00
if ( ( psFlash2xCSInfo - > OffsetFromZeroForVSA1Start ) ! = UNINIT_PTR_IN_CS ) {
2012-06-06 20:54:29 -06:00
/* Setting the 0th Bit representing the Section is present or not. */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > VSA1 = psFlash2xBitMap - > VSA1 | FLASH2X_SECTION_PRESENT ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* Setting the Access Bit. Map is not defined hece setting it always valid */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > VSA1 | = FLASH2X_SECTION_VALID ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* Checking For Access permission */
2013-10-28 02:36:19 -06:00
if ( IsSectionWritable ( Adapter , VSA1 ) = = false )
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > VSA1 | = FLASH2X_SECTION_RO ;
2012-06-06 20:54:29 -06:00
/* By Default section is Active */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > VSA1 | = FLASH2X_SECTION_ACT ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:29 -06:00
/*
* VSA 2
*/
2012-06-06 20:54:28 -06:00
if ( ( psFlash2xCSInfo - > OffsetFromZeroForVSA2Start ) ! = UNINIT_PTR_IN_CS ) {
2012-06-06 20:54:29 -06:00
/* Setting the 0th Bit representing the Section is present or not. */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > VSA2 = psFlash2xBitMap - > VSA2 | FLASH2X_SECTION_PRESENT ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* Setting the Access Bit. Map is not defined hece setting it always valid */
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > VSA2 | = FLASH2X_SECTION_VALID ;
2012-06-06 20:54:29 -06:00
/* Checking For Access permission */
2013-10-28 02:36:19 -06:00
if ( IsSectionWritable ( Adapter , VSA2 ) = = false )
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > VSA2 | = FLASH2X_SECTION_RO ;
2012-06-06 20:54:29 -06:00
/* By Default section is Active */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > VSA2 | = FLASH2X_SECTION_ACT ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:29 -06:00
/*
* SCSI Section
*/
2012-06-06 20:54:28 -06:00
if ( ( psFlash2xCSInfo - > OffsetFromZeroForScsiFirmware ) ! = UNINIT_PTR_IN_CS ) {
2012-06-06 20:54:29 -06:00
/* Setting the 0th Bit representing the Section is present or not. */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > SCSI = psFlash2xBitMap - > SCSI | FLASH2X_SECTION_PRESENT ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* Setting the Access Bit. Map is not defined hece setting it always valid */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > SCSI | = FLASH2X_SECTION_VALID ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* Checking For Access permission */
2013-10-28 02:36:19 -06:00
if ( IsSectionWritable ( Adapter , SCSI ) = = false )
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > SCSI | = FLASH2X_SECTION_RO ;
2012-06-06 20:54:29 -06:00
/* By Default section is Active */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > SCSI | = FLASH2X_SECTION_ACT ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:29 -06:00
/*
* Control Section
*/
2012-06-06 20:54:28 -06:00
if ( ( psFlash2xCSInfo - > OffsetFromZeroForControlSectionStart ) ! = UNINIT_PTR_IN_CS ) {
2012-06-06 20:54:29 -06:00
/* Setting the 0th Bit representing the Section is present or not. */
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > CONTROL_SECTION = psFlash2xBitMap - > CONTROL_SECTION | ( FLASH2X_SECTION_PRESENT ) ;
2012-06-06 20:54:29 -06:00
/* Setting the Access Bit. Map is not defined hece setting it always valid */
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > CONTROL_SECTION | = FLASH2X_SECTION_VALID ;
2012-06-06 20:54:29 -06:00
/* Checking For Access permission */
2013-10-28 02:36:19 -06:00
if ( IsSectionWritable ( Adapter , CONTROL_SECTION ) = = false )
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > CONTROL_SECTION | = FLASH2X_SECTION_RO ;
2012-06-06 20:54:29 -06:00
/* By Default section is Active */
2012-06-06 20:54:27 -06:00
psFlash2xBitMap - > CONTROL_SECTION | = FLASH2X_SECTION_ACT ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:29 -06:00
/*
* For Reserved Sections
*/
2010-09-08 15:46:36 -06:00
psFlash2xBitMap - > Reserved0 = 0 ;
psFlash2xBitMap - > Reserved0 = 0 ;
psFlash2xBitMap - > Reserved0 = 0 ;
BcmDumpFlash2xSectionBitMap ( psFlash2xBitMap ) ;
2012-06-06 20:54:27 -06:00
return STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:29 -06:00
/*
* BcmSetActiveSection : - Set Active section is used to make priority field highest over other
* section of same type .
*
* @ Adapater : - Bcm Driver Private Data Structure
* @ eFlash2xSectionVal : - Flash section val whose priority has to be made highest .
*
* Return Value : - Make the priorit highest else return erorr code
*
*/
2012-06-06 20:54:27 -06:00
2012-11-22 12:48:50 -07:00
int BcmSetActiveSection ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val eFlash2xSectVal )
2010-09-08 15:46:36 -06:00
{
2010-09-30 02:24:12 -06:00
unsigned int SectImagePriority = 0 ;
2012-06-19 18:14:52 -06:00
int Status = STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
2012-11-30 23:15:52 -07:00
/* struct bcm_dsd_header sDSD = {0};
2012-11-30 23:15:51 -07:00
* struct bcm_iso_header sISO = { 0 } ;
2012-06-06 20:54:29 -06:00
*/
2013-09-10 09:44:39 -06:00
int HighestPriDSD = 0 ;
2012-06-19 18:14:52 -06:00
int HighestPriISO = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
Status = IsSectionWritable ( Adapter , eFlash2xSectVal ) ;
2012-06-06 20:54:28 -06:00
if ( Status ! = TRUE ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Provided Section <%d> is not writable " , eFlash2xSectVal ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:27 -06:00
Adapter - > bHeaderChangeAllowed = TRUE ;
2012-06-06 20:54:28 -06:00
switch ( eFlash2xSectVal ) {
case ISO_IMAGE1 :
case ISO_IMAGE2 :
if ( ReadISOSignature ( Adapter , eFlash2xSectVal ) = = ISO_IMAGE_MAGIC_NUMBER ) {
HighestPriISO = getHighestPriISO ( Adapter ) ;
if ( HighestPriISO = = eFlash2xSectVal ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Given ISO<%x> already has highest priority " , eFlash2xSectVal ) ;
Status = STATUS_SUCCESS ;
break ;
}
SectImagePriority = ReadISOPriority ( Adapter , HighestPriISO ) + 1 ;
2014-06-25 08:38:01 -06:00
if ( ( SectImagePriority = = 0 ) & & IsSectionWritable ( Adapter , HighestPriISO ) ) {
2012-06-06 20:54:29 -06:00
/* This is a SPECIAL Case which will only happen if the current highest priority ISO has priority value = 0x7FFFFFFF.
* We will write 1 to the current Highest priority ISO And then shall increase the priority of the requested ISO
* by user
*/
2012-06-06 20:54:28 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " SectImagePriority wraparound happened, eFlash2xSectVal: 0x%x \n " , eFlash2xSectVal ) ;
SectImagePriority = htonl ( 0x1 ) ;
Status = BcmFlash2xBulkWrite ( Adapter ,
& SectImagePriority ,
HighestPriISO ,
2012-11-30 23:15:51 -07:00
0 + FIELD_OFFSET_IN_HEADER ( struct bcm_iso_header * , ISOImagePriority ) ,
2012-06-06 20:54:28 -06:00
SIGNATURE_SIZE ,
TRUE ) ;
if ( Status ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Priority has not been written properly " ) ;
Status = STATUS_FAILURE ;
break ;
}
2010-09-08 15:46:36 -06:00
HighestPriISO = getHighestPriISO ( Adapter ) ;
2012-06-06 20:54:28 -06:00
if ( HighestPriISO = = eFlash2xSectVal ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Given ISO<%x> already has highest priority " , eFlash2xSectVal ) ;
Status = STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
break ;
}
2012-06-06 20:54:28 -06:00
SectImagePriority = 2 ;
}
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
SectImagePriority = htonl ( SectImagePriority ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
Status = BcmFlash2xBulkWrite ( Adapter ,
& SectImagePriority ,
eFlash2xSectVal ,
2012-11-30 23:15:51 -07:00
0 + FIELD_OFFSET_IN_HEADER ( struct bcm_iso_header * , ISOImagePriority ) ,
2012-06-06 20:54:28 -06:00
SIGNATURE_SIZE ,
TRUE ) ;
if ( Status ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Priority has not been written properly " ) ;
break ;
}
} else {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Signature is currupted. Hence can't increase the priority " ) ;
Status = STATUS_FAILURE ;
break ;
}
break ;
case DSD0 :
case DSD1 :
case DSD2 :
if ( ReadDSDSignature ( Adapter , eFlash2xSectVal ) = = DSD_IMAGE_MAGIC_NUMBER ) {
HighestPriDSD = getHighestPriDSD ( Adapter ) ;
2014-03-19 12:55:25 -06:00
if ( HighestPriDSD = = eFlash2xSectVal ) {
2012-06-06 20:54:28 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Given DSD<%x> already has highest priority " , eFlash2xSectVal ) ;
Status = STATUS_SUCCESS ;
break ;
}
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
SectImagePriority = ReadDSDPriority ( Adapter , HighestPriDSD ) + 1 ;
2014-06-25 08:38:01 -06:00
if ( SectImagePriority = = 0 ) {
2012-06-06 20:54:29 -06:00
/* This is a SPECIAL Case which will only happen if the current highest priority DSD has priority value = 0x7FFFFFFF.
* We will write 1 to the current Highest priority DSD And then shall increase the priority of the requested DSD
* by user
*/
2012-06-06 20:54:28 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , NVM_RW , DBG_LVL_ALL , " SectImagePriority wraparound happened, eFlash2xSectVal: 0x%x \n " , eFlash2xSectVal ) ;
SectImagePriority = htonl ( 0x1 ) ;
2010-09-08 15:46:36 -06:00
Status = BcmFlash2xBulkWrite ( Adapter ,
2012-06-06 20:54:27 -06:00
& SectImagePriority ,
2012-06-06 20:54:28 -06:00
HighestPriDSD ,
2012-11-30 23:15:52 -07:00
Adapter - > psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER ( struct bcm_dsd_header * , DSDImagePriority ) ,
2012-06-06 20:54:27 -06:00
SIGNATURE_SIZE ,
TRUE ) ;
2012-06-06 20:54:28 -06:00
if ( Status ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Priority has not been written properly " ) ;
break ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:28 -06:00
2010-09-08 15:46:36 -06:00
HighestPriDSD = getHighestPriDSD ( Adapter ) ;
2012-06-06 20:54:28 -06:00
2014-03-19 12:55:25 -06:00
if ( HighestPriDSD = = eFlash2xSectVal ) {
2012-06-06 20:54:28 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Made the DSD: %x highest by reducing priority of other \n " , eFlash2xSectVal ) ;
2012-06-06 20:54:27 -06:00
Status = STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
break ;
}
2012-06-06 20:54:28 -06:00
SectImagePriority = htonl ( 0x2 ) ;
2010-09-08 15:46:36 -06:00
Status = BcmFlash2xBulkWrite ( Adapter ,
2012-06-06 20:54:27 -06:00
& SectImagePriority ,
2012-06-06 20:54:28 -06:00
HighestPriDSD ,
2012-11-30 23:15:52 -07:00
Adapter - > psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER ( struct bcm_dsd_header * , DSDImagePriority ) ,
2012-06-06 20:54:27 -06:00
SIGNATURE_SIZE ,
TRUE ) ;
2012-06-06 20:54:28 -06:00
if ( Status ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Priority has not been written properly " ) ;
break ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:28 -06:00
HighestPriDSD = getHighestPriDSD ( Adapter ) ;
2014-03-19 12:55:25 -06:00
if ( HighestPriDSD = = eFlash2xSectVal ) {
2012-06-06 20:54:28 -06:00
Status = STATUS_SUCCESS ;
break ;
}
SectImagePriority = 3 ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:28 -06:00
SectImagePriority = htonl ( SectImagePriority ) ;
Status = BcmFlash2xBulkWrite ( Adapter ,
& SectImagePriority ,
eFlash2xSectVal ,
2012-11-30 23:15:52 -07:00
Adapter - > psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER ( struct bcm_dsd_header * , DSDImagePriority ) ,
2012-06-06 20:54:28 -06:00
SIGNATURE_SIZE ,
TRUE ) ;
if ( Status ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Priority has not been written properly " ) ;
2012-06-06 20:54:27 -06:00
Status = STATUS_FAILURE ;
2010-09-08 15:46:36 -06:00
break ;
}
2012-06-06 20:54:28 -06:00
} else {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Signature is currupted. Hence can't increase the priority " ) ;
2012-06-06 20:54:27 -06:00
Status = STATUS_FAILURE ;
break ;
2012-06-06 20:54:28 -06:00
}
break ;
case VSA0 :
case VSA1 :
case VSA2 :
2012-06-06 20:54:29 -06:00
/* Has to be decided */
2012-06-06 20:54:28 -06:00
break ;
default :
Status = STATUS_FAILURE ;
break ;
2010-09-08 15:46:36 -06:00
}
2013-10-28 02:36:19 -06:00
Adapter - > bHeaderChangeAllowed = false ;
2010-09-08 15:46:36 -06:00
return Status ;
}
2012-06-06 20:54:29 -06:00
/*
* BcmCopyISO - Used only for copying the ISO section
* @ Adapater : - Bcm Driver Private Data Structure
* @ sCopySectStrut : - Section copy structure
*
* Return value : - SUCCESS if copies successfully else negative error code
*
*/
2012-06-06 20:54:27 -06:00
2012-11-22 12:48:44 -07:00
int BcmCopyISO ( struct bcm_mini_adapter * Adapter , struct bcm_flash2x_copy_section sCopySectStrut )
2010-09-08 15:46:36 -06:00
{
PCHAR Buff = NULL ;
2012-11-22 12:48:50 -07:00
enum bcm_flash2x_section_val eISOReadPart = 0 , eISOWritePart = 0 ;
2012-06-19 18:14:53 -06:00
unsigned int uiReadOffsetWithinPart = 0 , uiWriteOffsetWithinPart = 0 ;
unsigned int uiTotalDataToCopy = 0 ;
2013-10-28 02:36:19 -06:00
bool IsThisHeaderSector = false ;
2012-06-19 18:14:53 -06:00
unsigned int sigOffset = 0 ;
unsigned int ISOLength = 0 ;
unsigned int Status = STATUS_SUCCESS ;
unsigned int SigBuff [ MAX_RW_SIZE ] ;
unsigned int i = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( ReadISOSignature ( Adapter , sCopySectStrut . SrcSection ) ! = ISO_IMAGE_MAGIC_NUMBER ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " error as Source ISO Section does not have valid signature " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2014-07-20 07:14:09 -06:00
Status = BcmFlash2xBulkRead ( Adapter , & ISOLength ,
sCopySectStrut . SrcSection ,
0 + FIELD_OFFSET_IN_HEADER ( struct bcm_iso_header * , ISOImageSize ) ,
4 ) ;
2012-06-06 20:54:28 -06:00
if ( Status ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Read failed while copying ISO \n " ) ;
2010-09-08 15:46:36 -06:00
return Status ;
}
ISOLength = htonl ( ISOLength ) ;
2012-06-06 20:54:27 -06:00
if ( ISOLength % Adapter - > uiSectorSize )
ISOLength = Adapter - > uiSectorSize * ( 1 + ISOLength / Adapter - > uiSectorSize ) ;
2010-09-08 15:46:36 -06:00
2012-11-30 23:15:51 -07:00
sigOffset = FIELD_OFFSET_IN_HEADER ( struct bcm_iso_header * , ISOImageMagicNumber ) ;
2010-09-08 15:46:36 -06:00
Buff = kzalloc ( Adapter - > uiSectorSize , GFP_KERNEL ) ;
2012-06-19 18:14:54 -06:00
if ( ! Buff ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Memory allocation failed for section size " ) ;
return - ENOMEM ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:28 -06:00
if ( sCopySectStrut . SrcSection = = ISO_IMAGE1 & & sCopySectStrut . DstSection = = ISO_IMAGE2 ) {
2012-06-06 20:54:27 -06:00
eISOReadPart = ISO_IMAGE1 ;
eISOWritePart = ISO_IMAGE2 ;
2010-09-08 15:46:36 -06:00
uiReadOffsetWithinPart = 0 ;
2012-06-06 20:54:27 -06:00
uiWriteOffsetWithinPart = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
uiTotalDataToCopy = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1End ) -
( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1Start ) +
( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part2End ) -
( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part2Start ) +
( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part3End ) -
( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part3Start ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiTotalDataToCopy < ISOLength ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " error as Source ISO Section does not have valid signature " ) ;
2011-08-08 05:17:58 -06:00
Status = STATUS_FAILURE ;
goto out ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
uiTotalDataToCopy = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1End ) -
( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1Start ) +
( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part2End ) -
( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part2Start ) +
( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part3End ) -
( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part3Start ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiTotalDataToCopy < ISOLength ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " error as Dest ISO Section does not have enough section size " ) ;
2011-08-08 05:17:58 -06:00
Status = STATUS_FAILURE ;
goto out ;
2010-09-08 15:46:36 -06:00
}
uiTotalDataToCopy = ISOLength ;
2012-06-06 20:54:27 -06:00
CorruptISOSig ( Adapter , ISO_IMAGE2 ) ;
2012-06-06 20:54:28 -06:00
while ( uiTotalDataToCopy ) {
if ( uiTotalDataToCopy = = Adapter - > uiSectorSize ) {
2012-06-06 20:54:29 -06:00
/* Setting for write of first sector. First sector is assumed to be written in last */
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Writing the signature sector " ) ;
eISOReadPart = ISO_IMAGE1 ;
2010-09-08 15:46:36 -06:00
uiReadOffsetWithinPart = 0 ;
eISOWritePart = ISO_IMAGE2 ;
2012-06-06 20:54:27 -06:00
uiWriteOffsetWithinPart = 0 ;
IsThisHeaderSector = TRUE ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
uiReadOffsetWithinPart = uiReadOffsetWithinPart + Adapter - > uiSectorSize ;
uiWriteOffsetWithinPart = uiWriteOffsetWithinPart + Adapter - > uiSectorSize ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( ( eISOReadPart = = ISO_IMAGE1 ) & & ( uiReadOffsetWithinPart = = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1End - Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1Start ) ) ) {
2012-06-06 20:54:27 -06:00
eISOReadPart = ISO_IMAGE1_PART2 ;
2010-09-08 15:46:36 -06:00
uiReadOffsetWithinPart = 0 ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( ( eISOReadPart = = ISO_IMAGE1_PART2 ) & & ( uiReadOffsetWithinPart = = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part2End - Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part2Start ) ) ) {
2012-06-06 20:54:27 -06:00
eISOReadPart = ISO_IMAGE1_PART3 ;
2010-09-08 15:46:36 -06:00
uiReadOffsetWithinPart = 0 ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( ( eISOWritePart = = ISO_IMAGE2 ) & & ( uiWriteOffsetWithinPart = = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1End - Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1Start ) ) ) {
2012-06-06 20:54:27 -06:00
eISOWritePart = ISO_IMAGE2_PART2 ;
2010-09-08 15:46:36 -06:00
uiWriteOffsetWithinPart = 0 ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( ( eISOWritePart = = ISO_IMAGE2_PART2 ) & & ( uiWriteOffsetWithinPart = = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part2End - Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part2Start ) ) ) {
2012-06-06 20:54:27 -06:00
eISOWritePart = ISO_IMAGE2_PART3 ;
2010-09-08 15:46:36 -06:00
uiWriteOffsetWithinPart = 0 ;
}
}
Status = BcmFlash2xBulkRead ( Adapter ,
2012-06-06 20:54:27 -06:00
( PUINT ) Buff ,
eISOReadPart ,
uiReadOffsetWithinPart ,
Adapter - > uiSectorSize ) ;
2012-06-06 20:54:28 -06:00
if ( Status ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Read failed while copying ISO: Part: %x, OffsetWithinPart: %x \n " , eISOReadPart , uiReadOffsetWithinPart ) ;
2010-09-08 15:46:36 -06:00
break ;
}
2012-06-06 20:54:28 -06:00
if ( IsThisHeaderSector = = TRUE ) {
2012-06-06 20:54:29 -06:00
/* If this is header sector write 0xFFFFFFFF at the sig time and in last write sig */
2014-06-08 15:45:28 -06:00
memcpy ( SigBuff , Buff + sigOffset , sizeof ( SigBuff ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
for ( i = 0 ; i < MAX_RW_SIZE ; i + + )
2010-09-08 15:46:36 -06:00
* ( Buff + sigOffset + i ) = 0xFF ;
}
2012-06-06 20:54:27 -06:00
Adapter - > bHeaderChangeAllowed = TRUE ;
2010-09-08 15:46:36 -06:00
Status = BcmFlash2xBulkWrite ( Adapter ,
2012-06-06 20:54:27 -06:00
( PUINT ) Buff ,
eISOWritePart ,
uiWriteOffsetWithinPart ,
Adapter - > uiSectorSize ,
TRUE ) ;
2012-06-06 20:54:28 -06:00
if ( Status ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Write failed while copying ISO: Part: %x, OffsetWithinPart: %x \n " , eISOWritePart , uiWriteOffsetWithinPart ) ;
2010-09-08 15:46:36 -06:00
break ;
}
2013-10-28 02:36:19 -06:00
Adapter - > bHeaderChangeAllowed = false ;
2012-06-06 20:54:28 -06:00
if ( IsThisHeaderSector = = TRUE ) {
2010-09-08 15:46:36 -06:00
WriteToFlashWithoutSectorErase ( Adapter ,
2012-06-06 20:54:27 -06:00
SigBuff ,
eISOWritePart ,
sigOffset ,
MAX_RW_SIZE ) ;
2013-10-28 02:36:19 -06:00
IsThisHeaderSector = false ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:29 -06:00
/* subtracting the written Data */
2012-06-06 20:54:27 -06:00
uiTotalDataToCopy = uiTotalDataToCopy - Adapter - > uiSectorSize ;
2010-09-08 15:46:36 -06:00
}
}
2012-06-06 20:54:28 -06:00
if ( sCopySectStrut . SrcSection = = ISO_IMAGE2 & & sCopySectStrut . DstSection = = ISO_IMAGE1 ) {
2012-06-06 20:54:27 -06:00
eISOReadPart = ISO_IMAGE2 ;
eISOWritePart = ISO_IMAGE1 ;
uiReadOffsetWithinPart = 0 ;
uiWriteOffsetWithinPart = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
uiTotalDataToCopy = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1End ) -
( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1Start ) +
( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part2End ) -
( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part2Start ) +
( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part3End ) -
( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part3Start ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiTotalDataToCopy < ISOLength ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " error as Source ISO Section does not have valid signature " ) ;
2011-08-08 05:17:58 -06:00
Status = STATUS_FAILURE ;
goto out ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
uiTotalDataToCopy = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1End ) -
( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1Start ) +
( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part2End ) -
( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part2Start ) +
( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part3End ) -
( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part3Start ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( uiTotalDataToCopy < ISOLength ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " error as Dest ISO Section does not have enough section size " ) ;
2011-08-08 05:17:58 -06:00
Status = STATUS_FAILURE ;
goto out ;
2010-09-08 15:46:36 -06:00
}
uiTotalDataToCopy = ISOLength ;
2012-06-06 20:54:27 -06:00
CorruptISOSig ( Adapter , ISO_IMAGE1 ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
while ( uiTotalDataToCopy ) {
if ( uiTotalDataToCopy = = Adapter - > uiSectorSize ) {
2012-06-06 20:54:29 -06:00
/* Setting for write of first sector. First sector is assumed to be written in last */
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Writing the signature sector " ) ;
eISOReadPart = ISO_IMAGE2 ;
2010-09-08 15:46:36 -06:00
uiReadOffsetWithinPart = 0 ;
eISOWritePart = ISO_IMAGE1 ;
2012-06-06 20:54:27 -06:00
uiWriteOffsetWithinPart = 0 ;
2010-09-08 15:46:36 -06:00
IsThisHeaderSector = TRUE ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
uiReadOffsetWithinPart = uiReadOffsetWithinPart + Adapter - > uiSectorSize ;
uiWriteOffsetWithinPart = uiWriteOffsetWithinPart + Adapter - > uiSectorSize ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( ( eISOReadPart = = ISO_IMAGE2 ) & & ( uiReadOffsetWithinPart = = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1End - Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1Start ) ) ) {
2012-06-06 20:54:27 -06:00
eISOReadPart = ISO_IMAGE2_PART2 ;
2010-09-08 15:46:36 -06:00
uiReadOffsetWithinPart = 0 ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( ( eISOReadPart = = ISO_IMAGE2_PART2 ) & & ( uiReadOffsetWithinPart = = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part2End - Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part2Start ) ) ) {
2012-06-06 20:54:27 -06:00
eISOReadPart = ISO_IMAGE2_PART3 ;
2010-09-08 15:46:36 -06:00
uiReadOffsetWithinPart = 0 ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( ( eISOWritePart = = ISO_IMAGE1 ) & & ( uiWriteOffsetWithinPart = = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1End - Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1Start ) ) ) {
2012-06-06 20:54:27 -06:00
eISOWritePart = ISO_IMAGE1_PART2 ;
2010-09-08 15:46:36 -06:00
uiWriteOffsetWithinPart = 0 ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( ( eISOWritePart = = ISO_IMAGE1_PART2 ) & & ( uiWriteOffsetWithinPart = = ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part2End - Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part2Start ) ) ) {
2012-06-06 20:54:27 -06:00
eISOWritePart = ISO_IMAGE1_PART3 ;
2010-09-08 15:46:36 -06:00
uiWriteOffsetWithinPart = 0 ;
}
}
Status = BcmFlash2xBulkRead ( Adapter ,
2012-06-06 20:54:27 -06:00
( PUINT ) Buff ,
eISOReadPart ,
uiReadOffsetWithinPart ,
Adapter - > uiSectorSize ) ;
2012-06-06 20:54:28 -06:00
if ( Status ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Read failed while copying ISO: Part: %x, OffsetWithinPart: %x \n " , eISOReadPart , uiReadOffsetWithinPart ) ;
2010-09-08 15:46:36 -06:00
break ;
}
2012-06-06 20:54:28 -06:00
if ( IsThisHeaderSector = = TRUE ) {
2012-06-06 20:54:29 -06:00
/* If this is header sector write 0xFFFFFFFF at the sig time and in last write sig */
2014-06-08 15:45:28 -06:00
memcpy ( SigBuff , Buff + sigOffset , sizeof ( SigBuff ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
for ( i = 0 ; i < MAX_RW_SIZE ; i + + )
2010-09-08 15:46:36 -06:00
* ( Buff + sigOffset + i ) = 0xFF ;
}
2012-06-06 20:54:27 -06:00
Adapter - > bHeaderChangeAllowed = TRUE ;
2010-09-08 15:46:36 -06:00
Status = BcmFlash2xBulkWrite ( Adapter ,
2012-06-06 20:54:27 -06:00
( PUINT ) Buff ,
eISOWritePart ,
uiWriteOffsetWithinPart ,
Adapter - > uiSectorSize ,
TRUE ) ;
2012-06-06 20:54:28 -06:00
if ( Status ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Write failed while copying ISO: Part: %x, OffsetWithinPart: %x \n " , eISOWritePart , uiWriteOffsetWithinPart ) ;
2010-09-08 15:46:36 -06:00
break ;
}
2013-10-28 02:36:19 -06:00
Adapter - > bHeaderChangeAllowed = false ;
2012-06-06 20:54:28 -06:00
if ( IsThisHeaderSector = = TRUE ) {
2010-09-08 15:46:36 -06:00
WriteToFlashWithoutSectorErase ( Adapter ,
2012-06-06 20:54:27 -06:00
SigBuff ,
eISOWritePart ,
sigOffset ,
MAX_RW_SIZE ) ;
2013-10-28 02:36:19 -06:00
IsThisHeaderSector = false ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:29 -06:00
/* subtracting the written Data */
2012-06-06 20:54:27 -06:00
uiTotalDataToCopy = uiTotalDataToCopy - Adapter - > uiSectorSize ;
2010-09-08 15:46:36 -06:00
}
}
2011-08-08 05:17:58 -06:00
out :
2010-11-01 07:35:21 -06:00
kfree ( Buff ) ;
2010-09-08 15:46:36 -06:00
return Status ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:29 -06:00
/*
* BcmFlash2xCorruptSig : this API is used to corrupt the written sig in Bcm Header present in flash section .
* It will corrupt the sig , if Section is writable , by making first bytes as zero .
* @ Adapater : - Bcm Driver Private Data Structure
* @ eFlash2xSectionVal : - Flash section val which has header
*
* Return Value : -
* Success : - If Section is present and writable , corrupt the sig and return STATUS_SUCCESS
* Failure : - Return negative error code
*/
2012-06-06 20:54:27 -06:00
2012-11-22 12:48:50 -07:00
int BcmFlash2xCorruptSig ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val eFlash2xSectionVal )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:52 -06:00
int Status = STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Section Value :%x \n " , eFlash2xSectionVal ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( ( eFlash2xSectionVal = = DSD0 ) | | ( eFlash2xSectionVal = = DSD1 ) | | ( eFlash2xSectionVal = = DSD2 ) ) {
2010-09-08 15:46:36 -06:00
Status = CorruptDSDSig ( Adapter , eFlash2xSectionVal ) ;
2012-06-06 20:54:28 -06:00
} else if ( eFlash2xSectionVal = = ISO_IMAGE1 | | eFlash2xSectionVal = = ISO_IMAGE2 ) {
2010-09-08 15:46:36 -06:00
Status = CorruptISOSig ( Adapter , eFlash2xSectionVal ) ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Given Section <%d>does not have Header " , eFlash2xSectionVal ) ;
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
}
return Status ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:29 -06:00
/*
* BcmFlash2xWriteSig : - this API is used to Write the sig if requested Section has
* header and Write Permission .
* @ Adapater : - Bcm Driver Private Data Structure
* @ eFlashSectionVal : - Flash section val which has header
*
* Return Value : -
* Success : - If Section is present and writable write the sig and return STATUS_SUCCESS
* Failure : - Return negative error code
*/
2012-06-06 20:54:27 -06:00
2012-11-22 12:48:50 -07:00
int BcmFlash2xWriteSig ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val eFlashSectionVal )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiSignature = 0 ;
unsigned int uiOffset = 0 ;
2010-09-08 15:46:36 -06:00
2012-11-30 23:15:52 -07:00
/* struct bcm_dsd_header dsdHeader = {0}; */
2013-10-28 02:36:19 -06:00
if ( Adapter - > bSigCorrupted = = false ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Signature is not corrupted by driver, hence not restoring \n " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
}
2012-06-06 20:54:27 -06:00
2013-10-28 02:36:19 -06:00
if ( Adapter - > bAllDSDWriteAllow = = false ) {
if ( IsSectionWritable ( Adapter , eFlashSectionVal ) = = false ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Section is not Writable...Hence can't Write signature " ) ;
2010-09-08 15:46:36 -06:00
return SECTOR_IS_NOT_WRITABLE ;
}
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( ( eFlashSectionVal = = DSD0 ) | | ( eFlashSectionVal = = DSD1 ) | | ( eFlashSectionVal = = DSD2 ) ) {
2012-06-06 20:54:27 -06:00
uiSignature = htonl ( DSD_IMAGE_MAGIC_NUMBER ) ;
uiOffset = Adapter - > psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader ;
2010-09-08 15:46:36 -06:00
2012-11-30 23:15:52 -07:00
uiOffset + = FIELD_OFFSET_IN_HEADER ( struct bcm_dsd_header * , DSDImageMagicNumber ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( ( ReadDSDSignature ( Adapter , eFlashSectionVal ) & 0xFF000000 ) ! = CORRUPTED_PATTERN ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Corrupted Pattern is not there. Hence won't write sig " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:28 -06:00
} else if ( ( eFlashSectionVal = = ISO_IMAGE1 ) | | ( eFlashSectionVal = = ISO_IMAGE2 ) ) {
2010-09-08 15:46:36 -06:00
uiSignature = htonl ( ISO_IMAGE_MAGIC_NUMBER ) ;
2012-06-06 20:54:29 -06:00
/* uiOffset = 0; */
2012-11-30 23:15:51 -07:00
uiOffset = FIELD_OFFSET_IN_HEADER ( struct bcm_iso_header * , ISOImageMagicNumber ) ;
2012-06-06 20:54:28 -06:00
if ( ( ReadISOSignature ( Adapter , eFlashSectionVal ) & 0xFF000000 ) ! = CORRUPTED_PATTERN ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Currupted Pattern is not there. Hence won't write sig " ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " GIVEN SECTION< %d > IS NOT VALID FOR SIG WRITE... " , eFlashSectionVal ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Restoring the signature " ) ;
2010-09-08 15:46:36 -06:00
Adapter - > bHeaderChangeAllowed = TRUE ;
2013-10-28 02:36:19 -06:00
Adapter - > bSigCorrupted = false ;
2012-06-06 20:54:27 -06:00
BcmFlash2xBulkWrite ( Adapter , & uiSignature , eFlashSectionVal , uiOffset , SIGNATURE_SIZE , TRUE ) ;
2013-10-28 02:36:19 -06:00
Adapter - > bHeaderChangeAllowed = false ;
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:29 -06:00
/*
* validateFlash2xReadWrite : - This API is used to validate the user request for Read / Write .
* if requested Bytes goes beyond the Requested section , it reports error .
* @ Adapater : - Bcm Driver Private Data Structure
* @ psFlash2xReadWrite : - Flash2x Read / write structure pointer
*
2013-10-28 02:36:19 -06:00
* Return values : - Return TRUE is request is valid else false .
2012-06-06 20:54:29 -06:00
*/
2012-06-06 20:54:27 -06:00
2012-11-22 12:48:47 -07:00
int validateFlash2xReadWrite ( struct bcm_mini_adapter * Adapter , struct bcm_flash2x_readwrite * psFlash2xReadWrite )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiNumOfBytes = 0 ;
unsigned int uiSectStartOffset = 0 ;
unsigned int uiSectEndOffset = 0 ;
2012-06-06 20:54:27 -06:00
2010-09-08 15:46:36 -06:00
uiNumOfBytes = psFlash2xReadWrite - > numOfBytes ;
2012-06-06 20:54:28 -06:00
if ( IsSectionExistInFlash ( Adapter , psFlash2xReadWrite - > Section ) ! = TRUE ) {
2014-01-10 19:26:27 -07:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Section<%x> does not exist in Flash " , psFlash2xReadWrite - > Section ) ;
2013-10-28 02:36:19 -06:00
return false ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
uiSectStartOffset = BcmGetSectionValStartOffset ( Adapter , psFlash2xReadWrite - > Section ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Start offset :%x ,section :%d \n " , uiSectStartOffset , psFlash2xReadWrite - > Section ) ;
2012-06-06 20:54:28 -06:00
if ( ( psFlash2xReadWrite - > Section = = ISO_IMAGE1 ) | | ( psFlash2xReadWrite - > Section = = ISO_IMAGE2 ) ) {
if ( psFlash2xReadWrite - > Section = = ISO_IMAGE1 ) {
2012-06-06 20:54:27 -06:00
uiSectEndOffset = BcmGetSectionValEndOffset ( Adapter , ISO_IMAGE1 ) -
BcmGetSectionValStartOffset ( Adapter , ISO_IMAGE1 ) +
BcmGetSectionValEndOffset ( Adapter , ISO_IMAGE1_PART2 ) -
BcmGetSectionValStartOffset ( Adapter , ISO_IMAGE1_PART2 ) +
BcmGetSectionValEndOffset ( Adapter , ISO_IMAGE1_PART3 ) -
BcmGetSectionValStartOffset ( Adapter , ISO_IMAGE1_PART3 ) ;
2012-06-06 20:54:28 -06:00
} else if ( psFlash2xReadWrite - > Section = = ISO_IMAGE2 ) {
2012-06-06 20:54:27 -06:00
uiSectEndOffset = BcmGetSectionValEndOffset ( Adapter , ISO_IMAGE2 ) -
BcmGetSectionValStartOffset ( Adapter , ISO_IMAGE2 ) +
BcmGetSectionValEndOffset ( Adapter , ISO_IMAGE2_PART2 ) -
BcmGetSectionValStartOffset ( Adapter , ISO_IMAGE2_PART2 ) +
BcmGetSectionValEndOffset ( Adapter , ISO_IMAGE2_PART3 ) -
BcmGetSectionValStartOffset ( Adapter , ISO_IMAGE2_PART3 ) ;
2010-09-08 15:46:36 -06:00
}
2012-08-17 10:07:16 -06:00
/* since this uiSectEndoffset is the size of iso Image. hence for calculating the virtual endoffset
2012-06-06 20:54:29 -06:00
* it should be added in startoffset . so that check done in last of this function can be valued .
*/
2012-06-06 20:54:27 -06:00
uiSectEndOffset = uiSectStartOffset + uiSectEndOffset ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Total size of the ISO Image :%x " , uiSectEndOffset ) ;
2012-06-06 20:54:28 -06:00
} else
2012-06-06 20:54:27 -06:00
uiSectEndOffset = BcmGetSectionValEndOffset ( Adapter , psFlash2xReadWrite - > Section ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " End offset :%x \n " , uiSectEndOffset ) ;
2010-09-08 15:46:36 -06:00
2013-12-20 04:07:38 -07:00
/* psFlash2xReadWrite->offset and uiNumOfBytes are user controlled and can lead to integer overflows */
if ( psFlash2xReadWrite - > offset > uiSectEndOffset ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Invalid Request.... " ) ;
return false ;
}
if ( uiNumOfBytes > uiSectEndOffset ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Invalid Request.... " ) ;
return false ;
}
2012-06-06 20:54:29 -06:00
/* Checking the boundary condition */
2012-06-06 20:54:27 -06:00
if ( ( uiSectStartOffset + psFlash2xReadWrite - > offset + uiNumOfBytes ) < = uiSectEndOffset )
2010-09-08 15:46:36 -06:00
return TRUE ;
2012-06-06 20:54:28 -06:00
else {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Invalid Request.... " ) ;
2013-10-28 02:36:19 -06:00
return false ;
2010-09-08 15:46:36 -06:00
}
}
2012-06-06 20:54:29 -06:00
/*
* IsFlash2x : - check for Flash 2. x
* Adapater : - Bcm Driver Private Data Structure
*
* Return value : -
* return TRUE if flah2 . x of hgher version else return false .
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
int IsFlash2x ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-06 20:54:27 -06:00
if ( Adapter - > uiFlashLayoutMajorVersion > = FLASH_2X_MAJOR_NUMBER )
return TRUE ;
2010-09-08 15:46:36 -06:00
else
2013-10-28 02:36:19 -06:00
return false ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:29 -06:00
/*
* GetFlashBaseAddr : - Calculate the Flash Base address
* @ Adapater : - Bcm Driver Private Data Structure
*
* Return Value : -
* Success : - Base Address of the Flash
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
static int GetFlashBaseAddr ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiBaseAddr = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( Adapter - > bDDRInitDone ) {
2010-09-08 15:46:36 -06:00
/*
2012-06-06 20:54:29 -06:00
* For All Valid Flash Versions . . . except 1.1 , take the value from FlashBaseAddr
* In case of Raw Read . . . use the default value
*/
2013-10-28 02:36:19 -06:00
if ( Adapter - > uiFlashLayoutMajorVersion & & ( Adapter - > bFlashRawRead = = false ) & &
2012-06-06 20:54:27 -06:00
! ( ( Adapter - > uiFlashLayoutMajorVersion = = 1 ) & & ( Adapter - > uiFlashLayoutMinorVersion = = 1 ) ) )
uiBaseAddr = Adapter - > uiFlashBaseAdd ;
2010-09-08 15:46:36 -06:00
else
uiBaseAddr = FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT ;
2012-06-06 20:54:28 -06:00
} else {
2010-09-08 15:46:36 -06:00
/*
2012-06-06 20:54:29 -06:00
* For All Valid Flash Versions . . . except 1.1 , take the value from FlashBaseAddr
* In case of Raw Read . . . use the default value
*/
2013-10-28 02:36:19 -06:00
if ( Adapter - > uiFlashLayoutMajorVersion & & ( Adapter - > bFlashRawRead = = false ) & &
2012-06-06 20:54:27 -06:00
! ( ( Adapter - > uiFlashLayoutMajorVersion = = 1 ) & & ( Adapter - > uiFlashLayoutMinorVersion = = 1 ) ) )
2010-09-08 15:46:36 -06:00
uiBaseAddr = Adapter - > uiFlashBaseAdd | FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT ;
else
uiBaseAddr = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT ;
}
2012-06-06 20:54:27 -06:00
return uiBaseAddr ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:29 -06:00
/*
* BcmCopySection : - This API is used to copy the One section in another . Both section should
* be contiuous and of same size . Hence this Will not be applicabe to copy ISO .
*
* @ Adapater : - Bcm Driver Private Data Structure
* @ SrcSection : - Source section From where data has to be copied
* @ DstSection : - Destination section to which data has to be copied
* @ offset : - Offset from / to where data has to be copied from one section to another .
* @ numOfBytes : - number of byes that has to be copyed from one section to another at given offset .
* in case of numofBytes equal zero complete section will be copied .
* Return Values -
* Success : Return STATUS_SUCCESS
* Faillure : - return negative error code
*/
2010-09-08 15:46:36 -06:00
2012-06-19 18:14:52 -06:00
int BcmCopySection ( struct bcm_mini_adapter * Adapter ,
2012-11-22 12:48:50 -07:00
enum bcm_flash2x_section_val SrcSection ,
enum bcm_flash2x_section_val DstSection ,
2012-06-19 18:14:53 -06:00
unsigned int offset ,
unsigned int numOfBytes )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int BuffSize = 0 ;
unsigned int BytesToBeCopied = 0 ;
2012-06-06 20:54:27 -06:00
PUCHAR pBuff = NULL ;
2012-06-19 18:14:52 -06:00
int Status = STATUS_SUCCESS ;
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( SrcSection = = DstSection ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Source and Destination should be different ...try again " ) ;
2010-09-08 15:46:36 -06:00
return - EINVAL ;
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( ( SrcSection ! = DSD0 ) & & ( SrcSection ! = DSD1 ) & & ( SrcSection ! = DSD2 ) ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Source should be DSD subsection " ) ;
return - EINVAL ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( ( DstSection ! = DSD0 ) & & ( DstSection ! = DSD1 ) & & ( DstSection ! = DSD2 ) ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Destination should be DSD subsection " ) ;
return - EINVAL ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:29 -06:00
/* if offset zero means have to copy complete secton */
2012-06-06 20:54:28 -06:00
if ( numOfBytes = = 0 ) {
2012-06-06 20:54:27 -06:00
numOfBytes = BcmGetSectionValEndOffset ( Adapter , SrcSection )
- BcmGetSectionValStartOffset ( Adapter , SrcSection ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Section Size :0x%x " , numOfBytes ) ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
if ( ( offset + numOfBytes ) > BcmGetSectionValEndOffset ( Adapter , SrcSection )
2012-06-06 20:54:28 -06:00
- BcmGetSectionValStartOffset ( Adapter , SrcSection ) ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Input parameters going beyond the section offS: %x numB: %x of Source Section \n " ,
offset , numOfBytes ) ;
2010-09-08 15:46:36 -06:00
return - EINVAL ;
}
2012-06-06 20:54:27 -06:00
if ( ( offset + numOfBytes ) > BcmGetSectionValEndOffset ( Adapter , DstSection )
2012-06-06 20:54:28 -06:00
- BcmGetSectionValStartOffset ( Adapter , DstSection ) ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Input parameters going beyond the section offS: %x numB: %x of Destination Section \n " ,
offset , numOfBytes ) ;
2010-09-08 15:46:36 -06:00
return - EINVAL ;
}
2012-06-06 20:54:27 -06:00
if ( numOfBytes > Adapter - > uiSectorSize )
2010-09-08 15:46:36 -06:00
BuffSize = Adapter - > uiSectorSize ;
else
2012-06-06 20:54:27 -06:00
BuffSize = numOfBytes ;
2010-09-08 15:46:36 -06:00
2013-03-10 06:48:27 -06:00
pBuff = kzalloc ( BuffSize , GFP_KERNEL ) ;
2012-06-19 18:14:54 -06:00
if ( ! pBuff ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Memory allocation failed.. " ) ;
2010-09-08 15:46:36 -06:00
return - ENOMEM ;
}
2012-06-06 20:54:27 -06:00
BytesToBeCopied = Adapter - > uiSectorSize ;
if ( offset % Adapter - > uiSectorSize )
2010-09-08 15:46:36 -06:00
BytesToBeCopied = Adapter - > uiSectorSize - ( offset % Adapter - > uiSectorSize ) ;
2012-06-06 20:54:27 -06:00
if ( BytesToBeCopied > numOfBytes )
BytesToBeCopied = numOfBytes ;
2010-09-08 15:46:36 -06:00
Adapter - > bHeaderChangeAllowed = TRUE ;
2012-06-06 20:54:28 -06:00
do {
2012-06-06 20:54:27 -06:00
Status = BcmFlash2xBulkRead ( Adapter , ( PUINT ) pBuff , SrcSection , offset , BytesToBeCopied ) ;
2012-06-06 20:54:28 -06:00
if ( Status ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Read failed at offset :%d for NOB :%d " , SrcSection , BytesToBeCopied ) ;
2010-09-08 15:46:36 -06:00
break ;
}
2013-10-28 02:36:19 -06:00
Status = BcmFlash2xBulkWrite ( Adapter , ( PUINT ) pBuff , DstSection , offset , BytesToBeCopied , false ) ;
2012-06-06 20:54:28 -06:00
if ( Status ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Write failed at offset :%d for NOB :%d " , DstSection , BytesToBeCopied ) ;
2010-09-08 15:46:36 -06:00
break ;
}
offset = offset + BytesToBeCopied ;
2012-06-06 20:54:27 -06:00
numOfBytes = numOfBytes - BytesToBeCopied ;
2012-06-06 20:54:28 -06:00
if ( numOfBytes ) {
2012-06-06 20:54:27 -06:00
if ( numOfBytes > Adapter - > uiSectorSize )
2010-09-08 15:46:36 -06:00
BytesToBeCopied = Adapter - > uiSectorSize ;
else
BytesToBeCopied = numOfBytes ;
}
2012-06-06 20:54:27 -06:00
} while ( numOfBytes > 0 ) ;
2010-11-01 07:35:21 -06:00
kfree ( pBuff ) ;
2013-10-28 02:36:19 -06:00
Adapter - > bHeaderChangeAllowed = false ;
2012-06-06 20:54:27 -06:00
2010-09-08 15:46:36 -06:00
return Status ;
}
2012-06-06 20:54:29 -06:00
/*
* SaveHeaderIfPresent : - This API is use to Protect the Header in case of Header Sector write
* @ Adapater : - Bcm Driver Private Data Structure
* @ pBuff : - Data buffer that has to be written in sector having the header map .
* @ uiOffset : - Flash offset that has to be written .
*
* Return value : -
* Success : - On success return STATUS_SUCCESS
* Faillure : - Return negative error code
*/
2010-09-08 15:46:36 -06:00
2014-03-13 12:02:46 -06:00
static int SaveHeaderIfPresent ( struct bcm_mini_adapter * Adapter , PUCHAR pBuff , unsigned int uiOffset )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int offsetToProtect = 0 , HeaderSizeToProtect = 0 ;
2013-10-28 02:36:19 -06:00
bool bHasHeader = false ;
2012-06-06 20:54:27 -06:00
PUCHAR pTempBuff = NULL ;
2012-06-19 18:14:53 -06:00
unsigned int uiSectAlignAddr = 0 ;
unsigned int sig = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* making the offset sector aligned */
2010-09-08 15:46:36 -06:00
uiSectAlignAddr = uiOffset & ~ ( Adapter - > uiSectorSize - 1 ) ;
2012-06-06 20:54:27 -06:00
if ( ( uiSectAlignAddr = = BcmGetSectionValEndOffset ( Adapter , DSD2 ) - Adapter - > uiSectorSize ) | |
( uiSectAlignAddr = = BcmGetSectionValEndOffset ( Adapter , DSD1 ) - Adapter - > uiSectorSize ) | |
2012-06-06 20:54:28 -06:00
( uiSectAlignAddr = = BcmGetSectionValEndOffset ( Adapter , DSD0 ) - Adapter - > uiSectorSize ) ) {
2012-06-06 20:54:29 -06:00
/* offset from the sector boundary having the header map */
2010-09-08 15:46:36 -06:00
offsetToProtect = Adapter - > psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader % Adapter - > uiSectorSize ;
2012-11-30 23:15:52 -07:00
HeaderSizeToProtect = sizeof ( struct bcm_dsd_header ) ;
2012-06-06 20:54:27 -06:00
bHasHeader = TRUE ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
if ( uiSectAlignAddr = = BcmGetSectionValStartOffset ( Adapter , ISO_IMAGE1 ) | |
2012-06-06 20:54:28 -06:00
uiSectAlignAddr = = BcmGetSectionValStartOffset ( Adapter , ISO_IMAGE2 ) ) {
2010-09-08 15:46:36 -06:00
offsetToProtect = 0 ;
2012-11-30 23:15:51 -07:00
HeaderSizeToProtect = sizeof ( struct bcm_iso_header ) ;
2010-09-08 15:46:36 -06:00
bHasHeader = TRUE ;
}
2012-06-06 20:54:29 -06:00
/* If Header is present overwrite passed buffer with this */
2013-10-28 02:36:19 -06:00
if ( bHasHeader & & ( Adapter - > bHeaderChangeAllowed = = false ) ) {
2013-03-10 06:48:27 -06:00
pTempBuff = kzalloc ( HeaderSizeToProtect , GFP_KERNEL ) ;
2012-06-19 18:14:54 -06:00
if ( ! pTempBuff ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Memory allocation failed " ) ;
2010-09-08 15:46:36 -06:00
return - ENOMEM ;
}
2012-06-06 20:54:29 -06:00
/* Read header */
2012-06-06 20:54:27 -06:00
BeceemFlashBulkRead ( Adapter , ( PUINT ) pTempBuff , ( uiSectAlignAddr + offsetToProtect ) , HeaderSizeToProtect ) ;
BCM_DEBUG_PRINT_BUFFER ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , pTempBuff , HeaderSizeToProtect ) ;
2012-06-06 20:54:29 -06:00
/* Replace Buffer content with Header */
2012-06-06 20:54:27 -06:00
memcpy ( pBuff + offsetToProtect , pTempBuff , HeaderSizeToProtect ) ;
2010-09-08 15:46:36 -06:00
2010-11-01 07:35:21 -06:00
kfree ( pTempBuff ) ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:28 -06:00
if ( bHasHeader & & Adapter - > bSigCorrupted ) {
2012-11-30 23:15:52 -07:00
sig = * ( ( PUINT ) ( pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER ( struct bcm_dsd_header * , DSDImageMagicNumber ) ) ) ;
2010-09-08 15:46:36 -06:00
sig = ntohl ( sig ) ;
2012-06-06 20:54:28 -06:00
if ( ( sig & 0xFF000000 ) ! = CORRUPTED_PATTERN ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Desired pattern is not at sig offset. Hence won't restore " ) ;
2013-10-28 02:36:19 -06:00
Adapter - > bSigCorrupted = false ;
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
}
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Corrupted sig is :%X " , sig ) ;
2012-11-30 23:15:52 -07:00
* ( ( PUINT ) ( pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER ( struct bcm_dsd_header * , DSDImageMagicNumber ) ) ) = htonl ( DSD_IMAGE_MAGIC_NUMBER ) ;
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Restoring the signature in Header Write only " ) ;
2013-10-28 02:36:19 -06:00
Adapter - > bSigCorrupted = false ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
return STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:29 -06:00
/*
* BcmDoChipSelect : This will selcet the appropriate chip for writing .
* @ Adapater : - Bcm Driver Private Data Structure
*
* OutPut : -
* Select the Appropriate chip and retrn status Success
*/
2012-06-19 18:14:53 -06:00
static int BcmDoChipSelect ( struct bcm_mini_adapter * Adapter , unsigned int offset )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int FlashConfig = 0 ;
2012-06-19 18:14:52 -06:00
int ChipNum = 0 ;
2012-06-19 18:14:53 -06:00
unsigned int GPIOConfig = 0 ;
unsigned int PartNum = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
ChipNum = offset / FLASH_PART_SIZE ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/*
* Chip Select mapping to enable flash0 .
* To select flash 0 , we have to OR with ( 0 < < 12 ) .
* ORing 0 will have no impact so not doing that part .
* In future if Chip select value changes from 0 to non zero ,
* That needs be taken care with backward comaptibility . No worries for now .
*/
2010-09-08 15:46:36 -06:00
/*
2012-06-06 20:54:29 -06:00
* SelectedChip Variable is the selection that the host is 100 % Sure the same as what the register will hold . This can be ONLY ensured
* if the Chip doesn ' t goes to low power mode while the flash operation is in progress ( NVMRdmWrmLock is taken )
* Before every new Flash Write operation , we reset the variable . This is to ensure that after any wake - up from
* power down modes ( Idle mode / shutdown mode ) , the values in the register will be different .
*/
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( Adapter - > SelectedChip = = ChipNum )
return STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Selected Chip :%x", ChipNum); */
2012-06-06 20:54:27 -06:00
Adapter - > SelectedChip = ChipNum ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* bit[13..12] will select the appropriate chip */
2011-11-06 07:40:11 -07:00
rdmalt ( Adapter , FLASH_CONFIG_REG , & FlashConfig , 4 ) ;
rdmalt ( Adapter , FLASH_GPIO_CONFIG_REG , & GPIOConfig , 4 ) ;
2010-09-08 15:46:36 -06:00
{
2012-06-06 20:54:28 -06:00
switch ( ChipNum ) {
case 0 :
PartNum = 0 ;
break ;
case 1 :
PartNum = 3 ;
GPIOConfig | = ( 0x4 < < CHIP_SELECT_BIT12 ) ;
break ;
case 2 :
PartNum = 1 ;
GPIOConfig | = ( 0x1 < < CHIP_SELECT_BIT12 ) ;
break ;
case 3 :
PartNum = 2 ;
GPIOConfig | = ( 0x2 < < CHIP_SELECT_BIT12 ) ;
break ;
2010-09-08 15:46:36 -06:00
}
}
/* In case the bits already written in the FLASH_CONFIG_REG is same as what the user desired,
2012-06-06 20:54:29 -06:00
* nothing to do . . . can return immediately .
* ASSUMPTION : FLASH_GPIO_CONFIG_REG will be in sync with FLASH_CONFIG_REG .
* Even if the chip goes to low power mode , it should wake with values in each register in sync with each other .
* These values are not written by host other than during CHIP_SELECT .
*/
2012-06-06 20:54:27 -06:00
if ( PartNum = = ( ( FlashConfig > > CHIP_SELECT_BIT12 ) & 0x3 ) )
2010-09-08 15:46:36 -06:00
return STATUS_SUCCESS ;
2012-06-06 20:54:29 -06:00
/* clearing the bit[13..12] */
2010-09-08 15:46:36 -06:00
FlashConfig & = 0xFFFFCFFF ;
2012-06-06 20:54:29 -06:00
FlashConfig = ( FlashConfig | ( PartNum < < CHIP_SELECT_BIT12 ) ) ; /* 00 */
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
wrmalt ( Adapter , FLASH_GPIO_CONFIG_REG , & GPIOConfig , 4 ) ;
2010-09-08 15:46:36 -06:00
udelay ( 100 ) ;
2012-06-06 20:54:27 -06:00
wrmalt ( Adapter , FLASH_CONFIG_REG , & FlashConfig , 4 ) ;
2010-09-08 15:46:36 -06:00
udelay ( 100 ) ;
return STATUS_SUCCESS ;
}
2012-06-06 20:54:27 -06:00
2014-03-13 12:02:46 -06:00
static int ReadDSDSignature ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val dsd )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiDSDsig = 0 ;
/* unsigned int sigoffsetInMap = 0;
2012-11-30 23:15:52 -07:00
* struct bcm_dsd_header dsdHeader = { 0 } ;
2012-06-06 20:54:29 -06:00
*/
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* sigoffsetInMap =(PUCHAR)&(dsdHeader.DSDImageMagicNumber) -(PUCHAR)&dsdHeader; */
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( dsd ! = DSD0 & & dsd ! = DSD1 & & dsd ! = DSD2 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " passed section value is not for DSDs " ) ;
return STATUS_FAILURE ;
}
BcmFlash2xBulkRead ( Adapter ,
& uiDSDsig ,
dsd ,
2012-11-30 23:15:52 -07:00
Adapter - > psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER ( struct bcm_dsd_header * , DSDImageMagicNumber ) ,
2012-06-06 20:54:27 -06:00
SIGNATURE_SIZE ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
uiDSDsig = ntohl ( uiDSDsig ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " DSD SIG :%x " , uiDSDsig ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
return uiDSDsig ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2014-03-13 12:02:46 -06:00
static int ReadDSDPriority ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val dsd )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
/* unsigned int priOffsetInMap = 0 ; */
2010-09-30 02:24:12 -06:00
unsigned int uiDSDPri = STATUS_FAILURE ;
2012-11-30 23:15:52 -07:00
/* struct bcm_dsd_header dsdHeader = {0};
2012-06-06 20:54:29 -06:00
* priOffsetInMap = ( PUCHAR ) & ( dsdHeader . DSDImagePriority ) - ( PUCHAR ) & dsdHeader ;
*/
2012-06-06 20:54:28 -06:00
if ( IsSectionWritable ( Adapter , dsd ) ) {
if ( ReadDSDSignature ( Adapter , dsd ) = = DSD_IMAGE_MAGIC_NUMBER ) {
2010-09-08 15:46:36 -06:00
BcmFlash2xBulkRead ( Adapter ,
2012-06-06 20:54:27 -06:00
& uiDSDPri ,
dsd ,
2012-11-30 23:15:52 -07:00
Adapter - > psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER ( struct bcm_dsd_header * , DSDImagePriority ) ,
2012-06-06 20:54:27 -06:00
4 ) ;
2010-09-08 15:46:36 -06:00
uiDSDPri = ntohl ( uiDSDPri ) ;
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " DSD<%x> Priority :%x " , dsd , uiDSDPri ) ;
2010-09-08 15:46:36 -06:00
}
}
2012-06-06 20:54:27 -06:00
2010-09-08 15:46:36 -06:00
return uiDSDPri ;
}
2012-06-06 20:54:27 -06:00
2014-03-13 12:02:46 -06:00
static enum bcm_flash2x_section_val getHighestPriDSD ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:52 -06:00
int DSDHighestPri = STATUS_FAILURE ;
int DsdPri = 0 ;
2012-11-22 12:48:50 -07:00
enum bcm_flash2x_section_val HighestPriDSD = 0 ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( IsSectionWritable ( Adapter , DSD2 ) ) {
2012-06-06 20:54:27 -06:00
DSDHighestPri = ReadDSDPriority ( Adapter , DSD2 ) ;
HighestPriDSD = DSD2 ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( IsSectionWritable ( Adapter , DSD1 ) ) {
2012-06-06 20:54:27 -06:00
DsdPri = ReadDSDPriority ( Adapter , DSD1 ) ;
2012-06-06 20:54:28 -06:00
if ( DSDHighestPri < DsdPri ) {
2012-06-06 20:54:27 -06:00
DSDHighestPri = DsdPri ;
2010-09-08 15:46:36 -06:00
HighestPriDSD = DSD1 ;
2012-06-06 20:54:27 -06:00
}
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( IsSectionWritable ( Adapter , DSD0 ) ) {
2012-06-06 20:54:27 -06:00
DsdPri = ReadDSDPriority ( Adapter , DSD0 ) ;
2012-06-06 20:54:28 -06:00
if ( DSDHighestPri < DsdPri ) {
2012-06-06 20:54:27 -06:00
DSDHighestPri = DsdPri ;
2010-09-08 15:46:36 -06:00
HighestPriDSD = DSD0 ;
2012-06-06 20:54:27 -06:00
}
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
if ( HighestPriDSD )
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Highest DSD :%x , and its Pri :%x " , HighestPriDSD , DSDHighestPri ) ;
return HighestPriDSD ;
2010-09-08 15:46:36 -06:00
}
2014-03-13 12:02:46 -06:00
static int ReadISOSignature ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val iso )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:53 -06:00
unsigned int uiISOsig = 0 ;
/* unsigned int sigoffsetInMap = 0;
2012-11-30 23:15:51 -07:00
* struct bcm_iso_header ISOHeader = { 0 } ;
2012-06-06 20:54:29 -06:00
* sigoffsetInMap = ( PUCHAR ) & ( ISOHeader . ISOImageMagicNumber ) - ( PUCHAR ) & ISOHeader ;
*/
2012-06-06 20:54:28 -06:00
if ( iso ! = ISO_IMAGE1 & & iso ! = ISO_IMAGE2 ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " passed section value is not for ISOs " ) ;
return STATUS_FAILURE ;
}
BcmFlash2xBulkRead ( Adapter ,
& uiISOsig ,
iso ,
2012-11-30 23:15:51 -07:00
0 + FIELD_OFFSET_IN_HEADER ( struct bcm_iso_header * , ISOImageMagicNumber ) ,
2012-06-06 20:54:27 -06:00
SIGNATURE_SIZE ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
uiISOsig = ntohl ( uiISOsig ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " ISO SIG :%x " , uiISOsig ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
return uiISOsig ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2014-03-13 12:02:46 -06:00
static int ReadISOPriority ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val iso )
2010-09-08 15:46:36 -06:00
{
2010-09-30 02:24:12 -06:00
unsigned int ISOPri = STATUS_FAILURE ;
2014-07-09 09:59:29 -06:00
2012-06-06 20:54:28 -06:00
if ( IsSectionWritable ( Adapter , iso ) ) {
if ( ReadISOSignature ( Adapter , iso ) = = ISO_IMAGE_MAGIC_NUMBER ) {
2010-09-08 15:46:36 -06:00
BcmFlash2xBulkRead ( Adapter ,
2012-06-06 20:54:27 -06:00
& ISOPri ,
iso ,
2012-11-30 23:15:51 -07:00
0 + FIELD_OFFSET_IN_HEADER ( struct bcm_iso_header * , ISOImagePriority ) ,
2012-06-06 20:54:27 -06:00
4 ) ;
2010-09-08 15:46:36 -06:00
ISOPri = ntohl ( ISOPri ) ;
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " ISO<%x> Priority :%x " , iso , ISOPri ) ;
2010-09-08 15:46:36 -06:00
}
}
2012-06-06 20:54:27 -06:00
2010-09-08 15:46:36 -06:00
return ISOPri ;
}
2012-06-06 20:54:27 -06:00
2014-03-13 12:02:46 -06:00
static enum bcm_flash2x_section_val getHighestPriISO ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:52 -06:00
int ISOHighestPri = STATUS_FAILURE ;
int ISOPri = 0 ;
2012-11-22 12:48:50 -07:00
enum bcm_flash2x_section_val HighestPriISO = NO_SECTION_VAL ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( IsSectionWritable ( Adapter , ISO_IMAGE2 ) ) {
2012-06-06 20:54:27 -06:00
ISOHighestPri = ReadISOPriority ( Adapter , ISO_IMAGE2 ) ;
HighestPriISO = ISO_IMAGE2 ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2012-06-06 20:54:28 -06:00
if ( IsSectionWritable ( Adapter , ISO_IMAGE1 ) ) {
2012-06-06 20:54:27 -06:00
ISOPri = ReadISOPriority ( Adapter , ISO_IMAGE1 ) ;
2012-06-06 20:54:28 -06:00
if ( ISOHighestPri < ISOPri ) {
2012-06-06 20:54:27 -06:00
ISOHighestPri = ISOPri ;
2010-09-08 15:46:36 -06:00
HighestPriISO = ISO_IMAGE1 ;
2012-06-06 20:54:27 -06:00
}
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
if ( HighestPriISO )
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Highest ISO :%x and its Pri :%x " , HighestPriISO , ISOHighestPri ) ;
return HighestPriISO ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2014-03-13 12:02:46 -06:00
static int WriteToFlashWithoutSectorErase ( struct bcm_mini_adapter * Adapter ,
2012-06-06 20:54:27 -06:00
PUINT pBuff ,
2012-11-22 12:48:50 -07:00
enum bcm_flash2x_section_val eFlash2xSectionVal ,
2012-06-19 18:14:53 -06:00
unsigned int uiOffset ,
unsigned int uiNumBytes )
2010-09-08 15:46:36 -06:00
{
2012-06-06 20:54:27 -06:00
# if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
2012-06-19 18:14:53 -06:00
unsigned int uiTemp = 0 , value = 0 ;
unsigned int i = 0 ;
unsigned int uiPartOffset = 0 ;
2012-06-06 20:54:27 -06:00
# endif
2012-06-19 18:14:53 -06:00
unsigned int uiStartOffset = 0 ;
2012-06-06 20:54:29 -06:00
/* Adding section start address */
2012-06-19 18:14:52 -06:00
int Status = STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
PUCHAR pcBuff = ( PUCHAR ) pBuff ;
2012-06-06 20:54:28 -06:00
if ( uiNumBytes % Adapter - > ulFlashWriteSize ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Writing without Sector Erase for non-FlashWriteSize number of bytes 0x%x \n " , uiNumBytes ) ;
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:27 -06:00
uiStartOffset = BcmGetSectionValStartOffset ( Adapter , eFlash2xSectionVal ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( IsSectionExistInVendorInfo ( Adapter , eFlash2xSectionVal ) )
2010-09-08 15:46:36 -06:00
return vendorextnWriteSectionWithoutErase ( Adapter , pcBuff , eFlash2xSectionVal , uiOffset , uiNumBytes ) ;
uiOffset = uiOffset + uiStartOffset ;
2012-06-06 20:54:27 -06:00
# if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
Status = bcmflash_raw_writenoerase ( ( uiOffset / FLASH_PART_SIZE ) , ( uiOffset % FLASH_PART_SIZE ) , pcBuff , uiNumBytes ) ;
# else
rdmalt ( Adapter , 0x0f000C80 , & uiTemp , sizeof ( uiTemp ) ) ;
value = 0 ;
wrmalt ( Adapter , 0x0f000C80 , & value , sizeof ( value ) ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
Adapter - > SelectedChip = RESET_CHIP_SELECT ;
BcmDoChipSelect ( Adapter , uiOffset ) ;
uiPartOffset = ( uiOffset & ( FLASH_PART_SIZE - 1 ) ) + GetFlashBaseAddr ( Adapter ) ;
2010-09-08 15:46:36 -06:00
2013-09-10 09:44:39 -06:00
for ( i = 0 ; i < uiNumBytes ; i + = Adapter - > ulFlashWriteSize ) {
2012-06-06 20:54:27 -06:00
if ( Adapter - > ulFlashWriteSize = = BYTE_WRITE_SUPPORT )
Status = flashByteWrite ( Adapter , uiPartOffset , pcBuff ) ;
else
Status = flashWrite ( Adapter , uiPartOffset , pcBuff ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
if ( Status ! = STATUS_SUCCESS )
break ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
pcBuff = pcBuff + Adapter - > ulFlashWriteSize ;
uiPartOffset = uiPartOffset + Adapter - > ulFlashWriteSize ;
}
wrmalt ( Adapter , 0x0f000C80 , & uiTemp , sizeof ( uiTemp ) ) ;
Adapter - > SelectedChip = RESET_CHIP_SELECT ;
# endif
2010-09-08 15:46:36 -06:00
return Status ;
}
2013-10-28 02:35:59 -06:00
bool IsSectionExistInFlash ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val section )
2010-09-08 15:46:36 -06:00
{
2013-10-28 02:36:19 -06:00
bool SectionPresent = false ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
switch ( section ) {
case ISO_IMAGE1 :
if ( ( Adapter - > psFlash2xCSInfo - > OffsetISOImage1Part1Start ! = UNINIT_PTR_IN_CS ) & &
2013-10-28 02:36:19 -06:00
( IsNonCDLessDevice ( Adapter ) = = false ) )
2012-06-06 20:54:28 -06:00
SectionPresent = TRUE ;
break ;
case ISO_IMAGE2 :
if ( ( Adapter - > psFlash2xCSInfo - > OffsetISOImage2Part1Start ! = UNINIT_PTR_IN_CS ) & &
2013-10-28 02:36:19 -06:00
( IsNonCDLessDevice ( Adapter ) = = false ) )
2012-06-06 20:54:28 -06:00
SectionPresent = TRUE ;
break ;
case DSD0 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSDStart ! = UNINIT_PTR_IN_CS )
SectionPresent = TRUE ;
break ;
case DSD1 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD1Start ! = UNINIT_PTR_IN_CS )
SectionPresent = TRUE ;
break ;
case DSD2 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForDSD2Start ! = UNINIT_PTR_IN_CS )
SectionPresent = TRUE ;
break ;
case VSA0 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSAStart ! = UNINIT_PTR_IN_CS )
SectionPresent = TRUE ;
break ;
case VSA1 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA1Start ! = UNINIT_PTR_IN_CS )
SectionPresent = TRUE ;
break ;
case VSA2 :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForVSA2Start ! = UNINIT_PTR_IN_CS )
SectionPresent = TRUE ;
break ;
case SCSI :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForScsiFirmware ! = UNINIT_PTR_IN_CS )
SectionPresent = TRUE ;
break ;
case CONTROL_SECTION :
if ( Adapter - > psFlash2xCSInfo - > OffsetFromZeroForControlSectionStart ! = UNINIT_PTR_IN_CS )
SectionPresent = TRUE ;
break ;
default :
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Section Does not exist in Flash 2.x " ) ;
2013-10-28 02:36:19 -06:00
SectionPresent = false ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
return SectionPresent ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:27 -06:00
2014-03-13 12:02:46 -06:00
static int IsSectionWritable ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val Section )
2010-09-08 15:46:36 -06:00
{
2012-06-19 18:14:52 -06:00
int offset = STATUS_FAILURE ;
2013-10-28 02:36:19 -06:00
int Status = false ;
2010-09-08 15:46:36 -06:00
2013-10-28 02:36:19 -06:00
if ( IsSectionExistInFlash ( Adapter , Section ) = = false ) {
2014-01-10 19:26:27 -07:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Section <%d> does not exist " , Section ) ;
2013-10-28 02:36:19 -06:00
return false ;
2012-06-06 20:54:27 -06:00
}
offset = BcmGetSectionValStartOffset ( Adapter , Section ) ;
2012-06-06 20:54:28 -06:00
if ( offset = = INVALID_OFFSET ) {
2014-01-10 19:26:27 -07:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Section<%d> does not exist " , Section ) ;
2013-10-28 02:36:19 -06:00
return false ;
2012-06-06 20:54:27 -06:00
}
if ( IsSectionExistInVendorInfo ( Adapter , Section ) )
return ! ( Adapter - > psFlash2xVendorInfo - > VendorSection [ Section ] . AccessFlags & FLASH2X_SECTION_RO ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
Status = IsOffsetWritable ( Adapter , offset ) ;
return Status ;
2010-09-08 15:46:36 -06:00
}
2012-11-22 12:48:50 -07:00
static int CorruptDSDSig ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val eFlash2xSectionVal )
2010-09-08 15:46:36 -06:00
{
2010-09-30 02:24:12 -06:00
PUCHAR pBuff = NULL ;
2012-06-19 18:14:53 -06:00
unsigned int sig = 0 ;
unsigned int uiOffset = 0 ;
unsigned int BlockStatus = 0 ;
unsigned int uiSectAlignAddr = 0 ;
2010-09-08 15:46:36 -06:00
2013-10-28 02:36:19 -06:00
Adapter - > bSigCorrupted = false ;
if ( Adapter - > bAllDSDWriteAllow = = false ) {
2012-06-06 20:54:28 -06:00
if ( IsSectionWritable ( Adapter , eFlash2xSectionVal ) ! = TRUE ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Section is not Writable...Hence can't Corrupt signature " ) ;
2010-09-08 15:46:36 -06:00
return SECTOR_IS_NOT_WRITABLE ;
}
}
2013-03-10 06:48:27 -06:00
pBuff = kzalloc ( MAX_RW_SIZE , GFP_KERNEL ) ;
2012-06-19 18:14:54 -06:00
if ( ! pBuff ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Can't allocate memorey " ) ;
return - ENOMEM ;
2010-09-08 15:46:36 -06:00
}
2012-11-30 23:15:52 -07:00
uiOffset = Adapter - > psFlash2xCSInfo - > OffsetFromDSDStartForDSDHeader + sizeof ( struct bcm_dsd_header ) ;
2012-06-06 20:54:27 -06:00
uiOffset - = MAX_RW_SIZE ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
BcmFlash2xBulkRead ( Adapter , ( PUINT ) pBuff , eFlash2xSectionVal , uiOffset , MAX_RW_SIZE ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
sig = * ( ( PUINT ) ( pBuff + 12 ) ) ;
sig = ntohl ( sig ) ;
BCM_DEBUG_PRINT_BUFFER ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , pBuff , MAX_RW_SIZE ) ;
2012-06-06 20:54:29 -06:00
/* Now corrupting the sig by corrupting 4th last Byte. */
2010-09-08 15:46:36 -06:00
* ( pBuff + 12 ) = 0 ;
2012-06-06 20:54:28 -06:00
if ( sig = = DSD_IMAGE_MAGIC_NUMBER ) {
2010-09-08 15:46:36 -06:00
Adapter - > bSigCorrupted = TRUE ;
2012-06-06 20:54:28 -06:00
if ( Adapter - > ulFlashWriteSize = = BYTE_WRITE_SUPPORT ) {
2012-06-06 20:54:27 -06:00
uiSectAlignAddr = uiOffset & ~ ( Adapter - > uiSectorSize - 1 ) ;
BlockStatus = BcmFlashUnProtectBlock ( Adapter , uiSectAlignAddr , Adapter - > uiSectorSize ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:27 -06:00
WriteToFlashWithoutSectorErase ( Adapter , ( PUINT ) ( pBuff + 12 ) , eFlash2xSectionVal ,
( uiOffset + 12 ) , BYTE_WRITE_SUPPORT ) ;
2012-06-06 20:54:28 -06:00
if ( BlockStatus ) {
2012-06-06 20:54:27 -06:00
BcmRestoreBlockProtectStatus ( Adapter , BlockStatus ) ;
2010-09-08 15:46:36 -06:00
BlockStatus = 0 ;
}
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
WriteToFlashWithoutSectorErase ( Adapter , ( PUINT ) pBuff , eFlash2xSectionVal ,
uiOffset , MAX_RW_SIZE ) ;
2010-09-08 15:46:36 -06:00
}
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " BCM Signature is not present in header " ) ;
2010-11-01 07:35:21 -06:00
kfree ( pBuff ) ;
2012-06-06 20:54:27 -06:00
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2010-11-01 07:35:21 -06:00
kfree ( pBuff ) ;
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Corrupted the signature " ) ;
return STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
}
2012-11-22 12:48:50 -07:00
static int CorruptISOSig ( struct bcm_mini_adapter * Adapter , enum bcm_flash2x_section_val eFlash2xSectionVal )
2010-09-08 15:46:36 -06:00
{
2010-09-30 02:24:12 -06:00
PUCHAR pBuff = NULL ;
2012-06-19 18:14:53 -06:00
unsigned int sig = 0 ;
unsigned int uiOffset = 0 ;
2010-09-08 15:46:36 -06:00
2013-10-28 02:36:19 -06:00
Adapter - > bSigCorrupted = false ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:28 -06:00
if ( IsSectionWritable ( Adapter , eFlash2xSectionVal ) ! = TRUE ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Section is not Writable...Hence can't Corrupt signature " ) ;
2010-09-08 15:46:36 -06:00
return SECTOR_IS_NOT_WRITABLE ;
}
2013-03-10 06:48:27 -06:00
pBuff = kzalloc ( MAX_RW_SIZE , GFP_KERNEL ) ;
2012-06-19 18:14:54 -06:00
if ( ! pBuff ) {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Can't allocate memorey " ) ;
return - ENOMEM ;
2010-09-08 15:46:36 -06:00
}
uiOffset = 0 ;
2012-06-06 20:54:27 -06:00
BcmFlash2xBulkRead ( Adapter , ( PUINT ) pBuff , eFlash2xSectionVal , uiOffset , MAX_RW_SIZE ) ;
2010-09-08 15:46:36 -06:00
sig = * ( ( PUINT ) pBuff ) ;
2012-06-06 20:54:27 -06:00
sig = ntohl ( sig ) ;
2010-09-08 15:46:36 -06:00
2012-06-06 20:54:29 -06:00
/* corrupt signature */
2010-09-08 15:46:36 -06:00
* pBuff = 0 ;
2012-06-06 20:54:28 -06:00
if ( sig = = ISO_IMAGE_MAGIC_NUMBER ) {
2010-09-08 15:46:36 -06:00
Adapter - > bSigCorrupted = TRUE ;
2012-06-06 20:54:27 -06:00
WriteToFlashWithoutSectorErase ( Adapter , ( PUINT ) pBuff , eFlash2xSectionVal ,
uiOffset , Adapter - > ulFlashWriteSize ) ;
2012-06-06 20:54:28 -06:00
} else {
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " BCM Signature is not present in header " ) ;
2010-11-01 07:35:21 -06:00
kfree ( pBuff ) ;
2012-06-06 20:54:27 -06:00
2010-09-08 15:46:36 -06:00
return STATUS_FAILURE ;
}
2012-06-06 20:54:27 -06:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , " Corrupted the signature " ) ;
BCM_DEBUG_PRINT_BUFFER ( Adapter , DBG_TYPE_OTHERS , NVM_RW , DBG_LVL_ALL , pBuff , MAX_RW_SIZE ) ;
2010-09-08 15:46:36 -06:00
2010-11-01 07:35:21 -06:00
kfree ( pBuff ) ;
2012-06-06 20:54:27 -06:00
return STATUS_SUCCESS ;
2010-09-08 15:46:36 -06:00
}
2013-10-28 02:35:59 -06:00
bool IsNonCDLessDevice ( struct bcm_mini_adapter * Adapter )
2010-09-08 15:46:36 -06:00
{
2012-06-06 20:54:27 -06:00
if ( Adapter - > psFlash2xCSInfo - > IsCDLessDeviceBootSig = = NON_CDLESS_DEVICE_BOOT_SIG )
2010-09-08 15:46:36 -06:00
return TRUE ;
else
2013-10-28 02:36:19 -06:00
return false ;
2010-09-08 15:46:36 -06:00
}