diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2010-04-09 01:21:53 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2010-04-09 01:21:53 +0000 |
commit | 7abf2b53a462612808d46d6d77a7f35261a0e5a3 (patch) | |
tree | 241304f7cd2b5d1c2a9e091fe56a33d2d2f8e816 /firmware/target/arm/imx31/i2c-imx31.h | |
parent | 43304b87b0662d1619ac60e5297a1694aa580310 (diff) | |
download | rockbox-7abf2b53a462612808d46d6d77a7f35261a0e5a3.tar.gz rockbox-7abf2b53a462612808d46d6d77a7f35261a0e5a3.zip |
Gigabeat S/i.MX31: Sort files in the /target tree into things that are SoC-generic (into /imx31) and player-specific (into /gigabeat-s, based upon current appearances). Move i2s clock init into the appropriate file. Housekeeping only-- no functional changes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25547 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/imx31/i2c-imx31.h')
-rw-r--r-- | firmware/target/arm/imx31/i2c-imx31.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/firmware/target/arm/imx31/i2c-imx31.h b/firmware/target/arm/imx31/i2c-imx31.h new file mode 100644 index 0000000000..b36acecfcb --- /dev/null +++ b/firmware/target/arm/imx31/i2c-imx31.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Michael Sevakis | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef I2C_IMX31_H | ||
22 | #define I2C_IMX31_H | ||
23 | |||
24 | #include <stdbool.h> | ||
25 | |||
26 | /* I2C module usage masks */ | ||
27 | #define USE_I2C1_MODULE (1 << 0) | ||
28 | #define USE_I2C2_MODULE (1 << 1) | ||
29 | #define USE_I2C3_MODULE (1 << 2) | ||
30 | |||
31 | enum i2c_module_number | ||
32 | { | ||
33 | __I2C_NUM_START = -1, | ||
34 | #if (I2C_MODULE_MASK & USE_I2C1_MODULE) | ||
35 | I2C1_NUM, | ||
36 | #endif | ||
37 | #if (I2C_MODULE_MASK & USE_I2C2_MODULE) | ||
38 | I2C2_NUM, | ||
39 | #endif | ||
40 | #if (I2C_MODULE_MASK & USE_I2C3_MODULE) | ||
41 | I2C3_NUM, | ||
42 | #endif | ||
43 | I2C_NUM_I2C, | ||
44 | }; | ||
45 | |||
46 | /* Module interface map structure */ | ||
47 | struct i2c_map | ||
48 | { | ||
49 | volatile uint16_t iadr; /* 0x00 */ | ||
50 | volatile uint16_t unused1; | ||
51 | volatile uint16_t ifdr; /* 0x04 */ | ||
52 | volatile uint16_t unused2; | ||
53 | volatile uint16_t i2cr; /* 0x08 */ | ||
54 | volatile uint16_t unused3; | ||
55 | volatile uint16_t i2sr; /* 0x0C */ | ||
56 | volatile uint16_t unused4; | ||
57 | volatile uint16_t i2dr; /* 0x10 */ | ||
58 | }; | ||
59 | |||
60 | struct i2c_node | ||
61 | { | ||
62 | enum i2c_module_number num; /* Module that this node uses */ | ||
63 | unsigned int ifdr; /* Maximum frequency for node */ | ||
64 | unsigned char addr; /* Slave address on module */ | ||
65 | }; | ||
66 | |||
67 | void i2c_init(void); | ||
68 | /* Enable or disable the node - modules will be switch on/off accordingly. */ | ||
69 | void i2c_enable_node(struct i2c_node *node, bool enable); | ||
70 | /* If addr < 0, then raw read */ | ||
71 | int i2c_read(struct i2c_node *node, int addr, unsigned char *data, int count); | ||
72 | int i2c_write(struct i2c_node *node, const unsigned char *data, int count); | ||
73 | /* Gain mutually-exclusive access to the node and module to perform multiple | ||
74 | * operations atomically */ | ||
75 | void i2c_lock_node(struct i2c_node *node); | ||
76 | void i2c_unlock_node(struct i2c_node *node); | ||
77 | |||
78 | #endif /* I2C_IMX31_H */ | ||