op-pdbg-host-control: Fix boot scripts for pdbg
The current scripts use ecmd-style bit ranges and call a "putcfam"
function/command that doesn't exist.
Use latest VCS fix and IPL start commands from Dean Sanner (including
scratch register 8 value), converted to pdbg masked read-modify-write
format.
Add optional argument to scripts for specifying pdbg's '-d' flag.
Scripts tested to boot a Zaius machine, but not tested with systemd
services for sequencing.
Partially resolves openbmc/openbmc#647.
Signed-off-by: Xo Wang <xow@google.com>
Change-Id: I87761d1454306ebf4ad597057d2160eae10dc8cb
diff --git a/common/recipes-phosphor/host/op-pdbg-host-control/start_host.sh b/common/recipes-phosphor/host/op-pdbg-host-control/start_host.sh
old mode 100644
new mode 100755
index c68c9ab..909cde0
--- a/common/recipes-phosphor/host/op-pdbg-host-control/start_host.sh
+++ b/common/recipes-phosphor/host/op-pdbg-host-control/start_host.sh
@@ -1,4 +1,14 @@
-#!/bin/sh
+#!/bin/sh -e
+# Starts POWER9 IPL (boot)
-# send putcfam command to have SBE start IPL
-putcfam pu 2801 0 1 1 -ib
+PDBG=${PDBG:-pdbg}
+# Argument [device]: if provided, pass to pdbg as "-d [device]"
+DEVICE_OPT=${1:+-d $1}
+
+putcfam()
+{
+ $PDBG -b fsi $DEVICE_OPT putcfam $1 $2 $3
+}
+
+putcfam 0x283f 0x20000000 # Write scratch register 8
+putcfam 0x2801 0x80000000 0x80000000 # Set SBE start bit to start IPL
diff --git a/common/recipes-phosphor/host/op-pdbg-host-control/vcs_workaround.sh b/common/recipes-phosphor/host/op-pdbg-host-control/vcs_workaround.sh
old mode 100644
new mode 100755
index 49d6bfb..4b30bfc
--- a/common/recipes-phosphor/host/op-pdbg-host-control/vcs_workaround.sh
+++ b/common/recipes-phosphor/host/op-pdbg-host-control/vcs_workaround.sh
@@ -1,6 +1,24 @@
-#!/bin/sh
+#!/bin/sh -e
+# Apply fixes over FSI to POWER9 hosts. Required before VCS rail on.
-putcfam pu 0900 31 1 1 -ib # put the CFAM/FSI slave into async mode
-putcfam pu 2810 15 1 0 # Unfence PLL controls
-putcfam pu 281A 1 1 f # Assert Perv chiplet endpoint reset, just in case
-putcfam pu 281A 31 1 f # Enable Nest PLL
+PDBG=${PDBG:-pdbg}
+# Argument [device]: if provided, pass to pdbg as "-d [device]"
+DEVICE_OPT=${1:+-d $1}
+
+putcfam()
+{
+ $PDBG -b fsi $DEVICE_OPT putcfam $1 $2 $3
+}
+
+# P9 dd1 required workaround needed before powering VCS rails
+p9_dd1_vcs_workaround()
+{
+ putcfam 0x2810 0x00000000 0x00010000 && # Unfence PLL controls
+ putcfam 0x281A 0x40000000 0x40000000 && # Assert Perv chiplet endpoint reset, just in case
+ putcfam 0x281A 0x00000001 0x00000001 # Enable Nest PLL
+}
+
+# Put the CFAM/FSI slave into async mode
+putcfam 0x900 1
+
+p9_dd1_vcs_workaround