sysmgr: Introduce 3rd temperature sensor AUX1

On Optimus Prime, we need to monitor a third temperature sensor - the
one in the Quantenna SoC. Let's call it AUX1 to allow for miscellaneous
other temperature sensors on future platforms.

Fixes b/23119698

Change-Id: I4ec6067799593f27c67769d8ee578d150fc1bd41
diff --git a/sysmgr/peripheral/fancontrol.cc b/sysmgr/peripheral/fancontrol.cc
index 3bf2d64..3436c12 100644
--- a/sysmgr/peripheral/fancontrol.cc
+++ b/sysmgr/peripheral/fancontrol.cc
@@ -119,6 +119,22 @@
                         };
 
 /*
+ * On Optimus Prime, AUX1 refers to the temperature sensor in the Quantenna SoC
+ * which controls the 11ac wifi interface. The granularity of the temperature
+ * readings are very coarse: increments of 5C.
+ */
+const FanControlParams FanControl::kGFRG250FanCtrlAux1Defaults = {
+                          temp_setpt    : 95,
+                          temp_max      : 109, /* fan speed is set to max when
+                                                  temperatures reaches 110C */
+                          temp_step     : 3,
+                          duty_cycle_min: 30,
+                          duty_cycle_max: 100,
+                          pwm_step      : 2,
+                          temp_overheat : 120,
+                        };
+
+/*
  * Defaults of Fan control parameters for GFSC100 (Spacecast).
  * There is no direct SOC temp input, so we use the remote sensor.
  * Mapping between external temp sensor and actual cpu temp was determined
@@ -275,7 +291,8 @@
       /* Set thermal fan policy parameters of GFRG250 */
       pfan_ctrl_params_[BRUNO_SOC] = kGFRG250FanCtrlSocDefaults;
       pfan_ctrl_params_[BRUNO_IS_HDD] = kGFRG250FanCtrlHddDefaults;
-      max = BRUNO_IS_HDD;
+      pfan_ctrl_params_[BRUNO_AUX1] = kGFRG250FanCtrlAux1Defaults;
+      max = BRUNO_AUX1;
       break;
     case BRUNO_GFSC100:
       /* Set thermal fan policy parameters of GFSC100 */
@@ -300,8 +317,24 @@
   uint8_t idx;
   /* Adjust the fan control parameters for calculation. */
   for (idx = 0, pfan_ctrl = pfan_ctrl_params_; idx <= max; idx++, pfan_ctrl++) {
+    const char *suffix;
+    switch(idx) {
+      case BRUNO_SOC:
+        suffix = "_SOC";
+        break;
+      case BRUNO_IS_HDD:
+        suffix = "_HDD";
+        break;
+      case BRUNO_AUX1:
+        suffix = "_AUX1";
+        break;
+      default:
+        suffix = "_UNKNOWN";
+        break;
+    }
+
     LOG(LS_INFO) << platformInstance_->PlatformName()
-                 << ((idx == BRUNO_SOC)? "_SOC" : "_HDD") << std::endl
+                 << suffix << std::endl
                  << " Tsetpt: "    << pfan_ctrl->temp_setpt << std::endl
                  << " Tmax: "      << pfan_ctrl->temp_max << std::endl
                  << " Tstep: "     << pfan_ctrl->temp_step << std::endl
@@ -314,18 +347,21 @@
 
 
 bool FanControl::AdjustSpeed(
-      uint16_t soc_temp, uint16_t hdd_temp, uint16_t fan_speed) {
+      uint16_t soc_temp, uint16_t hdd_temp, uint16_t aux1_temp,
+      uint16_t fan_speed) {
   bool ret = true;
   uint16_t new_duty_cycle_pwm;
 
   LOG(LS_VERBOSE) << __func__ << ": soc_temp=" << soc_temp
-                  << " hdd_temp=" << hdd_temp << " fan_speed=" << fan_speed;
+                  << " hdd_temp=" << hdd_temp << " aux1_temp=" << aux1_temp
+                  << " fan_speed=" << fan_speed;
 
   do {
     /* Get new SOC PWM per the current SOC and HDD temperatures */
 
     /* Get new duty cycle per SOC and HDD temperatures */
-    ComputeDutyCycle(soc_temp, hdd_temp, fan_speed, &new_duty_cycle_pwm);
+    ComputeDutyCycle(soc_temp, hdd_temp, aux1_temp, fan_speed,
+        &new_duty_cycle_pwm);
 
     LOG(LS_INFO) << __func__ << ": duty_cycle_pwm = " << new_duty_cycle_pwm;
     if (new_duty_cycle_pwm != duty_cycle_pwm_) {
@@ -410,97 +446,86 @@
   return true;
 }
 
+uint16_t FanControl::__ComputeDutyCycle(
+  uint16_t temp,
+  uint16_t fan_speed,
+  FanControlParams &params) {
+
+  uint16_t  compute_duty_cycle = duty_cycle_pwm_;
+  if (temp > params.temp_max) {
+    compute_duty_cycle = params.duty_cycle_max;
+  }
+  else if (temp > (params.temp_setpt + params.temp_step)) {
+    if (fan_speed == kFanSpeedNotSpinning) {
+      compute_duty_cycle = params.duty_cycle_min;
+    }
+    else if (duty_cycle_pwm_ < params.duty_cycle_max) {
+      /* 1. Possibly, the fan still stops due to duty_cycle_pwm_ is not large
+       *    enough. Continue increase the duty cycle.
+       * 2. Or the fan is running, but it's not fast enough to cool down
+       *    the unit.
+       */
+      compute_duty_cycle = duty_cycle_pwm_ + params.pwm_step;
+      if (compute_duty_cycle > params.duty_cycle_max)
+        compute_duty_cycle = params.duty_cycle_max;
+    }
+  }
+  else if (temp < (params.temp_setpt - params.temp_step)) {
+    if ((fan_speed == kFanSpeedNotSpinning) ||
+        (duty_cycle_pwm_ < params.pwm_step)) {
+      compute_duty_cycle = kPwmMinValue;
+    }
+    else {
+      /* Reduce fan pwm if temp is lower than
+       * the (temp_setpt - temp_step) and plus fan is still spinning
+       */
+      compute_duty_cycle = duty_cycle_pwm_ - params.pwm_step;
+    }
+  }
+  return compute_duty_cycle;
+}
 
 void FanControl::ComputeDutyCycle(
   uint16_t soc_temp,
   uint16_t hdd_temp,
+  uint16_t aux1_temp,
   uint16_t fan_speed,
   uint16_t *new_duty_cycle_pwm) {
 
   uint16_t  soc_compute_duty_cycle = 0;
   uint16_t  hdd_compute_duty_cycle = 0;
+  uint16_t  aux1_compute_duty_cycle = 0;
   FanControlParams  *psoc = &pfan_ctrl_params_[BRUNO_SOC];
   FanControlParams  *phdd = get_hdd_fan_ctrl_parms();
+  FanControlParams  *paux1 = get_aux1_fan_ctrl_parms();
 
   LOG(LS_VERBOSE) << __func__ << " - duty_cycle_pwm_ = " << duty_cycle_pwm_
                << " i/p soc_temp=" << soc_temp
                << " hdd_temp="     << hdd_temp
+               << " aux1_temp="    << aux1_temp
                << " fan_speed="    << fan_speed;
 
   /* check SOC temps */
   if (psoc) {
-    soc_compute_duty_cycle = duty_cycle_pwm_;
-    if (soc_temp > psoc->temp_max) {
-      soc_compute_duty_cycle = psoc->duty_cycle_max;
-    }
-    else if (soc_temp > (psoc->temp_setpt + psoc->temp_step)) {
-      if (fan_speed == kFanSpeedNotSpinning) {
-        soc_compute_duty_cycle = psoc->duty_cycle_min;
-      }
-      else if (duty_cycle_pwm_ < psoc->duty_cycle_max) {
-        /* 1. Possibly, the fan still stops due to duty_cycle_pwm_ is not large
-         *    enough. Continue increase the duty cycle.
-         * 2. Or the fan is running, but it's not fast enough to cool down
-         *    the unit.
-         */
-        soc_compute_duty_cycle = duty_cycle_pwm_ + psoc->pwm_step;
-        if (soc_compute_duty_cycle > psoc->duty_cycle_max)
-          soc_compute_duty_cycle = psoc->duty_cycle_max;
-      }
-    }
-    else if (soc_temp < (psoc->temp_setpt - psoc->temp_step)) {
-      if ((fan_speed == kFanSpeedNotSpinning) ||
-          (duty_cycle_pwm_ < psoc->pwm_step)) {
-        soc_compute_duty_cycle = kPwmMinValue;
-      }
-      else {
-        /* Reduce fan pwm if soc_temp is lower than
-         * the (temp_setpt - temp_step) and plus fan is still spinning
-         */
-        soc_compute_duty_cycle = duty_cycle_pwm_ - psoc->pwm_step;
-      }
-    }
+    soc_compute_duty_cycle = __ComputeDutyCycle(soc_temp, fan_speed, *psoc);
   }
 
   /* check HDD temps */
   if (phdd) {
-    hdd_compute_duty_cycle = duty_cycle_pwm_;
-    if (if_hdd_temp_over_temp_max(hdd_temp, phdd) == true) {
-      hdd_compute_duty_cycle = phdd->duty_cycle_max;
-    }
-    else if (if_hdd_temp_over_temp_setpt(hdd_temp, phdd) == true) {
-      if (fan_speed == kFanSpeedNotSpinning) {
-        hdd_compute_duty_cycle = phdd->duty_cycle_min;
-      }
-      else if (duty_cycle_pwm_ < phdd->duty_cycle_max) {
-        /* 1. Possibly, the fan still stops due to duty_cycle_pwm_ is not large
-         *    enough. Continue increase the duty cycle.
-         * 2. Or the fan is running, but it's not fast enough to cool down
-         *    the unit.
-         */
-        hdd_compute_duty_cycle = duty_cycle_pwm_ + phdd->pwm_step;
-        if (hdd_compute_duty_cycle > phdd->duty_cycle_max)
-          hdd_compute_duty_cycle = phdd->duty_cycle_max;
-      }
-    }
-    else if (if_hdd_temp_lower_than_temp_setpt(hdd_temp, phdd) == true) {
-      if ((fan_speed == kFanSpeedNotSpinning) ||
-          (duty_cycle_pwm_ < phdd->pwm_step)) {
-        hdd_compute_duty_cycle = kPwmMinValue;
-      }
-      else {
-        /* Reduce fan pwm if both soc_temp and hdd_temp are lower than
-         * their (temp_setpt - temp_step) and plus fan is still spinning
-         */
-        hdd_compute_duty_cycle = duty_cycle_pwm_ - phdd->pwm_step;
-      }
-    }
+    hdd_compute_duty_cycle = __ComputeDutyCycle(hdd_temp, fan_speed, *phdd);
+  }
+
+  /* check HDD temps */
+  if (paux1) {
+    aux1_compute_duty_cycle = __ComputeDutyCycle(aux1_temp, fan_speed, *paux1);
   }
 
   LOG(LS_INFO) << "soc_duty_cycle_pwm = " << soc_compute_duty_cycle << " "
-               << "hdd_duty_cycle_pwm = " << hdd_compute_duty_cycle;
+               << "hdd_duty_cycle_pwm = " << hdd_compute_duty_cycle << " "
+               << "aux1_duty_cycle_pwm = " << aux1_compute_duty_cycle;
 
   *new_duty_cycle_pwm = MAX(soc_compute_duty_cycle, hdd_compute_duty_cycle);
+  *new_duty_cycle_pwm = MAX(*new_duty_cycle_pwm, aux1_compute_duty_cycle);
 
   LOG(LS_INFO) << "new_duty_cycle_pwm = " << *new_duty_cycle_pwm;
 
@@ -548,36 +573,12 @@
   return ptr;
 }
 
-
-bool FanControl::if_hdd_temp_over_temp_max(const uint16_t hdd_temp, const FanControlParams *phdd) const {
-  bool  ret = false;  /* if no hdd params, default is false */
-  if ((phdd != NULL) && (hdd_temp > phdd->temp_max)) {
-    ret = true;
+FanControlParams *FanControl::get_aux1_fan_ctrl_parms() {
+  FanControlParams  *ptr = NULL;
+  if (platformInstance_->PlatformHasAux1() == true) {
+    ptr = &pfan_ctrl_params_[BRUNO_AUX1];
   }
-  return ret;
-}
-
-
-bool FanControl::if_hdd_temp_over_temp_setpt(const uint16_t hdd_temp, const FanControlParams *phdd) const {
-  bool  ret = false;  /* if no hdd params, default is false */
-  if ((phdd != NULL) && (hdd_temp > (phdd->temp_setpt + phdd->temp_step))) {
-    ret = true;
-  }
-  return ret;
-}
-
-
-bool FanControl::if_hdd_temp_lower_than_temp_setpt(const uint16_t hdd_temp, const FanControlParams *phdd) const {
-  bool  ret = true;   /* if no hdd params, default is true */
-  if (phdd != NULL) {
-    if (hdd_temp < (phdd->temp_setpt - phdd->temp_step)) {
-      ret = true;
-    }
-    else {
-      ret = false;
-    }
-  }
-  return ret;
+  return ptr;
 }
 
 
@@ -614,6 +615,9 @@
     case BRUNO_IS_HDD:
       buf += "_HDD";
       break;
+    case BRUNO_AUX1:
+      buf += "_AUX1";
+      break;
     default:
       buf += "_UNKNOWN";
       LOG(LS_WARNING) << "Invalid fc_index: " << fc_idx << std::endl;
diff --git a/sysmgr/peripheral/fancontrol.h b/sysmgr/peripheral/fancontrol.h
index 95ff95a..0460973 100644
--- a/sysmgr/peripheral/fancontrol.h
+++ b/sysmgr/peripheral/fancontrol.h
@@ -50,6 +50,7 @@
   enum FanControlParamsTypes {
     BRUNO_SOC = 0,
     BRUNO_IS_HDD,
+    BRUNO_AUX1,
     BRUNO_PARAMS_TYPES
   };
 
@@ -68,6 +69,7 @@
 
   static const FanControlParams kGFRG250FanCtrlSocDefaults;
   static const FanControlParams kGFRG250FanCtrlHddDefaults;
+  static const FanControlParams kGFRG250FanCtrlAux1Defaults;
 
   static const FanControlParams kGFSC100FanCtrlSocDefaults;
   static const FanControlParams kGFSC100FanCtrlHddDefaults;
@@ -93,7 +95,7 @@
   bool Init(bool *gpio_mailbox_ready);
   void Terminate(void);
   bool DrivePwm(uint16_t duty_cycle);
-  bool AdjustSpeed(uint16_t soc_temp, uint16_t hdd_temp, uint16_t fan_speed);
+  bool AdjustSpeed(uint16_t soc_temp, uint16_t hdd_temp, uint16_t aux1_temp, uint16_t fan_speed);
   void GetHddTemperature(uint16_t *phdd_temp);
   void GetOverheatTemperature(uint16_t *poverheat_temp);
 
@@ -101,7 +103,9 @@
 
   void InitParams(void);
   std::string ExecCmd(char* cmd, std::string *pattern);
-  void ComputeDutyCycle(uint16_t soc_temp, uint16_t hdd_temp,
+  uint16_t __ComputeDutyCycle(uint16_t temp, uint16_t fan_speed,
+                  FanControlParams &params);
+  void ComputeDutyCycle(uint16_t soc_temp, uint16_t hdd_temp, uint16_t aux1_temp,
                         uint16_t fan_speed, uint16_t *new_duty_cycle_pwm);
 
   void dbgUpdateFanControlParams(void);
@@ -130,9 +134,7 @@
   Platform *platformInstance_;
 
   FanControlParams *get_hdd_fan_ctrl_parms();
-  bool if_hdd_temp_over_temp_max(const uint16_t hdd_temp, const FanControlParams *phdd) const;
-  bool if_hdd_temp_over_temp_setpt(const uint16_t hdd_temp, const FanControlParams *phdd) const;
-  bool if_hdd_temp_lower_than_temp_setpt(const uint16_t hdd_temp, const FanControlParams *phdd) const;
+  FanControlParams *get_aux1_fan_ctrl_parms();
 
   DISALLOW_COPY_AND_ASSIGN(FanControl);
 };
diff --git a/sysmgr/peripheral/mailbox.cc b/sysmgr/peripheral/mailbox.cc
index 2af9e2e..d1050fd 100644
--- a/sysmgr/peripheral/mailbox.cc
+++ b/sysmgr/peripheral/mailbox.cc
@@ -10,6 +10,7 @@
 const std::string  Mailbox::kMailboxFanPercentFile = "/tmp/gpio/fanpercent";
 const std::string  Mailbox::kMailboxFanSpeedFile = "/tmp/gpio/fanspeed";
 const std::string  Mailbox::kMailboxCpuTemperatureFile = "/tmp/gpio/cpu_temperature";
+const std::string  Mailbox::kMailboxAux1TemperatureFile = "/tmp/gpio/aux1_temperature";
 const std::string  Mailbox::kMailboxCpuVoltageFile = "/tmp/gpio/cpu_voltage";
 const std::string  Mailbox::kMailboxReadyFile = "/tmp/gpio/ready";
 
@@ -50,6 +51,23 @@
 }
 
 
+/* Read AUX1 temperature
+ * rtn = true, aux1_temperature - current AUX1 temperature
+ *       false aux1_temperature - an invalid value
+ */
+bool Mailbox::ReadAux1Temperature(float *aux1_temperature) {
+  std::string value_str;
+  bool  rtn;
+
+  *aux1_temperature = 0.0;
+  rtn = ReadValueString(kMailboxAux1TemperatureFile, &value_str);
+  if (rtn == true) {
+    rtn = ConvertStringToFloat(value_str, aux1_temperature);
+  }
+  return rtn;
+}
+
+
 /* Read CPU voltage
  *
  * Return:
diff --git a/sysmgr/peripheral/mailbox.h b/sysmgr/peripheral/mailbox.h
index 5ea3a43..c680ecf 100644
--- a/sysmgr/peripheral/mailbox.h
+++ b/sysmgr/peripheral/mailbox.h
@@ -39,6 +39,7 @@
   static const std::string  kMailboxFanPercentFile;
   static const std::string  kMailboxFanSpeedFile;
   static const std::string  kMailboxCpuTemperatureFile;
+  static const std::string  kMailboxAux1TemperatureFile;
   static const std::string  kMailboxCpuVoltageFile;
   static const std::string  kMailboxReadyFile;
 
@@ -47,6 +48,7 @@
 
   bool ReadFanSpeed(uint16_t *fan_speed);
   bool ReadSocTemperature(float *soc_temperature);
+  bool ReadAux1Temperature(float *soc_temperature);
   bool ReadSocVoltage(std::string *soc_voltage);
   bool WriteFanDutyCycle(uint16_t duty_cycle);
   bool ReadFanDutyCycle(uint16_t *duty_cycle);
diff --git a/sysmgr/peripheral/peripheralmon.cc b/sysmgr/peripheral/peripheralmon.cc
index 5f520ac..07d5503 100644
--- a/sysmgr/peripheral/peripheralmon.cc
+++ b/sysmgr/peripheral/peripheralmon.cc
@@ -17,6 +17,7 @@
 void PeripheralMon::Probe(void) {
   bruno_base::TimeStamp now = bruno_base::Time();
   float soc_temperature;
+  float aux1_temperature = 0.0;
   uint16_t  fan_speed = 0;
   std::string soc_voltage;
 
@@ -27,6 +28,10 @@
     next_time_hdd_temp_check_ = bruno_base::TimeAfter(hdd_temp_interval_);
   }
 
+  if (platform_->PlatformHasAux1()) {
+    ReadAux1Temperature(&aux1_temperature);
+  }
+
   if (gpio_mailbox_ready == false)
     gpio_mailbox_ready = CheckIfMailBoxIsReady();
 
@@ -41,6 +46,7 @@
     LOG(LS_INFO) << "voltage:" << soc_voltage
                  << "  soc_temperature:" << soc_temperature
                  << "  hdd_temperature:" << hdd_temp_
+                 << "  aux1_temperature:" << aux1_temperature
                  << "  fanspeed:" << fan_speed;
 
     if (read_soc_temperature) {
@@ -53,6 +59,7 @@
         fan_control_->AdjustSpeed(
                       static_cast<uint16_t>(soc_temperature),
                       hdd_temp_,
+                      aux1_temperature,
                       fan_speed);
       } else {
         LOG(LS_INFO) << "Not change PWM due to fail to read soc_temperature";
diff --git a/sysmgr/peripheral/platform.cc b/sysmgr/peripheral/platform.cc
index 0d206b6..a7ba418 100644
--- a/sysmgr/peripheral/platform.cc
+++ b/sysmgr/peripheral/platform.cc
@@ -9,18 +9,18 @@
 
 /* Platform table */
 const Platform Platform::kPlatformTable[] = {
-         /* model     type           hdd    fan */
-  Platform("GFMS100", BRUNO_GFMS100, true,  true),
-  Platform("GFHD100", BRUNO_GFHD100, false, true),
-  Platform("GFHD200", BRUNO_GFHD200, false, false),
-  Platform("GFRG200", BRUNO_GFRG200, false, true),
-  Platform("GFRG210", BRUNO_GFRG210, true,  true),
-  Platform("GFRG250", BRUNO_GFRG250, true,  true),
-  Platform("GFSC100", BRUNO_GFSC100, true,  true),
-  Platform("GFLT110", BRUNO_GFLT110, false, false),
-  Platform("GFLT120", BRUNO_GFLT110, false, false),
-  Platform("GFHD254", BRUNO_GFHD254, false, true),
-  Platform("UNKNOWN PLATFORM", BRUNO_UNKNOWN, false, false),
+         /* model     type           hdd    aux1   fan */
+  Platform("GFMS100", BRUNO_GFMS100, true,  false, true),
+  Platform("GFHD100", BRUNO_GFHD100, false, false, true),
+  Platform("GFHD200", BRUNO_GFHD200, false, false, false),
+  Platform("GFRG200", BRUNO_GFRG200, false, false, true),
+  Platform("GFRG210", BRUNO_GFRG210, true,  false, true),
+  Platform("GFRG250", BRUNO_GFRG250, true,  true,  true),
+  Platform("GFSC100", BRUNO_GFSC100, true,  false, true),
+  Platform("GFLT110", BRUNO_GFLT110, false, false, false),
+  Platform("GFLT120", BRUNO_GFLT110, false, false, false),
+  Platform("GFHD254", BRUNO_GFHD254, false, false, true),
+  Platform("UNKNOWN PLATFORM", BRUNO_UNKNOWN, false, false,  false),
 };
 
 void Platform::Init(void) {
@@ -39,6 +39,7 @@
       name_ = kPlatformTable[i].name_;
       type_ = kPlatformTable[i].type_;
       has_hdd_ = kPlatformTable[i].has_hdd_;
+      has_aux1_ = kPlatformTable[i].has_aux1_;
       has_fan_ = kPlatformTable[i].has_fan_;
       break;
     }
diff --git a/sysmgr/peripheral/platform.h b/sysmgr/peripheral/platform.h
index 642a57a..c4bfb55 100644
--- a/sysmgr/peripheral/platform.h
+++ b/sysmgr/peripheral/platform.h
@@ -33,11 +33,13 @@
 
  public:
   explicit Platform()
-      : name_("Unknown"), type_(BRUNO_UNKNOWN), has_hdd_(false), has_fan_(false) {}
+      : name_("Unknown"), type_(BRUNO_UNKNOWN), has_hdd_(false),
+        has_aux1_(false), has_fan_(false) {}
 
   Platform(const std::string& name, BrunoPlatformTypes type, bool has_hdd,
-           bool has_fan)
-      : name_(name), type_(type), has_hdd_(has_hdd), has_fan_(has_fan) {}
+           bool has_aux1, bool has_fan)
+      : name_(name), type_(type), has_hdd_(has_hdd), has_aux1_(has_aux1),
+        has_fan_(has_fan) {}
 
   virtual ~Platform() {}
 
@@ -48,12 +50,14 @@
   enum BrunoPlatformTypes PlatformType(void) const { return type_; }
   bool PlatformHasHdd(void) const { return has_hdd_; }
   bool PlatformHasFan(void) const { return has_fan_; }
+  bool PlatformHasAux1(void) const { return has_aux1_; }
   std::string GetLine(char *file, std::string *pattern);
 
  private:
   std::string name_;
   BrunoPlatformTypes type_;
   bool has_hdd_;
+  bool has_aux1_;
   bool has_fan_;
 
   void GetPlatformType(void);
diff --git a/sysmgr/utest/test_fan.cc b/sysmgr/utest/test_fan.cc
index fe228d3..8907595 100644
--- a/sysmgr/utest/test_fan.cc
+++ b/sysmgr/utest/test_fan.cc
@@ -20,6 +20,8 @@
   DEFINE_int(soc_high, 10, "SOC High temperature");
   DEFINE_int(hdd_low, 1, "HDD Low temperature");
   DEFINE_int(hdd_high, 10, "HDD High temperature");
+  DEFINE_int(aux1_low, 1, "AUX1 Low temperature");
+  DEFINE_int(aux1_high, 10, "AUX1 High temperature");
   DEFINE_int(percent, 0, "Percentage of the maximum speed the fan starts at");
   DEFINE_int(count, 10, "Repeat times");
   DEFINE_int(interval, 1, "Interval");
@@ -45,7 +47,7 @@
   }
 
   bruno_platform_peripheral::Platform platform(
-      "Unknown", bruno_platform_peripheral::BRUNO_UNKNOWN, false, false);
+      "Unknown", bruno_platform_peripheral::BRUNO_UNKNOWN, false, false, false);
   platform.Init();
   bruno_platform_peripheral::FanControl fan_control(&platform);
 
@@ -56,38 +58,43 @@
   fan_control.DrivePwm(FLAG_percent);
   sleep(2);
 
-  int i, h;
+  int i, h, g;
 
   LOG(LS_VERBOSE) << "soc_low=" << FLAG_soc_low << " soc_high=" << FLAG_soc_high
-                  << " hdd_low=" << FLAG_hdd_low << " hdd_high=" << FLAG_hdd_high;
+                  << " hdd_low=" << FLAG_hdd_low << " hdd_high=" << FLAG_hdd_high
+                  << " aux1_low=" << FLAG_aux1_low << " aux1_high=" << FLAG_aux1_high;
 
-  for (i=FLAG_soc_low, h=FLAG_hdd_low;
-       ((i<FLAG_soc_high) || (h<FLAG_hdd_high)); i++, h++) {
+  for (i=FLAG_soc_low, h=FLAG_hdd_low, g=FLAG_aux1_low;
+       ((i<FLAG_soc_high) || (h<FLAG_hdd_high) || (g<FLAG_aux1_high));
+       i++, h++, g++) {
     for (int j=0; j<FLAG_count; ++j) {
       fan_control.ReadFanSpeed(&fan_speed);
       fan_control.AdjustSpeed(
-                  static_cast<uint16_t>(i), static_cast<uint16_t>(h), fan_speed);
+                  static_cast<uint16_t>(i), static_cast<uint16_t>(h), static_cast<uint16_t>(g), fan_speed);
       fan_control.ReadFanSpeed(&fan_speed);
       fan_control.ReadSocVoltage(&soc_voltage);
       LOG(LS_INFO) << "voltage:" << soc_voltage
                    << "  emu-soc_temperature:" << i
                    << "  emu-hdd_temperature:" << h
+                   << "  emu-aux1_temperature:" << g
                    << "  fanspeed:" << fan_speed;
       sleep(FLAG_interval);
     }
   }
   if (FLAG_dec_temp == true) {
-    for (i=FLAG_soc_high, h=FLAG_hdd_high;
-         ((i>FLAG_soc_low) || (h>FLAG_hdd_low)); i--, h--) {
+    for (i=FLAG_soc_high, h=FLAG_hdd_high, g=FLAG_aux1_high;
+         ((i>FLAG_soc_low) || (h>FLAG_hdd_low) || (g>FLAG_aux1_low));
+          i--, h--, g--) {
       for (int j=0; j<FLAG_count; ++j) {
         fan_control.ReadFanSpeed(&fan_speed);
         fan_control.AdjustSpeed(
-                    static_cast<uint16_t>(i), static_cast<uint16_t>(h), fan_speed);
+                    static_cast<uint16_t>(i), static_cast<uint16_t>(h), static_cast<uint16_t>(g), fan_speed);
         fan_control.ReadFanSpeed(&fan_speed);
         fan_control.ReadSocVoltage(&soc_voltage);
         LOG(LS_INFO) << "voltage:" << soc_voltage
                      << "  emu-soc_temperature:" << i
                      << "  emu-hdd_temperature:" << h
+                     << "  emu-aux1_temperature:" << g
                      << "  fanspeed:" << fan_speed;
         sleep(FLAG_interval);
       }