diff options
| author | aalugore <aalugore@us.ibm.com> | 2016-01-22 13:36:14 -0600 |
|---|---|---|
| committer | Stephen Cprek <smcprek@us.ibm.com> | 2016-04-21 13:51:43 -0500 |
| commit | 4f4f097d65e919bcc8bd5706f50ea0f413b8bfef (patch) | |
| tree | 90030301032f3a87e952e5c161763bab0ad812be /src/usr/i2c/eepromdd.H | |
| parent | 18e7af4cee8e4a9b88dee257edffb528b969ecd3 (diff) | |
| download | blackbird-hostboot-4f4f097d65e919bcc8bd5706f50ea0f413b8bfef.tar.gz blackbird-hostboot-4f4f097d65e919bcc8bd5706f50ea0f413b8bfef.zip | |
DDR4 - Allow SPD writes
-DDR4 has 512-byte EEPROM with 2 256-byte pages.
This commit contains the necessary page switching
logic to support this.
Change-Id: Iaa8e3e344def98b71d6a9e9387c5e0d9137a0397
RTC:137707
ForwardPort: yes
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/797
Tested-by: Jenkins Server
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Tested-by: Jenkins OP Build CI
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
Tested-by: Jenkins OP HW
Tested-by: FSP CI Jenkins
Reviewed-by: Matthew A. Ploetz <maploetz@us.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/871
Diffstat (limited to 'src/usr/i2c/eepromdd.H')
| -rwxr-xr-x | src/usr/i2c/eepromdd.H | 133 |
1 files changed, 127 insertions, 6 deletions
diff --git a/src/usr/i2c/eepromdd.H b/src/usr/i2c/eepromdd.H index 234be5eb1..19eb0a7e3 100755 --- a/src/usr/i2c/eepromdd.H +++ b/src/usr/i2c/eepromdd.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ +/* Contributors Listed Below - COPYRIGHT 2011,2016 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -46,9 +46,10 @@ namespace EEPROM */ typedef enum { - ZERO_BYTE_ADDR = 0, - ONE_BYTE_ADDR = 1, - TWO_BYTE_ADDR = 2, + ZERO_BYTE_ADDR = 0, + ONE_BYTE_ADDR_PAGESELECT = 1, // page select + TWO_BYTE_ADDR = 2, + ONE_BYTE_ADDR = 3, LAST_DEVICE_TYPE } eeprom_addr_size_t; @@ -70,6 +71,14 @@ typedef struct uint64_t writeCycleTime; // in milliseconds } eeprom_addr_t; +/* + * @brief Miscellaneous enums for EEPROM + */ +enum +{ + EEPROM_PAGE_SIZE = 0x100 +}; + /** * * @brief Perform an EEPROM access operation. @@ -109,6 +118,60 @@ errlHndl_t eepromPerformOp( DeviceFW::OperationType i_opType, va_list i_args ); /** + * + * @brief Perform operations to lock and unlock the page mutex + * + * @param[in] i_target - the target to lock the page for + * @param[in] i_switchPage - bool to tell the function whether we are + * trying to switch pages/locking vs unlocking the page + * @param[in] i_lockMutex - bool to inform call chain whether we want + * to actually lock the page mutex or not. When false, + * the function assumes the appropriate mutex has already + * been locked and skips the call to mutex_lock + * @param[in/out] i_pageLocked - bool to tell the caller if the page + * was successfully locked. + * @param[in] i_desiredPage - The page we want to switch to + * @param[in] i_args - This is an argument list for the device driver + * framework. This argument list consists of the chip number of + * the EEPROM to access from the given I2C Master target and the + * internal offset to use on the slave I2C device. + * + * @return errlHndl_t - NULL if successful, otherwise a pointer to the + * error log. + */ +errlHndl_t eepromPageOp( TARGETING::Target * i_target, + bool i_switchPage, + bool i_lockMutex, + bool & io_pageLocked, + uint8_t i_desiredPage, + eeprom_addr_t i_i2cInfo ); + + +/* + * @brief This utility function determines if a read/write straddles + * the boundary between EEPROM pages and if so, returns the + * parameters to perform 2 operations, one for each page. + * + * @param[in] i_originalOffset - The requested read/write offset into + * the EEPROM. + * @param[in] i_originalLen - The requested length of the data. + * @param[in/out] io_newLen - The length of the data to retrieve + * @param[out] o_pageTwoBuflen - The length of data requested that + * crossed over into the second EEPROM page. + * @param[in] i_i2cInfo - Structure of I2C parameters needed to determine + * if we run the body of this function. + + * @return bool - True if the requested data straddles the EEPROM page + * boundary, False otherwise. If False, io_newLen == i_originalLen. + */ +bool crossesEepromPageBoundary( uint64_t i_originalOffset, + size_t i_originalLen, + size_t & io_newLen, + size_t & o_pageTwoBuflen, + eeprom_addr_t i_i2cInfo ); + + +/** * @brief This function peforms the sequencing to do a read of the * EEPROM that is identified. * @@ -130,6 +193,37 @@ errlHndl_t eepromRead ( TARGETING::Target * i_target, size_t i_buflen, eeprom_addr_t i_i2cInfo ); + +/** + * @brief This function actually performs the i2c operations to read data from + * the EEPROM + * + * @param[in] i_target - Target device + * + * @param[out] o_buffer - the buffer that will return the data read from + * the eeprom device + * + * @param[in] i_buflen - Number of bytes read from the EEPROM device + * + * @param[in] i_byteAddress - the offset into the EEPROM device + * + * @param[in] i_byteAddressSize - the size of the byte address (1 or 2 bytes) + * + * @param[in] i_i2cInfo - Structure of I2C parameters needed to execute the + * command to the I2C device driver + * + * @return errlHndl_t - NULL if successful, otherwise a pointer to the + * error log. + */ +errlHndl_t eepromReadData( TARGETING::Target * i_target, + void * o_buffer, + size_t i_buflen, + void * i_byteAddress, + size_t i_byteAddressSize, + eeprom_addr_t i_i2cInfo ); + + + /** * @brief This function peforms the sequencing to do a write of the * EEPROM that is identified. @@ -155,25 +249,52 @@ errlHndl_t eepromWrite ( TARGETING::Target * i_target, size_t & io_buflen, eeprom_addr_t i_i2cInfo ); + + +/** + * @brief This function actually writes data into the devices EEPROM + * + * @param[in] i_target - Target device. + * @param[in] i_dataToWrite - The data to be written into the device. + * @param[in] i_dataLen - The length of the data to be written. + * @param[in] i_byteAddress - the offset into the devices EEPROM. + * @param[in] i_byteAddressSize - the size of byte address varable. + * @param[in] i_i2cInfo - Structure of I2C parameters needed to execute + * the command to the I2C device driver. + */ +errlHndl_t eepromWriteData( TARGETING::Target * i_target, + void * i_dataToWrite, + size_t i_dataLen, + void * i_byteAddress, + size_t i_byteAddressSize, + eeprom_addr_t i_i2cInfo ); + + /** * @brief This function prepares the I2C byte address for adding to the * existing buffer (for Writes), or as a separate write operation * (for Reads). * + * @param[in] i_target - the target to prepare the addressing for. + * * @param[in/out] io_buffer - The buffer to be written as a byte address to * the EEPROM device. Must be pre-allocated to MAX_BYTE_ADDR size. * * @param[out] o_bufSize - The size of the buffer to be written. * + * @param[out] o_desiredPage - The page we want to switch to. + * * @param[in] i_i2cInfo - Structure of I2C parameters needed to execute * the command to the I2C device driver. * * @return errlHndl_t - NULL if successful, otherwise a pointer to the * error log. */ -errlHndl_t eepromPrepareAddress ( void * io_buffer, +errlHndl_t eepromPrepareAddress ( TARGETING::Target * i_target, + void * io_buffer, size_t & o_bufSize, - eeprom_addr_t i_i2cInfo ); + uint8_t & o_desiredPage, + eeprom_addr_t i_i2cInfo); /** * @brief this function will read all of the associated attributes needed |

