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.

(From meta-quanta rev: 2143eac88d3643e4a8d461eec2ed9a2d2e6a32f3)

Signed-off-by: George Hung <george.hung@quantatw.com>
Change-Id: Ibd69cb956d76dbe08f0bb6e6bce115d5bab469df
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/meta-quanta/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh b/meta-quanta/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh
index 5cbf49b..01c52de 100644
--- a/meta-quanta/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh
+++ b/meta-quanta/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
 }