metfa-facebook: harma: detect hsc power good

The CMM can't power on the host if the host sled cycles.
Therefore, the host BMC detects the HSC power good rising signal to power on the host.

Change-Id: I121422a5fa862e871b05676dd11ed29a14f745fd
Signed-off-by: Peter Yin <peter.yin@quantatw.com>
diff --git a/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor/deassert-power-hsc-good b/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor/deassert-power-hsc-good
new file mode 100644
index 0000000..ad9fc7c
--- /dev/null
+++ b/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor/deassert-power-hsc-good
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+# Set Host Power On
+obmcutil poweron
+
+exit 0
diff --git a/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor/deassert-power-hsc-good.service b/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor/deassert-power-hsc-good.service
new file mode 100644
index 0000000..9c5aee1
--- /dev/null
+++ b/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor/deassert-power-hsc-good.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Deassert Power HSC Good Status
+
+[Service]
+Type=oneshot
+ExecStart=/usr/libexec/phosphor-gpio-monitor/deassert-power-hsc-good
+
+SyslogIdentifier=deassert-power-hsc-good
diff --git a/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor/plat-phosphor-multi-gpio-monitor.json b/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor/plat-phosphor-multi-gpio-monitor.json
index 18593a0..22c1040 100644
--- a/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor/plat-phosphor-multi-gpio-monitor.json
+++ b/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor/plat-phosphor-multi-gpio-monitor.json
@@ -141,13 +141,13 @@
         "Continue": true
     },
     {
-        "Name": "host-ready-n",
+        "Name": "post-end-n",
         "ChipId": "2",
         "GpioNum": 66,
         "EventMon": "BOTH",
         "Targets": {
-            "RISING": ["deassert-post-end.service","deassert-gpio-log@host-ready-n.service"],
-            "FALLING": ["assert-post-end.service","assert-gpio-log@host-ready-n.service"]
+            "RISING": ["deassert-post-end.service","deassert-gpio-log@post-end-n.service"],
+            "FALLING": ["assert-post-end.service","assert-gpio-log@post-end-n.service"]
 
         },
         "Continue": true
@@ -162,5 +162,15 @@
             "FALLING": ["assert-gpio-log@leakage-detect-alert.service"]
         },
         "Continue": true
+    },
+    {
+        "Name": "power-hsc-good",
+        "ChipId": "2",
+        "GpioNum": 10,
+        "EventMon": "RISING",
+        "Targets": {
+            "RISING": ["deassert-power-hsc-good.service"]
+        },
+        "Continue": true
     }
-]
\ No newline at end of file
+]
diff --git a/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend b/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend
index 46b9d2d..19bb06f 100644
--- a/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend
+++ b/meta-facebook/meta-harma/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend
@@ -2,25 +2,27 @@
 
 inherit obmc-phosphor-systemd systemd
 
-SRC_URI += "file://plat-phosphor-multi-gpio-monitor.json \
-            file://plat-phosphor-multi-gpio-presence.json \
-            file://assert-reset-button.service \
-            file://assert-power-good.service \
-            file://assert-post-end.service \
-            file://deassert-reset-button.service \
-            file://deassert-power-good.service \
-            file://deassert-post-end.service \
-            file://multi-gpios-sys-init.service \
-            file://multi-gpios-sys-init \
-            file://assert-power-good \
-            file://deassert-power-good \
+SRC_URI += "file://assert-gpio-log@.service \
             file://assert-post-end \
-            file://deassert-post-end \
+            file://assert-post-end.service \
+            file://assert-power-good \
+            file://assert-power-good.service \
             file://assert-reset-button \
-            file://deassert-reset-button \
-            file://assert-gpio-log@.service \
+            file://assert-reset-button.service \
             file://deassert-gpio-log@.service \
+            file://deassert-post-end \
+            file://deassert-post-end.service \
+            file://deassert-power-good \
+            file://deassert-power-good.service \
+            file://deassert-power-hsc-good \
+            file://deassert-power-hsc-good.service \
+            file://deassert-reset-button \
+            file://deassert-reset-button.service \
             file://logging \
+            file://multi-gpios-sys-init \
+            file://multi-gpios-sys-init.service \
+            file://plat-phosphor-multi-gpio-monitor.json \
+            file://plat-phosphor-multi-gpio-presence.json \
             "
 
 RDEPENDS:${PN}:append = " bash"
@@ -28,12 +30,12 @@
 FILES:${PN} += "${systemd_system_unitdir}/*"
 
 SYSTEMD_SERVICE:${PN} += " \
-    assert-reset-button.service \
     assert-power-good.service \
     assert-post-end.service \
-    deassert-reset-button.service \
+    assert-reset-button.service \
     deassert-power-good.service \
     deassert-post-end.service \
+    deassert-reset-button.service \
     multi-gpios-sys-init.service \
     "
 
@@ -41,6 +43,9 @@
 
 do_install:append:() {
     install -d ${D}${datadir}/phosphor-gpio-monitor
+    install -d ${D}${systemd_system_unitdir}/
+    install -d ${D}${libexecdir}/${PN}
+
     install -m 0644 ${WORKDIR}/plat-phosphor-multi-gpio-monitor.json \
                     ${D}${datadir}/phosphor-gpio-monitor/phosphor-multi-gpio-monitor.json
     install -m 0644 ${WORKDIR}/plat-phosphor-multi-gpio-presence.json \
@@ -61,6 +66,8 @@
 
     install -m 0755 ${WORKDIR}/assert-power-good ${D}${libexecdir}/${PN}/
     install -m 0755 ${WORKDIR}/deassert-power-good ${D}${libexecdir}/${PN}/
+
+    install -m 0755 ${WORKDIR}/deassert-power-hsc-good ${D}${libexecdir}/${PN}/
 }
 
 SYSTEMD_OVERRIDE:${PN}-monitor += "phosphor-multi-gpio-monitor.conf:phosphor-multi-gpio-monitor.service.d/phosphor-multi-gpio-monitor.conf"