meta-facebook: yosemite4: Revise i/o config for medusa board's schematic changes

Revise medusa board i/o initialization for EVT schematic changes

Tested: Verified with yosemite4 POC/EVT medusa board

Change-Id: Iae1809de1b0ada79425a59f124387b974e22d168
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
diff --git a/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-early-sys-init b/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-early-sys-init
index b178985..d0b6fd4 100644
--- a/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-early-sys-init
+++ b/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-early-sys-init
@@ -31,23 +31,6 @@
 set_gpio SPI_LOCK_REQ_BMC_N   1
 set_gpio EN_P3V_BAT_SCALED_R  0
 
-set_gpio P48V_OCP_GPIO1       0
-set_gpio P48V_OCP_GPIO2       0
-set_gpio P48V_OCP_GPIO3       0
-set_gpio RST_MUX_R_N          1
-set_gpio RST_LED_CONTROL_FAN_BOARD_0_N 1
-set_gpio RST_LED_CONTROL_FAN_BOARD_1_N 1
-set_gpio RST_IOEXP_FAN_BOARD_0_N       1
-set_gpio RST_IOEXP_FAN_BOARD_1_N       1
-set_gpio EN_P48V_AUX_0        1
-set_gpio EN_P48V_AUX_1        1
-set_gpio HSC_OCP_SLOT_ODD_GPIO1        0
-set_gpio HSC_OCP_SLOT_ODD_GPIO2        0
-set_gpio HSC_OCP_SLOT_ODD_GPIO3        0
-set_gpio HSC_OCP_SLOT_EVEN_GPIO1       0
-set_gpio HSC_OCP_SLOT_EVEN_GPIO2       0
-set_gpio HSC_OCP_SLOT_EVEN_GPIO3       0
-
 set_gpio NIC0_MAIN_PWR_EN 1
 set_gpio NIC1_MAIN_PWR_EN 1
 set_gpio NIC2_MAIN_PWR_EN 1
diff --git a/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-schematic-init b/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-schematic-init
new file mode 100644
index 0000000..a68839e
--- /dev/null
+++ b/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-schematic-init
@@ -0,0 +1,45 @@
+#!/bin/bash -e
+# shellcheck source=meta-facebook/meta-yosemite4/recipes-yosemite4/plat-tool/files/yosemite4-common-functions
+source /usr/libexec/yosemite4-common-functions
+
+# probe devices behind mux for management board cpld
+
+stage=$(busctl introspect xyz.openbmc_project.FruDevice /xyz/openbmc_project/FruDevice/Medusa_Board | grep '.PRODUCT_VERSION' | awk -F\" '{print $2}')
+
+# set initial value for pca9555 i/o pins on medusa board
+if [ -z "$stage" ]; then
+    echo "Failed to check medusa board fru info, all I/O pins are keeping default input"
+elif [ "$stage" = "POC" ]; then
+    set_gpio P48V_OCP_GPIO1       0
+    set_gpio P48V_OCP_GPIO2       0
+    set_gpio P48V_OCP_GPIO3       0
+    set_gpio RST_MUX_R_N          1
+    set_gpio RST_LED_CONTROL_FAN_BOARD_0_N 1
+    set_gpio RST_LED_CONTROL_FAN_BOARD_1_N 1
+    set_gpio RST_IOEXP_FAN_BOARD_0_N       1
+    set_gpio RST_IOEXP_FAN_BOARD_1_N       1
+    set_gpio HSC_OCP_SLOT_ODD_GPIO3        1
+    set_gpio HSC_OCP_SLOT_EVEN_GPIO1       1
+    set_gpio MEDUSA_BOARD_REV_0   0
+    set_gpio MEDUSA_BOARD_REV_1   0
+    set_gpio MEDUSA_BOARD_REV_2   0
+    set_gpio MEDUSA_BOARD_TYPE    0
+    set_gpio DELTA_MODULE_TYPE    0
+    set_gpio P12V_HSC_TYPE        0
+else
+    set_gpio P48V_OCP_GPIO1       0
+    set_gpio P48V_OCP_GPIO2       0
+    set_gpio P48V_OCP_GPIO3       0
+    set_gpio RST_MUX_R_N          1
+    set_gpio RST_LED_CONTROL_FAN_BOARD_0_N 1
+    set_gpio RST_LED_CONTROL_FAN_BOARD_1_N 1
+    set_gpio RST_IOEXP_FAN_BOARD_0_N       1
+    set_gpio RST_IOEXP_FAN_BOARD_1_N       1
+    set_gpio HSC_OCP_SLOT_ODD_GPIO1        0
+    set_gpio HSC_OCP_SLOT_ODD_GPIO2        0
+    set_gpio HSC_OCP_SLOT_ODD_GPIO3        0
+    set_gpio HSC_OCP_SLOT_EVEN_GPIO1       0
+    set_gpio HSC_OCP_SLOT_EVEN_GPIO2       0
+    set_gpio HSC_OCP_SLOT_EVEN_GPIO3       0
+fi
+exit 0
diff --git a/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-schematic-init.service b/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-schematic-init.service
new file mode 100644
index 0000000..68b3934
--- /dev/null
+++ b/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-schematic-init.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Yosemite4 Schematic Init
+After=xyz.openbmc_project.FruDevice.service
+Requires=xyz.openbmc_project.FruDevice.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/libexec/yosemite4-schematic-init
+SyslogIdentifier=Yosemite4 Schematic Init
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/plat-svc_0.1.bb b/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/plat-svc_0.1.bb
index 65a3824..f50e0bb 100644
--- a/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/plat-svc_0.1.bb
+++ b/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/plat-svc_0.1.bb
@@ -10,15 +10,19 @@
 SRC_URI += " \
     file://yosemite4-sys-init.service \
     file://yosemite4-early-sys-init \
+    file://yosemite4-schematic-init.service \
+    file://yosemite4-schematic-init \
     "
 
 SYSTEMD_PACKAGES = "${PN}"
 SYSTEMD_SERVICE:${PN}:append = " \
     yosemite4-sys-init.service \
+    yosemite4-schematic-init.service \
     "
 
 do_install() {
     install -d ${D}${libexecdir}
     install -m 0755 ${WORKDIR}/yosemite4-early-sys-init ${D}${libexecdir}
+    install -m 0755 ${WORKDIR}/yosemite4-schematic-init ${D}${libexecdir}
 }