summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/superio/ite/common/Kconfig10
-rw-r--r--src/superio/ite/common/env_ctrl.c38
-rw-r--r--src/superio/ite/common/env_ctrl.h77
-rw-r--r--src/superio/ite/common/env_ctrl_chip.h8
4 files changed, 111 insertions, 22 deletions
diff --git a/src/superio/ite/common/Kconfig b/src/superio/ite/common/Kconfig
index 8e52cf4e4e..6c78741723 100644
--- a/src/superio/ite/common/Kconfig
+++ b/src/superio/ite/common/Kconfig
@@ -4,6 +4,7 @@
## Copyright (C) 2009 Ronald G. Minnich
## Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com>
## Copyright (C) 2016 secunet Security Networks AG
+## Copyright (C) 2019 Protectli
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -41,4 +42,13 @@ config SUPERIO_ITE_ENV_CTRL_PWM_FREQ2
help
The second FAN controller has a separate frequency setting.
+config SUPERIO_ITE_ENV_CTRL_NO_ONOFF
+ bool
+ help
+ FAN controller always works in SmartGuardian mode.
+
+config SUPERIO_ITE_ENV_CTRL_5FANS
+ bool
+ help
+ ITE FAN controller has 5 independent outputs.
endif
diff --git a/src/superio/ite/common/env_ctrl.c b/src/superio/ite/common/env_ctrl.c
index 92c9bcab3d..f69273e984 100644
--- a/src/superio/ite/common/env_ctrl.c
+++ b/src/superio/ite/common/env_ctrl.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
* Copyright (C) 2016 secunet Security Networks AG
+ * Copyright (C) 2019 Protectli
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -191,7 +192,9 @@ static void enable_fan(const u16 base, const u8 fan,
{
u8 reg;
- if (conf->mode == FAN_IGNORE)
+ if (conf->mode == FAN_IGNORE ||
+ (IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_NO_ONOFF) &&
+ conf->mode <= FAN_MODE_OFF))
return;
/* FAN_CTL2 might have its own frequency setting */
@@ -220,16 +223,29 @@ static void enable_fan(const u16 base, const u8 fan,
ite_ec_write(base, ITE_EC_FAN_TAC_COUNTER_ENABLE, reg);
}
- reg = ite_ec_read(base, ITE_EC_FAN_MAIN_CTL);
- if (conf->mode >= FAN_MODE_ON)
- reg |= ITE_EC_FAN_MAIN_CTL_TAC_EN(fan);
- else
- reg &= ~ITE_EC_FAN_MAIN_CTL_TAC_EN(fan);
- if (conf->mode >= FAN_SMART_SOFTWARE)
- reg |= ITE_EC_FAN_MAIN_CTL_SMART(fan);
- else
- reg &= ~ITE_EC_FAN_MAIN_CTL_SMART(fan);
- ite_ec_write(base, ITE_EC_FAN_MAIN_CTL, reg);
+ if (IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS) && fan > 3) {
+ reg = ite_ec_read(base, ITE_EC_FAN_SEC_CTL);
+ if (conf->mode >= FAN_MODE_ON)
+ reg |= ITE_EC_FAN_SEC_CTL_TAC_EN(fan);
+ else
+ reg &= ~ITE_EC_FAN_SEC_CTL_TAC_EN(fan);
+ ite_ec_write(base, ITE_EC_FAN_SEC_CTL, reg);
+ } else {
+ reg = ite_ec_read(base, ITE_EC_FAN_MAIN_CTL);
+ if (conf->mode >= FAN_MODE_ON)
+ reg |= ITE_EC_FAN_MAIN_CTL_TAC_EN(fan);
+ else
+ reg &= ~ITE_EC_FAN_MAIN_CTL_TAC_EN(fan);
+
+ /* Some ITEs have SmartGuardian always enabled */
+ if (!IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_NO_ONOFF)) {
+ if (conf->mode >= FAN_SMART_SOFTWARE)
+ reg |= ITE_EC_FAN_MAIN_CTL_SMART(fan);
+ else
+ reg &= ~ITE_EC_FAN_MAIN_CTL_SMART(fan);
+ }
+ ite_ec_write(base, ITE_EC_FAN_MAIN_CTL, reg);
+ }
}
static void enable_beeps(const u16 base, const struct ite_ec_config *const conf)
diff --git a/src/superio/ite/common/env_ctrl.h b/src/superio/ite/common/env_ctrl.h
index 11316db276..e67af3445e 100644
--- a/src/superio/ite/common/env_ctrl.h
+++ b/src/superio/ite/common/env_ctrl.h
@@ -3,6 +3,7 @@
*
* Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
* Copyright (C) 2016 secunet Security Networks AG
+ * Copyright (C) 2019 Protectli
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -52,8 +53,20 @@
#define ITE_EC_FAN_TAC_COUNTER_ENABLE 0x0c
#define ITE_EC_FAN_TAC_16BIT_ENABLE(x) (1 << ((x)-1))
-#define ITE_EC_FAN_TAC_LIMIT(x) (0x10 + ((x)-1))
-#define ITE_EC_FAN_TAC_EXT_LIMIT(x) (0x1b + ((x)-1))
+
+#define ITE_EC_FAN_SEC_CTL 0x0c
+#define ITE_EC_FAN_SEC_CTL_TAC_EN(x) (1 << (x))
+
+#define ITE_EC_FAN_TAC_LIMIT(x) \
+ (((x) > 3 && IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS)) \
+ ? (0x84 + ((x)-4) * 2) \
+ : (0x10 + ((x)-1)) \
+ )
+#define ITE_EC_FAN_TAC_EXT_LIMIT(x) \
+ (((x) > 3 && IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS)) \
+ ? (0x85 + ((x)-4) * 2) \
+ : (0x1b + ((x)-1)) \
+ )
#define ITE_EC_FAN_MAIN_CTL 0x13
#define ITE_EC_FAN_MAIN_CTL_TAC_EN(x) (1 << ((x)+3))
@@ -72,7 +85,21 @@
#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))
-#define ITE_EC_FAN_CTL_PWM_CONTROL(x) (0x15 + ((x)-1))
+
+#define ITE_EC_FAN_CTL_PWM_CONTROL(x) \
+ (((x) > 3 && IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS)) \
+ ? (0x1e + ((x)-4)) \
+ : (0x15 + ((x)-1)) \
+ )
+
+#if IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS)
+#define ITE_EC_FAN_CTL_TEMPIN_MASK (7 << 3)
+#define ITE_EC_FAN_CTL_TEMPIN(x) ((((x)-1) & 7) << 3)
+#else
+#define ITE_EC_FAN_CTL_TEMPIN_MASK (3 << 0)
+#define ITE_EC_FAN_CTL_TEMPIN(x) (((x)-1) & 3)
+#endif
+
#define ITE_EC_FAN_CTL_PWM_MODE_SOFTWARE (0 << 7)
#define ITE_EC_FAN_CTL_PWM_MODE_AUTOMATIC (1 << 7)
#define ITE_EC_FAN_CTL_PWM_DUTY_MASK (ITE_EC_FAN_MAX_PWM << 0)
@@ -83,8 +110,6 @@
? ITE_EC_FAN_MAX_PWM \
: (_p * ITE_EC_FAN_MAX_PWM) / 100; \
})
-#define ITE_EC_FAN_CTL_TEMPIN_MASK (3 << 0)
-#define ITE_EC_FAN_CTL_TEMPIN(x) (((x)-1) & 3)
#define ITE_EC_HIGH_TEMP_LIMIT(x) (0x40 + ((x-1) * 2))
#define ITE_EC_LOW_TEMP_LIMIT(x) (0x41 + ((x-1) * 2))
@@ -119,16 +144,46 @@ static const u8 ITE_EC_TEMP_ADJUST[] = { 0x56, 0x57, 0x59 };
#define ITE_EC_BEEP_TONE_DIVISOR(x) (((x) & 0x0f) << 4)
#define ITE_EC_BEEP_FREQ_DIVISOR(x) (((x) & 0x0f) << 0)
-#define ITE_EC_FAN_CTL_TEMP_LIMIT_OFF(x) (0x60 + ((x)-1) * 8)
-#define ITE_EC_FAN_CTL_TEMP_LIMIT_START(x) (0x61 + ((x)-1) * 8)
-#define ITE_EC_FAN_CTL_TEMP_LIMIT_FULL(x) (0x62 + ((x)-1) * 8)
-#define ITE_EC_FAN_CTL_PWM_START(x) (0x63 + ((x)-1) * 8)
+#define ITE_EC_FAN_CTL_TEMP_LIMIT_OFF(x) \
+ (((x) == 5 && IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS)) \
+ ? (0xa0) \
+ : (0x60 + ((x)-1) * 8) \
+ )
+#define ITE_EC_FAN_CTL_TEMP_LIMIT_START(x) \
+ (((x) == 5 && IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS)) \
+ ? (0xa1) \
+ : (0x61 + ((x)-1) * 8) \
+ )
+#define ITE_EC_FAN_CTL_TEMP_LIMIT_FULL(x) \
+ (((x) == 5 && IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS)) \
+ ? (0xa2) \
+ : (0x62 + ((x)-1) * 8) \
+ )
+#define ITE_EC_FAN_CTL_PWM_START(x) \
+ (((x) == 5 && IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS)) \
+ ? (0xa3) \
+ : (0x63 + ((x)-1) * 8) \
+ )
+#define ITE_EC_FAN_CTL_PWM_AUTO(x) \
+ (((x) == 5 && IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS)) \
+ ? (0xa4) \
+ : (0x64 + ((x)-1) * 8) \
+ )
+#define ITE_EC_FAN_CTL_DELTA_TEMP(x) \
+ (((x) == 5 && IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS)) \
+ ? (0xa5) \
+ : (0x65 + ((x)-1) * 8) \
+ )
+
+/* Common for ITE_EC_FAN_CTL_PWM_START */
#define ITE_EC_FAN_CTL_PWM_SLOPE_BIT6(s) (((s) & 0x40) << 1)
#define ITE_EC_FAN_CTL_PWM_START_DUTY(p) ITE_EC_FAN_CTL_PWM_DUTY(p)
-#define ITE_EC_FAN_CTL_PWM_AUTO(x) (0x64 + ((x)-1) * 8)
+
+/* Common for ITE_EC_FAN_CTL_PWM_AUTO */
#define ITE_EC_FAN_CTL_AUTO_SMOOTHING_EN (1 << 7)
#define ITE_EC_FAN_CTL_PWM_SLOPE_LOWER(s) ((s) & 0x3f)
-#define ITE_EC_FAN_CTL_DELTA_TEMP(x) (0x65 + ((x)-1) * 8)
+
+/* Common for ITE_EC_FAN_CTL_DELTA_TEMP */
#define ITE_EC_FAN_CTL_DELTA_TEMP_INTRVL(c) ((c) & 0x1f)
#define ITE_EC_EXTEMP_STATUS 0x88
diff --git a/src/superio/ite/common/env_ctrl_chip.h b/src/superio/ite/common/env_ctrl_chip.h
index f8f2e1ef0e..68bf5a035f 100644
--- a/src/superio/ite/common/env_ctrl_chip.h
+++ b/src/superio/ite/common/env_ctrl_chip.h
@@ -3,6 +3,7 @@
*
* Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
* Copyright (C) 2016 secunet Security Networks AG
+ * Copyright (C) 2019 Protectli
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +20,12 @@
#define SUPERIO_ITE_ENV_CTRL_CHIP_H
#define ITE_EC_TMPIN_CNT 3
+
+#if IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS)
+#define ITE_EC_FAN_CNT 5
+#else
#define ITE_EC_FAN_CNT 3
+#endif
/* Supported thermal mode on TMPINx */
enum ite_ec_thermal_mode {
@@ -105,5 +111,7 @@ struct ite_ec_config {
#define FAN1 ec.fan[0]
#define FAN2 ec.fan[1]
#define FAN3 ec.fan[2]
+#define FAN4 ec.fan[3]
+#define FAN5 ec.fan[4]
#endif /* SUPERIO_ITE_ENV_CTRL_CHIP_H */