Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/20879
Change subject: [WIP] sb/intel/common: limit smbus block read bytes according to slave
......................................................................
[WIP] sb/intel/common: limit smbus block read bytes according to slave
Should it also limit to 32?
Should it report to the user if slave bytes is less than function
input?
Change-Id: If9e5d24255a0a03039b52d2863bc278d0eefc311
Signed-off-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M src/southbridge/intel/common/smbus.c
1 file changed, 7 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/79/20879/1
diff --git a/src/southbridge/intel/common/smbus.c b/src/southbridge/intel/common/smbus.c
index cac9ba7..cb884dc 100644
--- a/src/southbridge/intel/common/smbus.c
+++ b/src/southbridge/intel/common/smbus.c
@@ -193,13 +193,14 @@
}
int do_smbus_block_read(unsigned int smbus_base, u8 device, u8 cmd,
- unsigned int bytes, u8 *buf)
+ unsigned int max_bytes, u8 *buf)
{
u8 status;
int bytes_read = 0;
unsigned int loops = SMBUS_TIMEOUT;
if (smbus_wait_until_ready(smbus_base) < 0)
return SMBUS_WAIT_UNTIL_READY_TIMEOUT;
+ u8 slave_bytes;
/* Set up transaction */
/* Disable interrupts */
@@ -223,6 +224,10 @@
if (smbus_wait_until_active(smbus_base) < 0)
return SMBUS_WAIT_UNTIL_ACTIVE_TIMEOUT;
+ slave_bytes = inb(smbus_base + SMBHSTDAT0);
+ if (slave_bytes < max_bytes)
+ max_bytes = slave_bytes;
+
/* Poll for transaction completion */
do {
loops--;
@@ -236,7 +241,7 @@
*buf = inb(smbus_base + SMBBLKDAT);
buf++;
bytes_read++;
- if (--bytes == 1) {
+ if (--max_bytes == 1) {
/* indicate that next byte is the last one */
outb(inb(smbus_base + SMBHSTCTL)
| SMBHSTCNT_LAST_BYTE,
--
To view, visit https://review.coreboot.org/20879
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: If9e5d24255a0a03039b52d2863bc278d0eefc311
Gerrit-Change-Number: 20879
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>