[coreboot-gerrit] New patch to review for coreboot: drivers/i2c/w83795: Add option to use auxiliary SMBUS controller

Timothy Pearson (tpearson@raptorengineeringinc.com) gerrit at coreboot.org
Sat Oct 17 11:46:11 CEST 2015


Timothy Pearson (tpearson at raptorengineeringinc.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/12080

-gerrit

commit 78bf70ec3a6ea81c93634260a2738a14e9f4ef87
Author: Timothy Pearson <tpearson at raptorengineeringinc.com>
Date:   Sat Oct 17 04:37:10 2015 -0500

    drivers/i2c/w83795: Add option to use auxiliary SMBUS controller
    
    Change-Id: I5a9b5eba992853b84b0cb6c3a1764edf42ac49b2
    Signed-off-by: Timothy Pearson <tpearson at raptorengineeringinc.com>
---
 src/drivers/i2c/w83795/chip.h   |  4 ++++
 src/drivers/i2c/w83795/w83795.c | 19 +++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/src/drivers/i2c/w83795/chip.h b/src/drivers/i2c/w83795/chip.h
index effe119..413ea87 100644
--- a/src/drivers/i2c/w83795/chip.h
+++ b/src/drivers/i2c/w83795/chip.h
@@ -139,4 +139,8 @@ struct drivers_i2c_w83795_config {
 	uint8_t fan6_duty;			/* % of full speed (0-100) */
 	uint8_t fan7_duty;			/* % of full speed (0-100) */
 	uint8_t fan8_duty;			/* % of full speed (0-100) */
+
+	uint8_t smbus_aux;			/* 0 == device located on first SMBUS,
+						 * 1 == device located on auxiliary SMBUS
+						 */
 };
diff --git a/src/drivers/i2c/w83795/w83795.c b/src/drivers/i2c/w83795/w83795.c
index cf0cf2f..cdd5b5a 100644
--- a/src/drivers/i2c/w83795/w83795.c
+++ b/src/drivers/i2c/w83795/w83795.c
@@ -26,6 +26,11 @@
 #include <device/smbus.h>
 #include "chip.h"
 
+#if IS_ENABLED(CONFIG_SOUTHBRIDGE_AMD_SB700)
+#	define SMBUS_AUX_CAPABLE 1
+#	include "southbridge/amd/sb700/smbus.h"
+#endif
+
 static int w83795_set_bank(struct device *dev, uint8_t bank)
 {
 	return smbus_write_byte(dev, W83795_REG_BANKSEL, bank);
@@ -141,7 +146,16 @@ static void w83795_init(struct device *dev, w83795_fan_mode_t mode, u8 dts_src)
 	uint8_t val;
 	uint16_t limit_value;
 
+#ifdef SMBUS_AUX_CAPABLE
+	uint8_t smbus_aux_prev = smbus_switched_to_aux();
+	switch_smbus_to_aux(config->smbus_aux);
+#endif
+
 	if (smbus_read_byte(dev, 0x00) < 0) {
+#ifdef SMBUS_AUX_CAPABLE
+		/* Restore SMBUS channel setting */
+		switch_smbus_to_aux(smbus_aux_prev);
+#endif
 		printk(BIOS_ERR, "W83795G/ADG Nuvoton H/W Monitor not found\n");
 		return;
 	}
@@ -325,6 +339,11 @@ static void w83795_init(struct device *dev, w83795_fan_mode_t mode, u8 dts_src)
 	val = w83795_read(dev, W83795_REG_CONFIG);
 	val |= W83795_REG_CONFIG_START;
 	w83795_write(dev, W83795_REG_CONFIG, val);
+
+#ifdef SMBUS_AUX_CAPABLE
+	/* Restore SMBUS channel setting */
+	switch_smbus_to_aux(smbus_aux_prev);
+#endif
 }
 
 static void w83795_hwm_init(struct device *dev)



More information about the coreboot-gerrit mailing list