[coreboot-gerrit] New patch to review for coreboot: 2a6bd421 superio/fintek: Add support for Fintek F81866AD-I

Fabian Kunkel (fabi@adv.bruhnspace.com) gerrit at coreboot.org
Tue May 26 15:39:33 CEST 2015


Fabian Kunkel (fabi at adv.bruhnspace.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10312

-gerrit

commit 2a6bd42122f983eab5bde9a27bd9050a2d59c0be
Author: Fabian Kunkel <fabi at adv.bruhnspace.com>
Date:   Tue May 26 15:37:54 2015 +0200

    superio/fintek: Add support for Fintek F81866AD-I
    
    This patch adds support for the Fintek F81866AD-I SuperIO,
    which is very similar to the fintek/f81865f.
    This code adds some fan control support, inspired by fintek/f71869ad.
    Furthermore its possible to change the temp sensor type (thermistor or diode).
    Datasheet: Name: F81866D/A-I, Release Date: Jan 2012, Version: V0.12P
    Link: http://www.alldatasheet.com/datasheet-pdf/pdf/459085/FINTEK/F81866AD-I.html
    
    Change-Id: Ibb5732f1ef475fe6ef18ad7521d22b977595c3d8
    Signed-off-by: Fabian Kunkel <fabi at adv.bruhnspace.com>
---
 src/superio/fintek/f81866d/Makefile.inc          |  2 +-
 src/superio/fintek/f81866d/chip.h                | 54 ++++++++++++++++++
 src/superio/fintek/f81866d/f81866d.h             |  4 +-
 src/superio/fintek/f81866d/f81866d_hwm.c         | 71 +++++++++---------------
 src/superio/fintek/f81866d/f81866d_temp_sensor.c | 47 ----------------
 src/superio/fintek/f81866d/fintek_internal.h     |  2 +-
 src/superio/fintek/f81866d/superio.c             |  9 +--
 7 files changed, 88 insertions(+), 101 deletions(-)

diff --git a/src/superio/fintek/f81866d/Makefile.inc b/src/superio/fintek/f81866d/Makefile.inc
index dd69894..2023b6c 100644
--- a/src/superio/fintek/f81866d/Makefile.inc
+++ b/src/superio/fintek/f81866d/Makefile.inc
@@ -1,6 +1,7 @@
 ##
 ## This file is part of the coreboot project.
 ##
+## Copyright (C) 2014 Edward O'Callaghan <eocallaghan at alterapraxis.com>
 ## Copyright (C) 2015 BAP - Bruhnspace Advanced Projects
 ## (Written by Fabian Kunkel <fabi at adv.bruhnspace.com> for BAP)
 ##
@@ -19,6 +20,5 @@
 ## Foundation, Inc.
 ##
 
-ramstage-$(CONFIG_SUPERIO_FINTEK_F81866D) += f81866d_temp_sensor.c
 ramstage-$(CONFIG_SUPERIO_FINTEK_F81866D) += f81866d_hwm.c
 ramstage-$(CONFIG_SUPERIO_FINTEK_F81866D) += superio.c
diff --git a/src/superio/fintek/f81866d/chip.h b/src/superio/fintek/f81866d/chip.h
new file mode 100644
index 0000000..9c9e799
--- /dev/null
+++ b/src/superio/fintek/f81866d/chip.h
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan at alterapraxis.com>
+ * Copyright (C) 2015 BAP - Bruhnspace Advanced Projects
+ * (Written by Fabian Kunkel <fabi at adv.bruhnspace.com> for BAP)
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.
+ */
+
+#ifndef SUPERIO_FINTEK_F81866D_CHIP_H
+#define SUPERIO_FINTEK_F81866D_CHIP_H
+
+#include <stdint.h>
+
+struct superio_fintek_f81866d_config {
+
+	/* AMD TSI */
+	uint8_t hwm_amd_tsi_addr;
+	uint8_t hwm_amd_tsi_control;
+
+	/* Fan control */
+	uint8_t hwm_fan_select;
+	uint8_t hwm_fan_mode;
+	uint8_t hwm_fan3_control;
+	uint8_t hwm_fan2_temp_map_select;
+
+	uint8_t hwm_fan2_bound1;
+	uint8_t hwm_fan2_bound2;
+	uint8_t hwm_fan2_bound3;
+	uint8_t hwm_fan2_bound4;
+	uint8_t hwm_fan2_seg1_speed;
+	uint8_t hwm_fan2_seg2_speed;
+	uint8_t hwm_fan2_seg3_speed;
+	uint8_t hwm_fan2_seg4_speed;
+	uint8_t hwm_fan2_seg5_speed;
+
+	/* Temp sensor type */
+	uint8_t hwm_temp_sens_type;
+};
+
+#endif /* SUPERIO_FINTEK_F81866D_CHIP_H */
diff --git a/src/superio/fintek/f81866d/f81866d.h b/src/superio/fintek/f81866d/f81866d.h
index 055bb9e..70a33b6 100644
--- a/src/superio/fintek/f81866d/f81866d.h
+++ b/src/superio/fintek/f81866d/f81866d.h
@@ -1,6 +1,7 @@
 /*
  * This file is part of the coreboot project.
  *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan at alterapraxis.com>
  * Copyright (C) 2015 BAP - Bruhnspace Advanced Projects
  * (Written by Fabian Kunkel <fabi at adv.bruhnspace.com> for BAP)
  *
@@ -21,7 +22,8 @@
 
 /*
  * Datasheet:
- *  - Name: F81866D/A-I
+ *  - Name: F81866D/A-I, Release Date: Jan 2012, Version: V0.12P
+ *  - Link: http://www.alldatasheet.com/datasheet-pdf/pdf/459085/FINTEK/F81866AD-I.html
  */
 
 #ifndef SUPERIO_FINTEK_F81866_H
diff --git a/src/superio/fintek/f81866d/f81866d_hwm.c b/src/superio/fintek/f81866d/f81866d_hwm.c
index 073b371..bc24468 100644
--- a/src/superio/fintek/f81866d/f81866d_hwm.c
+++ b/src/superio/fintek/f81866d/f81866d_hwm.c
@@ -1,6 +1,7 @@
 /*
  * This file is part of the coreboot project.
  *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan at alterapraxis.com>
  * Copyright (C) 2015 BAP - Bruhnspace Advanced Projects
  * (Written by Fabian Kunkel <fabi at adv.bruhnspace.com> for BAP)
  *
@@ -28,9 +29,11 @@
 #include <device/device.h>
 #include <device/pnp.h>
 #include "fintek_internal.h"
+#include "chip.h"
 
 
-// Set to AMD
+/* Register addresses */
+// Choose between AMD and Intel
 #define HWM_AMD_TSI_ADDR             0x08
 #define HWM_AMD_TSI_CONTROL_REG      0x0A
 
@@ -41,39 +44,20 @@
 #define HWM_FAN3_CONTROL	0x9A
 #define HWM_FAN_SEL		0x94
 #define HWM_FAN_MODE		0x96
-#define HWM_FAN_FAST_FILTER	0x97
-
-// Fan expected speed
-#define HWM_FAN2_EX_SPEED1     0xB2
-#define HWM_FAN2_EX_SPEED2     0xB3
+#define HWM_FAN2_TEMP_MAP_SEL      0xBF
 
-// 4 Boundries
+// Fan 2 - 4 Boundries
 #define HWM_FAN2_BOUND1	0xB6
 #define HWM_FAN2_BOUND2	0xB7
 #define HWM_FAN2_BOUND3	0xB8
 #define HWM_FAN2_BOUND4	0xB9
-
-// 5 Segment Speeds
+// Fan 2 - 5 Segment speeds
 #define HWM_FAN2_SEG1_SPEED_COUNT  0xBA
 #define HWM_FAN2_SEG2_SPEED_COUNT  0xBB
 #define HWM_FAN2_SEG3_SPEED_COUNT  0xBC
 #define HWM_FAN2_SEG4_SPEED_COUNT  0xBD
 #define HWM_FAN2_SEG5_SPEED_COUNT  0xBE
 
-// FAN1 Temp Mapping
-#define HWM_FAN2_TEMP_MAP_SEL      0xBF
-
-/* Defines freq. for fan control */
-#define PWM_220HZ_FAN3_CONTROL	0x20
-#define PWM_5KHZ_FAN3_CONTROL	0x20
-#define PWM_11KHZ_FAN3_CONTROL	0x00
-#define PWM_23KHZ_FAN3_CONTROL	0x00
-
-#define PWM_220HZ_FAN2_MAP_SEL	0x3D
-#define PWM_5KHZ_FAN2_MAP_SEL	0x1D
-#define PWM_11KHZ_FAN2_MAP_SEL	0x3D
-#define PWM_23KHZ_FAN2_MAP_SEL	0x1D
-
 
 void f81866d_hwm_init(struct device *dev)
 {
@@ -84,41 +68,40 @@ void f81866d_hwm_init(struct device *dev)
 		return;
 	}
 
+	const struct superio_fintek_f81866d_config *reg = dev->chip_info;
 	u16 port = res->base;
 
 	pnp_enter_conf_mode(dev);
 
 	/* Use AMD TSI */
-	pnp_write_index(port, HWM_AMD_TSI_ADDR, 0x98);
-	pnp_write_index(port, HWM_AMD_TSI_CONTROL_REG, 0x02);
+	pnp_write_index(port, HWM_AMD_TSI_ADDR, reg->hwm_amd_tsi_addr);
+	pnp_write_index(port, HWM_AMD_TSI_CONTROL_REG, reg->hwm_amd_tsi_control);
 
-	// Set temp1 sensor to thermistor
-	pnp_write_index(port, TEMP_SENS_TYPE_REG, 0x04);
+	/* Set temp1 sensor to thermistor */
+	pnp_write_index(port, TEMP_SENS_TYPE_REG, reg->hwm_temp_sens_type);
 
 	/* Select FAN Type */
-	pnp_write_index(port, HWM_FAN_SEL, 0xC0);	// 0xC0 set FAN2 to PWM
+	pnp_write_index(port, HWM_FAN_SEL, reg->hwm_fan_select);
 
 	/* Select FAN Mode*/
-	pnp_write_index(port, HWM_FAN_MODE, 0xD5);	// 0xD5 sets FAN1-3 to Auto RPM mode
-
-	pnp_write_index(port, HWM_FAN_FAST_FILTER, 0x02);	// Faster fan
+	pnp_write_index(port, HWM_FAN_MODE, reg->hwm_fan_mode);
 
 	/* Set Boundries */
-	pnp_write_index(port, HWM_FAN2_BOUND1, 0x3C);	//60°C
-	pnp_write_index(port, HWM_FAN2_BOUND2, 0x32);	//50°C
-	pnp_write_index(port, HWM_FAN2_BOUND3, 0x28);	//40°C
-	pnp_write_index(port, HWM_FAN2_BOUND4, 0x1E);	//30°C
+	pnp_write_index(port, HWM_FAN2_BOUND1, reg->hwm_fan2_bound1);
+	pnp_write_index(port, HWM_FAN2_BOUND2, reg->hwm_fan2_bound2);
+	pnp_write_index(port, HWM_FAN2_BOUND3, reg->hwm_fan2_bound3);
+	pnp_write_index(port, HWM_FAN2_BOUND4, reg->hwm_fan2_bound4);
 
 	/* Set Speed */
-	pnp_write_index(port, HWM_FAN2_SEG1_SPEED_COUNT, 0xFF);	// 100%
-	pnp_write_index(port, HWM_FAN2_SEG2_SPEED_COUNT, 0xD9); // 85%
-	pnp_write_index(port, HWM_FAN2_SEG3_SPEED_COUNT, 0xB2); // 70%
-	pnp_write_index(port, HWM_FAN2_SEG4_SPEED_COUNT, 0x99); // 60%
-	pnp_write_index(port, HWM_FAN2_SEG5_SPEED_COUNT, 0x80); // 50%
-
-	/* Set temp follows */
-	pnp_write_index(port, HWM_FAN3_CONTROL, PWM_220HZ_FAN3_CONTROL);
-	pnp_write_index(port, HWM_FAN2_TEMP_MAP_SEL, PWM_220HZ_FAN2_MAP_SEL);
+	pnp_write_index(port, HWM_FAN2_SEG1_SPEED_COUNT, reg->hwm_fan2_seg1_speed);
+	pnp_write_index(port, HWM_FAN2_SEG2_SPEED_COUNT, reg->hwm_fan2_seg2_speed);
+	pnp_write_index(port, HWM_FAN2_SEG3_SPEED_COUNT, reg->hwm_fan2_seg3_speed);
+	pnp_write_index(port, HWM_FAN2_SEG4_SPEED_COUNT, reg->hwm_fan2_seg4_speed);
+	pnp_write_index(port, HWM_FAN2_SEG5_SPEED_COUNT, reg->hwm_fan2_seg5_speed);
+
+	/* Set Fan control freq */
+	pnp_write_index(port, HWM_FAN3_CONTROL, reg->hwm_fan3_control);
+	pnp_write_index(port, HWM_FAN2_TEMP_MAP_SEL, reg->hwm_fan2_temp_map_select);
 
 	pnp_exit_conf_mode(dev);
 }
diff --git a/src/superio/fintek/f81866d/f81866d_temp_sensor.c b/src/superio/fintek/f81866d/f81866d_temp_sensor.c
deleted file mode 100644
index aaddd45..0000000
--- a/src/superio/fintek/f81866d/f81866d_temp_sensor.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2015 BAP - Bruhnspace Advanced Projects
- * (Written by Fabian Kunkel <fabi at adv.bruhnspace.com> for BAP)
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc.
- */
-
-#include <arch/io.h>
-#include <device/device.h>
-#include <device/pnp.h>
-#include <console/console.h>
-#include "fintek_internal.h"
-
-#define TEMP_SENS_TYPE_REG	0x6B
-
-void f81866d_temp_sensor(struct device *dev)
-{
-	struct resource *res = find_resource(dev, PNP_IDX_IO0);
-
-	if (!res) {
-		printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n");
-		return;
-	}
-
-	u16 port = res->base;
-
-	pnp_enter_conf_mode(dev);
-
-	// Set temp1 sensor correct to thermistor
-	pnp_write_index(port, TEMP_SENS_TYPE_REG, 0x04);
-
-	pnp_exit_conf_mode(dev);
-}
diff --git a/src/superio/fintek/f81866d/fintek_internal.h b/src/superio/fintek/f81866d/fintek_internal.h
index c198421..acd7532 100644
--- a/src/superio/fintek/f81866d/fintek_internal.h
+++ b/src/superio/fintek/f81866d/fintek_internal.h
@@ -1,6 +1,7 @@
 /*
  * This file is part of the coreboot project.
  *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan at alterapraxis.com>
  * Copyright (C) 2015 BAP - Bruhnspace Advanced Projects
  * (Written by Fabian Kunkel <fabi at adv.bruhnspace.com> for BAP)
  *
@@ -25,7 +26,6 @@
 #include <arch/io.h>
 #include <device/pnp.h>
 
-void f81866d_temp_sensor(struct device *dev);
 void f81866d_hwm_init(struct device *dev);
 
 #endif /* SUPERIO_FINTEK_F81866D_INTERNAL_H */
diff --git a/src/superio/fintek/f81866d/superio.c b/src/superio/fintek/f81866d/superio.c
index d12d241..a2245a0 100644
--- a/src/superio/fintek/f81866d/superio.c
+++ b/src/superio/fintek/f81866d/superio.c
@@ -1,6 +1,7 @@
 /*
  * This file is part of the coreboot project.
  *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan at alterapraxis.com>
  * Copyright (C) 2015 BAP - Bruhnspace Advanced Projects
  * (Written by Fabian Kunkel <fabi at adv.bruhnspace.com> for BAP)
  *
@@ -40,14 +41,8 @@ static void f81866d_init(struct device *dev)
 		pc_keyboard_init();
 		break;
 	case F81866D_HWM:
-
-	#if IS_ENABLED(CONFIG_HUDSON_IMC_FWM)
-		// Fixing temp sensor readout according data sheet
-		f81866d_temp_sensor(dev);
-	#else
 		// Fixing temp sensor read out and init Fan control
 		f81866d_hwm_init(dev);
-	#endif
 		break;
 	}
 }
@@ -84,6 +79,6 @@ static void enable_dev(struct device *dev)
 }
 
 struct chip_operations superio_fintek_f81866d_ops = {
-	CHIP_NAME("Fintek F81866D Super I/O")
+	CHIP_NAME("Fintek F81866AD-I Super I/O")
 	.enable_dev = enable_dev
 };



More information about the coreboot-gerrit mailing list