Nico Huber (nico.huber@secunet.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3774
-gerrit
commit 1e6ca600b49f6ad42bfc0676f3386945e81611a7 Author: Nico Huber nico.huber@secunet.com Date: Fri Jul 12 14:43:11 2013 +0200
ec/kontron/it8516e: Add PWM limits option
Add an option to set minimal and maximal PWM percentages when the fan is in temperature controlled mode. Also fix a non-ascii flaw.
Change-Id: I85ae244bee2145bf17d6c29e93dd4871540985c8 Signed-off-by: Nico Huber nico.huber@secunet.com --- src/ec/kontron/it8516e/chip.h | 7 +++++-- src/ec/kontron/it8516e/ec.c | 45 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/src/ec/kontron/it8516e/chip.h b/src/ec/kontron/it8516e/chip.h index 5638efd..a0e6dd7 100644 --- a/src/ec/kontron/it8516e/chip.h +++ b/src/ec/kontron/it8516e/chip.h @@ -30,12 +30,15 @@ struct ec_kontron_it8516e_config { * Can be overwritten by * systemp_type, * fan1_mode, fan2_mode, - * fan1_target, and fan2_target + * fan1_target, fan2_target, + * fan1_min, fan2_min, fan1_max, and fan2_max * nvram options. */ enum it8516e_systemp_types default_systemp; enum it8516e_fan_modes default_fan_mode[2]; - u16 default_fan_target[2]; /* PWM: % / Speed: RPM / Thermal: °C */ + u16 default_fan_target[2]; /* PWM: % / Speed: RPM / Thermal: degree C */ + u8 default_fan_min[2]; /* min PWM in % */ + u8 default_fan_max[2]; /* max PWM in % */ };
#endif /* EC_KONTRON_IT8516E_CHIP_H */ diff --git a/src/ec/kontron/it8516e/ec.c b/src/ec/kontron/it8516e/ec.c index f347415..a4be4a3 100644 --- a/src/ec/kontron/it8516e/ec.c +++ b/src/ec/kontron/it8516e/ec.c @@ -40,6 +40,7 @@ enum { /* EC commands */ IT8516E_CMD_SET_FAN_SPEED = 0x15, IT8516E_CMD_GET_FAN_TEMP = 0x16, IT8516E_CMD_SET_FAN_TEMP = 0x17, + IT8516E_CMD_SET_FAN_LIMITS = 0x1a, };
static void it8516e_set_systemp_type(const u8 type) @@ -86,7 +87,18 @@ static void it8516e_set_fan_temperature(const u8 idx, const u8 temp) return; if (send_ec_data((temp << 6) & 0xff)) return; - send_ec_data(((temp << 6) >> 8) & 0xff); + send_ec_data((temp >> (8 - 6)) & 0xff); +} + +static void it8516e_set_fan_limits(const u8 idx, const u8 min, const u8 max) +{ + if (send_ec_command(IT8516E_CMD_SET_FAN_LIMITS)) + return; + if (send_ec_data(idx)) + return; + if (send_ec_data(min)) + return; + send_ec_data(max); }
static void it8516e_set_fan_from_options(const config_t *const config, @@ -94,9 +106,13 @@ static void it8516e_set_fan_from_options(const config_t *const config, { static char fanX_mode[] = "fanX_mode"; static char fanX_target[] = "fanX_target"; + static char fanX_min[] = "fanX_min"; + static char fanX_max[] = "fanX_max";
- u8 fan_mode = config->default_fan_mode[fan_idx]; - u16 fan_target = config->default_fan_target[fan_idx]; + u8 fan_mode = config->default_fan_mode[fan_idx]; + u16 fan_target = config->default_fan_target[fan_idx]; + u8 fan_min = config->default_fan_min[fan_idx]; + u8 fan_max = config->default_fan_max[fan_idx];
fanX_mode[3] = '1' + fan_idx; get_option(&fan_mode, fanX_mode); @@ -129,11 +145,26 @@ static void it8516e_set_fan_from_options(const config_t *const config, break; case IT8516E_MODE_THERMAL: printk(BIOS_DEBUG, - "Setting it8516e fan%d " - "control to %d°C.\n", + "Setting it8516e fan%d control to %d C.\n", fan_idx + 1, fan_target); - it8516e_set_fan_temperature( - fan_idx, fan_target); + it8516e_set_fan_temperature(fan_idx, fan_target); + + fanX_min[3] = '1' + fan_idx; + fanX_max[3] = '1' + fan_idx; + get_option(&fan_min, fanX_min); + get_option(&fan_max, fanX_max); + + if (!fan_max || fan_max > 100) + fan_max = 100; + if (fan_min >= 100) + fan_min = 99; + if (fan_max <= fan_min) + fan_max = fan_min + 1; + + printk(BIOS_DEBUG, + "Setting it8516e fan%d limits to %d%% - %d%% PWM.\n", + fan_idx + 1, fan_min, fan_max); + it8516e_set_fan_limits(fan_idx, fan_min, fan_max); break; } }