summaryrefslogtreecommitdiffstats
path: root/src/usr/i2c/runtime/rt_i2c.C
diff options
context:
space:
mode:
authorCorey Swenson <cswenson@us.ibm.com>2015-03-09 21:14:29 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2015-03-26 14:47:50 -0500
commitb0b7adcd0c1a072d6ee70c126dee95d570a86bef (patch)
tree1b0561b7456831879b340812cab48211483d410d /src/usr/i2c/runtime/rt_i2c.C
parenta0f4a934254572ce49a1ddf5e4d5d944b52779be (diff)
downloadtalos-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>
Diffstat (limited to 'src/usr/i2c/runtime/rt_i2c.C')
-rwxr-xr-xsrc/usr/i2c/runtime/rt_i2c.C52
1 files changed, 43 insertions, 9 deletions
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
);
OpenPOWER on IntegriCloud