<p>Vagiz Tarkhanov has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/21843">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">superio/ite/common: Add temperature offset<br><br>Add devicetree options to set temperature adjustment registers<br>required for thermal diode sensors and PECI.<br><br>Without these adjustmets thermal diode sensors and PECI display raw<br>values. For PECI it means negative temperatures.<br><br>I'd gladly update TMPINx shorthands to FANx format, but many boards<br>already assume that TMPINx set mode.<br><br>Change-Id: Ibce6809ca86b6c7c0c696676e309665fc57965d4<br>Signed-off-by: Vagiz Tarkhanov <rakkin@autistici.org><br>---<br>M src/superio/ite/common/env_ctrl.c<br>M src/superio/ite/common/env_ctrl.h<br>M src/superio/ite/common/env_ctrl_chip.h<br>3 files changed, 47 insertions(+), 12 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/43/21843/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/superio/ite/common/env_ctrl.c b/src/superio/ite/common/env_ctrl.c<br>index 1e313ce..5f216c1 100644<br>--- a/src/superio/ite/common/env_ctrl.c<br>+++ b/src/superio/ite/common/env_ctrl.c<br>@@ -99,13 +99,13 @@<br>  * into TMPINx register<br>  */<br> static void enable_tmpin(const u16 base, const u8 tmpin,<br>-                      const enum ite_ec_thermal_mode mode)<br>+                         const struct ite_ec_thermal_config *const conf)<br> {<br>  u8 reg;<br> <br>    reg = ite_ec_read(base, ITE_EC_ADC_TEMP_CHANNEL_ENABLE);<br> <br>-  switch (mode) {<br>+      switch (conf->mode) {<br>      case THERMAL_DIODE:<br>           reg |= ITE_EC_ADC_TEMP_DIODE_MODE(tmpin);<br>             break;<br>@@ -115,11 +115,17 @@<br>         default:<br>              printk(BIOS_WARNING,<br>                 "Unsupported thermal mode 0x%x on TMPIN%d\n",<br>-                      mode, tmpin);<br>+                conf->mode, tmpin);<br>                 return;<br>       }<br> <br>  ite_ec_write(base, ITE_EC_ADC_TEMP_CHANNEL_ENABLE, reg);<br>+<br>+  /* Set temperature offsets */<br>+        reg = ite_ec_read(base, ITE_EC_BEEP_ENABLE);<br>+ reg |= ITE_EC_TEMP_ADJUST_WRITE_ENABLE;<br>+      ite_ec_write(base, ITE_EC_BEEP_ENABLE, reg);<br>+ ite_ec_write(base, ITE_EC_TEMP_ADJUST[tmpin-1], conf->offset);<br> <br>  /* Enable the startup of monitoring operation */<br>      reg = ite_ec_read(base, ITE_EC_CONFIGURATION);<br>@@ -233,7 +239,7 @@<br> <br>        /* Enable HWM if configured */<br>        for (i = 0; i < ITE_EC_TMPIN_CNT; ++i)<br>-            enable_tmpin(base, i + 1, conf->tmpin_mode[i]);<br>+           enable_tmpin(base, i + 1, &conf->tmpin[i]);<br> <br>         /* Enable reading of voltage pins */<br>  ite_ec_write(base, ITE_EC_ADC_VOLTAGE_CHANNEL_ENABLE, conf->vin_mask);<br>diff --git a/src/superio/ite/common/env_ctrl.h b/src/superio/ite/common/env_ctrl.h<br>index fa13116..1be6436 100644<br>--- a/src/superio/ite/common/env_ctrl.h<br>+++ b/src/superio/ite/common/env_ctrl.h<br>@@ -93,6 +93,26 @@<br> #define   ITE_EC_ADC_TEMP_DIODE_MODE(x)            (1 << ((x)-1))<br> #define ITE_EC_ADC_TEMP_EXTRA_CHANNEL_ENABLE     0x55<br> <br>+/* Matches length of ITE_EC_TMPIN_CNT */<br>+static const u8 ITE_EC_TEMP_ADJUST[] = { 0x56, 0x57, 0x59 };<br>+<br>+#define ITE_EC_BEEP_ENABLE                       0x5C<br>+#define   ITE_EC_TEMP_ADJUST_WRITE_ENABLE        (1 << 7)<br>+#define   ITE_EC_ADC_CLOCK_1MHZ                        (6 << 4)<br>+#define   ITE_EC_ADC_CLOCK_2MHZ                        (7 << 4)<br>+#define   ITE_EC_ADC_CLOCK_24MHZ               (5 << 4)<br>+#define   ITE_EC_ADC_CLOCK_31KHZ               (4 << 4)<br>+#define   ITE_EC_ADC_CLOCK_62KHZ               (3 << 4)<br>+#define   ITE_EC_ADC_CLOCK_125KHZ              (2 << 4)<br>+#define   ITE_EC_ADC_CLOCK_250KHZ              (1 << 4)<br>+#define   ITE_EC_ADC_CLOCK_500KHZ              (0 << 4)<br>+#define   ITE_EC_BEEP_ON_TMP_LIMIT             (1 << 2)<br>+#define   ITE_EC_BEEP_ON_VIN_LIMIT             (1 << 1)<br>+#define   ITE_EC_BEEP_ON_FAN_LIMIT             (1 << 0)<br>+#define ITE_EC_BEEP_FREQ_DIV_OF_FAN            0x5D<br>+#define ITE_EC_BEEP_FREQ_DIV_OF_VOLT             0x5E<br>+#define ITE_EC_BEEP_FREQ_DIV_OF_TEMP             0x5F<br>+<br> #define ITE_EC_FAN_CTL_TEMP_LIMIT_OFF(x)      (0x60 + ((x)-1) * 8)<br> #define ITE_EC_FAN_CTL_TEMP_LIMIT_START(x)       (0x61 + ((x)-1) * 8)<br> #define ITE_EC_FAN_CTL_TEMP_LIMIT_FULL(x)        (0x62 + ((x)-1) * 8)<br>diff --git a/src/superio/ite/common/env_ctrl_chip.h b/src/superio/ite/common/env_ctrl_chip.h<br>index f01c574..a1bb89d 100644<br>--- a/src/superio/ite/common/env_ctrl_chip.h<br>+++ b/src/superio/ite/common/env_ctrl_chip.h<br>@@ -28,6 +28,12 @@<br>     THERMAL_RESISTOR,<br> };<br> <br>+struct ite_ec_thermal_config {<br>+   enum ite_ec_thermal_mode mode;<br>+       /* Offset is used for diode sensors and PECI */<br>+      u8 offset;<br>+};<br>+<br> /* Bit mask for voltage pins VINx */<br> enum ite_ec_voltage_pin {<br>         VIN0 = 0x01,<br>@@ -74,25 +80,28 @@<br>     u8 peci_tmpin;<br> <br>     /*<br>-    * Enable thermal mode on TMPINx.<br>-     */<br>-  enum ite_ec_thermal_mode tmpin_mode[ITE_EC_TMPIN_CNT];<br>-<br>-    /*<br>     * Enable reading of voltage pins VINx.<br>        */<br>   enum ite_ec_voltage_pin vin_mask;<br> <br>  /*<br>+    * Enable temperature sensors in given mode.<br>+  */<br>+  struct ite_ec_thermal_config tmpin[ITE_EC_TMPIN_CNT];<br>+<br>+     /*<br>     * Enable a FAN in given mode.<br>         */<br>   struct ite_ec_fan_config fan[ITE_EC_FAN_CNT];<br>+<br>+     /* FIXME: enable beep when exceeding TMPIN, VIN, FAN limits */<br> };<br> <br> /* Some shorthands for device trees */<br>-#define TMPIN1        ec.tmpin_mode[0]<br>-#define TMPIN2       ec.tmpin_mode[1]<br>-#define TMPIN3       ec.tmpin_mode[2]<br>+#define TMPIN1       ec.tmpin[0].mode<br>+#define TMPIN2       ec.tmpin[1].mode<br>+#define TMPIN3       ec.tmpin[2].mode<br>+<br> #define FAN1      ec.fan[0]<br> #define FAN2        ec.fan[1]<br> #define FAN3        ec.fan[2]<br></pre><p>To view, visit <a href="https://review.coreboot.org/21843">change 21843</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/21843"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ibce6809ca86b6c7c0c696676e309665fc57965d4 </div>
<div style="display:none"> Gerrit-Change-Number: 21843 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Vagiz Tarkhanov <rakkin@autistici.org> </div>