Merge pull request #770 from pragupta/witherspoon_12_7

Fixes to get witherspoon xml working with latest hb
diff --git a/openpower/package/hostboot/p9Patches/hostboot-0003-processMrw-fixes-to-work-with-latest-witherspoon.xml.patch b/openpower/package/hostboot/p9Patches/hostboot-0003-processMrw-fixes-to-work-with-latest-witherspoon.xml.patch
new file mode 100644
index 0000000..ee27fc8
--- /dev/null
+++ b/openpower/package/hostboot/p9Patches/hostboot-0003-processMrw-fixes-to-work-with-latest-witherspoon.xml.patch
@@ -0,0 +1,377 @@
+From 06f2d36f5e7b7f48d85f93da974816d5b25dfaf1 Mon Sep 17 00:00:00 2001
+From: Prachi Gupta <pragupta@us.ibm.com>
+Date: Tue, 29 Nov 2016 09:46:43 -0600
+Subject: [PATCH 1/4] processMrw: fixes to work with latest witherspoon.xml
+
+- Fix logic to find lpc bus under the bmc target
+- Updated I2C_BUS_SPEED_ARRAY to be 4x4
+- Fixed XBUS HUID
+- Update all BAR attributes
+
+Change-Id: I82dcf21e28f77bcd1fb2391a5bd40d8ce1a6b172
+---
+ src/usr/targeting/common/Targets.pm                | 81 +++++++++++++++++++--
+ src/usr/targeting/common/processMrw.pl             | 83 ++++++++++++----------
+ .../targeting/common/xmltohb/attribute_types.xml   |  2 +-
+ .../targeting/common/xmltohb/target_types_hb.xml   |  4 +-
+ 4 files changed, 123 insertions(+), 47 deletions(-)
+
+diff --git a/src/usr/targeting/common/Targets.pm b/src/usr/targeting/common/Targets.pm
+index fc18675..42780dd 100644
+--- a/src/usr/targeting/common/Targets.pm
++++ b/src/usr/targeting/common/Targets.pm
+@@ -123,7 +123,8 @@ sub loadXML
+     print "Loading MRW XML: $filename\n";
+     $self->{xml} =
+       XMLin($filename,forcearray => [ 'child_id', 'hidden_child_id', 'bus',
+-                                      'property', 'field', 'attribute' ]);
++                                      'property', 'field', 'attribute',
++                                      'enumerator' ]);
+ 
+     if (defined($self->{xml}->{'enumerationTypes'}))
+     {
+@@ -462,7 +463,6 @@ sub buildHierarchy
+     {
+         $baseptr = $self->{xml}->{'targetInstances'}->{'targetInstance'};
+     }
+-
+     if ($target eq "")
+     {
+         ## find system target
+@@ -816,7 +816,11 @@ sub setCommonAttrForChiplet
+ 
+     my $fapi_name       = getFapiName($tgt_type, $node, $proc, $pos);
+ 
+-    $self->{huid_idx}->{$tgt_type} = $pos;
++    if ($tgt_type ne "XBUS")
++    {
++       $self->{huid_idx}->{$tgt_type} = $pos;
++    }
++
+     $self->setHuid($target, $sys, $node);
+     $self->setAttribute($target, "FAPI_NAME",       $fapi_name);
+     $self->setAttribute($target, "PHYS_PATH",       $physical_path);
+@@ -1332,16 +1336,16 @@ sub findConnections
+     my $target   = shift;
+     my $bus_type = shift;
+     my $end_type = shift;
++
+     my %connections;
+     my $num=0;
+     my $target_children = $self->getTargetChildren($target);
+-
+     if ($target_children eq "")
+     {
+         return "";
+     }
+ 
+-    foreach my $child (@{ $self->getTargetChildren($target) })
++    foreach my $child ($self->getAllTargetChildren($target))
+     {
+         my $child_bus_type = $self->getBusType($child);
+         if ($child_bus_type eq $bus_type)
+@@ -1353,7 +1357,6 @@ sub findConnections
+                 my $type        = $self->getMrwType($dest_parent);
+                 my $dest_type   = $self->getType($dest_parent);
+                 my $dest_class  = $self->getAttribute($dest_parent,"CLASS");
+-
+                 if ($type eq "NA")
+                 {
+                     $type = $dest_type;
+@@ -1361,6 +1364,29 @@ sub findConnections
+                 if ($type eq "NA") {
+                     $type = $dest_class;
+                 }
++
++                if ($end_type ne "") {
++                    #Look for an end_type match on any ancestor, as
++                    #connections may have a destination unit with a hierarchy
++                    #like unit->pingroup->muxgroup->chip where the chip has
++                    #the interesting type.
++                    while ($type ne $end_type) {
++
++                        $dest_parent = $self->getTargetParent($dest_parent);
++                        if ($dest_parent eq "") {
++                            last;
++                        }
++
++                        $type = $self->getMrwType($dest_parent);
++                        if ($type eq "NA") {
++                            $type = $self->getType($dest_parent);
++                        }
++                        if ($type eq "NA") {
++                            $type = $self->getAttribute($dest_parent, "CLASS");
++                        }
++                    }
++                }
++
+                 if ($type eq $end_type || $end_type eq "")
+                 {
+                     $connections{CONN}[$num]{SOURCE}=$child;
+@@ -1554,6 +1580,22 @@ sub renameAttribute
+     return 0;
+ }
+ 
++## remove an attribute from a target
++sub removeAttribute
++{
++    my $self = shift;
++    my $target = shift;
++    my $attribute = shift;
++
++    my $target_ptr = $self->{data}->{TARGETS}->{$target};
++    if (!defined($target_ptr->{ATTRIBUTES}->{$attribute}))
++    {
++        return 1;
++    }
++    delete($target_ptr->{ATTRIBUTES}->{$attribute});
++    $self->log($target, "Removing attribute: $attribute");
++}
++
+ ## copy an attribute between targets
+ sub copyAttribute
+ {
+@@ -1589,7 +1631,6 @@ sub setAttributeField
+     my $value     = shift;
+     $self->{data}->{TARGETS}->{$target}->{ATTRIBUTES}->{$attribute}->{default}
+       ->{field}->{$field}->{value} = $value;
+-
+     $self->log($target, "Setting Attribute: $attribute ($field) =$value");
+ }
+ ## returns complex attribute value
+@@ -1652,6 +1693,27 @@ sub getTargetChildren
+     return $target_ptr->{CHILDREN};
+ }
+ 
++## returns an array of all child (including grandchildren) target names
++sub getAllTargetChildren
++{
++    my $self   = shift;
++    my $target = shift;
++    my @children;
++
++    my $targets = $self->getTargetChildren($target);
++    if ($targets ne "")
++    {
++        for my $child (@$targets)
++        {
++            push @children, $child;
++            my @more = $self->getAllTargetChildren($child);
++            push @children, @more;
++        }
++    }
++
++    return @children;
++}
++
+ sub getEnumValue
+ {
+     my $self     = shift;
+@@ -1964,6 +2026,11 @@ C<INDEX>.
+ Returns an array of target strings representing all the children of target
+ C<TARGET_STRING>.
+ 
++=item getAllTargetChildren(C<TARGET_STRING>)
++
++Returns an array of target strings representing all the children of target
++C<TARGET_STRING>, including grandchildren and below as well.
++
+ =item getEnumValue(C<ENUM_TYPE>,C<ENUM_NAME>)
+ 
+ Returns the enum value of type C<ENUM_TYPE> and name C<ENUM_NAME>.  The
+diff --git a/src/usr/targeting/common/processMrw.pl b/src/usr/targeting/common/processMrw.pl
+index f898500..312582d 100644
+--- a/src/usr/targeting/common/processMrw.pl
++++ b/src/usr/targeting/common/processMrw.pl
+@@ -112,7 +112,7 @@ foreach my $target (sort keys %{ $targetObj->getAllTargets() })
+         processApss($targetObj, $target);
+     }
+ 
+-    processIpmiSensors($targetObj,$target);
++    #processIpmiSensors($targetObj,$target);
+ }
+ 
+ ## check topology
+@@ -427,16 +427,6 @@ sub processProcessor
+        $targetObj->getTargetParent($target);
+     $targetObj->copyAttribute($module_target,$target,"LOCATION_CODE");
+ 
+-    ## Copy all attributes from module
+-    foreach my $attr (sort (keys
+-           %{ $targetObj->getTarget($module_target)->{TARGET}->{attribute} }))
+-    {
+-        if (($attr ne "TYPE") && ($attr ne "PHYS_PATH"))
+-        {
+-            $targetObj->copyAttribute($module_target,$target,$attr);
+-        }
+-    }
+-
+     ## Copy PCIE attributes from socket
+     ## Copy Position attribute from socket
+     foreach my $attr (sort (keys
+@@ -453,7 +443,7 @@ sub processProcessor
+     }
+ 
+     $targetObj->log($target,"Finding master proc");
+-    my $lpcs=$targetObj->findConnections($target,"LPC","FSP");
++    my $lpcs=$targetObj->findConnections($target,"LPC","BMC");
+     if ($lpcs ne "")
+     {
+        $targetObj->log ($target, "Setting master proc to $target");
+@@ -522,9 +512,9 @@ sub processProcessor
+     {
+         $targetObj->setAttributeField($target, "FSI_OPTION_FLAGS", "reserved",
+             "0");
+-        $targetObj->setAttribute($target, "FSI_MASTER_CHIP",    "physical:sys");
++        $targetObj->setAttribute($target, "FSI_MASTER_CHIP",    "physical:sys-0");
+         $targetObj->setAttribute($target, "FSI_MASTER_PORT",    "0xFF");
+-        $targetObj->setAttribute($target, "ALTFSI_MASTER_CHIP", "physical:sys");
++        $targetObj->setAttribute($target, "ALTFSI_MASTER_CHIP", "physical:sys-0");
+         $targetObj->setAttribute($target, "ALTFSI_MASTER_PORT", "0xFF");
+         $targetObj->setAttribute($target, "FSI_MASTER_TYPE",    "NO_MASTER");
+         $targetObj->setAttribute($target, "FSI_SLAVE_CASCADE",  "0");
+@@ -534,6 +524,7 @@ sub processProcessor
+     {
+         $targetObj->setAttribute($target, "PROC_MASTER_TYPE",
+             "NOT_MASTER");
++        $targetObj->setAttribute($target, "ALTFSI_MASTER_CHIP", "physical:sys-0");
+     }
+     ## Update bus speeds
+     processI2cSpeeds($targetObj,$target);
+@@ -562,15 +553,19 @@ sub processI2cSpeeds
+     $bus_speeds[0][0] = $bus_speeds2[0];
+     $bus_speeds[0][1] = $bus_speeds2[1];
+     $bus_speeds[0][2] = $bus_speeds2[2];
+-    $bus_speeds[1][0] = $bus_speeds2[3];
+-    $bus_speeds[1][1] = $bus_speeds2[4];
+-    $bus_speeds[1][2] = $bus_speeds2[5];
+-    $bus_speeds[2][0] = $bus_speeds2[6];
+-    $bus_speeds[2][1] = $bus_speeds2[7];
+-    $bus_speeds[2][2] = $bus_speeds2[8];
+-    $bus_speeds[3][0] = $bus_speeds2[9];
+-    $bus_speeds[3][1] = $bus_speeds2[10];
+-    $bus_speeds[3][2] = $bus_speeds2[11];
++    $bus_speeds[0][3] = $bus_speeds2[3];
++    $bus_speeds[1][0] = $bus_speeds2[4];
++    $bus_speeds[1][1] = $bus_speeds2[5];
++    $bus_speeds[1][2] = $bus_speeds2[6];
++    $bus_speeds[1][3] = $bus_speeds2[7];
++    $bus_speeds[2][0] = $bus_speeds2[8];
++    $bus_speeds[2][1] = $bus_speeds2[9];
++    $bus_speeds[2][2] = $bus_speeds2[10];
++    $bus_speeds[2][3] = $bus_speeds2[11];
++    $bus_speeds[3][0] = $bus_speeds2[12];
++    $bus_speeds[3][1] = $bus_speeds2[13];
++    $bus_speeds[3][2] = $bus_speeds2[14];
++    $bus_speeds[3][3] = $bus_speeds2[15];
+ 
+     my $i2cs=$targetObj->findConnections($target,"I2C","");
+     if ($i2cs ne "") {
+@@ -581,13 +576,11 @@ sub processI2cSpeeds
+             my $bus_speed=$targetObj->getBusAttribute(
+                   $i2c->{SOURCE},$i2c->{BUS_NUM},"I2C_SPEED");
+ 
+-            #@todo RTC:164224 > currently the bus_speed fields are empty in the xml
+-=begin
+             if ($bus_speed eq "" || $bus_speed==0) {
+                 print "ERROR: I2C bus speed not defined for $i2c->{SOURCE}\n";
+                 $targetObj->myExit(3);
+             }
+-=cut
++
+             ## choose lowest bus speed
+             if ($bus_speeds[$engine][$port] eq "" ||
+                   $bus_speeds[$engine][$port]==0  ||
+@@ -599,15 +592,19 @@ sub processI2cSpeeds
+     $bus_speed_attr = $bus_speeds[0][0].",".
+                       $bus_speeds[0][1].",".
+                       $bus_speeds[0][2].",".
++                      $bus_speeds[0][3].",".
+                       $bus_speeds[1][0].",".
+                       $bus_speeds[1][1].",".
+                       $bus_speeds[1][2].",".
++                      $bus_speeds[1][3].",".
+                       $bus_speeds[2][0].",".
+                       $bus_speeds[2][1].",".
+                       $bus_speeds[2][2].",".
++                      $bus_speeds[2][3].",".
+                       $bus_speeds[3][0].",".
+                       $bus_speeds[3][1].",".
+-                      $bus_speeds[3][2];
++                      $bus_speeds[3][2].",".
++                      $bus_speeds[3][3];
+ 
+     $targetObj->setAttribute($target,"I2C_BUS_SPEED_ARRAY",$bus_speed_attr);
+ }
+@@ -626,16 +623,28 @@ sub setupBars
+     my $proc   = $targetObj->getAttribute($target, "FABRIC_CHIP_ID");
+     $targetObj->{TOPOLOGY}->{$group}->{$proc}++;
+ 
+-    my @bars=("FSP_BASE_ADDR","PSI_BRIDGE_BASE_ADDR",
+-              "INTP_BASE_ADDR","PHB_MMIO_ADDRS_64","PHB_MMIO_ADDRS_32",
+-              "PHB_XIVE_ESB_ADDRS","PHB_REG_ADDRS","XIVE_ROUTING_ESB_ADDR",
+-              "XIVE_ROUTING_END_ADDR","XIVE_PRESENTATION_NVT_ADDR",
+-              "VAS_HYPERVISOR_WINDOW_CONTEXT_ADDR",
+-              "VAS_USER_WINDOW_CONTEXT_ADDR","LPC_BUS_ADDR",
+-              "NVIDIA_NPU_PRIVILEGED_ADDR","NVIDIA_NPU_USER_REG_ADDR",
+-              "NVIDIA_PHY0_REG_ADDR","NVIDIA_PHY1_REG_ADDR",
+-              "XIVE_CONTROLLER_BAR_ADDR","XIVE_PRESENTATION_BAR_ADDR",
+-              "NX_RNG_ADDR");
++    my @bars=(  "FSP_BASE_ADDR", #
++                "PSI_BRIDGE_BASE_ADDR", #
++                "INTP_BASE_ADDR",
++                "PHB_MMIO_ADDRS_64", #
++                "PHB_MMIO_ADDRS_32", #
++                "PHB_XIVE_ESB_ADDRS", #
++                "PHB_REG_ADDRS", #
++                "XIVE_ROUTING_ESB_ADDR", #
++                "XIVE_ROUTING_END_ADDR", #
++                "XIVE_PRESENTATION_NVT_ADDR", #
++                "VAS_HYPERVISOR_WINDOW_CONTEXT_ADDR", #
++                "VAS_USER_WINDOW_CONTEXT_ADDR", #
++                "LPC_BUS_ADDR", #
++                "NVIDIA_NPU_PRIVILEGED_ADDR", #
++                "NVIDIA_NPU_USER_REG_ADDR", #
++                "NVIDIA_PHY0_REG_ADDR", #
++                "NVIDIA_PHY1_REG_ADDR", #
++                "PSI_HB_ESB_ADDR", #
++                "XIVE_CONTROLLER_BAR_ADDR", #
++                "XIVE_PRESENTATION_BAR_ADDR", #
++                "XSCOM_BASE_ADDRESS", #
++                "NX_RNG_ADDR"); #
+ 
+     # Attribute only valid in naples-based systems
+     if (!$targetObj->isBadAttribute($target,"NPU_MMIO_BAR_BASE_ADDR") ) {
+diff --git a/src/usr/targeting/common/xmltohb/attribute_types.xml b/src/usr/targeting/common/xmltohb/attribute_types.xml
+index 9fce73d..70342c5 100644
+--- a/src/usr/targeting/common/xmltohb/attribute_types.xml
++++ b/src/usr/targeting/common/xmltohb/attribute_types.xml
+@@ -15548,7 +15548,7 @@ Measured in GB</description>
+ <attribute>
+     <id>REDUNDANT_CLOCKS</id>
+     <description>
+-        1 = System has redundant clock oscillators
++        1 = System has redundant clock oscillators
+         0 = System does not have redundant clock oscillators
+         From the Machine Readable Workbook
+     </description>
+diff --git a/src/usr/targeting/common/xmltohb/target_types_hb.xml b/src/usr/targeting/common/xmltohb/target_types_hb.xml
+index aa941be..4e2447d 100755
+--- a/src/usr/targeting/common/xmltohb/target_types_hb.xml
++++ b/src/usr/targeting/common/xmltohb/target_types_hb.xml
+@@ -258,10 +258,10 @@
+     <attribute><id>VPD_SWITCHES</id></attribute>
+ </targetTypeExtension>
+ 
+-<targetType>
++<targetTypeExtension>
+     <id>unit-xbus-nimbus</id>
+     <attribute><id>HB_TARGET_SCOMABLE</id></attribute>
+-</targetType>
++</targetTypeExtension>
+ 
+ <targetTypeExtension>
+     <id>occ</id>
+-- 
+1.8.2.2
+
diff --git a/openpower/package/hostboot/p9Patches/hostboot-0005-filter_out_unwanted_attributes-initial-check-in.patch b/openpower/package/hostboot/p9Patches/hostboot-0005-filter_out_unwanted_attributes-initial-check-in.patch
new file mode 100644
index 0000000..21153e8
--- /dev/null
+++ b/openpower/package/hostboot/p9Patches/hostboot-0005-filter_out_unwanted_attributes-initial-check-in.patch
@@ -0,0 +1,168 @@
+From 0e0e28e214d7277698a781d271a846b81ebbd834 Mon Sep 17 00:00:00 2001
+From: Prachi Gupta <pragupta@us.ibm.com>
+Date: Tue, 6 Dec 2016 17:09:35 -0600
+Subject: [PATCH 2/4] filter_out_unwanted_attributes:initial check-in
+
+script to remove any unwanted attributes from mrw xml
+based on target_types
+
+Change-Id: Ic8965134a122a2561383481128036245ce158c02
+---
+ .../common/filter_out_unwanted_attributes.pl       | 145 +++++++++++++++++++++
+ 1 file changed, 145 insertions(+)
+ create mode 100755 src/usr/targeting/common/filter_out_unwanted_attributes.pl
+
+diff --git a/src/usr/targeting/common/filter_out_unwanted_attributes.pl b/src/usr/targeting/common/filter_out_unwanted_attributes.pl
+new file mode 100755
+index 0000000..8f2a69f
+--- /dev/null
++++ b/src/usr/targeting/common/filter_out_unwanted_attributes.pl
+@@ -0,0 +1,145 @@
++#! /usr/bin/perl
++# IBM_PROLOG_BEGIN_TAG
++# This is an automatically generated prolog.
++#
++# $Source: src/usr/targeting/common/filter_out_unwanted_attributes.pl $
++#
++# OpenPOWER HostBoot Project
++#
++# Contributors Listed Below - COPYRIGHT 2016
++#
++#
++# Licensed under the Apache License, Version 2.0 (the "License");
++# you may not use this file except in compliance with the License.
++# You may obtain a copy of the License at
++#
++#     http://www.apache.org/licenses/LICENSE-2.0
++#
++# Unless required by applicable law or agreed to in writing, software
++# distributed under the License is distributed on an "AS IS" BASIS,
++# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
++# implied. See the License for the specific language governing
++# permissions and limitations under the License.
++#
++# IBM_PROLOG_END_TAG
++
++use strict;
++use XML::Simple;
++use XML::LibXML;
++use XML::Parser;
++use Data::Dumper;
++use feature "state";
++use Getopt::Long qw(GetOptions);
++
++my @tgt_files;
++my $mrw_file;
++
++GetOptions(
++    "tgt-xml=s"    => \@tgt_files,
++    "mrw-xml=s"    => \$mrw_file,
++);
++
++if ((scalar @tgt_files eq 0) || ($mrw_file eq ""))
++{
++    print "ERROR: tgt-xml or mrw-xml is not specified\n";
++    print "tgt-xml: \n";
++    print Dumper @tgt_files;
++    print "mrw-xml: $mrw_file\n";
++    exit (-1);
++}
++
++$XML::Simple::PREFERRED_PARSER = 'XML::Parser';
++
++#Load all the attr-files
++my @tgt_xmls;
++foreach my $i (0 .. $#tgt_files)
++{
++    my $tgt_file  = $tgt_files[$i];
++    print "Loading TGT XML: $tgt_file in $i\n";
++
++    $tgt_xmls[$i] =
++           XMLin($tgt_file,
++                forcearray => ['attribute', 'targetType', 'field']);
++}
++
++#Load MRW XML
++$XML::LibXML::skipXMLDeclaration = 1;
++print "Loading MRW XML: $mrw_file\n";
++my $parser = XML::LibXML->new();
++my $mrw_parsed = $parser->parse_file($mrw_file);
++
++foreach my $tgt
++    ($mrw_parsed->findnodes('/attributes/targetInstance'))
++{
++    my $tgt_type = $tgt->findnodes('./type');
++    foreach my $attr ($tgt->findnodes('./attribute'))
++    {
++        my $attr_id = $attr->findnodes('./id');
++        my $found = findAttribute($tgt_type, $attr_id);
++        if ($found eq 0)
++        {
++            print "Target: $tgt_type Attr: $attr_id\n";
++            $tgt->removeChild($attr);
++        }
++    }
++}
++
++
++sub findAttribute
++{
++    my $tgt  = shift;
++    my $attr = shift;
++    foreach my $i (0 .. $#tgt_xmls)
++    {
++        my $tgt_xml = $tgt_xmls[$i];
++        if (defined $tgt_xml->{targetType}{$tgt}{attribute}{$attr})
++        {
++            return 1;
++        }
++        else
++        {
++            my %tgt_hash = %$tgt_xml;
++            if (lookAtParentAttributes (\%tgt_hash, $tgt, $attr) eq 1)
++            {
++                return 1;
++            }
++        }
++    }
++    return 0;
++}
++
++sub lookAtParentAttributes
++{
++    my ($tgt_xml, $tgt, $attr) = @_;
++
++    my $parent = $tgt_xml->{targetType}{$tgt}{parent};
++
++    if ($parent eq "")
++    {
++        return 0;
++    }
++    elsif ($parent eq "base")
++    {
++         return (defined  $tgt_xml->{targetType}{$parent}{attribute}{$attr}) ?
++                        1 : 0;
++    }
++    else
++    {
++        if (defined  $tgt_xml->{targetType}{$parent}{attribute}{$attr})
++        {
++            return 1;
++        }
++        else
++        {
++            my %tgt_hash = %$tgt_xml;
++            return lookAtParentAttributes(\%tgt_hash, $parent, $attr);
++        }
++    }
++}
++#OUTPUT
++my $xml_fh;
++my $filename = $mrw_file . ".updated";
++print "Creating XML: $filename\n";
++open($xml_fh, ">$filename") || die "Unable to create: $filename";
++print {$xml_fh} $mrw_parsed->toString();
++close($xml_fh);
+-- 
+1.8.2.2
+
diff --git a/openpower/package/hostboot/p9Patches/hostboot-0007-Add-filtering-script-to-openpower-distribution.patch b/openpower/package/hostboot/p9Patches/hostboot-0007-Add-filtering-script-to-openpower-distribution.patch
new file mode 100644
index 0000000..682caeb
--- /dev/null
+++ b/openpower/package/hostboot/p9Patches/hostboot-0007-Add-filtering-script-to-openpower-distribution.patch
@@ -0,0 +1,25 @@
+From fbcbbde51e42bf8ed34999685b9db3a1ec16762c Mon Sep 17 00:00:00 2001
+From: Prachi Gupta <pragupta@us.ibm.com>
+Date: Tue, 6 Dec 2016 17:38:31 -0600
+Subject: [PATCH 3/4] Add filtering script to openpower distribution
+
+Change-Id: I3cab96608b05641c0ce10d1c6b8b3011ead9f1fa
+---
+ src/build/mkrules/dist.targets.mk | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/build/mkrules/dist.targets.mk b/src/build/mkrules/dist.targets.mk
+index 2ec1ee6..5bae3dd 100644
+--- a/src/build/mkrules/dist.targets.mk
++++ b/src/build/mkrules/dist.targets.mk
+@@ -79,6 +79,7 @@ COPY_FILES = \
+     src/build/buildpnor/PnorUtils.pm:openpower \
+     src/usr/targeting/common/processMrw.pl:openpower \
+     src/usr/targeting/common/Targets.pm:openpower \
++    src/usr/targeting/common/filter_out_unwanted_attributes.pl:openpower \
+     src/usr/targeting/common/xmltohb/mergexml.sh:openpower \
+     src/usr/targeting/common/xmltohb/attribute_types.xml:openpower \
+     src/usr/targeting/common/xmltohb/attribute_types_hb.xml:openpower \
+-- 
+1.8.2.2
+
diff --git a/openpower/package/hostboot/p9Patches/hostboot-0008-Add-Hacked-values-for-VPD-attributes.patch b/openpower/package/hostboot/p9Patches/hostboot-0008-Add-Hacked-values-for-VPD-attributes.patch
new file mode 100644
index 0000000..29d2444
--- /dev/null
+++ b/openpower/package/hostboot/p9Patches/hostboot-0008-Add-Hacked-values-for-VPD-attributes.patch
@@ -0,0 +1,122 @@
+From 85b90b1ceae68b9f473a12b652bdaf2c8d78a007 Mon Sep 17 00:00:00 2001
+From: Prachi Gupta <pragupta@us.ibm.com>
+Date: Wed, 7 Dec 2016 10:44:25 -0600
+Subject: [PATCH 4/4] Add Hacked values for VPD attributes
+
+Change-Id: Ida797dba646f0110637521daf27dfeea0f730959
+---
+ src/usr/targeting/common/Targets.pm    | 14 ++++++++
+ src/usr/targeting/common/processMrw.pl | 61 ++++++++++++++++++++++++++++++++++
+ 2 files changed, 75 insertions(+)
+
+diff --git a/src/usr/targeting/common/Targets.pm b/src/usr/targeting/common/Targets.pm
+index 42780dd..25fe0cb 100644
+--- a/src/usr/targeting/common/Targets.pm
++++ b/src/usr/targeting/common/Targets.pm
+@@ -1655,6 +1655,20 @@ sub getAttributeField
+ }
+ 
+ ## returns an attribute from a bus
++sub setBusAttribute
++{
++    my $self       = shift;
++    my $target     = shift;
++    my $busnum     = shift;
++    my $attr       = shift;
++    my $value      = shift;
++    my $target_ptr = $self->getTarget($target);
++    $target_ptr->{CONNECTION}->{BUS}->[$busnum]->{bus_attribute}->{$attr}->{default}
++        = $value;
++    $self->log($target, "Setting Attribute (BusNum=$busnum): $attr=$value");
++}
++
++## returns an attribute from a bus
+ sub getBusAttribute
+ {
+     my $self       = shift;
+diff --git a/src/usr/targeting/common/processMrw.pl b/src/usr/targeting/common/processMrw.pl
+index 312582d..bfe33a4 100644
+--- a/src/usr/targeting/common/processMrw.pl
++++ b/src/usr/targeting/common/processMrw.pl
+@@ -538,6 +538,7 @@ sub processProcessor
+     $targetObj->setAttributeField($target, "SCOM_SWITCHES", "useXscom", "0");
+ 
+     processMembufVpdAssociation($targetObj,$target);
++    processNodeVpd($targetObj, $target);
+     setupBars($targetObj,$target);
+ }
+ 
+@@ -1110,10 +1111,70 @@ sub processOcc
+     $targetObj->setAttribute($target,"OCC_MASTER_CAPABLE",$master_capable);
+ }
+ 
++#@FIXME: This is just a hack to get the witherspoon xml to compile
++sub processNodeVpd
++{
++    my $targetObj = shift;
++    my $target    = shift; #proc target
++    my $name      = "EEPROM_VPD_PRIMARY_INFO";
++    foreach my $child (@{$targetObj->getTargetChildren($target)})
++    {
++        if ($targetObj->getType($child) eq "MCBIST")
++        {
++            foreach my $mcs (@{$targetObj->getTargetChildren($child)})
++            {
++                if ($targetObj->getType($mcs) eq "MCS")
++                {
++                    my $path            = "physical:sys-0/node-0";
++                    my $port            = 0x02;
++                    my $addr            = 0xE0;
++                    my $engine          = 1;
++                    my $offset          = 0x01;
++                    my $mem             = 0x01;
++                    my $count           = 2;
++                    my $page            = 0x50;
++                    my $cycle           = 0x05;
++                    $targetObj->setAttributeField($mcs, $name, "i2cMasterPath", $path);
++                    $targetObj->setAttributeField($mcs, $name, "port", $port);
++                    $targetObj->setAttributeField($mcs, $name, "devAddr", $addr);
++                    $targetObj->setAttributeField($mcs, $name, "engine", $engine);
++                    $targetObj->setAttributeField($mcs, $name, "byteAddrOffset", $offset);
++                    $targetObj->setAttributeField($mcs, $name, "maxMemorySizeKB", $mem);
++                    $targetObj->setAttributeField($mcs, $name, "chipCount", $count);
++                    $targetObj->setAttributeField($mcs, $name, "writePageSize", $page);
++                    $targetObj->setAttributeField($mcs, $name, "writeCycleTime", $cycle);
++                }
++
++            }
++        }
++    }
++
++}
++
+ sub processMembufVpdAssociation
+ {
+     my $targetObj = shift;
+     my $target    = shift;
++    my $dimms=$targetObj->findConnections($target,"I2C","SPD");
++    if ($dimms ne "") {
++        foreach my $dimm (@{$dimms->{CONN}}) {
++            my $dimm_target = $targetObj->getTargetParent($dimm->{DEST_PARENT});
++
++            #@FIXME: hacked value for now
++            my $addr = $targetObj->setBusAttribute($dimm->{SOURCE},
++                    $dimm->{BUS_NUM}, "I2C_ADDRESS", 0xE0);
++
++            setEepromAttributes($targetObj,
++                       "EEPROM_VPD_PRIMARY_INFO",$dimm_target,
++                       $dimm);
++            my $i2cMasterPath = $targetObj->getAttributeField($dimm_target,
++                "EEPROM_VPD_PRIMARY_INFO", "i2cMasterPath");
++
++            $targetObj->setAttributeField($dimm_target,"TEMP_SENSOR_I2C_CONFIG",
++                "i2cMasterPath", $i2cMasterPath);
++        }
++    }
++
+     my $vpds=$targetObj->findConnections($target,"I2C","VPD");
+     if ($vpds ne "" ) {
+         my $vpd = $vpds->{CONN}->[0];
+-- 
+1.8.2.2
+
diff --git a/openpower/package/witherspoon-xml/witherspoon.mk b/openpower/package/witherspoon-xml/witherspoon.mk
index 79955ea..2975378 100644
--- a/openpower/package/witherspoon-xml/witherspoon.mk
+++ b/openpower/package/witherspoon-xml/witherspoon.mk
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-WITHERSPOON_XML_VERSION ?= 3a89d5efc33377302418c06d654cc3356561c797
+WITHERSPOON_XML_VERSION ?=5cfb191919a40752001e5918fb84dd64a783a00a
 WITHERSPOON_XML_SITE ?= $(call github,open-power,witherspoon-xml,$(WITHERSPOON_XML_VERSION))
 
 WITHERSPOON_XML_LICENSE = Apache-2.0
@@ -35,12 +35,24 @@
         perl -I $(MRW_HB_TOOLS) \
         $(MRW_HB_TOOLS)/processMrw.pl -x $(MRW_SCRATCH)/witherspoon.xml
 
+        chmod +x $(MRW_HB_TOOLS)/filter_out_unwanted_attributes.pl
+
+       $(MRW_HB_TOOLS)/filter_out_unwanted_attributes.pl \
+            --tgt-xml $(MRW_HB_TOOLS)/target_types_merged.xml \
+            --tgt-xml $(MRW_HB_TOOLS)/target_types_hb.xml \
+            --tgt-xml $(MRW_HB_TOOLS)/target_types_oppowervm.xml \
+            --mrw-xml $(MRW_SCRATCH)/WITHERSPOON_hb.mrw.xml
+
+       cp  $(MRW_SCRATCH)/WITHERSPOON_hb.mrw.xml.updated  $(MRW_SCRATCH)/WITHERSPOON_hb.mrw.xml
+
         # merge in any system specific attributes, hostboot attributes
         $(MRW_HB_TOOLS)/mergexml.sh $(MRW_SCRATCH)/$(BR2_WITHERSPOON_SYSTEM_XML_FILENAME) \
             $(MRW_HB_TOOLS)/attribute_types.xml \
             $(MRW_HB_TOOLS)/attribute_types_hb.xml \
+            $(MRW_HB_TOOLS)/attribute_types_oppowervm.xml \
             $(MRW_HB_TOOLS)/target_types_merged.xml \
             $(MRW_HB_TOOLS)/target_types_hb.xml \
+            $(MRW_HB_TOOLS)/target_types_oppowervm.xml \
             $(MRW_SCRATCH)/$(BR2_WITHERSPOON_MRW_XML_FILENAME) > $(MRW_HB_TOOLS)/temporary_hb.hb.xml;
 
         # creating the targeting binary