Set SBE seeprom boot side

The default side for the SBE to boot from is side 0, which
is indicated by a 0 in bit 17 of cfam 0x2808.

When the boot count goes to 1 (the last before giving up), the
start_host logic will switch over to side 1 for the SBE to
boot from.

Resolves openbmc/openbmc#1467

Change-Id: I61aa22939baa4cde38c8716429b6ca55f7c850bd
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/procedures/p9/start_host.cpp b/procedures/p9/start_host.cpp
index 6494086..3049eac 100644
--- a/procedures/p9/start_host.cpp
+++ b/procedures/p9/start_host.cpp
@@ -18,6 +18,7 @@
 #include "p9_cfam.hpp"
 #include "registration.hpp"
 #include "targeting.hpp"
+#include "ext_interface.hpp"
 
 namespace openpower
 {
@@ -65,7 +66,25 @@
 
     //Kick off the SBE to start the boot
 
-    //First ensure ISTEP stepping isn't enabled
+    // Choose seeprom side to boot from
+    cfam_data_t sbeSide = 0;
+    if(getBootCount() > 1)
+    {
+        sbeSide = 0;
+        log<level::INFO>("Setting SBE seeprom side to 0",
+                entry("SBE_SIDE_SELECT=%d", 0));
+    }
+    else
+    {
+        sbeSide = 0x00004000;
+        log<level::INFO>("Setting SBE seeprom side to 1",
+                entry("SBE_SIDE_SELECT=%d", 1));
+    }
+    // Bit 17 of the ctrl status reg indicates sbe seeprom boot side
+    // 0 -> Side 0, 1 -> Side 1
+    writeRegWithMask(master, P9_SBE_CTRL_STATUS, sbeSide, 0x00004000);
+
+    //Ensure ISTEP stepping isn't enabled
     writeRegWithMask(master, P9_SCRATCH_REGISTER_8, 0x20000000, 0x20000000);
 
     //Start the SBE