Add procedure and service file to set the SPI mux on P10
This procedure will be called before powering on in order to set the mux
for accessing host EEPROMs from the BMC through the FSI SPI masters.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Change-Id: I238d3bc449c5924740cf4c2e69d794605a6ae916
diff --git a/Makefile.am b/Makefile.am
index eb6bb2c..8f72036 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,6 +4,10 @@
pcie-poweroff@.service \
xyz.openbmc_project.Control.Host.NMI.service
+if ENABLE_PHAL
+ systemdsystemunit_DATA += set-spi-mux.service
+endif
+
bin_PROGRAMS = \
openpower-proc-control \
openpower-proc-nmi
diff --git a/configure.ac b/configure.ac
index 7bad72f..f2989d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,8 +65,10 @@
fi
CHIPS+=" phal"
+ AC_CONFIG_FILES([set-spi-mux.service])
]
)
+AM_CONDITIONAL([ENABLE_PHAL], [test "$enable_phal" == "yes"])
AS_IF([test "x$CHIPS" == "x"], [CHIPS="p9 openfsi"])
diff --git a/p10_cfam.hpp b/p10_cfam.hpp
new file mode 100644
index 0000000..a8e47c4
--- /dev/null
+++ b/p10_cfam.hpp
@@ -0,0 +1,14 @@
+#pragma once
+
+namespace openpower
+{
+namespace cfam
+{
+namespace p10
+{
+
+static constexpr uint16_t P10_ROOT_CTRL8 = 0x2818;
+
+} // namespace p10
+} // namespace cfam
+} // namespace openpower
diff --git a/procedures/phal/set_SPI_mux.cpp b/procedures/phal/set_SPI_mux.cpp
new file mode 100644
index 0000000..4d40a7d
--- /dev/null
+++ b/procedures/phal/set_SPI_mux.cpp
@@ -0,0 +1,48 @@
+/**
+ * Copyright (C) 2020 IBM Corporation
+ *
+ * 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.
+ */
+#include "cfam_access.hpp"
+#include "p10_cfam.hpp"
+#include "registration.hpp"
+#include "targeting.hpp"
+
+namespace openpower
+{
+namespace p10
+{
+
+using namespace openpower::cfam::access;
+using namespace openpower::cfam::p10;
+using namespace openpower::targeting;
+
+/**
+ * Sets the mux on the P10 to the FSI SPI masters rather than the PIB SPI
+ * masters. This should only be executed before the host is powering on since
+ * the host will set the mux to the PIB SPI masters.
+ */
+void setSPIMux()
+{
+ Targeting targets;
+
+ for (const auto& t : targets)
+ {
+ writeReg(t, P10_ROOT_CTRL8, 0xFFFFFFFF);
+ }
+}
+
+REGISTER_PROCEDURE("setSPIMux", setSPIMux);
+
+} // namespace p10
+} // namespace openpower
diff --git a/set-spi-mux.service.in b/set-spi-mux.service.in
new file mode 100644
index 0000000..16004d2
--- /dev/null
+++ b/set-spi-mux.service.in
@@ -0,0 +1,12 @@
+[Unit]
+Description=Set the SPI mux
+ConditionPathExists=!/run/openbmc/chassis@0-on
+
+[Service]
+ExecStart=@bindir@/openpower-proc-control setSPIMux
+SyslogIdentifier=openpower-proc-control
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target