i.MX31: Make some style changes to some driver code so that hardware vs. variable...
[kugel-rb.git] / firmware / target / arm / imx31 / i2c-imx31.h
bloba29c7ce96b9f71c892554be15ade3da6dad4c3c7
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 by Michael Sevakis
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #ifndef I2C_IMX31_H
22 #define I2C_IMX31_H
24 #include <stdbool.h>
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)
31 enum i2c_module_number
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,
46 struct i2c_node
48 enum i2c_module_number num; /* Module that this node uses */
49 unsigned int ifdr; /* Maximum frequency for node */
50 unsigned char addr; /* Slave address on module */
53 void i2c_init(void);
54 /* Enable or disable the node - modules will be switch on/off accordingly. */
55 void i2c_enable_node(struct i2c_node *node, bool enable);
56 /* If addr < 0, then raw read */
57 int i2c_read(struct i2c_node *node, int addr, unsigned char *data, int count);
58 int i2c_write(struct i2c_node *node, const unsigned char *data, int count);
59 /* Gain mutually-exclusive access to the node and module to perform multiple
60 * operations atomically */
61 void i2c_lock_node(struct i2c_node *node);
62 void i2c_unlock_node(struct i2c_node *node);
64 #endif /* I2C_IMX31_H */