meta-ampere: use watchdog status to check A/C power

With the removal of u-boot patch that adds resetreason to /proc/cmdline
no information to check if the BMC is booted from A/C power or cold reboot.
This commit removes the dependency of resetreason on the
phosphor-discover-system-state application and updates the A/C power
check in the ampere_platform_init.sh script to use information from
/sys/class/watchdog/watchdog0/bootstatus.

Tested:
1. Check power restore policy feature work well.
2. Check ampere_platform_init.sh works properly in both A/C and D/C
power.

Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
Change-Id: I4f2e7a241f9ddebf21b2b8c021b9ce87a1c8b26c
diff --git a/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager/resetreason.conf b/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager/resetreason.conf
deleted file mode 100644
index 828d98b..0000000
--- a/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager/resetreason.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-[Unit]
-ConditionKernelCommandLine=resetreason=power
diff --git a/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager_%.bbappend b/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager_%.bbappend
index 6ef9ac5..703ff48 100644
--- a/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager_%.bbappend
+++ b/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager_%.bbappend
@@ -1,9 +1,5 @@
 FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
 
-DEPS_CFG = "resetreason.conf"
-DEPS_TGT = "phosphor-discover-system-state@.service"
-SYSTEMD_OVERRIDE:${PN}-discover:append = "${DEPS_CFG}:${DEPS_TGT}.d/${DEPS_CFG}"
-
 DEPENDS += "gpioplus libgpiod"
 
 EXTRA_OEMESON:append = " -Dhost-gpios=enabled"
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh
index c3772fb..4b448ef 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh
@@ -30,8 +30,8 @@
 # =======================================================
 # Below GPIOs are controlled by other services so just
 # initialize in A/C power only.
-cmdline=$(cat /proc/cmdline)
-if [[ $cmdline == *resetreason=power* ]]; then
+bootstatus=$(cat /sys/class/watchdog/watchdog0/bootstatus)
+if [ "$bootstatus" == '32' ]; then
 	# BMC_GPIOR2_EXT_HIGHTEMP_L
 	gpio_configure_output 138 1