[coreboot-gerrit] Change in coreboot[master]: superio/ite/it8728f: Hook up common environment-controller d...

Martin Roth (Code Review) gerrit at coreboot.org
Tue May 9 18:03:30 CEST 2017


Martin Roth has submitted this change and it was merged. ( https://review.coreboot.org/19293 )

Change subject: superio/ite/it8728f: Hook up common environment-controller driver
......................................................................


superio/ite/it8728f: Hook up common environment-controller driver

This replaces the custom environment controller handling in the it8728
driver with the common library.

It also updates the two existing boards with hwm register settings in
their devicetree config so they better match their vendor BIOS fan
control settings.

Change-Id: Idf0c8908ba5ad6ff552b8302bffc638aa9052941
Signed-off-by: Tobias Diedrich <ranma+coreboot at tdiedrich.de>
Reviewed-on: https://review.coreboot.org/19293
Tested-by: build bot (Jenkins) <no-reply at coreboot.org>
Reviewed-by: Paul Menzel <paulepanter at users.sourceforge.net>
Reviewed-by: Felix Held <felix-coreboot at felixheld.de>
---
M src/mainboard/asus/f2a85-m/devicetree_f2a85-m.cb
M src/mainboard/asus/f2a85-m/devicetree_f2a85-m_le.cb
M src/superio/ite/it8728f/Kconfig
M src/superio/ite/it8728f/Makefile.inc
M src/superio/ite/it8728f/chip.h
D src/superio/ite/it8728f/it8728f_hwm.c
M src/superio/ite/it8728f/superio.c
7 files changed, 48 insertions(+), 93 deletions(-)

Approvals:
  Felix Held: Looks good to me, approved
  Paul Menzel: Looks good to me, but someone else must approve
  build bot (Jenkins): Verified



diff --git a/src/mainboard/asus/f2a85-m/devicetree_f2a85-m.cb b/src/mainboard/asus/f2a85-m/devicetree_f2a85-m.cb
index d942445..e1fbc51 100644
--- a/src/mainboard/asus/f2a85-m/devicetree_f2a85-m.cb
+++ b/src/mainboard/asus/f2a85-m/devicetree_f2a85-m.cb
@@ -58,12 +58,22 @@
 				device pci 14.2 on  end # HDA	0x4383
 				device pci 14.3 on      # LPC	0x439d
 					chip superio/ite/it8728f
-						register hwm_ctl_register = "0xc0"
-						register hwm_main_ctl_register = "0x33"
-						register hwm_adc_temp_chan_en_reg = "0x38"
-						register hwm_fan1_ctl_pwm = "0x00"
-						register hwm_fan2_ctl_pwm = "0x00"
-						register hwm_fan3_ctl_pwm = "0x00"
+						register "TMPIN1" = "THERMAL_RESISTOR"
+						register "TMPIN2" = "THERMAL_RESISTOR"
+						register "TMPIN3" = "THERMAL_RESISTOR"
+
+						register "FAN1.mode" = "FAN_SMART_AUTOMATIC"
+						register "FAN1.smart.tmpin" = "1"
+						register "FAN1.smart.tmp_off" = "0x80" # never
+						register "FAN1.smart.tmp_start" = "20"
+						register "FAN1.smart.tmp_full" = "70"
+						register "FAN1.smart.tmp_delta" = "0"
+						register "FAN1.smart.smoothing" = "1"
+						register "FAN1.smart.pwm_start" = "20"
+						register "FAN1.smart.slope" = "32"
+
+						# Enable tacho reading for chassis fan.
+						register "FAN2.mode" = "FAN_MODE_OFF"
 
 						device pnp 2e.0 off #  Floppy
 							io 0x60 = 0x3f0
diff --git a/src/mainboard/asus/f2a85-m/devicetree_f2a85-m_le.cb b/src/mainboard/asus/f2a85-m/devicetree_f2a85-m_le.cb
index d83f466..128ff18 100644
--- a/src/mainboard/asus/f2a85-m/devicetree_f2a85-m_le.cb
+++ b/src/mainboard/asus/f2a85-m/devicetree_f2a85-m_le.cb
@@ -58,12 +58,22 @@
 				device pci 14.2 on  end # HDA	0x4383
 				device pci 14.3 on      # LPC	0x439d
 					chip superio/ite/it8728f
-						register hwm_ctl_register = "0xc0"
-						register hwm_main_ctl_register = "0x33"
-						register hwm_adc_temp_chan_en_reg = "0x38"
-						register hwm_fan1_ctl_pwm = "0x00"
-						register hwm_fan2_ctl_pwm = "0x00"
-						register hwm_fan3_ctl_pwm = "0x00"
+						register "TMPIN1" = "THERMAL_RESISTOR"
+						register "TMPIN2" = "THERMAL_RESISTOR"
+						register "TMPIN3" = "THERMAL_RESISTOR"
+
+						register "FAN1.mode" = "FAN_SMART_AUTOMATIC"
+						register "FAN1.smart.tmpin" = "1"
+						register "FAN1.smart.tmp_off" = "0x80" # never
+						register "FAN1.smart.tmp_start" = "20"
+						register "FAN1.smart.tmp_full" = "70"
+						register "FAN1.smart.tmp_delta" = "0"
+						register "FAN1.smart.smoothing" = "1"
+						register "FAN1.smart.pwm_start" = "20"
+						register "FAN1.smart.slope" = "32"
+
+						# Enable tacho reading for chassis fan.
+						register "FAN2.mode" = "FAN_MODE_OFF"
 
 						device pnp 2e.0 off #  Floppy
 							io 0x60 = 0x3f0
diff --git a/src/superio/ite/it8728f/Kconfig b/src/superio/ite/it8728f/Kconfig
index 12af418..90c3b50 100644
--- a/src/superio/ite/it8728f/Kconfig
+++ b/src/superio/ite/it8728f/Kconfig
@@ -17,3 +17,7 @@
 config SUPERIO_ITE_IT8728F
 	bool
 	select SUPERIO_ITE_COMMON_ROMSTAGE
+	select SUPERIO_ITE_ENV_CTRL
+	select SUPERIO_ITE_ENV_CTRL_PWM_FREQ2
+	select SUPERIO_ITE_ENV_CTRL_FAN16_CONFIG
+	select SUPERIO_ITE_ENV_CTRL_8BIT_PWM
diff --git a/src/superio/ite/it8728f/Makefile.inc b/src/superio/ite/it8728f/Makefile.inc
index e0e26f4..fb75418 100644
--- a/src/superio/ite/it8728f/Makefile.inc
+++ b/src/superio/ite/it8728f/Makefile.inc
@@ -14,5 +14,4 @@
 ## GNU General Public License for more details.
 ##
 
-ramstage-$(CONFIG_SUPERIO_ITE_IT8728F) += it8728f_hwm.c
 ramstage-$(CONFIG_SUPERIO_ITE_IT8728F) += superio.c
diff --git a/src/superio/ite/it8728f/chip.h b/src/superio/ite/it8728f/chip.h
index c925c85..3442439 100644
--- a/src/superio/ite/it8728f/chip.h
+++ b/src/superio/ite/it8728f/chip.h
@@ -17,14 +17,10 @@
 #ifndef SUPERIO_ITE_IT8728F_CHIP_H
 #define SUPERIO_ITE_IT8728F_CHIP_H
 
+#include <superio/ite/common/env_ctrl_chip.h>
+
 struct superio_ite_it8728f_config {
-	/* HWM configuration registers */
-	uint8_t hwm_ctl_register;
-	uint8_t hwm_main_ctl_register;
-	uint8_t hwm_adc_temp_chan_en_reg;
-	uint8_t hwm_fan1_ctl_pwm;
-	uint8_t hwm_fan2_ctl_pwm;
-	uint8_t hwm_fan3_ctl_pwm;
+	struct ite_ec_config ec;
 };
 
 #endif /* SUPERIO_ITE_IT8728F_CHIP_H */
diff --git a/src/superio/ite/it8728f/it8728f_hwm.c b/src/superio/ite/it8728f/it8728f_hwm.c
deleted file mode 100644
index 5ab4a39..0000000
--- a/src/superio/ite/it8728f/it8728f_hwm.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2014 Edward O'Callaghan <eocallaghan at alterapraxis.com>
- *
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include <arch/io.h>
-#include <console/console.h>
-#include <device/device.h>
-#include <device/pnp.h>
-#include "chip.h"
-#include "it8728f_internal.h"
-
-/*
- * FAN controller configuration register index's
- */
-#define HWM_MAIN_CTL_REG		 0x13	/* default 0x07 */
-#define HWM_CTL_REG			 0x14	/* default 0x40 */
-#define HWM_FAN1_CTL_PWM		 0x15	/* default 0x00 */
-#define HWM_FAN2_CTL_PWM		 0x16	/* default 0x00 */
-#define HWM_FAN3_CTL_PWM		 0x17	/* default 0x00 */
-#define HWM_ADC_TEMP_CHAN_EN_REG 0x51	/* default 0x00 */
-
-void it8728f_hwm_ec_init(struct device *dev)
-{
-	struct superio_ite_it8728f_config *conf = dev->chip_info;
-	struct resource *res = find_resource(dev, PNP_IDX_IO0);
-
-	if (!res) {
-		printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n");
-		return;
-	}
-	/* I/O port for HWM is at base + 5 */
-	u16 port = res->base + 5;
-
-	printk(BIOS_INFO,
-		"ITE IT8728F Super I/O HWM: Initializing Hardware Monitor..\n");
-	printk(BIOS_DEBUG,
-		"ITE IT8728F Super I/O HWM: Base Address at 0x%x\n", port);
-
-	pnp_enter_conf_mode(dev);
-	pnp_set_logical_device(dev);
-
-	/* ITE IT8728F HWM (ordered) programming sequence. */
-
-	/* configure fan polarity */
-	pnp_write_index(port, HWM_CTL_REG, conf->hwm_ctl_register);
-
-	/* enable fans 1-3 */
-	pnp_write_index(port, HWM_MAIN_CTL_REG, conf->hwm_main_ctl_register);
-
-	/* enable termistor temps for temp1-temp3 */
-	pnp_write_index(port, HWM_ADC_TEMP_CHAN_EN_REG, conf->hwm_adc_temp_chan_en_reg);
-
-	/* configure which fanX uses which tempY */
-	pnp_write_index(port, HWM_FAN1_CTL_PWM, conf->hwm_fan1_ctl_pwm);
-	pnp_write_index(port, HWM_FAN2_CTL_PWM, conf->hwm_fan2_ctl_pwm);
-	pnp_write_index(port, HWM_FAN3_CTL_PWM, conf->hwm_fan3_ctl_pwm);
-
-	pnp_exit_conf_mode(dev);
-}
diff --git a/src/superio/ite/it8728f/superio.c b/src/superio/ite/it8728f/superio.c
index 9a1ceb1..b8c5b22 100644
--- a/src/superio/ite/it8728f/superio.c
+++ b/src/superio/ite/it8728f/superio.c
@@ -21,6 +21,7 @@
 #include <console/console.h>
 #include <pc80/keyboard.h>
 #include <stdlib.h>
+#include <superio/ite/common/env_ctrl.h>
 
 #include "chip.h"
 #include "it8728f.h"
@@ -28,13 +29,19 @@
 
 static void it8728f_init(struct device *dev)
 {
+	const struct superio_ite_it8728f_config *conf = dev->chip_info;
+	const struct resource *res;
+
 	if (!dev->enabled)
 		return;
 
 	switch(dev->path.pnp.device) {
-	/* TODO: Might potentially need code for HWM or FDC etc. */
+	/* TODO: Might potentially need code for FDC etc. */
 	case IT8728F_EC:
-		it8728f_hwm_ec_init(dev);
+		res = find_resource(dev, PNP_IDX_IO0);
+		if (!conf || !res)
+			break;
+		ite_ec_init(res->base, &conf->ec);
 		break;
 	case IT8728F_KBCK:
 		set_kbc_ps2_mode();

-- 
To view, visit https://review.coreboot.org/19293
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idf0c8908ba5ad6ff552b8302bffc638aa9052941
Gerrit-PatchSet: 8
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Tobias Diedrich <ranma+coreboot at tdiedrich.de>
Gerrit-Reviewer: Arthur Heymans <arthur at aheymans.xyz>
Gerrit-Reviewer: Felix Held <felix-coreboot at felixheld.de>
Gerrit-Reviewer: Martin Roth <martinroth at google.com>
Gerrit-Reviewer: Paul Menzel <paulepanter at users.sourceforge.net>
Gerrit-Reviewer: Rudolf Marek <r.marek at assembler.cz>
Gerrit-Reviewer: Sergej Ivanov <getinaks at gmail.com>
Gerrit-Reviewer: Tobias Diedrich <ranma+coreboot at tdiedrich.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply at coreboot.org>



More information about the coreboot-gerrit mailing list