summaryrefslogtreecommitdiffstats
path: root/src/usr/i2c/i2c.C
diff options
context:
space:
mode:
authorMatt Derksen <mderkse1@us.ibm.com>2017-07-28 10:46:18 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2017-08-12 21:17:36 -0400
commit64c5f756d00f902ce974306c783cd4f1464b3159 (patch)
treeb89a509a2e083f0ae45f581ac8dde2c5caac531b /src/usr/i2c/i2c.C
parent42ecd455ada336844fe97f710250813e0d47b08f (diff)
downloadtalos-hostboot-64c5f756d00f902ce974306c783cd4f1464b3159.tar.gz
talos-hostboot-64c5f756d00f902ce974306c783cd4f1464b3159.zip
Hostboot HDAT: update to match section 19 in HDAT spec
Add new i2cLabel string Change-Id: I007441e3973a16eaae4dbdbe703297f0f6978c8f RTC: 176759 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/44301 Reviewed-by: Martin Gloff <mgloff@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/i2c/i2c.C')
-rwxr-xr-xsrc/usr/i2c/i2c.C106
1 files changed, 89 insertions, 17 deletions
diff --git a/src/usr/i2c/i2c.C b/src/usr/i2c/i2c.C
index 6a8463eae..307bef806 100755
--- a/src/usr/i2c/i2c.C
+++ b/src/usr/i2c/i2c.C
@@ -55,6 +55,7 @@
#include <i2c/eepromif.H>
#include <i2c/tpmddif.H>
+
// ----------------------------------------------
// Globals
// ----------------------------------------------
@@ -3840,6 +3841,7 @@ void getMasterInfo( const TARGETING::Target* i_chip,
}
}
+
//******************************************************************************
// areI2cDevicesLogicallyEqual (std::unique equality comparison)
//******************************************************************************
@@ -3883,6 +3885,67 @@ bool byI2cDeviceOrder(
return lhsLogicallyBeforeRhs;
}
+//******************************************************************************
+// removeI2CDeviceDuplicates
+//******************************************************************************
+void removeI2cDeviceDuplicates(std::vector<DeviceInfo_t>& io_deviceInfo)
+{
+ std::vector<DeviceInfo_t> l_unique_deviceInfo;
+
+ // Begin by sorting the list
+ // Order I2C devices by chip, engine, port, address, slave port
+ std::sort(io_deviceInfo.begin(), io_deviceInfo.end(),
+ byI2cDeviceOrder);
+
+ // Build up new unique list (thus removing duplicates)
+ if (io_deviceInfo.size() > 1)
+ {
+ auto currentItr = io_deviceInfo.begin();
+ auto nextItr = currentItr + 1;
+
+ do {
+ if (nextItr != io_deviceInfo.end() && (currentItr != NULL))
+ {
+ if (areI2cDevicesLogicallyEqual(*currentItr, *nextItr))
+ {
+ // skip if first letter is ?, these are guessed defaults
+ if (currentItr->deviceLabel[0] == '?')
+ {
+ // don't save currentItr as it is a guessed default
+ currentItr = nextItr;
+ }
+ }
+ else
+ {
+ // Save currentItr as nextItr isn't the same logical device
+ if (currentItr != NULL)
+ {
+ l_unique_deviceInfo.push_back(*currentItr);
+ }
+ currentItr = nextItr;
+ }
+ }
+ else
+ {
+ // Save currentItr if pointing at something valid
+ if (currentItr != NULL)
+ {
+ l_unique_deviceInfo.push_back(*currentItr);
+ currentItr = nextItr;
+ }
+ }
+
+ if (nextItr != io_deviceInfo.end())
+ {
+ ++nextItr;
+ }
+
+ } while (currentItr != io_deviceInfo.end());
+
+ io_deviceInfo = l_unique_deviceInfo;
+ }
+}
+
/**
* Retrieve some information about I2C devices that the Host
* needs to know about
@@ -4029,11 +4092,15 @@ void getDeviceInfo( TARGETING::Target* i_i2cMaster,
//TODO RTC:165485 this isn't currently right. we'll need
//to add the changes in the enum and possibly the other
//struct/attribute.
+ strcpy(l_currentDI.deviceLabel,
+ "?atmel,28c128,vpd,module");
break;
case EEPROM::SBE_PRIMARY:
case EEPROM::SBE_BACKUP:
l_currentDI.devicePurpose =
TARGETING::HDAT_I2C_DEVICE_PURPOSE_SBE_SEEPROM;
+ strcpy(l_currentDI.deviceLabel,
+ "?atmel,28c128,unknown,unknown");
break;
case EEPROM::LAST_CHIP_TYPE:
break;
@@ -4083,7 +4150,7 @@ void getDeviceInfo( TARGETING::Target* i_i2cMaster,
TARGETING::HDAT_I2C_DEVICE_TYPE_NUVOTON_TPM;
l_currentDI.devicePurpose =
TARGETING::HDAT_I2C_DEVICE_PURPOSE_TPM;
-
+ strcpy(l_currentDI.deviceLabel,"?nuvoton,npct601,tpm,host");
o_deviceInfo.push_back(l_currentDI);
} //end of tpm iter
@@ -4150,6 +4217,12 @@ void getDeviceInfo( TARGETING::Target* i_i2cMaster,
"ATTR_HDAT_I2C_DEVICE_PURPOSE attribute",
TARGETING::get_huid(pChipTarget));
+ TARGETING::ATTR_HDAT_I2C_DEVICE_LABEL_type l_i2cDevLabel;
+ present = pChipTarget->tryGetAttr<
+ TARGETING::ATTR_HDAT_I2C_DEVICE_LABEL>(l_i2cDevLabel);
+ assert(present,"Target 0x%08X does not have ATTR_HDAT_I2C_DEVICE_LABEL "
+ "attribute",TARGETING::get_huid(pChipTarget));
+
for(TARGETING::ATTR_HDAT_I2C_ELEMENTS_type l_idx=0;
l_idx < l_arrayLength;
++l_idx)
@@ -4178,8 +4251,17 @@ void getDeviceInfo( TARGETING::Target* i_i2cMaster,
l_currentDevice.slavePort = l_i2cSlavePort[l_idx];
l_currentDevice.busFreqKhz = l_i2cBusFreq[l_idx]
/ FREQ_CONVERSION::HZ_PER_KHZ;
- l_currentDevice.deviceType = l_i2cDevType[l_idx];
- l_currentDevice.devicePurpose = l_i2cDevPurpose[l_idx];
+ l_currentDevice.deviceType =
+ static_cast<TARGETING::HDAT_I2C_DEVICE_TYPE>(
+ l_i2cDevType[l_idx]);
+ l_currentDevice.devicePurpose =
+ static_cast<TARGETING::HDAT_I2C_DEVICE_PURPOSE>(
+ l_i2cDevPurpose[l_idx]);
+
+ memcpy(l_currentDevice.deviceLabel, l_i2cDevLabel[l_idx],
+ sizeof(l_currentDevice.deviceLabel));
+ l_currentDevice.deviceLabel[sizeof(l_currentDevice.deviceLabel) - 1]
+ = '\0';
o_deviceInfo.push_back(l_currentDevice);
}
@@ -4187,23 +4269,13 @@ void getDeviceInfo( TARGETING::Target* i_i2cMaster,
} //end of per chip loop
- // Order I2C devices by chip, engine, port, address, slave port
- std::sort(o_deviceInfo.begin(), o_deviceInfo.end(),
- byI2cDeviceOrder);
-
- // Move logical duplicates to end
- std::vector<DeviceInfo_t>::iterator
- pInvalidEntries = std::unique(
- o_deviceInfo.begin(),
- o_deviceInfo.end(),
- areI2cDevicesLogicallyEqual);
-
- // Erase the duplicates
- o_deviceInfo.erase(pInvalidEntries,o_deviceInfo.end());
+ // remove duplicates (also use deviceLabel from MRW, when possible)
+ removeI2cDeviceDuplicates(o_deviceInfo);
TRACFCOMP(g_trac_i2c,"<<getDeviceInfo");
return;
-};
+}
+
/**
* @brief Utility Function to capture error log user data consisting of
OpenPOWER on IntegriCloud