aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxim Polyakov <max.senia.poliak@gmail.com>2020-06-20 17:26:21 +0300
committerNico Huber <nico.h@gmx.de>2020-10-11 11:24:19 +0000
commitfb623a02c5a4d2258afef9b7c9fa7f2166ee0428 (patch)
tree920a25c9a393444ea132b4279f2d74cc96b350d1 /src
parent7b27f4b62fc2302cfe7018829780bdfabea5d35e (diff)
drivers/i2c/nct7802y: Configure remote diodes and local sensor
The patch allows to configure sensors with a remote diode connected and a on-chip local temperature sensor from the devicetree for the board that uses this HWM. According to the documentation [1], this is done by setting the corresponding bits in the Mode Selection Register (22h). It is necessary for some Intel processors (Apollo Lake SoC) that do not support PECI and the CPU temperature is taken from the thermistor. TEST = After loading the nct7802 module on the Kontron mAL-10 [2] with Linux OS, we can see configuration of the HWM with one sensor in the thermistor mode: user@user-apl:~$ sensors coretemp-isa-0000 Adapter: ISA adapter Package id 0: +41.0°C (high = +110.0°C, crit = +110.0°C) Core 0: +40.0°C (high = +110.0°C, crit = +110.0°C) Core 1: +40.0°C (high = +110.0°C, crit = +110.0°C) Core 2: +41.0°C (high = +110.0°C, crit = +110.0°C) Core 3: +41.0°C (high = +110.0°C, crit = +110.0°C) nct7802-i2c-0-2e Adapter: SMBus CMI adapter cmi in0: +3.35 V (min = +0.00 V, max = +4.09 V) in1: +1.92 V in3: +1.21 V (min = +0.00 V, max = +2.05 V) in4: +1.68 V (min = +0.00 V, max = +2.05 V) fan1: 0 RPM (min = 0 RPM) fan2: 868 RPM (min = 0 RPM) fan3: 0 RPM (min = 0 RPM) temp1: +42.5°C (low = +0.0°C, high = +85.0°C) (crit = +100.0°C) sensor = thermistor temp4: +44.0°C (low = +0.0°C, high = +85.0°C) (crit = +100.0°C) temp6: +0.0°C [1] page 30, section 7.2.32, Nuvoton Hardware Monitoring IC NCT7802Y with PECI 3.0 interface, datasheet, revision 1.2, february 2012 [2] https://review.coreboot.org/c/coreboot/+/39133 Change-Id: I28cc4e5cae76cf0bcdad26a50ee6cd43a201d31e Signed-off-by: Maxim Polyakov <max.senia.poliak@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/39766 Reviewed-by: Werner Zeh <werner.zeh@siemens.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r--src/drivers/i2c/nct7802y/chip.h15
-rw-r--r--src/drivers/i2c/nct7802y/nct7802y.h3
-rw-r--r--src/drivers/i2c/nct7802y/nct7802y_fan.c20
3 files changed, 31 insertions, 7 deletions
diff --git a/src/drivers/i2c/nct7802y/chip.h b/src/drivers/i2c/nct7802y/chip.h
index 925dca1eae..03c464af82 100644
--- a/src/drivers/i2c/nct7802y/chip.h
+++ b/src/drivers/i2c/nct7802y/chip.h
@@ -7,6 +7,15 @@
#define NCT7802Y_PECI_CNT 2
#define NCT7802Y_FAN_CNT 3
+#define NCT7802Y_RTD_CNT 3
+
+/* Remote temperature diode sensors mode */
+enum nct7802y_rtd_mode {
+ RTD_CLOSED = 0,
+ RTD_CURRENT_MODE,
+ RTD_THERMISTOR_MODE,
+ RTD_VOLTAGE_MODE,
+};
enum nct7802y_peci_mode {
PECI_DISABLED = 0,
@@ -53,6 +62,11 @@ enum nct7802y_temp_source {
TEMP_SOURCE_PROGRAMMABLE_1,
};
+struct nct7802y_sensors_config {
+ bool local_enable;
+ enum nct7802y_rtd_mode rtd[NCT7802Y_RTD_CNT];
+};
+
struct nct7802y_fan_smartconfig {
enum nct7802y_fan_smartmode mode;
enum nct7802y_fan_speed speed;
@@ -76,6 +90,7 @@ struct nct7802y_fan_config {
struct drivers_i2c_nct7802y_config {
struct nct7802y_peci_config peci[NCT7802Y_PECI_CNT];
struct nct7802y_fan_config fan[NCT7802Y_FAN_CNT];
+ struct nct7802y_sensors_config sensors;
enum nct7802y_fan_pecierror on_pecierror;
u8 pecierror_minduty;
};
diff --git a/src/drivers/i2c/nct7802y/nct7802y.h b/src/drivers/i2c/nct7802y/nct7802y.h
index aa07e7082e..d9b5878c67 100644
--- a/src/drivers/i2c/nct7802y/nct7802y.h
+++ b/src/drivers/i2c/nct7802y/nct7802y.h
@@ -11,6 +11,9 @@
#define BANK_SELECT 0x00
/* Bank 0 */
+#define MODE_SELECTION 0x22
+#define MODE_SELECTION_LTD_EN (1 << 6)
+#define MODE_SELECTION_RTDx(x, val) ((val) << (x) * 2)
#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 7771b78808..a608802c7b 100644
--- a/src/drivers/i2c/nct7802y/nct7802y_fan.c
+++ b/src/drivers/i2c/nct7802y/nct7802y_fan.c
@@ -68,7 +68,7 @@ void nct7802y_init_fan(struct device *const dev)
{
const struct drivers_i2c_nct7802y_config *const config = dev->chip_info;
unsigned int i;
- u8 set;
+ u8 value;
if (nct7802y_select_bank(dev, 0) != CB_SUCCESS)
return;
@@ -78,21 +78,27 @@ void nct7802y_init_fan(struct device *const dev)
init_fan(dev, &config->fan[i], i);
}
+ value = 0;
+ for (i = 0; i < NCT7802Y_RTD_CNT; ++i)
+ value |= MODE_SELECTION_RTDx(i, config->sensors.rtd[i]);
+ if (config->sensors.local_enable)
+ value |= MODE_SELECTION_LTD_EN;
+ nct7802y_write(dev, MODE_SELECTION, value);
+
switch (config->on_pecierror) {
case PECI_ERROR_KEEP:
- set = CLOSE_LOOP_FAN_PECI_ERR_CURR;
+ value = CLOSE_LOOP_FAN_PECI_ERR_CURR;
break;
case PECI_ERROR_VALUE:
- set = CLOSE_LOOP_FAN_PECI_ERR_VALUE;
+ value = CLOSE_LOOP_FAN_PECI_ERR_VALUE;
break;
case PECI_ERROR_FULLSPEED:
- set = CLOSE_LOOP_FAN_PECI_ERR_MAX;
+ value = CLOSE_LOOP_FAN_PECI_ERR_MAX;
break;
default:
- set = 0;
+ value = 0;
break;
}
- nct7802y_update(dev, CLOSE_LOOP_FAN_RPM_CTRL,
- CLOSE_LOOP_FAN_PECI_ERR_MASK, set);
+ nct7802y_update(dev, CLOSE_LOOP_FAN_RPM_CTRL, CLOSE_LOOP_FAN_PECI_ERR_MASK, value);
nct7802y_write(dev, FAN_DUTY_ON_PECI_ERROR, config->pecierror_minduty);
}