From owner-svn-src-head@FreeBSD.ORG Wed Jun 25 05:39:30 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DECCC188; Wed, 25 Jun 2014 05:39:30 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B12862B33; Wed, 25 Jun 2014 05:39:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5P5dUOJ098209; Wed, 25 Jun 2014 05:39:30 GMT (envelope-from daichi@svn.freebsd.org) Received: (from daichi@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5P5dUtL098208; Wed, 25 Jun 2014 05:39:30 GMT (envelope-from daichi@svn.freebsd.org) Message-Id: <201406250539.s5P5dUtL098208@svn.freebsd.org> From: Daichi GOTO Date: Wed, 25 Jun 2014 05:39:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267852 - head/sys/dev/glxiic X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jun 2014 05:39:31 -0000 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 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);