Module Name: src
Committed By: kiyohara
Date: Sun Oct 10 04:49:48 UTC 2010
Modified Files:
src/sys/dev/marvell: gttwsi.c
Log Message:
Add timeout for wait.
Not send STOP, if received ACK.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/marvell/gttwsi.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/marvell/gttwsi.c
diff -u src/sys/dev/marvell/gttwsi.c:1.4 src/sys/dev/marvell/gttwsi.c:1.5
--- src/sys/dev/marvell/gttwsi.c:1.4 Sun Oct 3 07:14:33 2010
+++ src/sys/dev/marvell/gttwsi.c Sun Oct 10 04:49:48 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: gttwsi.c,v 1.4 2010/10/03 07:14:33 kiyohara Exp $ */
+/* $NetBSD: gttwsi.c,v 1.5 2010/10/10 04:49:48 kiyohara Exp $ */
/*
* Copyright (c) 2008 Eiji Kawauchi.
* All rights reserved.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gttwsi.c,v 1.4 2010/10/03 07:14:33 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gttwsi.c,v 1.5 2010/10/10 04:49:48 kiyohara Exp $");
#include "locators.h"
#include <sys/param.h>
@@ -335,7 +335,7 @@
struct gttwsi_softc *sc = v;
int error;
- if (flags & I2C_F_STOP)
+ if (flags & I2C_F_LAST)
error = gttwsi_wait(sc, 0, STAT_MRRD_ANT, flags);
else
error = gttwsi_wait(sc, CONTROL_ACK, STAT_MRRD_AT, flags);
@@ -360,13 +360,14 @@
int flags)
{
uint32_t status;
- int error = 0;
+ int timo, error = 0;
DELAY(5);
if (!(flags & I2C_F_POLL))
control |= CONTROL_INTEN;
WREG(sc, TWSI_CONTROL, control | CONTROL_TWSIEN);
+ timo = 0;
for (;;) {
control = RREG(sc, TWSI_CONTROL);
if (control & CONTROL_IFLG)
@@ -379,6 +380,8 @@
return error;
}
DELAY(TWSI_RETRY_DELAY);
+ if (timo++ > 1000000) /* 1sec */
+ break;
}
status = RREG(sc, TWSI_STATUS);
@@ -388,7 +391,8 @@
return EIO;
}
- if ((flags & I2C_F_STOP) && expect != STAT_MRRD_AT)
+ if ((flags & I2C_F_STOP) && expect != STAT_RSCT &&
+ expect != STAT_MRRD_AT && expect != STAT_ARBT_AR)
error = gttwsi_send_stop(sc, flags);
return error;