Module Name:    src
Committed By:   pgoyette
Date:           Sun Apr 22 14:10:36 UTC 2012

Modified Files:
        src/sys/dev/i2c: i2c_exec.c i2c_io.h

Log Message:
Identify SMBus block-mode operations.

XXX Nothing in the kernel issues block-mode commands, and each i2c bus
XXX driver needs its own support for the block-mode operations.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/i2c/i2c_exec.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/i2c_io.h

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/i2c/i2c_exec.c
diff -u src/sys/dev/i2c/i2c_exec.c:1.7 src/sys/dev/i2c/i2c_exec.c:1.8
--- src/sys/dev/i2c/i2c_exec.c:1.7	Tue Feb  3 16:17:54 2009
+++ src/sys/dev/i2c/i2c_exec.c	Sun Apr 22 14:10:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2c_exec.c,v 1.7 2009/02/03 16:17:54 pgoyette Exp $	*/
+/*	$NetBSD: i2c_exec.c,v 1.8 2012/04/22 14:10:36 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c_exec.c,v 1.7 2009/02/03 16:17:54 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c_exec.c,v 1.8 2012/04/22 14:10:36 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -284,7 +284,7 @@ iic_smbus_block_read(i2c_tag_t tag, i2c_
     uint8_t *vbuf, size_t buflen, int flags)
 {
 
-	return (iic_exec(tag, I2C_OP_READ_WITH_STOP, addr, &cmd, 1,
+	return (iic_exec(tag, I2C_OP_READ_BLOCK, addr, &cmd, 1,
 			 vbuf, buflen, flags));
 }
 
@@ -298,7 +298,7 @@ iic_smbus_block_write(i2c_tag_t tag, i2c
     uint8_t *vbuf, size_t buflen, int flags)
 {
 
-	return (iic_exec(tag, I2C_OP_WRITE_WITH_STOP, addr, &cmd, 1,
+	return (iic_exec(tag, I2C_OP_WRITE_BLOCK, addr, &cmd, 1,
 			 vbuf, buflen, flags));
 }
 

Index: src/sys/dev/i2c/i2c_io.h
diff -u src/sys/dev/i2c/i2c_io.h:1.2 src/sys/dev/i2c/i2c_io.h:1.3
--- src/sys/dev/i2c/i2c_io.h:1.2	Sun Dec 11 12:21:22 2005
+++ src/sys/dev/i2c/i2c_io.h	Sun Apr 22 14:10:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2c_io.h,v 1.2 2005/12/11 12:21:22 christos Exp $	*/
+/*	$NetBSD: i2c_io.h,v 1.3 2012/04/22 14:10:36 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -44,17 +44,25 @@
 typedef uint16_t i2c_addr_t;
 
 /* High-level I2C operations. */
+#define	I2C_OPMASK_STOP		1
+#define	I2C_OPMASK_WRITE	2
+#define	I2C_OPMASK_BLKMODE	4
+
+#define	I2C_OP_STOP_P(x)	(((int)(x) & I2C_OPMASK_STOP) != 0)
+#define	I2C_OP_WRITE_P(x)	(((int)(x) & I2C_OPMASK_WRITE) != 0)
+#define	I2C_OP_READ_P(x)	(!I2C_OP_WRITE_P(x))
+#define	I2C_OP_BLKMODE_P(x)	(((int)(x) & I2C_OPMASK_BLKMODE) != 0)
+
 typedef enum {
-	I2C_OP_READ		= 0,
-	I2C_OP_READ_WITH_STOP	= 1,
-	I2C_OP_WRITE		= 2,
-	I2C_OP_WRITE_WITH_STOP	= 3,
+        I2C_OP_READ		= 0,
+        I2C_OP_READ_WITH_STOP	= I2C_OPMASK_STOP,
+        I2C_OP_WRITE		= I2C_OPMASK_WRITE,
+        I2C_OP_WRITE_WITH_STOP	= I2C_OPMASK_WRITE   | I2C_OPMASK_STOP,
+        I2C_OP_READ_BLOCK	= I2C_OPMASK_BLKMODE | I2C_OPMASK_STOP,
+        I2C_OP_WRITE_BLOCK	= I2C_OPMASK_BLKMODE | I2C_OPMASK_WRITE |
+					I2C_OPMASK_STOP,
 } i2c_op_t;
 
-#define	I2C_OP_READ_P(x)	(((int)(x) & 2) == 0)
-#define	I2C_OP_WRITE_P(x)	(! I2C_OP_READ_P(x))
-#define	I2C_OP_STOP_P(x)	(((int)(x) & 1) != 0)
-
 /*
  * This structure describes a single I2C control script fragment.
  *

Reply via email to