meta-facebook: yosemite4: Add 99-platform-init

Port 99-platform-init from bletchley to enable alternate boot.

Tested:
- FMC_WDT2 is enabled and timer is counting down:
```
U-Boot SPL 2019.04 yosemite4-runtime-addc-test (Mar 25 2024 - 04:43:19 +0000)
already initialized, Trying to boot from RAM

U-Boot 2019.04 yosemite4-runtime-addc-test (Mar 25 2024 - 04:43:19 +0000)

SOC: AST2620-A3
RST: WDT1 SOC
PCI RST: #2
RST: External
FMC 2nd Boot (ABR): Enable, Dual flashes, Source: Primary
Set FMC_WDT2 timer reload value to 0x0BB8
eSPI Mode: SIO:Enable : SuperIO-2e
Eth: MAC0: RMII/NCSI, MAC1: RMII/NCSI, MAC2: RMII/NCSI, MAC3: RMII/NCSI
Model: AST2600 EVB
DRAM:  already initialized, 1 GiB (capacity:1024 MiB, VGA:0 MiB, ECC:off)
MMC:

sdhci_slot0@100: 1, sdhci_slot1@200: 2, emmc_slot0@100: 0
Loading Environment from SPI Flash... SF: Detected mx66l1g45g with page size 256 Bytes, erase size 4 KiB, total 128 MiB
OK
In:    serial@1e784000
Out:   serial@1e784000
Err:   serial@1e784000
Model: AST2600 EVB
Net:   No MDIO found.
No ethernet found.
Hit any key to stop autoboot:  0
ast# md.l 0x1e620064 2
1e620064: 00000001 0b0a0bb8                      ........
ast# md.l 0x1e620064 2
```
- Boot from alternate flash when timeout occured:
```
U-Boot 2019.04 yosemite4-runtime-addc-test (Mar 25 2024 - 04:43:19 +0000)

SOC: AST2620-A3
PCI RST: #2
RST: SYS_FLASH_ABR_RESET
FMC 2nd Boot (ABR): Enable, Dual flashes, Source: Alternate
Set FMC_WDT2 timer reload value to 0x0BB8
eSPI Mode: SIO:Enable : SuperIO-2e
Eth: MAC0: RMII/NCSI, MAC1: RMII/NCSI, MAC2: RMII/NCSI, MAC3: RMII/NCSI
Model: AST2600 EVB
DRAM:  already initialized, 1 GiB (capacity:1024 MiB, VGA:0 MiB, ECC:off)
MMC:

...

root@bmc:~# devmem 0x1e620064
0x00000110
root@bmc:~# devmem 0x1e620068
0x0BB80BB8
root@bmc:~# cat /run/media/slot
1
```

Change-Id: I524eae906526c16469f1dd2d0927c289c35a7380
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bbappend b/meta-facebook/meta-yosemite4/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bbappend
new file mode 100644
index 0000000..a718b14
--- /dev/null
+++ b/meta-facebook/meta-yosemite4/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-yosemite4/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/99-platform-init b/meta-facebook/meta-yosemite4/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/99-platform-init
new file mode 100644
index 0000000..d9def86
--- /dev/null
+++ b/meta-facebook/meta-yosemite4/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