From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 23 14:13:13 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15BAE106566C; Tue, 23 Nov 2010 14:13:13 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA2CE8FC13; Tue, 23 Nov 2010 14:13:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oANEDCFN032868; Tue, 23 Nov 2010 14:13:12 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oANEDCY1032865; Tue, 23 Nov 2010 14:13:12 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201011231413.oANEDCY1032865@svn.freebsd.org> From: Nathan Whitehorn Date: Tue, 23 Nov 2010 14:13:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r215749 - stable/8/sys/dev/iicbus X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Nov 2010 14:13:13 -0000 Author: nwhitehorn Date: Tue Nov 23 14:13:12 2010 New Revision: 215749 URL: http://svn.freebsd.org/changeset/base/215749 Log: MFC r208839,214999: Add two new flags (IIC_M_NOSTOP and IIC_M_NOSTART) to struct iic_msg to allow consumers of iicbus_transfer() to send messages with repeated starts. Reviewed by: imp, thompsa Modified: stable/8/sys/dev/iicbus/iic.h stable/8/sys/dev/iicbus/iiconf.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/iicbus/iic.h ============================================================================== --- stable/8/sys/dev/iicbus/iic.h Tue Nov 23 13:55:30 2010 (r215748) +++ stable/8/sys/dev/iicbus/iic.h Tue Nov 23 14:13:12 2010 (r215749) @@ -38,6 +38,8 @@ struct iic_msg uint16_t flags; #define IIC_M_WR 0 /* Fake flag for write */ #define IIC_M_RD 0x0001 /* read vs write */ +#define IIC_M_NOSTOP 0x0002 /* do not send a I2C stop after message */ +#define IIC_M_NOSTART 0x0004 /* do not send a I2C start before message */ uint16_t len; /* msg legnth */ uint8_t * buf; }; Modified: stable/8/sys/dev/iicbus/iiconf.c ============================================================================== --- stable/8/sys/dev/iicbus/iiconf.c Tue Nov 23 13:55:30 2010 (r215748) +++ stable/8/sys/dev/iicbus/iiconf.c Tue Nov 23 14:13:12 2010 (r215749) @@ -363,7 +363,7 @@ iicbus_transfer(device_t bus, struct iic int iicbus_transfer_gen(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) { - int i, error, lenread, lenwrote, nkid; + int i, error, lenread, lenwrote, nkid, rpstart, addr; device_t *children, bus; if ((error = device_get_children(dev, &children, &nkid)) != 0) @@ -373,14 +373,38 @@ iicbus_transfer_gen(device_t dev, struct return (EIO); } bus = children[0]; + rpstart = 0; free(children, M_TEMP); for (i = 0, error = 0; i < nmsgs && error == 0; i++) { + addr = msgs[i].slave; if (msgs[i].flags & IIC_M_RD) - error = iicbus_block_read(bus, msgs[i].slave, - msgs[i].buf, msgs[i].len, &lenread); + addr |= LSB; else - error = iicbus_block_write(bus, msgs[i].slave, - msgs[i].buf, msgs[i].len, &lenwrote); + addr &= ~LSB; + + if (!(msgs[i].flags & IIC_M_NOSTART)) { + if (rpstart) + error = iicbus_repeated_start(bus, addr, 0); + else + error = iicbus_start(bus, addr, 0); + } + + if (error) + break; + + if (msgs[i].flags & IIC_M_RD) + error = iicbus_read(bus, msgs[i].buf, msgs[i].len, + &lenread, IIC_LAST_READ, 0); + else + error = iicbus_write(bus, msgs[i].buf, msgs[i].len, + &lenwrote, 0); + + if (!(msgs[i].flags & IIC_M_NOSTOP)) { + rpstart = 0; + iicbus_stop(bus); + } else { + rpstart = 1; /* Next message gets repeated start */ + } } return (error); }