yosemite4: Support gpio monitor for server board device probing

If 12v stby power state was off when bmc boot up,
server board device driver will not be probed.
so add gpio monitor support for server board device probing

Tested:
devices on server board were probed after 12v on or hot-pluged

Change-Id: I9e2a6cee966dd1c64cbff53b368fa6686a8c3924
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/probe-slot-device b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/probe-slot-device
new file mode 100644
index 0000000..d837720
--- /dev/null
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/probe-slot-device
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+HOST_BUS=$(($1 - 1))
+HOST_VIRTUAL_BUS=$(($1 + 15))
+# probe server board cpld I/O expander
+echo $HOST_BUS-0020 > /sys/bus/i2c/drivers/pca953x/bind
+echo $HOST_BUS-0021 > /sys/bus/i2c/drivers/pca953x/bind
+echo $HOST_BUS-0022 > /sys/bus/i2c/drivers/pca953x/bind
+echo $HOST_BUS-0023 > /sys/bus/i2c/drivers/pca953x/bind
+# probe server board I/O expander and eeprom behind i2c-mux
+echo $HOST_VIRTUAL_BUS-0049 > /sys/bus/i2c/drivers/pca953x/bind
+echo $HOST_VIRTUAL_BUS-0050 > /sys/bus/i2c/drivers/at24/bind
+echo $HOST_VIRTUAL_BUS-0051 > /sys/bus/i2c/drivers/at24/bind
+echo $HOST_VIRTUAL_BUS-0054 > /sys/bus/i2c/drivers/at24/bind
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/probe-slot-device@.service b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/probe-slot-device@.service
new file mode 100644
index 0000000..0e1d2bb
--- /dev/null
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/probe-slot-device@.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Probe Device For Slot%i
+
+[Service]
+Type=oneshot
+ExecStart=/usr/libexec/phosphor-gpio-monitor/probe-slot-device %i
+SyslogIdentifier=probe-slot-device%i
+
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/yosemite4-phosphor-multi-gpio-monitor.json b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/yosemite4-phosphor-multi-gpio-monitor.json
index 008eddd..96a06f2 100644
--- a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/yosemite4-phosphor-multi-gpio-monitor.json
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor/yosemite4-phosphor-multi-gpio-monitor.json
@@ -8,5 +8,85 @@
             "RISING": ["set-button-sled.service"]
         },
         "Continue": true
+    },
+    {
+        "Name": "PWROK_STBY_BMC_SLOT1",
+        "ChipId": "0",
+        "GpioNum": 10,
+        "EventMon": "RISING",
+        "Targets": {
+            "RISING": ["probe-slot-device@1.service"]
+        },
+        "Continue": true
+    },
+    {
+        "Name": "PWROK_STBY_BMC_SLOT2",
+        "ChipId": "0",
+        "GpioNum": 11,
+        "EventMon": "RISING",
+        "Targets": {
+            "RISING": ["probe-slot-device@2.service"]
+        },
+        "Continue": true
+    },
+    {
+        "Name": "PWROK_STBY_BMC_SLOT3",
+        "ChipId": "0",
+        "GpioNum": 12,
+        "EventMon": "RISING",
+        "Targets": {
+            "RISING": ["probe-slot-device@3.service"]
+        },
+        "Continue": true
+    },
+    {
+        "Name": "PWROK_STBY_BMC_SLOT4",
+        "ChipId": "0",
+        "GpioNum": 13,
+        "EventMon": "RISING",
+        "Targets": {
+            "RISING": ["probe-slot-device@4.service"]
+        },
+        "Continue": true
+    },
+    {
+        "Name": "PWROK_STBY_BMC_SLOT5",
+        "ChipId": "0",
+        "GpioNum": 190,
+        "EventMon": "RISING",
+        "Targets": {
+            "RISING": ["probe-slot-device@5.service"]
+        },
+        "Continue": true
+    },
+    {
+        "Name": "PWROK_STBY_BMC_SLOT6",
+        "ChipId": "0",
+        "GpioNum": 191,
+        "EventMon": "RISING",
+        "Targets": {
+            "RISING": ["probe-slot-device@6.service"]
+        },
+        "Continue": true
+    },
+    {
+        "Name": "PWROK_STBY_BMC_SLOT7",
+        "ChipId": "0",
+        "GpioNum": 195,
+        "EventMon": "RISING",
+        "Targets": {
+            "RISING": ["probe-slot-device@7.service"]
+        },
+        "Continue": true
+    },
+    {
+        "Name": "PWROK_STBY_BMC_SLOT8",
+        "ChipId": "0",
+        "GpioNum": 202,
+        "EventMon": "RISING",
+        "Targets": {
+            "RISING": ["probe-slot-device@8.service"]
+        },
+        "Continue": true
     }
 ]
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend
index 7580795..c6240c7 100644
--- a/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend
@@ -4,13 +4,19 @@
 
 SRC_URI += "file://yosemite4-phosphor-multi-gpio-monitor.json \
             file://set-button-sled.service \
+            file://probe-slot-device@.service \
+            file://probe-slot-device \
             "
 
+RDEPENDS:${PN}:append:yosemite4 = " bash"
+
 FILES:${PN} += "${systemd_system_unitdir}/*"
 
 SYSTEMD_SERVICE:${PN} += " \
     set-button-sled.service \
+    probe-slot-device@.service \
     "
+
 SYSTEMD_AUTO_ENABLE = "enable"
 
 do_install:append:() {
@@ -18,4 +24,7 @@
     install -m 0644 ${WORKDIR}/yosemite4-phosphor-multi-gpio-monitor.json \
                     ${D}${datadir}/phosphor-gpio-monitor/phosphor-multi-gpio-monitor.json
     install -m 0644 ${WORKDIR}/set-button-sled.service ${D}${systemd_system_unitdir}/set-button-sled.service
+    install -m 0644 ${WORKDIR}/probe-slot-device@.service ${D}${systemd_system_unitdir}/probe-slot-device@.service
+    install -d ${D}${libexecdir}/${PN}
+    install -m 0777 ${WORKDIR}/probe-slot-device ${D}${libexecdir}/${PN}/
 }