Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/i2c Identify SMBus block-mode operations.



details:   https://anonhg.NetBSD.org/src/rev/5dfc2680c869
branches:  trunk
changeset: 778956:5dfc2680c869
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Apr 22 14:10:36 2012 +0000

description:
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.

diffstat:

 sys/dev/i2c/i2c_exec.c |   8 ++++----
 sys/dev/i2c/i2c_io.h   |  26 +++++++++++++++++---------
 2 files changed, 21 insertions(+), 13 deletions(-)

diffs (79 lines):

diff -r e288f11864ac -r 5dfc2680c869 sys/dev/i2c/i2c_exec.c
--- a/sys/dev/i2c/i2c_exec.c    Sun Apr 22 14:04:45 2012 +0000
+++ b/sys/dev/i2c/i2c_exec.c    Sun Apr 22 14:10:36 2012 +0000
@@ -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 @@
     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 @@
     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));
 }
 
diff -r e288f11864ac -r 5dfc2680c869 sys/dev/i2c/i2c_io.h
--- a/sys/dev/i2c/i2c_io.h      Sun Apr 22 14:04:45 2012 +0000
+++ b/sys/dev/i2c/i2c_io.h      Sun Apr 22 14:10:36 2012 +0000
@@ -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.
  *



Home | Main Index | Thread Index | Old Index