meta-gsj: phosphor-pid-control: Add fan control algorithm

This change adds fan control function with following features.

1) Fans will be at full speed while rebooting or a sensor is not ready.
2) Detect different skus automatically.

Signed-off-by: Hank Liou <Hank.Liou@quantatw.com>
Change-Id: I44b3501bf1991d023957f2906e932d77709d8ab4
diff --git a/meta-gsj/recipes-phosphor/fans/phosphor-pid-control/fan-control.sh b/meta-gsj/recipes-phosphor/fans/phosphor-pid-control/fan-control.sh
new file mode 100644
index 0000000..3c84ce4
--- /dev/null
+++ b/meta-gsj/recipes-phosphor/fans/phosphor-pid-control/fan-control.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+NVME_GPIO_NUM=( 148 149 150 151 152 153 154 155 )
+NVME=( 1 1 1 1 1 1 1 1 )
+FAN_TABLE_PATH="/usr/share/swampd/config.json"
+FAN_TABLE=( "/usr/share/swampd/config-8ssd.json" "/usr/share/swampd/config-2ssd.json" )
+TYPE=-1
+
+# get nvme presence
+for i in {0..7}
+do
+  gpioNum=${NVME_GPIO_NUM[$i]}
+  NVME[$i]=$(cat /sys/class/gpio/gpio$gpioNum/value)
+done
+
+# distinguish between 8-ssd and 2-ssd sku
+for i in {2..7}
+do
+  if [ ${NVME[$i]} -eq 0 ]; then
+    TYPE=0
+  fi
+done
+if [ $TYPE -eq -1 ]; then
+  for i in {0..1}
+  do
+    if [ ${NVME[$i]} -eq 0 ]; then
+      TYPE=1
+    fi
+  done
+fi
+
+if [ $TYPE -eq 1 ]; then
+  cp ${FAN_TABLE[1]} $FAN_TABLE_PATH
+else
+  cp ${FAN_TABLE[0]} $FAN_TABLE_PATH
+fi
+
+# start pid control
+/usr/bin/swampd