Maxim Polyakov has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/39766 )
Change subject: drivers/i2c/nct7802y: configure local temp sensor [WIP] ......................................................................
drivers/i2c/nct7802y: configure local temp sensor [WIP]
According to the documentation[1], the Mode Selection Register sets the operation mode of the local temperature sensors. The patch allows to do this from a tree of devices for a board that uses uses this HWM.
[1] page 30, section 7.2.32, Nuvoton Hardware Monitoring IC NCT7802Y with PECI 3.0 interface, datasheet, revision 1.2, february 2012
Change-Id: I28cc4e5cae76cf0bcdad26a50ee6cd43a201d31e --- M src/drivers/i2c/nct7802y/chip.h M src/drivers/i2c/nct7802y/nct7802y.h M src/drivers/i2c/nct7802y/nct7802y_fan.c 3 files changed, 33 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/66/39766/1
diff --git a/src/drivers/i2c/nct7802y/chip.h b/src/drivers/i2c/nct7802y/chip.h index adff0f5..693cc41 100644 --- a/src/drivers/i2c/nct7802y/chip.h +++ b/src/drivers/i2c/nct7802y/chip.h @@ -19,6 +19,13 @@ #define NCT7802Y_PECI_CNT 2 #define NCT7802Y_FAN_CNT 3
+enum nct7802y_sensor_mode_type { + RTD_CLOSED = 0, + RTD_CURRENT_MODE, + RTD_THERMISTOR_MODE, + RTD_VOLTAGE_MODE, +}; + enum nct7802y_peci_mode { PECI_DISABLED = 0, PECI_DOMAIN_0, @@ -64,6 +71,14 @@ TEMP_SOURCE_PROGRAMMABLE_1, };
+/* Local temperature sensor configuration */ +struct nct7802y_sensor_mode_selection { + bool local_temp_sensor_enable; + enum nct7802y_sensor_mode_type rtd3_md; + enum nct7802y_sensor_mode_type rtd2_md; + enum nct7802y_sensor_mode_type rtd1_md; +}; + struct nct7802y_fan_smartconfig { enum nct7802y_fan_smartmode mode; enum nct7802y_fan_speed speed; @@ -85,6 +100,7 @@
/* Implements only those parts currently used by coreboot mainboards. */ struct drivers_i2c_nct7802y_config { + struct nct7802y_sensor_mode_selection sensor_mode; struct nct7802y_peci_config peci[NCT7802Y_PECI_CNT]; struct nct7802y_fan_config fan[NCT7802Y_FAN_CNT]; enum nct7802y_fan_pecierror on_pecierror; diff --git a/src/drivers/i2c/nct7802y/nct7802y.h b/src/drivers/i2c/nct7802y/nct7802y.h index 9f3aaef..a105fea 100644 --- a/src/drivers/i2c/nct7802y/nct7802y.h +++ b/src/drivers/i2c/nct7802y/nct7802y.h @@ -23,6 +23,15 @@
/* Bank 0 */
+#define MODE_SELECTION 0x22 +#define MODE_SELECTION_EN_LTD(x) (x << 6) +#define MODE_SELECTION_RTD3_MD(x) (x << 4) +#define MODE_SELECTION_RTD2_MD(x) (x << 2) +#define MODE_SELECTION_RTD1_MD(x) (x) + +#define PECI_ENABLE 0x23 +#define PECI_ENABLE_AGENTx(x) (1 << (x)) + #define PECI_ENABLE 0x23 #define PECI_ENABLE_AGENTx(x) (1 << (x))
diff --git a/src/drivers/i2c/nct7802y/nct7802y_fan.c b/src/drivers/i2c/nct7802y/nct7802y_fan.c index d7cfb90..1193bb9 100644 --- a/src/drivers/i2c/nct7802y/nct7802y_fan.c +++ b/src/drivers/i2c/nct7802y/nct7802y_fan.c @@ -89,6 +89,14 @@ init_fan(dev, &config->fan[i], i); }
+ if (config->sensor_mode.local_temp_sensor_enable) { + nct7802y_write(dev, MODE_SELECTION, + MODE_SELECTION_EN_LTD(config->sensor_mode.local_temp_sensor_enable) | + MODE_SELECTION_RTD3_MD(config->sensor_mode.rtd3_md) | + MODE_SELECTION_RTD2_MD(config->sensor_mode.rtd2_md) | + MODE_SELECTION_RTD1_MD(config->sensor_mode.rtd1_md)); + } + switch (config->on_pecierror) { case PECI_ERROR_KEEP: set = CLOSE_LOOP_FAN_PECI_ERR_CURR;