meta-quanta: gbs: stop hwmon while doing tray reset

Stop phosphor-hwmon before performing a tray power cycle to
avoid ADM1272 doing an abnormal I2C transaction and causing
ADM1272 driver probe to fail due to wrong Manufacturer ID.

Signed-off-by: George Hung <george.hung@quantatw.com>
Change-Id: I040aa1660e1bfe98f0979c0930b2658b5d0a6228
diff --git a/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh b/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh
index 5cbf49b..01c52de 100644
--- a/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh
+++ b/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh
@@ -7,6 +7,23 @@
 # Global variable: PSU_HARDRESET_DELAY specifies the number of seconds to wait
 # before pulling the trigger. If not specified or zero, the script power cycles
 # immediately.
+
+##################################################
+# Stop the phosphor-hwmon daemon
+# Return:
+#   0 if success, non-zero if error
+##################################################
+stop_phosphor_hwmon() {
+  if (( $# != 0 )); then
+    echo 'Usage: stop_phosphor_hwmon' >&2
+    return 1
+  fi
+
+  echo "Stopping phosphor-hwmon" >&2
+  local srv='system-xyz.openbmc_project.Hwmon.slice'
+  systemctl stop "${srv}"
+}
+
 main() {
   # Sleep PSU_HARDRESET_DELAY seconds
   local psu_delay=$((PSU_HARDRESET_DELAY))
@@ -15,6 +32,10 @@
     sleep "${psu_delay}"
   fi
 
+  # Stop phosphor-hwmon so that ADM1272 powercycle doesn't happen
+  # in the middle of an i2c transaction and stuck the bus low
+  stop_phosphor_hwmon
+
   gpioset gpiochip6 26=1
 }