Michał Żygowski has uploaded this change for review.

View Change

src/superio/ite/common: Prepare for new SuperIO

Introduce 7bit Slope PWM registers. New ITE SuperIO may have contiguous
7bit values for PWM slope.

Add option to enable External Sensor SMBus Host.

Allow early SuperIO serial init in bootblock for platforms supporting
C_ENVIRONMENT_BOOTBLOCK.

Update/add registers macros for IT8786E-F which are not backwards
compatible.

Change-Id: I68fbfe62dfa05d0c166abaefbdc2ab873114b236
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
---
M src/superio/ite/Makefile.inc
M src/superio/ite/common/Kconfig
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
5 files changed, 53 insertions(+), 4 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/53/30553/1
diff --git a/src/superio/ite/Makefile.inc b/src/superio/ite/Makefile.inc
index 382dbd7..a54db6f 100644
--- a/src/superio/ite/Makefile.inc
+++ b/src/superio/ite/Makefile.inc
@@ -14,7 +14,11 @@
##

## include generic ite pre-ram stage driver
-romstage-$(CONFIG_SUPERIO_ITE_COMMON_ROMSTAGE) += common/early_serial.c
+
+ifeq ($(CONFIG_SUPERIO_ITE_COMMON_ROMSTAGE),y)
+bootblock-$(CONFIG_C_ENVIRONMENT_BOOTBLOCK) += common/early_serial.c
+romstage-y += common/early_serial.c
+endif

## include generic ite environment controller driver
ramstage-$(CONFIG_SUPERIO_ITE_ENV_CTRL) += common/env_ctrl.c
diff --git a/src/superio/ite/common/Kconfig b/src/superio/ite/common/Kconfig
index 162b7f1..fd6a699 100644
--- a/src/superio/ite/common/Kconfig
+++ b/src/superio/ite/common/Kconfig
@@ -41,4 +41,10 @@
help
The second FAN controller has a separate frequency setting.

+config SUPERIO_ITE_ENV_CTRL_7BIT_SLOPE_REG
+ bool
+ help
+ Slope PWM registers have no separate BIT6 and are set directly by
+ 7-bit values instead.
+
endif
diff --git a/src/superio/ite/common/env_ctrl.c b/src/superio/ite/common/env_ctrl.c
index 1dc5bb6..fb347de 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) 2018 Libretrend LDA
*
* 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
@@ -164,9 +165,14 @@
pwm_ctrl |= ITE_EC_FAN_CTL_TEMPIN(conf->tmpin);

pwm_start = ITE_EC_FAN_CTL_PWM_START_DUTY(conf->pwm_start);
- pwm_start |= ITE_EC_FAN_CTL_PWM_SLOPE_BIT6(conf->slope);

- pwm_auto = ITE_EC_FAN_CTL_PWM_SLOPE_LOWER(conf->slope);
+ if (IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_7BIT_SLOPE_REG)) {
+ pwm_auto = conf->slope & 0x7f;
+ } else {
+ pwm_start |= ITE_EC_FAN_CTL_PWM_SLOPE_BIT6(conf->slope);
+ pwm_auto = ITE_EC_FAN_CTL_PWM_SLOPE_LOWER(conf->slope);
+ }
+
if (conf->smoothing)
pwm_auto |= ITE_EC_FAN_CTL_AUTO_SMOOTHING_EN;

@@ -213,7 +219,7 @@
ite_ec_write(base, ITE_EC_FAN_CTL_MODE, reg);
}

- if (IS_ENABLED(SUPERIO_ITE_ENV_CTRL_FAN16_CONFIG)
+ if (IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_FAN16_CONFIG)
&& conf->mode >= FAN_MODE_ON) {
reg = ite_ec_read(base, ITE_EC_FAN_TAC_COUNTER_ENABLE);
reg |= ITE_EC_FAN_TAC_16BIT_ENABLE(fan);
@@ -271,6 +277,13 @@
for (i = 0; i < ITE_EC_TMPIN_CNT; ++i)
enable_tmpin(base, i + 1, &conf->tmpin[i]);

+ /* Enable External Sensor SMBus Host if configured */
+ if (conf->smbus_en) {
+ ite_ec_write(base, ITE_EC_INTERFACE_SELECT,
+ ite_ec_read(base, ITE_EC_INTERFACE_SELECT) |
+ ITE_EC_INTERFACE_SMB_ENABLE);
+ }
+
/* Enable reading of voltage pins */
ite_ec_write(base, ITE_EC_ADC_VOLTAGE_CHANNEL_ENABLE, conf->vin_mask);

diff --git a/src/superio/ite/common/env_ctrl.h b/src/superio/ite/common/env_ctrl.h
index 11316db..06a41a5 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) 2018 Libretrend LDA
*
* 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
@@ -48,13 +49,34 @@
#define ITE_EC_FAN_PWM_SMOOTHING_1KHZ (0 << 6)
#define ITE_EC_FAN_PWM_SMOOTHING_256HZ (1 << 6)
#define ITE_EC_FAN_PWM_SMOOTHING_64HZ (2 << 6)
+#if IS_ENABLED(CONFIG_SUPERIO_ITE_IT8786E)
+#define ITE_EC_FAN_PWM_SMOOTHING_16HZ (1 << 6)
+#else
#define ITE_EC_FAN_PWM_SMOOTHING_16HZ (3 << 6)
+#endif
+/* SUPERIO_ITE_IT8786E PWM_SMOOTHING_FREQ contents */
+#define ITE_EC_FAN_PWM_SMOOTHING_1HZ (0 << 6)
+#define ITE_EC_FAN_PWM_SMOOTHING_8HZ (2 << 6)
+#define ITE_EC_FAN_PWM_SMOOTHING_4HZ (3 << 6)
+#define ITE_EC_FAN_CTL5_SEL(x) ((((x)-1) & 3) << 2)
+#define ITE_EC_FAN_CTL5_SEL_NONE (3 << 2)
+#define ITE_EC_FAN_CTL4_SEL(x) (((x)-1) & 3)
+#define ITE_EC_FAN_CTL4_SEL_NONE (3 << 0)

#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))

+/* SUPERIO_ITE_IT8786E FAN_TAC_CNTRL register content */
+#define ITE_EC_FAN_TAC_CNTRL 0x0c
+#define ITE_EC_TMPIN3_ENHANCED_INT_MODE (1 << 7)
+#define ITE_EC_TMPIN2_ENHANCED_INT_MODE (1 << 6)
+#define ITE_EC_FAN_TAC5_EN (1 << 5)
+#define ITE_EC_FAN_TAC4_EN (1 << 4)
+#define ITE_EC_TMPIN1_ENHANCED_INT_MODE (1 << 3)
+#define ITE_EC_AMDTSI_ERR_EN (1 << 0)
+
#define ITE_EC_FAN_MAIN_CTL 0x13
#define ITE_EC_FAN_MAIN_CTL_TAC_EN(x) (1 << ((x)+3))
#define ITE_EC_FAN_MAIN_CTL_COLL_FULL_SPEED (1 << 3)
@@ -130,6 +152,8 @@
#define ITE_EC_FAN_CTL_PWM_SLOPE_LOWER(s) ((s) & 0x3f)
#define ITE_EC_FAN_CTL_DELTA_TEMP(x) (0x65 + ((x)-1) * 8)
#define ITE_EC_FAN_CTL_DELTA_TEMP_INTRVL(c) ((c) & 0x1f)
+#define ITE_EC_FAN_CTL_TARGET_ZONE(x) (0x66 + ((x)-1) * 8)
+#define ITE_EC_FAN_CTL_TARGET_ZONE_MASK 0x0f

#define ITE_EC_EXTEMP_STATUS 0x88
#define ITE_EC_EXTEMP_STATUS_HOST_BUSY (1 << 0)
diff --git a/src/superio/ite/common/env_ctrl_chip.h b/src/superio/ite/common/env_ctrl_chip.h
index f8f2e1e..4df9b01 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) 2018 Libretrend LDA
*
* 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
@@ -95,6 +96,7 @@
bool tmpin_beep;
bool fan_beep;
bool vin_beep;
+ bool smbus_en;
};

/* Some shorthands for device trees */

To view, visit change 30553. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I68fbfe62dfa05d0c166abaefbdc2ab873114b236
Gerrit-Change-Number: 30553
Gerrit-PatchSet: 1
Gerrit-Owner: Michał Żygowski <michal.zygowski@3mdeb.com>
Gerrit-MessageType: newchange