diff options
author | Matt DeVillier <matt.devillier@gmail.com> | 2018-12-25 04:43:21 -0600 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2018-12-28 12:24:52 +0000 |
commit | 680ed1f632897b3ec493156863b05115f28102ef (patch) | |
tree | a85ae587141e44914078500343e1f40ed2bd263c /src | |
parent | 337afb05676e4079263d289b21ff822570e90d3d (diff) | |
download | coreboot-680ed1f632897b3ec493156863b05115f28102ef.tar.xz |
ec/chromeec: fix LPC read/write for MEC devices
Commit 8cf8aa2 [ec/google/chromeec: Use common MEC interface]
changed the return mechanism for the checksum on reads/writes
for MEC devices, but incorrectly handled the passed-in csum
parameter by not dereferencing. This led to the returned csum
value always being zero, which causes all EC commands with non-
NULL data_in to fail with a checksum error.
Fix this by storing the returned checksum in a temp variable,
and only assigning to csum when the pointer isn't NULL;
Test: build/boot google/chell, verify EC hello command succeeds,
keyboard backlight turned on at boot.
Change-Id: I7122c3fdc5a19f87f12975ee448728cf29948436
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-on: https://review.coreboot.org/c/30444
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Diffstat (limited to 'src')
-rw-r--r-- | src/ec/google/chromeec/ec_lpc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ec/google/chromeec/ec_lpc.c b/src/ec/google/chromeec/ec_lpc.c index c8665c9e82..61005d3e3b 100644 --- a/src/ec/google/chromeec/ec_lpc.c +++ b/src/ec/google/chromeec/ec_lpc.c @@ -41,9 +41,11 @@ static void read_bytes(u16 port, unsigned int length, u8 *dest, u8 *csum) #if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_MEC) /* Access desired range though EMI interface */ if (port >= MEC_EMI_RANGE_START && port <= MEC_EMI_RANGE_END) { - csum += mec_io_bytes(MEC_IO_READ, MEC_EMI_BASE, + u8 ret = mec_io_bytes(MEC_IO_READ, MEC_EMI_BASE, port - MEC_EMI_RANGE_START, dest, length); + if (csum) + *csum += ret; return; } #endif @@ -78,9 +80,11 @@ static void write_bytes(u16 port, unsigned int length, u8 *msg, u8 *csum) #if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_MEC) /* Access desired range though EMI interface */ if (port >= MEC_EMI_RANGE_START && port <= MEC_EMI_RANGE_END) { - csum += mec_io_bytes(MEC_IO_WRITE, MEC_EMI_BASE, + u8 ret = mec_io_bytes(MEC_IO_WRITE, MEC_EMI_BASE, port - MEC_EMI_RANGE_START, msg, length); + if (csum) + *csum += ret; return; } #endif |