Attention is currently required from: Nico Huber.
Hello Nico Huber,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/80168?usp=email
to review the following change.
Change subject: superio/ite/env_ctrl: Allow to override the fan PWM clock ......................................................................
superio/ite/env_ctrl: Allow to override the fan PWM clock
Change-Id: I5c43aec792195df835d1c39c9c25233899ba1a85 Signed-off-by: Nico Huber nico.huber@secunet.com --- M src/superio/ite/common/env_ctrl.c M src/superio/ite/common/env_ctrl.h M src/superio/ite/common/env_ctrl_chip.h 3 files changed, 29 insertions(+), 14 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/68/80168/1
diff --git a/src/superio/ite/common/env_ctrl.c b/src/superio/ite/common/env_ctrl.c index 9149c58..a0388f1 100644 --- a/src/superio/ite/common/env_ctrl.c +++ b/src/superio/ite/common/env_ctrl.c @@ -129,6 +129,14 @@ pnp_write_hwm5_index(base, ITE_EC_CONFIGURATION, reg); }
+static u8 fan_pwm_clock(const struct ite_ec_config *const conf) +{ + if (!conf->fan_pwm_clock & 1) + return ITE_EC_FAN_PWM_DEFAULT_CLOCK; + + return conf->fan_pwm_clock & ITE_EC_FAN_PWM_CLOCK_MASK; +} + static void fan_smartconfig(const u16 base, const u8 fan, const enum ite_ec_fan_mode mode, const struct ite_ec_fan_smartconfig *const conf) @@ -188,8 +196,9 @@ }
static void enable_fan(const u16 base, const u8 fan, - const struct ite_ec_fan_config *const conf) + const struct ite_ec_config *const ec_conf) { + const struct ite_ec_fan_config *const conf = &ec_conf->fan[fan - 1]; u8 reg;
if (conf->mode == FAN_IGNORE || @@ -201,7 +210,7 @@ if (CONFIG(SUPERIO_ITE_ENV_CTRL_PWM_FREQ2) && fan == 2) { reg = pnp_read_hwm5_index(base, ITE_EC_ADC_TEMP_EXTRA_CHANNEL_ENABLE); reg &= ~ITE_EC_FAN_PWM_CLOCK_MASK; - reg |= ITE_EC_FAN_PWM_DEFAULT_CLOCK; + reg |= fan_pwm_clock(ec_conf); pnp_write_hwm5_index(base, ITE_EC_ADC_TEMP_EXTRA_CHANNEL_ENABLE, reg); }
@@ -278,7 +287,7 @@ /* Configure 23.43kHz PWM active high output */ u8 fan_ctl = pnp_read_hwm5_index(base, ITE_EC_FAN_CTL_MODE); fan_ctl &= ~ITE_EC_FAN_PWM_CLOCK_MASK; - fan_ctl |= ITE_EC_FAN_PWM_DEFAULT_CLOCK; + fan_ctl |= fan_pwm_clock(conf); fan_ctl |= ITE_EC_FAN_CTL_POLARITY_HIGH; pnp_write_hwm5_index(base, ITE_EC_FAN_CTL_MODE, fan_ctl);
@@ -305,7 +314,7 @@
/* Enable FANx if configured */ for (i = 0; i < ITE_EC_FAN_CNT; ++i) - enable_fan(base, i + 1, &conf->fan[i]); + enable_fan(base, i + 1, conf);
/* 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 5a31e7c..40076b8 100644 --- a/src/superio/ite/common/env_ctrl.h +++ b/src/superio/ite/common/env_ctrl.h @@ -7,10 +7,10 @@
#if CONFIG(SUPERIO_ITE_ENV_CTRL_8BIT_PWM) #define ITE_EC_FAN_MAX_PWM 0xff -#define ITE_EC_FAN_PWM_DEFAULT_CLOCK ITE_EC_FAN_PWM_CLOCK_6MHZ +#define ITE_EC_FAN_PWM_DEFAULT_CLOCK (FAN_PWM_CLOCK_6MHZ & ITE_EC_FAN_PWM_CLOCK_MASK) #else #define ITE_EC_FAN_MAX_PWM 0x7f -#define ITE_EC_FAN_PWM_DEFAULT_CLOCK ITE_EC_FAN_PWM_CLOCK_3MHZ +#define ITE_EC_FAN_PWM_DEFAULT_CLOCK (FAN_PWM_CLOCK_3MHZ & ITE_EC_FAN_PWM_CLOCK_MASK) #endif
#define ITE_EC_CONFIGURATION 0x00 @@ -75,14 +75,6 @@ #define ITE_EC_FAN_CTL_MODE 0x14 #define ITE_EC_FAN_CTL_POLARITY_HIGH (1 << 7) #define ITE_EC_FAN_PWM_CLOCK_MASK (7 << 4) -#define ITE_EC_FAN_PWM_CLOCK_48MHZ (0 << 4) -#define ITE_EC_FAN_PWM_CLOCK_24MHZ (1 << 4) -#define ITE_EC_FAN_PWM_CLOCK_12MHZ (2 << 4) -#define ITE_EC_FAN_PWM_CLOCK_8MHZ (3 << 4) -#define ITE_EC_FAN_PWM_CLOCK_6MHZ (4 << 4) -#define ITE_EC_FAN_PWM_CLOCK_3MHZ (5 << 4) -#define ITE_EC_FAN_PWM_CLOCK_1_5MHZ (6 << 4) -#define ITE_EC_FAN_PWM_CLOCK_51KHZ (7 << 4) #define ITE_EC_FAN_PWM_MIN_DUTY_20 (1 << 3) #define ITE_EC_FAN_CTL_ON(x) (1 << ((x)-1))
diff --git a/src/superio/ite/common/env_ctrl_chip.h b/src/superio/ite/common/env_ctrl_chip.h index 2bb0780..d6f46e3 100644 --- a/src/superio/ite/common/env_ctrl_chip.h +++ b/src/superio/ite/common/env_ctrl_chip.h @@ -69,6 +69,19 @@ struct ite_ec_fan_smartconfig smart; };
+/* bit 0 is used to mark non-default values */ +enum ite_ec_fan_pwm_clock { + FAN_PWM_CLOCK_DEFAULT = 0, + FAN_PWM_CLOCK_48MHZ = 0 << 4 | 1, + FAN_PWM_CLOCK_24MHZ = 1 << 4 | 1, + FAN_PWM_CLOCK_12MHZ = 2 << 4 | 1, + FAN_PWM_CLOCK_8MHZ = 3 << 4 | 1, + FAN_PWM_CLOCK_6MHZ = 4 << 4 | 1, + FAN_PWM_CLOCK_3MHZ = 5 << 4 | 1, + FAN_PWM_CLOCK_1_5MHZ = 6 << 4 | 1, + FAN_PWM_CLOCK_51KHZ = 7 << 4 | 1, +}; + struct ite_ec_config { /* * Enable reading of voltage pins VINx. @@ -84,6 +97,7 @@ * Enable a FAN in given mode. */ struct ite_ec_fan_config fan[ITE_EC_FAN_CNT]; + enum ite_ec_fan_pwm_clock fan_pwm_clock;
bool tmpin_beep; bool fan_beep;