summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/gigabeat-s/i2c-imx31.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/i2c-imx31.h')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/i2c-imx31.h56
1 files changed, 55 insertions, 1 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/i2c-imx31.h b/firmware/target/arm/imx31/gigabeat-s/i2c-imx31.h
index c708ebbfb4..d6de5c47e8 100644
--- a/firmware/target/arm/imx31/gigabeat-s/i2c-imx31.h
+++ b/firmware/target/arm/imx31/gigabeat-s/i2c-imx31.h
@@ -16,7 +16,61 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19#ifndef _I2C_IMX31_H_
20#define _I2C_IMX31_H_
21
22#include <stdbool.h>
23
24/* I2C module usage masks */
25#define USE_I2C1_MODULE (1 << 0)
26#define USE_I2C2_MODULE (1 << 1)
27#define USE_I2C3_MODULE (1 << 2)
28
29enum i2c_module_number
30{
31 __I2C_NUM_START = -1,
32#if (I2C_MODULE_MASK & USE_I2C1_MODULE)
33 I2C1_NUM,
34#endif
35#if (I2C_MODULE_MASK & USE_I2C2_MODULE)
36 I2C2_NUM,
37#endif
38#if (I2C_MODULE_MASK & USE_I2C3_MODULE)
39 I2C3_NUM,
40#endif
41 I2C_NUM_I2C,
42};
43
44/* Module interface map structure */
45struct i2c_map
46{
47 volatile uint16_t iadr; /* 0x00 */
48 volatile uint16_t unused1;
49 volatile uint16_t ifdr; /* 0x04 */
50 volatile uint16_t unused2;
51 volatile uint16_t i2cr; /* 0x08 */
52 volatile uint16_t unused3;
53 volatile uint16_t i2sr; /* 0x0C */
54 volatile uint16_t unused4;
55 volatile uint16_t i2dr; /* 0x10 */
56};
57
58struct i2c_node
59{
60 enum i2c_module_number num; /* Module that this node uses */
61 unsigned int ifdr; /* Maximum frequency for node */
62 unsigned char addr; /* Slave address on module */
63};
19 64
20void i2c_init(void); 65void i2c_init(void);
21void i2c_write(int addr, const unsigned char *data, int count); 66/* Enable or disable the node - modules will be switch on/off accordingly. */
67void i2c_enable_node(struct i2c_node *node, bool enable);
68/* If addr < 0, then raw read */
69int i2c_read(struct i2c_node *node, int addr, unsigned char *data, int count);
70int i2c_write(struct i2c_node *node, const unsigned char *data, int count);
71/* Gain mutually-exclusive access to the node and module to perform multiple
72 * operations atomically */
73void i2c_lock_node(struct i2c_node *node);
74void i2c_unlock_node(struct i2c_node *node);
22 75
76#endif /* _I2C_IMX31_H_ */