www.pudn.com > PlxSdk.rar > Eep_6000.c
/*******************************************************************************
* Copyright (c) 2007 PLX Technology, Inc.
*
* PLX Technology Inc. licenses this software under specific terms and
* conditions. Use of any of the software or derviatives thereof in any
* product without a PLX Technology chip is strictly prohibited.
*
* PLX Technology, Inc. provides this software AS IS, WITHOUT ANY WARRANTY,
* EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. PLX makes no guarantee
* or representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL PLX BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL PLX'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO PLX FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
/******************************************************************************
*
* File Name:
*
* Eep_6000.c
*
* Description:
*
* This file contains 6000-series EEPROM support functions
*
* Revision History:
*
* 06-01-07 : PLX SDK v5.10
*
******************************************************************************/
#include "Eep_6000.h"
#include "PciSupport.h"
#include "SupportFunc.h"
/******************************************************************************
*
* Function : Plx6000_EepromSignatureGet
*
* Description: Returns the current value of the EEPROM signature and its status
*
******************************************************************************/
RETURN_CODE
Plx6000_EepromSignatureGet(
DEVICE_EXTENSION *pdx,
U32 *pSignature,
U8 *pStatus
)
{
U16 value;
// Read updated value
Plx6000_EepromReadByOffset_16(
pdx,
EEPROM_6000_TEST_OFFSET,
&value
);
// Return signature
*pSignature = value;
// Determine signature status
if (value == 0x1516)
*pStatus = PLX_CRC_VALID;
else
*pStatus = PLX_CRC_INVALID;
return ApiSuccess;
}
/******************************************************************************
*
* Function : Plx6000_EepromReadByOffset_16
*
* Description: Read a 16-bit value from the EEPROM at a specified offset
*
******************************************************************************/
RETURN_CODE
Plx6000_EepromReadByOffset_16(
DEVICE_EXTENSION *pdx,
U16 offset,
U16 *pValue
)
{
U16 Offset_EepromCtrl;
U32 RegSave;
U32 RegValue;
// Save the chip control register
PLX_PCI_REG_READ(
pdx,
0xD8,
&RegSave
);
// Enable shadow register access
PLX_PCI_REG_WRITE(
pdx,
0xD8,
RegSave | (1 << 6)
);
// Set EEPROM control register offset
Offset_EepromCtrl = 0x54;
// Offset can only be 8-bits
offset = offset & 0xFF;
// Prepare EEPROM read command
RegValue = ((U32)offset << 8) | (1 << 0);
// Write EEPROM command
PLX_PCI_REG_WRITE(
pdx,
Offset_EepromCtrl,
RegValue
);
// Insert a small delay
Plx_sleep(50);
// Read data
PLX_PCI_REG_READ(
pdx,
Offset_EepromCtrl,
&RegValue
);
// Store data
*pValue = (U16)(RegValue >> 16);
// Restore chip control register
PLX_PCI_REG_WRITE(
pdx,
0xD8,
RegSave
);
return ApiSuccess;
}
/******************************************************************************
*
* Function : Plx6000_EepromWriteByOffset_16
*
* Description: Write a 16-bit value to the EEPROM at a specified offset
*
******************************************************************************/
RETURN_CODE
Plx6000_EepromWriteByOffset_16(
DEVICE_EXTENSION *pdx,
U16 offset,
U16 value
)
{
U16 Offset_EepromCtrl;
U32 RegSave;
U32 RegValue;
// Save the chip control register
PLX_PCI_REG_READ(
pdx,
0xD8,
&RegSave
);
// Enable shadow register access
PLX_PCI_REG_WRITE(
pdx,
0xD8,
RegSave | (1 << 6)
);
// Set EEPROM control register offset
Offset_EepromCtrl = 0x54;
// Offset can only be 8-bits
offset = offset & 0xFF;
// Prepare EEPROM write command & data
RegValue = (value << 16) | ((U32)offset << 8) | (1 << 1) | (1 << 0);
// Write EEPROM command
PLX_PCI_REG_WRITE(
pdx,
Offset_EepromCtrl,
RegValue
);
// Insert a small delay
Plx_sleep(100);
// Restore chip control register
PLX_PCI_REG_WRITE(
pdx,
0xD8,
RegSave
);
return ApiSuccess;
}