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>
This commit is contained in:
Ted Kuo 2015-03-18 10:42:22 +08:00 committed by Martin Roth
parent 4f3d400a30
commit 4e8f23b896
3 changed files with 59 additions and 0 deletions

View File

@ -18,6 +18,7 @@
#define SUPERIO_ITE_IT8772F_CHIP_H #define SUPERIO_ITE_IT8772F_CHIP_H
#include <device/device.h> #include <device/device.h>
#include "it8772f.h"
struct superio_ite_it8772f_config { struct superio_ite_it8772f_config {
/* GPIO SimpleIO register values via devicetree.cb */ /* GPIO SimpleIO register values via devicetree.cb */
@ -36,6 +37,12 @@ struct superio_ite_it8772f_config {
*/ */
u8 peci_tmpin; u8 peci_tmpin;
/*
* Enable thermal mode on tmpinx.
*/
enum thermal_mode tmpin1_mode;
enum thermal_mode tmpin2_mode;
/* /*
* Enable a FAN for sofware control. * Enable a FAN for sofware control.
*/ */

View File

@ -17,6 +17,13 @@
#ifndef SUPERIO_ITE_IT8772F_H #ifndef SUPERIO_ITE_IT8772F_H
#define SUPERIO_ITE_IT8772F_H #define SUPERIO_ITE_IT8772F_H
/* Supported thermal mode on TMPINx */
enum thermal_mode {
THERMAL_MODE_DISABLED = 0,
THERMAL_DIODE,
THERMAL_RESISTOR,
};
#define IT8772F_FDC 0x00 /* Floppy disk controller */ #define IT8772F_FDC 0x00 /* Floppy disk controller */
#define IT8772F_SP1 0x01 /* Com1 */ #define IT8772F_SP1 0x01 /* Com1 */
#define IT8772F_EC 0x04 /* Environment controller */ #define IT8772F_EC 0x04 /* Environment controller */
@ -26,6 +33,7 @@
#define IT8772F_IR 0x0a /* Consumer IR */ #define IT8772F_IR 0x0a /* Consumer IR */
/* Environmental Controller interface */ /* Environmental Controller interface */
#define IT8772F_CONFIGURATION 0x00
#define IT8772F_INTERFACE_SELECT 0x0a #define IT8772F_INTERFACE_SELECT 0x0a
#define IT8772F_INTERFACE_PSEUDO_EOC (1 << 7) #define IT8772F_INTERFACE_PSEUDO_EOC (1 << 7)
#define IT8772F_INTERFACE_SMB_ENABLE (1 << 6) #define IT8772F_INTERFACE_SMB_ENABLE (1 << 6)

View File

@ -16,6 +16,7 @@
#include <device/device.h> #include <device/device.h>
#include <device/pnp.h> #include <device/pnp.h>
#include <console/console.h>
#include <pc80/keyboard.h> #include <pc80/keyboard.h>
#include <arch/io.h> #include <arch/io.h>
#include <delay.h> #include <delay.h>
@ -96,6 +97,43 @@ static void it8772f_enable_peci(struct resource *res, int tmpin)
(tmpin & 3) << 6); (tmpin & 3) << 6);
} }
/*
* 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 * Setup a FAN PWM interface for software control
*/ */
@ -160,6 +198,12 @@ static void it8772f_init(struct device *dev)
/* Enable PECI if configured */ /* Enable PECI if configured */
it8772f_enable_peci(res, conf->peci_tmpin); 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 */ /* Enable FANx if configured */
if (conf->fan1_enable) if (conf->fan1_enable)
it8772f_enable_fan(res, 1); it8772f_enable_fan(res, 1);