aboutsummaryrefslogtreecommitdiff
path: root/src/southbridge/via
diff options
context:
space:
mode:
authorFlorian Zumbiehl <florz@florz.de>2011-11-01 20:17:13 +0100
committerRudolf Marek <r.marek@assembler.cz>2011-11-03 21:39:03 +0100
commite037f9f17473b0bd21b8ca63b1cb9479652f3b6b (patch)
treec11afa6b40eab4625fd6d7818051e107836ed5f2 /src/southbridge/via
parent8c4cf18fc48baa15388e12efa1d2b8da685df7b8 (diff)
add support for writing to SMBus with vt8237
Change-Id: I70fe072f8f3447d0be7b7ac64508a954fe47091d Signed-off-by: Florian Zumbiehl <florz@florz.de> Reviewed-on: http://review.coreboot.org/372 Tested-by: build bot (Jenkins) Reviewed-by: Rudolf Marek <r.marek@assembler.cz>
Diffstat (limited to 'src/southbridge/via')
-rw-r--r--src/southbridge/via/vt8237r/early_smbus.c31
-rw-r--r--src/southbridge/via/vt8237r/vt8237r.h1
2 files changed, 22 insertions, 10 deletions
diff --git a/src/southbridge/via/vt8237r/early_smbus.c b/src/southbridge/via/vt8237r/early_smbus.c
index a298e84676..e25535bf0f 100644
--- a/src/southbridge/via/vt8237r/early_smbus.c
+++ b/src/southbridge/via/vt8237r/early_smbus.c
@@ -87,17 +87,12 @@ static void smbus_reset(void)
PRINT_DEBUG("\n");
}
-/**
- * Read a byte from the SMBus.
- *
- * @param dimm The address location of the DIMM on the SMBus.
- * @param offset The offset the data is located at.
- */
-u8 smbus_read_byte(u8 dimm, u8 offset)
+static u8 smbus_transaction(u8 dimm, u8 offset, u8 data, int do_read)
{
u8 val;
- PRINT_DEBUG("DIMM ");
+ PRINT_DEBUG(do_read ? "RD: " : "WR: ");
+ PRINT_DEBUG("ADDR ");
PRINT_DEBUG_HEX16(dimm);
PRINT_DEBUG(" OFFSET ");
PRINT_DEBUG_HEX16(offset);
@@ -106,13 +101,13 @@ u8 smbus_read_byte(u8 dimm, u8 offset)
smbus_reset();
/* Clear host data port. */
- outb(0x00, SMBHSTDAT0);
+ outb(do_read ? 0x00 : data, SMBHSTDAT0);
SMBUS_DELAY();
smbus_wait_until_ready();
/* Actual addr to reg format. */
dimm = (dimm << 1);
- dimm |= 1;
+ dimm |= !!do_read;
outb(dimm, SMBXMITADD);
outb(offset, SMBHSTCMD);
@@ -132,6 +127,22 @@ u8 smbus_read_byte(u8 dimm, u8 offset)
return val;
}
+/**
+ * Read a byte from the SMBus.
+ *
+ * @param dimm The address location of the DIMM on the SMBus.
+ * @param offset The offset the data is located at.
+ */
+u8 smbus_read_byte(u8 dimm, u8 offset)
+{
+ return smbus_transaction(dimm, offset, 0, 1);
+}
+
+void smbus_write_byte(u8 dimm, u8 offset, u8 data)
+{
+ smbus_transaction(dimm, offset, data, 0);
+}
+
#define PSONREADY_TIMEOUT 0x7fffffff
static device_t get_vt8237_lpc(void)
diff --git a/src/southbridge/via/vt8237r/vt8237r.h b/src/southbridge/via/vt8237r/vt8237r.h
index 94b1840361..9d5a1fc608 100644
--- a/src/southbridge/via/vt8237r/vt8237r.h
+++ b/src/southbridge/via/vt8237r/vt8237r.h
@@ -148,6 +148,7 @@ __attribute__ ((packed))
#ifdef __PRE_RAM__
#ifndef __ROMCC__
u8 smbus_read_byte(u8 dimm, u8 offset);
+void smbus_write_byte(u8 dimm, u8 offset, u8 data);
void enable_smbus(void);
void smbus_fixup(const struct mem_controller *ctrl);
// these are in vt8237_early_smbus.c - do they really belong there?