Add IR38163 re-probe workaround

IR38163 work on DC on state, need re-probe for centriq2400 HW design

Change-Id: I8f2bf997d3fdd9c223367c96b4bd38768c006cdb
Signed-off-by: Ken Chen <chen.kenyy@inventec.com>
diff --git a/meta-centriq2400-rep/recipes-phosphor/chassis/ir38163-workaround/ir-add@.service b/meta-centriq2400-rep/recipes-phosphor/chassis/ir38163-workaround/ir-add@.service
new file mode 100644
index 0000000..0b3574b
--- /dev/null
+++ b/meta-centriq2400-rep/recipes-phosphor/chassis/ir38163-workaround/ir-add@.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Add IR38163 device
+Wants=obmc-power-start@%i.target
+Before=obmc-power-start@%i.target
+Conflicts=obmc-chassis-poweroff@%i.target
+ConditionPathExists=!/run/openbmc/chassis@%i-on
+
+[Service]
+ExecStart=/usr/bin/env ir38163_workaround.sh add
+SyslogIdentifier=ir38163_workaround.sh
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-host-start@%i.target
+
diff --git a/meta-centriq2400-rep/recipes-phosphor/chassis/ir38163-workaround/ir-remove@.service b/meta-centriq2400-rep/recipes-phosphor/chassis/ir38163-workaround/ir-remove@.service
new file mode 100644
index 0000000..15e8d01
--- /dev/null
+++ b/meta-centriq2400-rep/recipes-phosphor/chassis/ir38163-workaround/ir-remove@.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Remove IR38163 device
+After=obmc-power-off@%i.target
+Conflicts=obmc-chassis-poweron@%i.target
+
+[Service]
+ExecStart=/usr/bin/env ir38163_workaround.sh rm
+SyslogIdentifier=ir38163_workaround.sh
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-host-stop@%i.target
diff --git a/meta-centriq2400-rep/recipes-phosphor/chassis/ir38163-workaround/ir38163_workaround.sh b/meta-centriq2400-rep/recipes-phosphor/chassis/ir38163-workaround/ir38163_workaround.sh
new file mode 100644
index 0000000..60120cf
--- /dev/null
+++ b/meta-centriq2400-rep/recipes-phosphor/chassis/ir38163-workaround/ir38163_workaround.sh
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+# For one of the IR38163 device on i2c bus 5, address 0x42
+# Because the device only work when DC-ON, so when BMC during the DC-OFF state
+# the device will probe fail, need the workaround for this HW design..
+
+if [ "$1" == "add" ]; then
+    echo Add the 0x42 device on i2c bus 5....
+    sleep 2
+    echo 5-0042 > /sys/bus/i2c/drivers/ir38163/bind
+    sleep 1
+elif [ "$1" == "rm" ]; then
+    echo Remove the 0x42 deivce
+    sleep 2
+    echo 5-0042 > /sys/bus/i2c/drivers/ir38163/unbind
+    sleep 1
+else
+    echo "$0 <add|rm>" to set state
+fi
+