Files
system76-coreboot/src/drivers/i2c/nct7802y/chip.h
Maxim Polyakov fb623a02c5 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>
2020-10-11 11:24:19 +00:00

99 lines
2.1 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef DRIVERS_I2C_NCT7802Y_CHIP_H
#define DRIVERS_I2C_NCT7802Y_CHIP_H
#include <stdint.h>
#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,
PECI_DOMAIN_0,
PECI_DOMAIN_1,
PECI_HIGHEST,
};
struct nct7802y_peci_config {
enum nct7802y_peci_mode mode;
u8 base_temp;
};
enum nct7802y_fan_mode {
FAN_IGNORE = 0,
FAN_MANUAL,
FAN_SMART,
};
enum nct7802y_fan_smartmode {
SMART_FAN_DUTY = 0, /* Target values given in duty cycle %. */
SMART_FAN_RPM, /* Target valuse given in RPM. */
};
enum nct7802y_fan_speed {
FAN_SPEED_NORMAL = 0, /* RPM values <= 12,750. */
FAN_SPPED_HIGHSPEED, /* RPM values <= 25,500. */
};
enum nct7802y_fan_pecierror {
PECI_ERROR_KEEP = 0, /* Keep current value. */
PECI_ERROR_VALUE, /* Use `pecierror_minduty`. */
PECI_ERROR_FULLSPEED, /* Run PWM at 100% duty cycle. */
};
enum nct7802y_temp_source {
TEMP_SOURCE_REMOTE_1 = 0,
TEMP_SOURCE_REMOTE_2,
TEMP_SOURCE_REMOTE_3,
TEMP_SOURCE_LOCAL,
TEMP_SOURCE_PECI_0,
TEMP_SOURCE_PECI_1,
TEMP_SOURCE_PROGRAMMABLE_0,
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;
enum nct7802y_temp_source tempsrc;
struct {
u8 temp;
u16 target;
} table[4];
u8 critical_temp;
};
struct nct7802y_fan_config {
enum nct7802y_fan_mode mode;
union {
u8 duty_cycle;
struct nct7802y_fan_smartconfig smart;
};
};
/* Implements only those parts currently used by coreboot mainboards. */
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;
};
#endif /* DRIVERS_I2C_NCT7802Y_CHIP_H */