diff mbox

[2/3] greybus: i2c: Split structure definitions into i2c.h

Message ID 1428371979-9737-3-git-send-email-john.stultz@linaro.org
State New
Headers show

Commit Message

John Stultz April 7, 2015, 1:59 a.m. UTC
In order to facilitate re-use of the i2c structures,
split the definitions out into i2c.h

This will be a prereq to sharing these headers w/ gbsim.

Cc: Alex Elder <alex.elder@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 i2c.c | 57 ++---------------------------------------------------
 i2c.h | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 55 deletions(-)
 create mode 100644 i2c.h
diff mbox

Patch

diff --git a/i2c.c b/i2c.c
index 84d20e5..84d1d77 100644
--- a/i2c.c
+++ b/i2c.c
@@ -13,6 +13,8 @@ 
 #include <linux/i2c.h>
 
 #include "greybus.h"
+#include "i2c.h"
+
 
 struct gb_i2c_device {
 	struct gb_connection	*connection;
@@ -26,61 +28,6 @@  struct gb_i2c_device {
 	struct i2c_adapter	adapter;
 };
 
-/* Version of the Greybus i2c protocol we support */
-#define	GB_I2C_VERSION_MAJOR		0x00
-#define	GB_I2C_VERSION_MINOR		0x01
-
-/* Greybus i2c request types */
-#define	GB_I2C_TYPE_INVALID		0x00
-#define	GB_I2C_TYPE_PROTOCOL_VERSION	0x01
-#define	GB_I2C_TYPE_FUNCTIONALITY	0x02
-#define	GB_I2C_TYPE_TIMEOUT		0x03
-#define	GB_I2C_TYPE_RETRIES		0x04
-#define	GB_I2C_TYPE_TRANSFER		0x05
-#define	GB_I2C_TYPE_RESPONSE		0x80	/* OR'd with rest */
-
-#define	GB_I2C_RETRIES_DEFAULT		3
-#define	GB_I2C_TIMEOUT_DEFAULT		1000	/* milliseconds */
-
-/* functionality request has no payload */
-struct gb_i2c_functionality_response {
-	__le32	functionality;
-};
-
-struct gb_i2c_timeout_request {
-	__le16	msec;
-};
-/* timeout response has no payload */
-
-struct gb_i2c_retries_request {
-	__u8	retries;
-};
-/* retries response has no payload */
-
-/*
- * Outgoing data immediately follows the op count and ops array.
- * The data for each write (master -> slave) op in the array is sent
- * in order, with no (e.g. pad) bytes separating them.
- *
- * Short reads cause the entire transfer request to fail So response
- * payload consists only of bytes read, and the number of bytes is
- * exactly what was specified in the corresponding op.  Like
- * outgoing data, the incoming data is in order and contiguous.
- */
-struct gb_i2c_transfer_op {
-	__le16	addr;
-	__le16	flags;
-	__le16	size;
-};
-
-struct gb_i2c_transfer_request {
-	__le16				op_count;
-	struct gb_i2c_transfer_op	ops[0];		/* op_count of these */
-};
-struct gb_i2c_transfer_response {
-	__u8				data[0];	/* inbound data */
-};
-
 /* Define get_version() routine */
 define_get_version(gb_i2c_device, I2C);
 
diff --git a/i2c.h b/i2c.h
new file mode 100644
index 0000000..0bfee86
--- /dev/null
+++ b/i2c.h
@@ -0,0 +1,72 @@ 
+#ifndef __GB_I2C_H__
+#define __GB_I2C_H__
+
+/*
+ * I2C header for the Greybus "generic" I2C module.
+ *
+ * Copyright 2014 Google Inc.
+ * Copyright 2014 Linaro Ltd.
+ *
+ * Released under the GPLv2 only.
+ */
+
+#include "greybus.h"
+
+/* Version of the Greybus i2c protocol we support */
+#define	GB_I2C_VERSION_MAJOR		0x00
+#define	GB_I2C_VERSION_MINOR		0x01
+
+/* Greybus i2c request types */
+#define	GB_I2C_TYPE_INVALID		0x00
+#define	GB_I2C_TYPE_PROTOCOL_VERSION	0x01
+#define	GB_I2C_TYPE_FUNCTIONALITY	0x02
+#define	GB_I2C_TYPE_TIMEOUT		0x03
+#define	GB_I2C_TYPE_RETRIES		0x04
+#define	GB_I2C_TYPE_TRANSFER		0x05
+#define	GB_I2C_TYPE_RESPONSE		0x80	/* OR'd with rest */
+
+#define	GB_I2C_RETRIES_DEFAULT		3
+#define	GB_I2C_TIMEOUT_DEFAULT		1000	/* milliseconds */
+
+/* functionality request has no payload */
+struct gb_i2c_functionality_response {
+	__le32	functionality;
+};
+
+struct gb_i2c_timeout_request {
+	__le16	msec;
+};
+/* timeout response has no payload */
+
+struct gb_i2c_retries_request {
+	__u8	retries;
+};
+/* retries response has no payload */
+
+/*
+ * Outgoing data immediately follows the op count and ops array.
+ * The data for each write (master -> slave) op in the array is sent
+ * in order, with no (e.g. pad) bytes separating them.
+ *
+ * Short reads cause the entire transfer request to fail So response
+ * payload consists only of bytes read, and the number of bytes is
+ * exactly what was specified in the corresponding op.  Like
+ * outgoing data, the incoming data is in order and contiguous.
+ */
+struct gb_i2c_transfer_op {
+	__le16	addr;
+	__le16	flags;
+	__le16	size;
+};
+
+struct gb_i2c_transfer_request {
+	__le16				op_count;
+	struct gb_i2c_transfer_op	ops[0];		/* op_count of these */
+};
+struct gb_i2c_transfer_response {
+	__u8				data[0];	/* inbound data */
+};
+
+#endif /* __GB_I2S_H__ */
+
+