Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jun 2014 05:39:30 +0000 (UTC)
From:      Daichi GOTO <daichi@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r267852 - head/sys/dev/glxiic
Message-ID:  <201406250539.s5P5dUtL098208@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: daichi (ports committer)
Date: Wed Jun 25 05:39:30 2014
New Revision: 267852
URL: http://svnweb.freebsd.org/changeset/base/267852

Log:
  Fixed an IIC timing issue between the glxiic master and a slave of
  peripheral devices.  When transmitting (rx) from slave to master,
  sometimes nAKC delays. As a result, some slaves fails their
  transmission.
  
  Submitted by:	Masanori OZAWA <ozawa@ongs.co.jp>
  Reviewed by:	brix
  MFC after:	1 week

Modified:
  head/sys/dev/glxiic/glxiic.c

Modified: head/sys/dev/glxiic/glxiic.c
==============================================================================
--- head/sys/dev/glxiic/glxiic.c	Wed Jun 25 03:54:02 2014	(r267851)
+++ head/sys/dev/glxiic/glxiic.c	Wed Jun 25 05:39:30 2014	(r267852)
@@ -711,6 +711,7 @@ static int
 glxiic_state_master_addr_callback(struct glxiic_softc *sc, uint8_t status)
 {
 	uint8_t slave;
+	uint8_t ctrl1;
 
 	GLXIIC_ASSERT_LOCKED(sc);
 
@@ -746,6 +747,13 @@ glxiic_state_master_addr_callback(struct
 
 	bus_write_1(sc->smb_res, GLXIIC_SMB_SDA, slave);
 
+	if ((sc->msg->flags & IIC_M_RD) != 0 && sc->ndata == 1) {
+		/* Last byte from slave, set NACK. */
+		ctrl1 = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL1);
+		bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1,
+		    ctrl1 | GLXIIC_SMB_CTRL1_ACK_BIT);
+	}
+
 	return (IIC_NOERR);
 }
 
@@ -811,13 +819,6 @@ glxiic_state_master_rx_callback(struct g
 		return (IIC_ENOACK);
 	}
 
-	if (sc->ndata == 1) {
-		/* Last byte from slave, set NACK. */
-		ctrl1 = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL1);
-		bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1,
-		    ctrl1 | GLXIIC_SMB_CTRL1_ACK_BIT);
-	}
-
 	if ((status & GLXIIC_SMB_STS_STASTR_BIT) != 0) {
 		/* Bus is stalled, clear and wait for data. */
 		bus_write_1(sc->smb_res, GLXIIC_SMB_STS,
@@ -837,6 +838,13 @@ glxiic_state_master_rx_callback(struct g
 		return (glxiic_state_table[sc->state].callback(sc, status));
 	}
 
+	if (sc->ndata == 1) {
+		/* Last byte from slave, set NACK. */
+		ctrl1 = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL1);
+		bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1,
+		    ctrl1 | GLXIIC_SMB_CTRL1_ACK_BIT);
+	}
+
 	glxiic_start_timeout_locked(sc);
 
 	return (IIC_NOERR);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406250539.s5P5dUtL098208>