[coreboot-gerrit] New patch to review for coreboot: [WIP] superio/ite/it8718f: Init the environment controller
Arthur Heymans (arthur@aheymans.xyz)
gerrit at coreboot.org
Mon Nov 14 00:35:04 CET 2016
Arthur Heymans (arthur at aheymans.xyz) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17413
-gerrit
commit bc9053fedd152db0c22566e76e2c5890f503e004
Author: Arthur Heymans <arthur at aheymans.xyz>
Date: Mon Nov 14 00:24:50 2016 +0100
[WIP] superio/ite/it8718f: Init the environment controller
Code is copied from it8728f.
Change-Id: I4743e5087df30dc2c498c718dc7d0e09d7f3788d
Signed-off-by: Arthur Heymans <arthur at aheymans.xyz>
---
src/superio/ite/it8718f/Makefile.inc | 1 +
src/superio/ite/it8718f/chip.h | 30 +++++++++++++
src/superio/ite/it8718f/it8718f_hwm.c | 72 ++++++++++++++++++++++++++++++
src/superio/ite/it8718f/it8718f_internal.h | 24 ++++++++++
src/superio/ite/it8718f/superio.c | 3 +-
5 files changed, 129 insertions(+), 1 deletion(-)
diff --git a/src/superio/ite/it8718f/Makefile.inc b/src/superio/ite/it8718f/Makefile.inc
index 7627d1c..6137eb8 100644
--- a/src/superio/ite/it8718f/Makefile.inc
+++ b/src/superio/ite/it8718f/Makefile.inc
@@ -14,5 +14,6 @@
## GNU General Public License for more details.
##
+ramstage-$(CONFIG_SUPERIO_ITE_IT8728F) += it8718f_hwm.c
romstage-$(CONFIG_SUPERIO_ITE_IT8718F) += early_serial.c
ramstage-$(CONFIG_SUPERIO_ITE_IT8718F) += superio.c
diff --git a/src/superio/ite/it8718f/chip.h b/src/superio/ite/it8718f/chip.h
new file mode 100644
index 0000000..93a2b4d
--- /dev/null
+++ b/src/superio/ite/it8718f/chip.h
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+#ifndef SUPERIO_ITE_IT8718F_CHIP_H
+#define SUPERIO_ITE_IT8718F_CHIP_H
+
+struct superio_ite_it8718f_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;
+};
+
+#endif /* SUPERIO_ITE_IT8718F_CHIP_H */
diff --git a/src/superio/ite/it8718f/it8718f_hwm.c b/src/superio/ite/it8718f/it8718f_hwm.c
new file mode 100644
index 0000000..5c3640f
--- /dev/null
+++ b/src/superio/ite/it8718f/it8718f_hwm.c
@@ -0,0 +1,72 @@
+/*
+ * 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 "it8718f_internal.h"
+
+/*
+ * FAN controller configuration register index's
+ */
+#define HWM_MAIN_CTL_REG 0x13 /* default 0x07 */
+#define HWM_CTL_REG 0x14 /* default 0x50 */
+#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 it8718f_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 IT8718F 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/it8718f/it8718f_internal.h b/src/superio/ite/it8718f/it8718f_internal.h
new file mode 100644
index 0000000..7e551a2
--- /dev/null
+++ b/src/superio/ite/it8718f/it8718f_internal.h
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+#ifndef SUPERIO_ITE_IT8718F_INTERNAL_H
+#define SUPERIO_ITE_IT8718F_INTERNAL_H
+
+#include <device/device.h>
+
+void it8718f_hwm_ec_init(struct device *dev);
+
+#endif /* SUPERIO_ITE_IT8718F_INTERNAL_H */
diff --git a/src/superio/ite/it8718f/superio.c b/src/superio/ite/it8718f/superio.c
index a156aa6..f2ebf14 100644
--- a/src/superio/ite/it8718f/superio.c
+++ b/src/superio/ite/it8718f/superio.c
@@ -31,7 +31,8 @@ static void init(struct device *dev)
break;
case IT8718F_PP: /* TODO. */
break;
- case IT8718F_EC: /* TODO. */
+ case IT8718F_EC:
+ it8718f_hwm_ec_init(dev);
break;
case IT8718F_KBCK:
pc_keyboard_init(NO_AUX_DEVICE);
More information about the coreboot-gerrit
mailing list