diff options
author | Corey Swenson <cswenson@us.ibm.com> | 2015-03-09 21:14:29 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2015-03-26 14:47:50 -0500 |
commit | b0b7adcd0c1a072d6ee70c126dee95d570a86bef (patch) | |
tree | 1b0561b7456831879b340812cab48211483d410d | |
parent | a0f4a934254572ce49a1ddf5e4d5d944b52779be (diff) | |
download | talos-hostboot-b0b7adcd0c1a072d6ee70c126dee95d570a86bef.tar.gz talos-hostboot-b0b7adcd0c1a072d6ee70c126dee95d570a86bef.zip |
Fix device address and offset for I2C runtime
Change-Id: I8aae26f0e7d774059547b110c4bd643115570116
RTC: 125281
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/16255
Tested-by: Jenkins Server
Reviewed-by: Michael Baiocchi <baiocchi@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
-rw-r--r-- | src/include/usr/i2c/i2creasoncodes.H | 1 | ||||
-rwxr-xr-x | src/usr/i2c/runtime/rt_i2c.C | 52 |
2 files changed, 44 insertions, 9 deletions
diff --git a/src/include/usr/i2c/i2creasoncodes.H b/src/include/usr/i2c/i2creasoncodes.H index a63e8d5a6..6dda540da 100644 --- a/src/include/usr/i2c/i2creasoncodes.H +++ b/src/include/usr/i2c/i2creasoncodes.H @@ -84,6 +84,7 @@ enum i2cReasonCode I2C_ARBITRATION_LOST_ONLY_FOUND = I2C_COMP_ID | 0x0C, // Bus Arbi lost found in status reg I2C_RUNTIME_INTERFACE_ERR = I2C_COMP_ID | 0x0D, // Read/write unavailable at runtime I2C_RUNTIME_ERR = I2C_COMP_ID | 0x0E, // Failed run-time operation + I2C_RUNTIME_INVALID_OFFSET_LENGTH = I2C_COMP_ID | 0x0F, // Offset length of invalid size }; diff --git a/src/usr/i2c/runtime/rt_i2c.C b/src/usr/i2c/runtime/rt_i2c.C index 9938ebe19..5d21bbf42 100755 --- a/src/usr/i2c/runtime/rt_i2c.C +++ b/src/usr/i2c/runtime/rt_i2c.C @@ -76,15 +76,49 @@ errlHndl_t i2cPerformOp( DeviceFW::OperationType i_opType, args.engine = va_arg( i_args, uint64_t ); args.devAddr = va_arg( i_args, uint64_t ); + // i2c addresses are 7 bits so shift that right 1 bit + args.devAddr >>= 1; + // These are additional parms in the case an offset is passed in // via va_list, as well + args.offset_length = va_arg( i_args, uint64_t); - uint64_t offset_length = va_arg( i_args, uint64_t); - uint64_t offset_buffer = 0; - - if ( offset_length != 0 ) + uint32_t offset = 0; + if ( args.offset_length != 0 ) { - offset_buffer = va_arg(i_args, uint64_t); + args.offset_buffer = reinterpret_cast<uint8_t*> + (va_arg(i_args, uint64_t)); + if ( args.offset_length == 1 ) + { + offset = *(args.offset_buffer); + } + else if ( args.offset_length == 2 ) + { + offset = *(reinterpret_cast<uint16_t*>(args.offset_buffer)); + } + else if ( args.offset_length == 4 ) + { + offset = *(reinterpret_cast<uint32_t*>(args.offset_buffer)); + } + else + { + /*@ + * @errortype + * @moduleid I2C_PERFORM_OP + * @reasoncode I2C_RUNTIME_INVALID_OFFSET_LENGTH + * @userdata1 Offset length + * @userdata2 Op type + * @devdesc I2C offset length is invalid + */ + err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_INFORMATIONAL, + I2C_PERFORM_OP, + I2C_RUNTIME_INVALID_OFFSET_LENGTH, + args.offset_length, + i_opType); + + err->addProcedureCallout(HWAS::EPUB_PRC_HB_CODE, + HWAS::SRCI_PRIORITY_HIGH); + } } int rc = 0; @@ -113,8 +147,8 @@ errlHndl_t i2cPerformOp( DeviceFW::OperationType i_opType, ( proc_engine_port, // Master Chip/Engine/Port args.devAddr, // Dev Addr - offset_length, // Offset size - offset_buffer, // Offset + args.offset_length, // Offset size + offset, // Offset io_buflen, // Buffer length io_buffer // Buffer ); @@ -133,8 +167,8 @@ errlHndl_t i2cPerformOp( DeviceFW::OperationType i_opType, ( proc_engine_port, // Master Chip/Engine/Port args.devAddr, // Dev Addr - offset_length, // Offset size - offset_buffer, // Offset + args.offset_length, // Offset size + offset, // Offset io_buflen, // Buffer length io_buffer // Buffer ); |