summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2020-01-11 11:30:48 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2020-01-11 11:30:48 +0000
commitdf846f6abfb419ae53f7b57fa9e79664d3b47e19 (patch)
tree00033bed57c26b9a648de233f2ef39e2af6f8ed9
parent2fa17f6cd76868c729fd270c28bbd43a137d834b (diff)
Add constants to support block mode. Needed to support SMBus block read
and write. ok claudio@
-rw-r--r--sys/dev/i2c/i2c_io.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/sys/dev/i2c/i2c_io.h b/sys/dev/i2c/i2c_io.h
index 8a4aea81e12..65d95329c3e 100644
--- a/sys/dev/i2c/i2c_io.h
+++ b/sys/dev/i2c/i2c_io.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: i2c_io.h,v 1.1 2004/05/23 17:33:43 grange Exp $ */
-/* $NetBSD: i2c_io.h,v 1.1 2003/09/30 00:35:31 thorpej Exp $ */
+/* $OpenBSD: i2c_io.h,v 1.2 2020/01/11 11:30:47 kettenis Exp $ */
+/* $NetBSD: i2c_io.h,v 1.3 2012/04/22 14:10:36 pgoyette Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -45,17 +45,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_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.
*