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>
This commit is contained in:
parent
337afb0567
commit
680ed1f632
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue