diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/superio/ite/common/Kconfig | 11 | ||||
-rw-r--r-- | src/superio/ite/common/env_ctrl.c | 49 | ||||
-rw-r--r-- | src/superio/ite/common/env_ctrl.h | 11 | ||||
-rw-r--r-- | src/superio/ite/common/env_ctrl_chip.h | 21 | ||||
-rw-r--r-- | src/superio/ite/it8728f/Kconfig | 1 | ||||
-rw-r--r-- | src/superio/ite/it8772f/Kconfig | 2 |
6 files changed, 95 insertions, 0 deletions
diff --git a/src/superio/ite/common/Kconfig b/src/superio/ite/common/Kconfig index 6fde3c883f..4701056bfa 100644 --- a/src/superio/ite/common/Kconfig +++ b/src/superio/ite/common/Kconfig @@ -54,4 +54,15 @@ config SUPERIO_ITE_ENV_CTRL_NO_FULLSPEED_SETTING Fan controller does not support running at full speed when limit temperature is reached. +config SUPERIO_ITE_ENV_CTRL_FAN_VECTOR + bool + help + Special fan control that will assist the smart control + +config SUPERIO_ITE_ENV_CTRL_FAN_VECTOR_RANGED + bool + depends on SUPERIO_ITE_ENV_CTRL_FAN_VECTOR + help + Range and negative slope support + endif diff --git a/src/superio/ite/common/env_ctrl.c b/src/superio/ite/common/env_ctrl.c index 112401985c..105d6da8cf 100644 --- a/src/superio/ite/common/env_ctrl.c +++ b/src/superio/ite/common/env_ctrl.c @@ -253,6 +253,49 @@ static void enable_fan(const u16 base, const u8 fan, } } +static void enable_fan_vector(const u16 base, const u8 fan_vector, + const struct ite_ec_fan_vector_config *const conf) +{ + u8 reg; + + u8 start = conf->tmp_start; + if (!start) { + /* When tmp_start is not configured we would set the + * register to it's default of 0xFF here, which would + * effectively disable the vector functionality of the + * SuperIO altogether since that temperature will never + * be reached. We can therefore return here and don't + * need to set any other registers. + */ + return; + } + pnp_write_hwm5_index(base, ITE_EC_FAN_VEC_CTL_LIMIT_START(fan_vector), start); + + const s8 slope = conf->slope; + const bool slope_neg = slope < 0; + if (slope <= -128) + reg = 127; + else if (slope_neg) + reg = -slope; + else + reg = slope; + reg |= ITE_EC_FAN_VEC_CTL_SLOPE_TMPIN0(conf->tmpin); + pnp_write_hwm5_index(base, ITE_EC_FAN_VEC_CTL_SLOPE(fan_vector), reg); + + reg = ITE_EC_FAN_VEC_CTL_DELTA_TEMP_INTRVL(conf->tmp_delta); + reg |= ITE_EC_FAN_VEC_CTL_DELTA_FANOUT(conf->fanout); + reg |= ITE_EC_FAN_VEC_CTL_DELTA_TMPIN1(conf->tmpin); + pnp_write_hwm5_index(base, ITE_EC_FAN_VEC_CTL_DELTA(fan_vector), reg); + + if (CONFIG(SUPERIO_ITE_ENV_CTRL_FAN_VECTOR_RANGED)) { + reg = conf->tmp_range & 0x7f; + reg |= ITE_EC_FAN_VEC_CTL_RANGE_SLOPESIGN(slope_neg); + pnp_write_hwm5_index(base, ITE_EC_FAN_VEC_CTL_RANGE(fan_vector), reg); + } else if (slope_neg) { + printk(BIOS_WARNING, "Unsupported negative slope on fan vector control\n"); + } +} + static void enable_beeps(const u16 base, const struct ite_ec_config *const conf) { u8 reg = 0; @@ -313,6 +356,12 @@ void ite_ec_init(const u16 base, const struct ite_ec_config *const conf) for (i = 0; i < ITE_EC_FAN_CNT; ++i) enable_fan(base, i + 1, &conf->fan[i]); + if (CONFIG(SUPERIO_ITE_ENV_CTRL_FAN_VECTOR)) { + /* Enable Special FAN Vector X if configured */ + for (i = 0; i < ITE_EC_FAN_VECTOR_CNT; ++i) + enable_fan_vector(base, i, &conf->fan_vector[i]); + } + /* Enable beeps if configured */ enable_beeps(base, conf); diff --git a/src/superio/ite/common/env_ctrl.h b/src/superio/ite/common/env_ctrl.h index 5a31e7cfbc..8a461aa3f2 100644 --- a/src/superio/ite/common/env_ctrl.h +++ b/src/superio/ite/common/env_ctrl.h @@ -199,6 +199,17 @@ static const u8 ITE_EC_TEMP_ADJUST[] = { 0x56, 0x57, 0x59 }; #define ITE_EC_FAN_CTL_TARGET_ZONE(x) (0x66 + ((x)-1) * 8) #define ITE_EC_FAN_CTL_TARGET_ZONE_MASK 0x0f +#define ITE_EC_FAN_VEC_CTL_LIMIT_START(x) (0x90 + (x) * 4) +#define ITE_EC_FAN_VEC_CTL_SLOPE(x) (0x91 + (x) * 4) +#define ITE_EC_FAN_VEC_CTL_DELTA(x) (0x92 + (x) * 4) +#define ITE_EC_FAN_VEC_CTL_RANGE(x) (0x93 + (x) * 4) + +#define ITE_EC_FAN_VEC_CTL_SLOPE_TMPIN0(x) (((x) & 0x1) << 7) +#define ITE_EC_FAN_VEC_CTL_DELTA_TMPIN1(x) (((x) & 0x2) << 6) +#define ITE_EC_FAN_VEC_CTL_DELTA_TEMP_INTRVL(c) ITE_EC_FAN_CTL_DELTA_TEMP_INTRVL(c) +#define ITE_EC_FAN_VEC_CTL_DELTA_FANOUT(x) (((x) & 0x3) << 5) +#define ITE_EC_FAN_VEC_CTL_RANGE_SLOPESIGN(x) (((x) & 0x1) << 7) + #define ITE_EC_EXTEMP_STATUS 0x88 #define ITE_EC_EXTEMP_STATUS_HOST_BUSY (1 << 0) #define ITE_EC_EXTEMP_ADDRESS 0x89 diff --git a/src/superio/ite/common/env_ctrl_chip.h b/src/superio/ite/common/env_ctrl_chip.h index 2bb0780c53..6d716bb845 100644 --- a/src/superio/ite/common/env_ctrl_chip.h +++ b/src/superio/ite/common/env_ctrl_chip.h @@ -11,6 +11,8 @@ #define ITE_EC_FAN_CNT 3 #endif +#define ITE_EC_FAN_VECTOR_CNT 2 /* A, B */ + /* Supported thermal mode on TMPINx */ enum ite_ec_thermal_mode { THERMAL_MODE_DISABLED = 0, @@ -69,6 +71,17 @@ struct ite_ec_fan_config { struct ite_ec_fan_smartconfig smart; }; +/* Special fan control modes that will assist smart control */ +struct ite_ec_fan_vector_config { + u8 tmpin; /* select TMPINx (1, 2 or 3) */ + u8 fanout; /* select FANx (1, 2 or 3) */ + u8 tmp_start; + u8 tmp_delta; + u8 tmp_range; /* restrict the range of the vector function, + 0x00 to disable */ + s8 slope; +}; + struct ite_ec_config { /* * Enable reading of voltage pins VINx. @@ -85,6 +98,11 @@ struct ite_ec_config { */ struct ite_ec_fan_config fan[ITE_EC_FAN_CNT]; + /* + * Enable special FAN vector control. + */ + struct ite_ec_fan_vector_config fan_vector[ITE_EC_FAN_VECTOR_CNT]; + bool tmpin_beep; bool fan_beep; bool vin_beep; @@ -111,4 +129,7 @@ struct ite_ec_config { #define FAN4 ec.fan[3] #define FAN5 ec.fan[4] +#define FAN_VECA ec.fan_vector[0] +#define FAN_VECB ec.fan_vector[1] + #endif /* SUPERIO_ITE_ENV_CTRL_CHIP_H */ diff --git a/src/superio/ite/it8728f/Kconfig b/src/superio/ite/it8728f/Kconfig index 6d02c0b424..be16a2dbf6 100644 --- a/src/superio/ite/it8728f/Kconfig +++ b/src/superio/ite/it8728f/Kconfig @@ -10,3 +10,4 @@ config SUPERIO_ITE_IT8728F select SUPERIO_ITE_ENV_CTRL_5FANS select SUPERIO_ITE_ENV_CTRL_7BIT_SLOPE_REG select SUPERIO_ITE_ENV_CTRL_EXT_ANY_TMPIN + select SUPERIO_ITE_ENV_CTRL_FAN_VECTOR diff --git a/src/superio/ite/it8772f/Kconfig b/src/superio/ite/it8772f/Kconfig index 3137cf0d35..8e9af54922 100644 --- a/src/superio/ite/it8772f/Kconfig +++ b/src/superio/ite/it8772f/Kconfig @@ -7,5 +7,7 @@ config SUPERIO_ITE_IT8772F select SUPERIO_ITE_ENV_CTRL_7BIT_SLOPE_REG select SUPERIO_ITE_ENV_CTRL_8BIT_PWM select SUPERIO_ITE_ENV_CTRL_EXT_ANY_TMPIN + select SUPERIO_ITE_ENV_CTRL_FAN_VECTOR + select SUPERIO_ITE_ENV_CTRL_FAN_VECTOR_RANGED select SUPERIO_ITE_ENV_CTRL_NO_FULLSPEED_SETTING select SUPERIO_ITE_ENV_CTRL_PWM_FREQ2 |