Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Oct 2014 07:51:27 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r273728 - head/sys/dev/iicbus
Message-ID:  <201410270751.s9R7pR4K031613@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Oct 27 07:51:26 2014
New Revision: 273728
URL: https://svnweb.freebsd.org/changeset/base/273728

Log:
  Add a method to iicbus to request IIC_M_NOSTOP behaviour for multibyte
  transfers to be default.  It simplifies porting code which assumes
  such settings.
  
  Discussed with:	avg, llos, nwhitehorn
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/dev/iicbus/iicbus.h
  head/sys/dev/iicbus/iiconf.c

Modified: head/sys/dev/iicbus/iicbus.h
==============================================================================
--- head/sys/dev/iicbus/iicbus.h	Mon Oct 27 07:47:13 2014	(r273727)
+++ head/sys/dev/iicbus/iicbus.h	Mon Oct 27 07:51:26 2014	(r273728)
@@ -49,16 +49,19 @@ struct iicbus_softc
 struct iicbus_ivar
 {
 	uint32_t	addr;
+	bool		nostop;
 };
 
 enum {
-	IICBUS_IVAR_ADDR		/* Address or base address */
+	IICBUS_IVAR_ADDR,		/* Address or base address */
+	IICBUS_IVAR_NOSTOP,		/* nostop defaults */
 };
 
 #define IICBUS_ACCESSOR(A, B, T)					\
 	__BUS_ACCESSOR(iicbus, A, IICBUS, B, T)
 	
 IICBUS_ACCESSOR(addr,		ADDR,		uint32_t)
+IICBUS_ACCESSOR(nostop,		NOSTOP,		bool)
 
 #define	IICBUS_LOCK(sc)			mtx_lock(&(sc)->lock)
 #define	IICBUS_UNLOCK(sc)      		mtx_unlock(&(sc)->lock)

Modified: head/sys/dev/iicbus/iiconf.c
==============================================================================
--- head/sys/dev/iicbus/iiconf.c	Mon Oct 27 07:47:13 2014	(r273727)
+++ head/sys/dev/iicbus/iiconf.c	Mon Oct 27 07:51:26 2014	(r273728)
@@ -365,6 +365,7 @@ iicbus_transfer_gen(device_t dev, struct
 {
 	int i, error, lenread, lenwrote, nkid, rpstart, addr;
 	device_t *children, bus;
+	bool nostop;
 
 	if ((error = device_get_children(dev, &children, &nkid)) != 0)
 		return (error);
@@ -375,6 +376,7 @@ iicbus_transfer_gen(device_t dev, struct
 	bus = children[0];
 	rpstart = 0;
 	free(children, M_TEMP);
+	nostop = iicbus_get_nostop(dev);
 	for (i = 0, error = 0; i < nmsgs && error == 0; i++) {
 		addr = msgs[i].slave;
 		if (msgs[i].flags & IIC_M_RD)
@@ -399,11 +401,12 @@ iicbus_transfer_gen(device_t dev, struct
 			error = iicbus_write(bus, msgs[i].buf, msgs[i].len,
 			    &lenwrote, 0);
 
-		if (!(msgs[i].flags & IIC_M_NOSTOP)) {
+		if ((msgs[i].flags & IIC_M_NOSTOP) != 0 ||
+		    (nostop && i + 1 < nmsgs)) {
+			rpstart = 1;	/* Next message gets repeated start */
+		} else {
 			rpstart = 0;
 			iicbus_stop(bus);
-		} else {
-			rpstart = 1;	/* Next message gets repeated start */
 		}
 	}
 	return (error);



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