meta-facebook: catalina: add 99-platform-init

Add 99-platform-init to archive following items

1. Disable FMC_WDT2
AST2600 use FMC_WDT2 to archive ABR feature.
Disable FMC_WDT2 before systemd start.

2. Detect boot flash source
Write boot source into /run/media/slot
0: boot from primary
1: boot from alternate

Change-Id: I31ee96551f25a1396ccd16924939faa91fb3a3ad
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
diff --git a/meta-facebook/meta-catalina/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bbappend b/meta-facebook/meta-catalina/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bbappend
new file mode 100644
index 0000000..a718b14
--- /dev/null
+++ b/meta-facebook/meta-catalina/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bbappend
@@ -0,0 +1,2 @@
+FILESEXTRAPATHS:append := ":${THISDIR}/${PN}"
+SOURCE_FILES:append = " 99-platform-init"
\ No newline at end of file
diff --git a/meta-facebook/meta-catalina/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/99-platform-init b/meta-facebook/meta-catalina/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/99-platform-init
new file mode 100644
index 0000000..d9def86
--- /dev/null
+++ b/meta-facebook/meta-catalina/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/99-platform-init
@@ -0,0 +1,23 @@
+#bin/sh
+
+# Create /dev/mem
+if [ ! -c /dev/mem ]; then
+    /bin/mknod /dev/mem c 1 1
+fi
+
+# Disable FMC_WDT2
+FMC_WDT2_CTRL_VAL=$(/sbin/devmem 0x1e620064)
+FMC_WDT2_CTRL_VAL=$((16#${FMC_WDT2_CTRL_VAL#"0x"}))
+SET_VAL=$((FMC_WDT2_CTRL_VAL & 0xFFFFFFFE))
+/sbin/devmem 0x1e620064 32 "$SET_VAL"
+
+# Detect boot flash source
+SLOT_FILE="/run/media/slot"
+mkdir -p "$(dirname "${SLOT_FILE}")"
+if [ "$((FMC_WDT2_CTRL_VAL & 0x00000010))" != "0" ]; then
+    echo "1" > "$SLOT_FILE"
+else
+    echo "0" > "$SLOT_FILE"
+fi
+
+exit 0