summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/i2c-imx31.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx31/i2c-imx31.h')
-rw-r--r--firmware/target/arm/imx31/i2c-imx31.h47
1 files changed, 39 insertions, 8 deletions
diff --git a/firmware/target/arm/imx31/i2c-imx31.h b/firmware/target/arm/imx31/i2c-imx31.h
index a29c7ce96b..f73a8e6320 100644
--- a/firmware/target/arm/imx31/i2c-imx31.h
+++ b/firmware/target/arm/imx31/i2c-imx31.h
@@ -50,15 +50,46 @@ struct i2c_node
50 unsigned char addr; /* Slave address on module */ 50 unsigned char addr; /* Slave address on module */
51}; 51};
52 52
53struct i2c_transfer_desc;
54
55typedef void (*i2c_transfer_cb_fn_type)(struct i2c_transfer_desc *);
56
57/* Basic transfer descriptor for normal asynchronous read/write */
58struct i2c_transfer_desc
59{
60 struct i2c_node *node;
61 const unsigned char *txdata;
62 int txcount;
63 unsigned char *rxdata;
64 int rxcount;
65 i2c_transfer_cb_fn_type callback;
66 struct i2c_transfer_desc *next;
67};
68
69/* Extended transfer descriptor for synchronous read/write that handles
70 thread wait and wakeup */
71struct i2c_sync_transfer_desc
72{
73 struct i2c_transfer_desc xfer;
74 struct semaphore sema;
75};
76
77/* One-time init of i2c driver */
53void i2c_init(void); 78void i2c_init(void);
54/* Enable or disable the node - modules will be switch on/off accordingly. */ 79
80/* Enable or disable the node - modules will be switched on/off accordingly. */
55void i2c_enable_node(struct i2c_node *node, bool enable); 81void i2c_enable_node(struct i2c_node *node, bool enable);
56/* If addr < 0, then raw read */ 82
57int i2c_read(struct i2c_node *node, int addr, unsigned char *data, int count); 83/* Send and/or receive data on the specified node asynchronously */
58int i2c_write(struct i2c_node *node, const unsigned char *data, int count); 84bool i2c_transfer(struct i2c_transfer_desc *xfer);
59/* Gain mutually-exclusive access to the node and module to perform multiple 85
60 * operations atomically */ 86/* Read bytes from a device on the I2C bus, with optional sub-addressing
61void i2c_lock_node(struct i2c_node *node); 87 * If addr < 0, then raw read without sub-addressing */
62void i2c_unlock_node(struct i2c_node *node); 88int i2c_read(struct i2c_node *node, int addr, unsigned char *data,
89 int data_count);
90
91/* Write bytes to a device on the I2C bus */
92int i2c_write(struct i2c_node *node, const unsigned char *data,
93 int data_count);
63 94
64#endif /* I2C_IMX31_H */ 95#endif /* I2C_IMX31_H */