From a92f91459eb2a1c197e4f15d7341f1f501b89079 Mon Sep 17 00:00:00 2001 From: Roland Veloz Date: Fri, 31 Aug 2018 04:35:33 -0500 Subject: Added the I2C MUX attribute and target definitions - Defined the I2C_MUX_INFO attribute - Defined the i2c_mux target with I2C_MUX_INFO as an attribute - Defined the i2c_mux target to have parent 'chip' - Added attribute fields i2cMuxSelector and i2cMuxPath to attributes EEPROM_NV_INFO, EEPROM_SBE_BACKUP_INFO, EEPROM_SBE_PRIMARY_INFO, EEPROM_VPD_BACKUP_INFO, EEPROM_VPD_PRIMARY_INFO, FAPI_I2C_CONTROL_INFO, TEMP_SENSOR_I2C_CONFIG and TPM_INFO. All these had I2C info in them (i2cMasterPath, port, devAddr, engine, etc). RTC:196807 CMVC-Prereq:1068716 Change-Id: Iadf4909411329c8b7b961efc2cb0789f5b96a49f Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/65540 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: FSP CI Jenkins Reviewed-by: Nicholas E. Bofferding Tested-by: Jenkins OP HW Reviewed-by: Daniel M. Crowell --- .../targeting/common/xmltohb/attribute_types.xml | 215 +++++++++++++++++- .../common/xmltohb/simics_CUMULUS.system.xml | 48 ++++- src/usr/targeting/common/xmltohb/target_types.xml | 17 +- src/usr/targeting/common/xmltohb/xmltohb.pl | 240 ++++++++++++++++++--- 4 files changed, 471 insertions(+), 49 deletions(-) mode change 100755 => 100644 src/usr/targeting/common/xmltohb/attribute_types.xml (limited to 'src/usr/targeting/common/xmltohb') diff --git a/src/usr/targeting/common/xmltohb/attribute_types.xml b/src/usr/targeting/common/xmltohb/attribute_types.xml old mode 100755 new mode 100644 index 6b0c2acdd..5250b2b05 --- a/src/usr/targeting/common/xmltohb/attribute_types.xml +++ b/src/usr/targeting/common/xmltohb/attribute_types.xml @@ -959,6 +959,24 @@ uint64_t 0x05 + + + 0xFF + Determines which of the N selectable buses the mux + will connect to. OxFF indicates no mux present + or N/A. + i2cMuxBusSelector + uint8_t + + + + + physical:sys-0 + Entity path to the I2C mux for this device. + i2cMuxPath + EntityPath + non-volatile @@ -1033,6 +1051,24 @@ writeCycleTime uint64_t + + + 0xFF + Determines which of the N selectable buses the mux + will connect to. OxFF indicates no mux present + or N/A. + i2cMuxBusSelector + uint8_t + + + + + physical:sys-0 + Entity path to the I2C mux for this device. + i2cMuxPath + EntityPath + Information needed to address the EERPROM slaves EEPROM_SBE_BACKUP_INFO @@ -1109,6 +1145,24 @@ writeCycleTime uint64_t + + + 0xFF + Determines which of the N selectable buses the mux + will connect to. OxFF indicates no mux present + or N/A. + i2cMuxBusSelector + uint8_t + + + + + physical:sys-0 + Entity path to the I2C mux for this device. + i2cMuxPath + EntityPath + Information needed to address the EERPROM slaves EEPROM_SBE_PRIMARY_INFO @@ -1185,6 +1239,24 @@ writeCycleTime uint64_t + + + 0xFF + Determines which of the N selectable buses the mux + will connect to. OxFF indicates no mux present + or N/A. + i2cMuxBusSelector + uint8_t + + + + + physical:sys-0 + Entity path to the I2C mux for this device. + i2cMuxPath + EntityPath + Information needed to address the EERPROM slaves EEPROM_VPD_BACKUP_INFO @@ -1268,6 +1340,24 @@ writeCycleTime uint64_t + + + 0xFF + Determines which of the N selectable buses the mux + will connect to. OxFF indicates no mux present + or N/A. + i2cMuxBusSelector + uint8_t + + + + + physical:sys-0 + Entity path to the I2C mux for this device. + i2cMuxPath + EntityPath + Information needed to address the EEPROM slaves EEPROM_VPD_PRIMARY_INFO @@ -1295,8 +1385,8 @@ - EFF_DRAM_COLS + Number of DRAM columns. Initialized and used by HWPs. @@ -1307,8 +1397,8 @@ - EFF_DRAM_ROWS + Number of DRAM rows. Initialized and used by HWPs. @@ -1455,6 +1545,24 @@ devAddr uint8_t + + + 0xFF + Determines which of the N selectable buses the mux + will connect to. OxFF indicates no mux present + or N/A. + i2cMuxBusSelector + uint8_t + + + + + physical:sys-0 + Entity path to the I2C mux for this device. + i2cMuxPath + EntityPath + non-volatile @@ -1621,6 +1729,7 @@ + FREQ_PROC_REFCLOCK @@ -2016,8 +2125,8 @@ 0xA - NVLINK + 0xB @@ -2056,13 +2165,13 @@ 0x1 - 955X + 0x1 - SEEPROM + 0x2 @@ -2082,8 +2191,8 @@ 0x5 - NVLINK + 0x6 @@ -2396,6 +2505,51 @@ + + + Structure to define the addressing for + an I2C mux target. + + + + physical:sys-0 + Entity path to the chip that contains the I2C + master. + i2cMasterPath + EntityPath + + + + 0x00 + Port from the I2C Master device. This is a + 6-bit value. + port + uint8_t + + + + 0x00 + Device address on the I2C bus. This is a 7-bit + value, but then shifted 1 bit left. + devAddr + uint8_t + + + + 0x00 + I2C master engine. This is a 2-bit value. + engine + uint8_t + + + Information used to control a specific i2c mux device, + to select a particular target bus. + I2C_MUX_INFO + non-volatile + + + Structure which defines which I2C access method to use at @@ -2774,6 +2928,7 @@ + MAX_DMI_PER_PROC @@ -3172,7 +3327,6 @@ - 0x4000000000000 @@ -3689,6 +3843,9 @@ AST2500 + + PCA9847 + MODEL @@ -6068,8 +6225,8 @@ - non-volatile + @@ -6979,6 +7136,24 @@ devAddr uint8_t + + + 0xFF + Determines which of the N selectable buses the mux + will connect to. OxFF indicates no mux present + or N/A. + i2cMuxBusSelector + uint8_t + + + + + physical:sys-0 + Entity path to the I2C mux for this device. + i2cMuxPath + EntityPath + Information needed to address an I2C slave device TEMP_SENSOR_I2C_CONFIG @@ -7255,6 +7430,24 @@ byteAddrOffset uint8_t + + + 0xFF + Determines which of the N selectable buses the mux + will connect to. OxFF indicates no mux present + or N/A. + i2cMuxBusSelector + uint8_t + + + + + physical:sys-0 + Entity path to the I2C mux for this device. + i2cMuxPath + EntityPath + Information needed to address the TPM slaves TPM_INFO @@ -7624,9 +7817,13 @@ 76 - LAST_IN_RANGE + I2C_MUX 77 + + LAST_IN_RANGE + 78 + TYPE diff --git a/src/usr/targeting/common/xmltohb/simics_CUMULUS.system.xml b/src/usr/targeting/common/xmltohb/simics_CUMULUS.system.xml index c7d87beaa..2a9c82f72 100644 --- a/src/usr/targeting/common/xmltohb/simics_CUMULUS.system.xml +++ b/src/usr/targeting/common/xmltohb/simics_CUMULUS.system.xml @@ -13635,10 +13635,48 @@ - - - - - + + + sys0node0i2cmux0 + i2c_mux_pca9847 + + HUID + 0x004D0000 + + + PHYS_PATH + physical:sys-0/node-0/i2c_mux-0 + + + AFFINITY_PATH + affinity:sys-0/node-0/proc-0/i2c_mux-0 + + + PRIMARY_CAPABILITIES + + reserved0 + supportsFsiScom0 + supportsInbandScom0 + supportsXscom0 + + + + ORDINAL_ID + 0 + + + FAPI_NAME + NA + + + I2C_MUX_INFO + + i2cMasterPathphysical:sys-0/node-0/proc-0 + port4 + devAddr0xA0 + engine2 + + + diff --git a/src/usr/targeting/common/xmltohb/target_types.xml b/src/usr/targeting/common/xmltohb/target_types.xml index 16a7fc60d..f0640050f 100644 --- a/src/usr/targeting/common/xmltohb/target_types.xml +++ b/src/usr/targeting/common/xmltohb/target_types.xml @@ -877,6 +877,22 @@ + + i2c_mux_pca9847 + chip + + I2C_MUX_INFO + + + MODEL + PCA9847 + + + TYPE + I2C_MUX + + + lcard-dimm card @@ -2217,7 +2233,6 @@ HWAS_STATE_CHANGED_SUBSCRIPTION_MASK - 0x00000001 diff --git a/src/usr/targeting/common/xmltohb/xmltohb.pl b/src/usr/targeting/common/xmltohb/xmltohb.pl index eef142c9d..60fe126d3 100755 --- a/src/usr/targeting/common/xmltohb/xmltohb.pl +++ b/src/usr/targeting/common/xmltohb/xmltohb.pl @@ -4985,37 +4985,177 @@ sub getAttributeDefault { return $default; } +################################################################################ +# Merge the fields of two complex attributes +################################################################################ + +# This function will merge the fields of two complex attributes. +# +# The field's value from $newAttrFields will be merged into $currentAttrFields. +# $currentAttrFields must have, at a minimum, all the fields that are in +# $newAttrFields. If not then this function will halt execution with an error +# message. Fields that are in $currentAttrFields that have no associated value +# within $newAttrFields will be left as is. +# +# param [in] - $newAttrFields - These are the new fields with new values that +# are to be merged. +# +# param [in] - $currentAttrFields - These are the current fields which, at a +# minimum, include ALL the fields from $newAttrFields. +# There may be more. +# +# return - The two fields successfully merged +# + +sub mergeComplexAttributeFields { + my($newAttrFields, $currentAttrFields) = @_; + + # Make a deep copy of the current fields, don't want to modify + # $currentAttrFields - leave as is. This copy will contain the merger of + # the two fields. + my $mergedFields = dclone $currentAttrFields; + + # Iterate over the fields of $newField and look for their corresponding id + # in $currentAttrFields. All the fields in $newField should exist in + # $currentAttrFields, if not, then there is a problem + foreach my $newField (@{$newAttrFields->{default}->{field}}) + { + my $foundField = 0; + + # Iterate over $mergedFields (really $currentAttrFields) looking + # for the $newField of $newAttrFields + foreach my $currentField (@{$mergedFields->{default}->{field}}) + { + # Found the field in question + if ($currentField->{id} eq $newField->{id}) + { + # Merge in the new value from $newField + $currentField->{value} = $newField->{value}; + $foundField = 1; + last; + } + } # end foreach my $currentField ... + + # A field was not found ... halt execution + if ($foundField == 0) + { + croak("Field $newField is not supported.") + } + } # end foreach my $newField ... + + return $mergedFields; +} + ################################################################################ # Get target attributes ################################################################################ +# This function will recursively work from the most derived target to the base +# target. This function does not work on target instances, only the target +# types themselves. $type is the current target being worked on. +# +# The default values for the attributes associated with the current target +# are gathered and consolidated in the attribute hash ($attrhasha). If there is +# no default value assocaited with that attribute then the attribute in the hash +# does not get updated - don't want to wipe out the current data with no data. +# +# BUT if the current target is the base target type (or the most derived target +# type) and there is no default value for the attribute, the attribute is still +# added to the attribute hash with defaults taken from the attribute definition +# itself as found in the attrubutes_types.xml. +# +# If the attribute is a simple type and it has a default value associated with +# it, then the attribute hash is simply updated with the new default value. +# +# If the attribute is a complex type and it has default values, the fields of +# the attribute will be merged with the same attribute in the hash, with the new +# attribute's fields taking precedence and any undefined fields keeping thier +# current value. Again do not want to wipe out the current fields with no data. +# +# param [in] - $type - The target type (ie 'base', 'unit', 'unit-phb-power9', +# etc) currently being processed +# param [in] - $attributes - This has all data associated with attributes, +# target types, target instances and other data aggregates. +# param [in/out] - $attrhasha - An aggregate list of the attributes as each +# attribute is gathered from the target type and maintained +# in this list. +# + sub getTargetAttributes { my($type,$attributes,$attrhasha) = @_; foreach my $targetType (@{$attributes->{targetType}}) { - if($targetType->{id} eq $type) + if ($targetType->{id} eq $type) { - if(exists $targetType->{parent}) + if (exists $targetType->{parent}) { getTargetAttributes($targetType->{parent}, - $attributes,$attrhasha); + $attributes,$attrhasha); } + # Iterate thru all of this target's attribute and + # copy them over to aggregate attributes if necessary foreach my $attr (@{$targetType->{attribute}}) { - $attrhasha->{ $attr->{id} } = $attr; + # Flag to indicate that a complex type has been found + my $isComplex = 0; - if(!exists $attrhasha->{ $attr->{id}}->{default}) + # Determine if attribute ($attr) is a complex type. + # Complex types are handled differently than simple types. + # This is SO inefficient, I know no other way to determine this + foreach my $attribute (@{$attributes->{attribute}}) { - my $default = getAttributeDefault($attr->{id},$attributes); - $attrhasha->{ $attr->{id}}->{default} = $default; + if ( ($attribute->{id} eq $attr->{id}) && + (exists $attribute->{complexType}) ) + { + $isComplex = 1; + last; + } } - } - last; - } - } + # If the aggregate of attributes ($attrhasha) does NOT currently + # contain the attribute ($attr) then set the base's attribute + # to the aggregate list ($attrhasha), regardless if attribute + # ($attr) is complex or not. This will give a base line to + # work with. + if (!exists $attrhasha->{ $attr->{id}}) + { + my $default = getAttributeDefault($attr->{id},$attributes); + $attrhasha->{ $attr->{id}}->{default} = $default; + + # Add the 'id' value to the attribute + $attrhasha->{ $attr->{id}}->{id} = $attr->{id}; + } + + # If the attribute ($attr) has no default, then there is + # nothing to do. Move onto the next attribute. + if (!exists $attr->{default}) + { + next; + } + + # The simple type attribute ($attr) has a default value, + # replace current attribute in aggregate list ($attrhasha) + # with this one ($attr) + if ($isComplex == 0) + { + $attrhasha->{ $attr->{id} } = $attr; + } + else + # This is a complex attribute. Need to merge fields of + # current attribute, within the aggregate list ($attrhasha), + # with this new attribute's fields ($attr). + { + my $mergedFields = mergeComplexAttributeFields($attr, + $attrhasha->{ $attr->{id}}); + $attrhasha->{ $attr->{id}}->{default} = + $mergedFields->{default}; + } # end if ($isComplex == 0) ... else ... + } # end foreach my $attr (@{$targetType->{attribute}}) + last; + } # end if($targetType->{id} eq $type) + } # end foreach my $targetType (@{$attributes->{targetType}}) } ################################################################################ @@ -6221,10 +6361,54 @@ sub generateTargetingImage { # attribute has already been defined foreach my $targetInstanceAttribute (@{$targetInstance->{attribute}}) { - # if the default tag is missing from an attribute then verify that + # If the attribute($targetInstanceAttribute->{id}) is defined for + # the hash ($attrhash) AND the attribute($targetInstanceAttribute) + # has default data then update the hash. There is no point in + # updating the hash if the attribute has nothing to update with and + # could possibly wipe out a valid default value currently in + # the hash. + if ( (exists $attrhash{$targetInstanceAttribute->{id}}) && + (exists $targetInstanceAttribute->{default}) ) + { + # Determine if the attribute is a complex attribute by probing + # the default. If the default is a HASH then this indicates + # a complex type. + if (ref ($targetInstanceAttribute->{default}) eq "HASH") + { + # Grab a copy of the attribute data from the hash + my $attrData = $attrhash{ $targetInstanceAttribute->{id} }; + + # Merge the two data types into one consolidated data with + # the attribute's field defaults replacing the hash's + # attribute field data. Leaving any undefined attribute's + # field as is (keeping the hash's field data in this case). + my $defaultFields = mergeComplexAttributeFields( + $targetInstanceAttribute, $attrData); + + # Update the hash with the merged data + $attrhash{$targetInstanceAttribute->{id}} = $defaultFields; + } + else + # This is a simple type, just set the data + { + $attrhash{ $targetInstanceAttribute->{id} } = + $targetInstanceAttribute; + } + } + # If the attribute is not defined in the hash, then + # throw out an error + elsif ( !exists $attrhash{ $targetInstanceAttribute->{id} } ) + { + croak("Target instance \"$targetInstance->{id}\" of type \" " + . "$targetInstance->{type} \" cannot override attribute " + . "\"$targetInstanceAttribute->{id}\" unless the attribute " + . "has already been defined in the target type " + . "inheritance chain."); + } + # If the default tag is missing from an attribute then verify that # it is not required to be assigned a default value by the system # owner. - if(!exists $targetInstanceAttribute->{default}) + else { foreach my $attribute_type (@{$allAttributes->{attribute}}) { @@ -6233,29 +6417,17 @@ sub generateTargetingImage { if (exists $attribute_type->{mrwRequired}) { croak("Error in Target instance " - . "\"$targetInstance->{id}\": " - . "Attribute \"$attribute_type->{id}\" with tag " - . "\"\" is required to have an " - . "instance level override from either the MRW " - . "or MRW processing tools."); + . "\"$targetInstance->{id}\": " + . "Attribute \"$attribute_type->{id}\" with tag " + . "\"\" is required to have an " + . "instance level override from either the MRW " + . "or MRW processing tools."); } last; - } - } - } - - if(exists $attrhash{$targetInstanceAttribute->{id}}) - { - $attrhash{ $targetInstanceAttribute->{id} } = $targetInstanceAttribute; - } - else - { - croak("Target instance \"$targetInstance->{id}\" of type \" $targetInstance->{type} \" cannot " - . "override attribute \"$targetInstanceAttribute->{id}\" unless " - . "the attribute has already been defined in the target " - . "type inheritance chain."); - } - } + }# end if ($attribute_type->{id} ... + } # end foreach my $attribute_type ... + } # end else + } # end foreach my $targetInstanceAttribute ... my $huidValue = $attrhash{HUID}->{default}; -- cgit v1.2.1