summaryrefslogtreecommitdiff
path: root/src/superio/ite/it8772f/superio.c
diff options
context:
space:
mode:
authorTed Kuo <tedkuo@ami.com.tw>2015-03-18 10:42:22 +0800
committerMartin Roth <martinroth@google.com>2015-12-31 17:39:47 +0100
commit4e8f23b896fe31851c26e056ee55fb8191419fa0 (patch)
tree80c543d02b8f6843e76e65f1eac3dd25324db06b /src/superio/ite/it8772f/superio.c
parent4f3d400a30247b7795254517078529d070f4129f (diff)
superio/it8772f: Add switch to enable HWM (Hardware Monitor)
Set up External Temperature to read via thermal diode/resistor into TMPINx register by setting thermal_mode switch. Original-Signed-off-by: Ted Kuo <tedkuo@ami.com.tw> Change-Id: I0e8621b92faa5c6246e009d2f852c8d4db484034 Original-Reviewed-on: https://chromium-review.googlesource.com/260545 Original-Reviewed-by: Shawn N <shawnn@chromium.org> Original-Tested-by: Ted Kuo <tedkuo@ami.com.tw> Original-(cherry picked from commit 973e2d393f2595b756f8aa20f6fbe3b6e045621a) Original-Reviewed-on: https://chromium-review.googlesource.com/262340 Signed-off-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-on: https://review.coreboot.org/12798 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Diffstat (limited to 'src/superio/ite/it8772f/superio.c')
-rw-r--r--src/superio/ite/it8772f/superio.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/superio/ite/it8772f/superio.c b/src/superio/ite/it8772f/superio.c
index 7079b1a829..2d897d83ba 100644
--- a/src/superio/ite/it8772f/superio.c
+++ b/src/superio/ite/it8772f/superio.c
@@ -16,6 +16,7 @@
#include <device/device.h>
#include <device/pnp.h>
+#include <console/console.h>
#include <pc80/keyboard.h>
#include <arch/io.h>
#include <delay.h>
@@ -97,6 +98,43 @@ static void it8772f_enable_peci(struct resource *res, int tmpin)
}
/*
+ * Set up External Temperature to read via thermal diode/resistor
+ * into TMPINx register
+ */
+static void it8772f_enable_tmpin(struct resource *res, int tmpin,
+ enum thermal_mode mode)
+{
+ u8 reg;
+
+ if (tmpin != 1 && tmpin != 2)
+ return;
+
+ reg = it8772f_envc_read(res, IT8772F_ADC_TEMP_CHANNEL_ENABLE);
+
+ switch (mode) {
+ case THERMAL_DIODE:
+ /* Thermal Diode Mode */
+ it8772f_envc_write(res, IT8772F_ADC_TEMP_CHANNEL_ENABLE,
+ reg | tmpin);
+ break;
+ case THERMAL_RESISTOR:
+ /* Thermal Resistor Mode */
+ it8772f_envc_write(res, IT8772F_ADC_TEMP_CHANNEL_ENABLE,
+ reg | (tmpin << 3));
+ break;
+ default:
+ printk(BIOS_ERR, "Unsupported thermal mode 0x%x on TMPIN%d\n",
+ mode, tmpin);
+ return;
+ }
+
+ reg = it8772f_envc_read(res, IT8772F_CONFIGURATION);
+
+ /* Enable the startup of monitoring operation */
+ it8772f_envc_write(res, IT8772F_CONFIGURATION, reg | 0x01);
+}
+
+/*
* Setup a FAN PWM interface for software control
*/
static void it8772f_enable_fan(struct resource *res, int fan)
@@ -160,6 +198,12 @@ static void it8772f_init(struct device *dev)
/* Enable PECI if configured */
it8772f_enable_peci(res, conf->peci_tmpin);
+ /* Enable HWM if configured */
+ if (conf->tmpin1_mode != THERMAL_MODE_DISABLED)
+ it8772f_enable_tmpin(res, 1, conf->tmpin1_mode);
+ if (conf->tmpin2_mode != THERMAL_MODE_DISABLED)
+ it8772f_enable_tmpin(res, 2, conf->tmpin2_mode);
+
/* Enable FANx if configured */
if (conf->fan1_enable)
it8772f_enable_fan(res, 1);