diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-04-27 10:30:54 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-04-27 10:30:54 +0000 |
commit | 27fac88548366f57c32931ed4d7c7dfc5b4f1627 (patch) | |
tree | e45132b551ce39a44a6fefa31e85971cea6df47e /firmware/target/arm/imx31/gigabeat-s/i2c-imx31.h | |
parent | fec6af659f809d47f6e750975289e220908396fe (diff) | |
download | rockbox-27fac88548366f57c32931ed4d7c7dfc5b4f1627.tar.gz rockbox-27fac88548366f57c32931ed4d7c7dfc5b4f1627.zip |
Gigabeat S: Implement i2c driver - transmit works but no testing of receiving which will get a chance later. Add some seeds for codec driver. Correct a few #defines.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17254 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/i2c-imx31.h')
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/i2c-imx31.h | 56 |
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 | |||
29 | enum 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 */ | ||
45 | struct 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 | |||
58 | struct 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 | ||
20 | void i2c_init(void); | 65 | void i2c_init(void); |
21 | void i2c_write(int addr, const unsigned char *data, int count); | 66 | /* Enable or disable the node - modules will be switch on/off accordingly. */ |
67 | void i2c_enable_node(struct i2c_node *node, bool enable); | ||
68 | /* If addr < 0, then raw read */ | ||
69 | int i2c_read(struct i2c_node *node, int addr, unsigned char *data, int count); | ||
70 | int 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 */ | ||
73 | void i2c_lock_node(struct i2c_node *node); | ||
74 | void i2c_unlock_node(struct i2c_node *node); | ||
22 | 75 | ||
76 | #endif /* _I2C_IMX31_H_ */ | ||