Merge pull request #128 from open-power/master

Merge v1.1 content back into master-next.
diff --git a/buildroot b/buildroot
index 3120591..f462e06 160000
--- a/buildroot
+++ b/buildroot
@@ -1 +1 @@
-Subproject commit 31205912fed95fa0edf1adc5d89dc78d7a068a29
+Subproject commit f462e06ab10035029f24d494d9936fcb8c6cf49a
diff --git a/openpower/package/hostboot/hostboot-0012-Cap-off-the-TRACFBIN-such-that-nothing-exceeds-64-by.patch b/openpower/package/hostboot/hostboot-0012-Cap-off-the-TRACFBIN-such-that-nothing-exceeds-64-by.patch
index 8b0b4ab..fd60ef3 100644
--- a/openpower/package/hostboot/hostboot-0012-Cap-off-the-TRACFBIN-such-that-nothing-exceeds-64-by.patch
+++ b/openpower/package/hostboot/hostboot-0012-Cap-off-the-TRACFBIN-such-that-nothing-exceeds-64-by.patch
@@ -1,25 +1,30 @@
-From 22c58d6a7d3e6d69294aa16c9b0fa354ae9cf861 Mon Sep 17 00:00:00 2001
+From 7cd4c46c4b6689dcd16f7667076283abf14ef575 Mon Sep 17 00:00:00 2001
 From: Elizabeth Liner <eliner@us.ibm.com>
 Date: Mon, 30 Mar 2015 12:41:45 -0500
-Subject: [PATCH 4/5] Cap off the TRACFBIN such that nothing exceeds 64 bytes
+Subject: [PATCH 08/10] Cap off the TRACFBIN such that nothing exceeds 64 bytes
 
 Change-Id: If8f08d1602b4437aa0e72e6d2e8d99ca615a2c77
-(cherry picked from commit cb2ea9c1b5d1906e0f58eda347367c648c18809a)
+Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/16762
+Tested-by: Jenkins Server
+Reviewed-by: Brian H. Horton <brianh@linux.ibm.com>
+Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
+(cherry picked from commit 56ab0ee178b8277c4cc7e24e8535802821b4cba7)
 ---
- src/include/usr/trace/interface.H | 16 +++++++++++-----
- src/include/usr/trace/trace.H     |  2 ++
- 2 files changed, 13 insertions(+), 5 deletions(-)
+ src/include/usr/trace/interface.H | 17 ++++++++++++-----
+ src/include/usr/trace/trace.H     |  3 +++
+ 2 files changed, 15 insertions(+), 5 deletions(-)
 
 diff --git a/src/include/usr/trace/interface.H b/src/include/usr/trace/interface.H
-index 3ef8575..d02db76 100644
+index 3ef8575..4115ec2 100644
 --- a/src/include/usr/trace/interface.H
 +++ b/src/include/usr/trace/interface.H
-@@ -218,13 +218,19 @@ const uint32_t TRACE_FIELD   = 0;       //Indicates trace is field
+@@ -218,13 +218,20 @@ const uint32_t TRACE_FIELD   = 0;       //Indicates trace is field
  */
  #define TRACFBIN(des,printf_string,address,len) \
      { \
++        /*TODO: RTC 124618 - remove this block once issue is resolved*/ \
 +        uint16_t l_length = len; \
-+        if(len > MAX_WORKING_TRACBIN_SIZE) \
++        if(l_length > MAX_WORKING_TRACBIN_SIZE) \
 +        { \
 +            l_length = MAX_WORKING_TRACBIN_SIZE; \
 +            TRACFCOMP(des,"Shrinking to max size in TRACFBIN"); \
@@ -40,13 +45,14 @@
  
  /**
 diff --git a/src/include/usr/trace/trace.H b/src/include/usr/trace/trace.H
-index fdcce88..e969487 100644
+index fdcce88..bf5421c 100644
 --- a/src/include/usr/trace/trace.H
 +++ b/src/include/usr/trace/trace.H
-@@ -42,6 +42,8 @@ const uint32_t TRACE_DEBUG_OFF   = 0;       //< Set to this when debug trace off
+@@ -42,6 +42,9 @@ const uint32_t TRACE_DEBUG_OFF   = 0;       //< Set to this when debug trace off
  const uint32_t TRAC_COMP_SIZE    = 16;      //< Max component name size
  const uint32_t TRAC_MAX_ARGS     = 9;       //< Max number of arguments in trace
  
++//TODO: RTC 124618 - remove this block once issue is resolved
 +const uint16_t MAX_WORKING_TRACBIN_SIZE = 64; //< Max working tracBin size
 +
  typedef uint32_t trace_hash_val;    //< Hash values are 32 bits.
diff --git a/openpower/package/hostboot/hostboot-0017-Fix-I2C-Reset-to-resolve-I2C-Bus-Arbitration-Lost-Er.patch b/openpower/package/hostboot/hostboot-0017-Fix-I2C-Reset-to-resolve-I2C-Bus-Arbitration-Lost-Er.patch
new file mode 100644
index 0000000..757f701
--- /dev/null
+++ b/openpower/package/hostboot/hostboot-0017-Fix-I2C-Reset-to-resolve-I2C-Bus-Arbitration-Lost-Er.patch
@@ -0,0 +1,306 @@
+From 3f630837040bae961612214307d2903e65af9e5d Mon Sep 17 00:00:00 2001
+From: Mike Baiocchi <baiocchi@us.ibm.com>
+Date: Thu, 2 Apr 2015 13:42:00 -0500
+Subject: [PATCH 05/10] Fix I2C Reset to resolve I2C Bus Arbitration Lost
+ Errors
+
+This commit fixes 2 bugs where the full "Force Reset and Unlock"
+I2C reset procedure used to both avoid and recover from I2C Bus
+Arbitration Lost errors was not being performed correctly on any
+ports but port 0.
+
+Change-Id: Ie967d81917e9b942d5cb516856075ebdb5029487
+CQ: SW297864
+(cherry picked from commit 01ee7107170c867d25af2485b75307e3bfa87339)
+---
+ src/include/usr/i2c/i2creasoncodes.H |   1 +
+ src/usr/i2c/i2c.C                    | 182 ++++++++++++++++++++++++-----------
+ src/usr/i2c/i2c.H                    |   4 +-
+ 3 files changed, 130 insertions(+), 57 deletions(-)
+
+diff --git a/src/include/usr/i2c/i2creasoncodes.H b/src/include/usr/i2c/i2creasoncodes.H
+index a63e8d5..454ef15 100644
+--- a/src/include/usr/i2c/i2creasoncodes.H
++++ b/src/include/usr/i2c/i2creasoncodes.H
+@@ -58,6 +58,7 @@ enum i2cModuleId
+     I2C_SETUP_MASTERS                   = 0x08,
+     I2C_SEND_SLAVE_STOP                 = 0x09,
+     I2C_PROCESS_ACTIVE_MASTERS          = 0x0A,
++    I2C_FORCE_RESET_AND_UNLOCK          = 0x0B,
+ };
+ 
+ 
+diff --git a/src/usr/i2c/i2c.C b/src/usr/i2c/i2c.C
+index bc4bb7b..ee7e5e3 100755
+--- a/src/usr/i2c/i2c.C
++++ b/src/usr/i2c/i2c.C
+@@ -1925,6 +1925,11 @@ errlHndl_t i2cForceResetAndUnlock( TARGETING::Target * i_target,
+ {
+ 
+     errlHndl_t err = NULL;
++    mode_reg_t mode;
++    uint64_t l_speed = I2C_BUS_SPEED_FROM_MRW;
++
++    // I2C Bus Speed Array
++    TARGETING::ATTR_I2C_BUS_SPEED_ARRAY_type speed_array;
+ 
+     TRACDCOMP( g_trac_i2c,
+                ENTER_MRK"i2cForceResetAndUnlock()" );
+@@ -1932,62 +1937,122 @@ errlHndl_t i2cForceResetAndUnlock( TARGETING::Target * i_target,
+     do
+     {
+ 
+-        // enable diagnostic mode
+-        // set bit in mode register
+-        mode_reg_t diagnostic;
+-
+-        diagnostic.diag_mode = 0x1;
+-
+-        err = i2cRegisterOp( DeviceFW::WRITE,
+-                             i_target,
+-                             &diagnostic.value,
+-                             I2C_REG_MODE,
+-                             i_args );
+-
+-        if( err )
++        // Get I2C Bus Speed Array attribute.  It will be used to determine
++        // which engine/port combinations have devices on them
++        if (  !( i_target->tryGetAttr<TARGETING::ATTR_I2C_BUS_SPEED_ARRAY>
++                                          (speed_array) ) )
+         {
+             TRACFCOMP( g_trac_i2c,
+-                       ERR_MRK"I2C Enable Diagnostic mode Failed!!" );
++                       ERR_MRK"i2cForceResetAndUnlock() - Cannot find "
++                       "ATTR_I2C_BUS_SPEED_ARRAY needed for operation");
++            /*@
++             * @errortype
++             * @reasoncode     I2C_ATTRIBUTE_NOT_FOUND
++             * @severity       ERRORLOG_SEV_UNRECOVERABLE
++             * @moduleid       I2C_FORCE_RESET_AND_UNLOCK
++             * @userdata1      Target for the attribute
++             * @userdata2      <UNUSED>
++             * @devdesc        ATTR_I2C_BUS_SPEED_ARRAY not found
++             * @custdesc       I2C configuration data missing
++             */
++            err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
++                                           I2C_FORCE_RESET_AND_UNLOCK,
++                                           I2C_ATTRIBUTE_NOT_FOUND,
++                                           TARGETING::get_huid(i_target),
++                                           0x0,
++                                           true /*Add HB SW Callout*/ );
++
++            err->collectTrace( I2C_COMP_NAME, 256);
++
+             break;
+         }
+ 
++        // Need to send slave stop to all ports with a device on the engine
++        for( uint32_t port = 0; port < P8_MASTER_PORTS; port++ )
++        {
+ 
+-        //toggle clock line
+-        err = i2cToggleClockLine( i_target,
+-                                  i_args );
++            // Only send stop to a port if there are devices on it
++            l_speed = speed_array[i_args.engine][port];
++            if ( l_speed == 0 )
++            {
++                continue;
++            }
+ 
+-        if( err )
+-        {
+-            break;
+-        }
++            TRACUCOMP( g_trac_i2c,
++                       INFO_MRK"i2cForceResetAndUnlock() - Performing op on "
++                       "engine=%d, port=%d",
++                       i_args.engine, port);
+ 
+-        //manually send stop signal
+-        err = i2cSendStopSignal( i_target,
+-                                  i_args );
++            // Clear mode register
++            mode.value = 0x0ull;
+ 
+-        if( err )
+-        {
+-            break;
+-        }
++            // set port in mode register
++            mode.port_num = port;
+ 
+-        //disable diagnostic mode
+-        //set bit in mode register
+-        diagnostic.diag_mode = 0x0;
++            // enable diagnostic mode in mode register
++            mode.diag_mode = 0x1;
+ 
+-        err = i2cRegisterOp( DeviceFW::WRITE,
+-                             i_target,
+-                             &diagnostic.value,
+-                             I2C_REG_MODE,
+-                             i_args );
++            err = i2cRegisterOp( DeviceFW::WRITE,
++                                 i_target,
++                                 &mode.value,
++                                 I2C_REG_MODE,
++                                 i_args );
+ 
++            if( err )
++            {
++                TRACFCOMP( g_trac_i2c,
++                           ERR_MRK"I2C Enable Diagnostic mode Failed!!" );
+ 
+-        if( err )
+-        {
+-            TRACFCOMP( g_trac_i2c,
+-                       ERR_MRK"I2C disable Diagnostic mode Failed!!" );
+-            break;
+-        }
+ 
++                // We still need to reset the other ports on this I2C engine
++                errlCommit( err, I2C_COMP_ID );
++                continue;
++            }
++
++
++            //toggle clock line
++            err = i2cToggleClockLine( i_target,
++                                      i_args );
++
++            if( err )
++            {
++                // We still need to reset the other ports on this I2C engine
++                errlCommit( err, I2C_COMP_ID );
++                continue;
++            }
++
++            //manually send stop signal
++            err = i2cSendStopSignal( i_target,
++                                     i_args );
++
++            if( err )
++            {
++                // We still need to reset the other ports on this I2C engine
++                errlCommit( err, I2C_COMP_ID );
++                continue;
++            }
++
++            // disable diagnostic mode in mode register
++            mode.diag_mode = 0x0;
++
++            err = i2cRegisterOp( DeviceFW::WRITE,
++                                 i_target,
++                                 &mode.value,
++                                 I2C_REG_MODE,
++                                 i_args );
++
++
++            if( err )
++            {
++                TRACFCOMP( g_trac_i2c,
++                           ERR_MRK"I2C disable Diagnostic mode Failed!!" );
++                // We still need to reset the other ports on this I2C engine
++                errlCommit( err, I2C_COMP_ID );
++                continue;
++            }
++
++
++        } // end of port for loop
+ 
+     }while(0);
+ 
+@@ -2036,8 +2101,10 @@ errlHndl_t i2cReset ( TARGETING::Target * i_target,
+ 
+             if( err )
+             {
+-                //error trying to force a reset break
+-                break;
++                // We still want to send the slave stop command since the
++                // initial reset completed above.
++                // So just commit the log here and let the function continue.
++                errlCommit( err, I2C_COMP_ID );
+             }
+         }
+ 
+@@ -2114,13 +2181,6 @@ errlHndl_t i2cSendSlaveStop ( TARGETING::Target * i_target,
+         // Need to send slave stop to all ports with a device on the engine
+         for( uint32_t port = 0; port < P8_MASTER_PORTS; port++ )
+         {
+-            // Only do port 0 for FSI I2C
+-            if ( ( i_args.switches.useFsiI2C == 1 ) &&
+-                 ( port != 0 ) )
+-            {
+-                break;
+-            }
+-
+             // Only send stop to a port if there are devices on it
+             l_speed = speed_array[i_args.engine][port];
+             if ( l_speed == 0 )
+@@ -2139,7 +2199,10 @@ errlHndl_t i2cSendSlaveStop ( TARGETING::Target * i_target,
+                                        i_args );
+             if( err )
+             {
+-                break;
++                // We still need to send the slave stop to the other ports
++                // on this I2C engine
++                errlCommit( err, I2C_COMP_ID );
++                continue;
+             }
+ 
+             mode.bit_rate_div = i_args.bit_rate_divisor;
+@@ -2156,7 +2219,10 @@ errlHndl_t i2cSendSlaveStop ( TARGETING::Target * i_target,
+ 
+             if( err )
+             {
+-                break;
++                // We still need to send the slave stop to the other ports
++                // on this I2C engine
++                errlCommit( err, I2C_COMP_ID );
++                continue;
+             }
+ 
+             cmd.value = 0x0ull;
+@@ -2174,7 +2240,10 @@ errlHndl_t i2cSendSlaveStop ( TARGETING::Target * i_target,
+ 
+             if( err )
+             {
+-                break;
++                // We still need to send the slave stop to the other ports
++                // on this I2C engine
++                errlCommit( err, I2C_COMP_ID );
++                continue;
+             }
+ 
+             // Now wait for cmd Complete
+@@ -2183,7 +2252,10 @@ errlHndl_t i2cSendSlaveStop ( TARGETING::Target * i_target,
+ 
+             if( err )
+             {
+-                break;
++                // We still need to send the slave stop to the other ports
++                // on this I2C engine
++                errlCommit( err, I2C_COMP_ID );
++                continue;
+             }
+ 
+         } // end of port for-loop
+diff --git a/src/usr/i2c/i2c.H b/src/usr/i2c/i2c.H
+index c3e5278..4a74663 100755
+--- a/src/usr/i2c/i2c.H
++++ b/src/usr/i2c/i2c.H
+@@ -723,8 +723,8 @@ errlHndl_t i2cSendStopSignal(TARGETING::Target * i_target,
+ 
+ /**
+  * @brief This function will reset the I2C Master engine specified
+- *      by the args.  It will also then initiate a Stop cmd to the
+- *      slave device.
++ *      by the args.  It will also end the sequence by initiating a Stop
++ *      cmd to all ports on the engine that have a slave device.
+  *
+  * @param[in] i_target - The I2C master target.
+  *
+-- 
+1.8.2.2
+
diff --git a/openpower/package/hostboot/hostboot-0018-Fix-constant-refresh-of-vpd-cache.patch b/openpower/package/hostboot/hostboot-0018-Fix-constant-refresh-of-vpd-cache.patch
new file mode 100644
index 0000000..ac16f09
--- /dev/null
+++ b/openpower/package/hostboot/hostboot-0018-Fix-constant-refresh-of-vpd-cache.patch
@@ -0,0 +1,116 @@
+From 5f06da05527c3ef2d9ee709e912c5840eb366e87 Mon Sep 17 00:00:00 2001
+From: Dan Crowell <dcrowell@us.ibm.com>
+Date: Thu, 2 Apr 2015 12:29:45 -0500
+Subject: [PATCH 04/10] Fix constant refresh of vpd cache
+
+Code was inadvertantly detecting mismatched pnor cache contents
+on every boot.
+
+Change-Id: I631dc758e03316a28d13f6d19032c1a76e3cffc1
+(cherry picked from commit 0d95414e03ff337404a3e20fd421fd8b4272ebc5)
+---
+ src/usr/vpd/ipvpd.C | 18 ++++++++++++------
+ src/usr/vpd/ipvpd.H |  5 ++++-
+ src/usr/vpd/vpd.C   |  2 +-
+ 3 files changed, 17 insertions(+), 8 deletions(-)
+
+diff --git a/src/usr/vpd/ipvpd.C b/src/usr/vpd/ipvpd.C
+index a0682d2..2cefb6e 100644
+--- a/src/usr/vpd/ipvpd.C
++++ b/src/usr/vpd/ipvpd.C
+@@ -397,6 +397,9 @@ errlHndl_t IpVpdFacade::cmpPnorToSeeprom ( TARGETING::Target * i_target,
+                     l_dataSeeprom,
+                     l_sizePnor ) != 0 )
+         {
++            TRACFCOMP( g_trac_vpd, "cmpPnorToSeeprom found mismatch for HUID %.8X 0x%X:0x%X", TARGETING::get_huid(i_target), i_record, i_keyword );
++            TRACFBIN( g_trac_vpd, "EEPROM", l_dataSeeprom, l_sizeSeeprom );
++            TRACFBIN( g_trac_vpd, "PNOR", l_dataPnor, l_sizePnor );
+             break;
+         }
+ 
+@@ -898,8 +901,9 @@ bool IpVpdFacade::hasVpdPresent( TARGETING::Target * i_target,
+         }
+ 
+         vpdPresent = recordPresent( recordName,
+-                                recordOffset,
+-                                i_target );
++                                    recordOffset,
++                                    i_target,
++                                    VPD::AUTOSELECT );
+ 
+     }while( 0 );
+ 
+@@ -918,7 +922,8 @@ bool IpVpdFacade::hasVpdPresent( TARGETING::Target * i_target,
+ // ------------------------------------------------------------------
+ bool IpVpdFacade::recordPresent( const char * i_record,
+                                  uint16_t & o_offset,
+-                                 TARGETING::Target * i_target )
++                                 TARGETING::Target * i_target,
++                                 VPD::vpdCmdTarget i_location )
+ {
+     errlHndl_t err = NULL;
+     uint64_t tmpOffset = 0x0;
+@@ -946,7 +951,7 @@ bool IpVpdFacade::recordPresent( const char * i_record,
+                              RECORD_BYTE_SIZE,
+                              record,
+                              i_target,
+-                             VPD::AUTOSELECT );
++                             i_location );
+             tmpOffset += RECORD_BYTE_SIZE;
+ 
+             if( err )
+@@ -963,7 +968,7 @@ bool IpVpdFacade::recordPresent( const char * i_record,
+                                  RECORD_ADDR_BYTE_SIZE,
+                                  &o_offset,
+                                  i_target,
+-                                 VPD::AUTOSELECT );
++                                 i_location );
+                 if( err )
+                 {
+                     break;
+@@ -1003,7 +1008,8 @@ errlHndl_t IpVpdFacade::findRecordOffsetPnor ( const char * i_record,
+ 
+     matchFound = recordPresent( i_record,
+                                 offset,
+-                                i_target );
++                                i_target,
++                                i_args.location );
+ 
+     if( !matchFound )
+     {
+diff --git a/src/usr/vpd/ipvpd.H b/src/usr/vpd/ipvpd.H
+index 2350bdd..7c2090c 100644
+--- a/src/usr/vpd/ipvpd.H
++++ b/src/usr/vpd/ipvpd.H
+@@ -353,11 +353,14 @@ class IpVpdFacade
+      *
+      * @param[in] i_target - The target to retrieve the data for.
+      *
++     * @param[in] i_location - VPD location to fetch data from (PNOR/SEEPROM)
++     *
+      * @return bool - True if the record is found, False otherwise.
+      */
+     bool recordPresent( const char * i_record,
+                         uint16_t & offset,
+-                        TARGETING::Target * i_target );
++                        TARGETING::Target * i_target,
++                        VPD::vpdCmdTarget i_location );
+ 
+     /**
+      * @brief This function will read the VPD TOC to find the offset where the
+diff --git a/src/usr/vpd/vpd.C b/src/usr/vpd/vpd.C
+index 3533af9..963025f 100755
+--- a/src/usr/vpd/vpd.C
++++ b/src/usr/vpd/vpd.C
+@@ -533,7 +533,7 @@ errlHndl_t ensureCacheIsInSync ( TARGETING::Target * i_target )
+         // If we did not match, we need to load SEEPROM VPD data into PNOR
+         if( l_matchPN && l_matchSN )
+         {
+-            TRACFCOMP(g_trac_vpd,"VPD::ensureCacheIsInSync: PNOR_PN/SN = SEEPROM_PN/SN for target %.8X",TARGETING::get_huid(i_target));
++            TRACFCOMP(g_trac_vpd,"VPD::ensureCacheIsInSync: PNOR_PN/SN == SEEPROM_PN/SN for target %.8X",TARGETING::get_huid(i_target));
+         }
+         else
+         {
+-- 
+1.8.2.2
+