Updating FSF address in the code.
[coreboot.git] / src / northbridge / motorola / mpc107 / i2c.h
1 /* 
2  * (C) Copyright 2002
3  * Humboldt Solutions Ltd, <adrian@humboldt.co.uk>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of
8  * the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
18  * MA 02110-1301 USA
19  */
20
21 #ifndef _I2C_H
22 #define _I2C_H
23
24 struct i2c_bus;
25
26 typedef struct i2c_fn
27 {
28     void (* start)(struct i2c_bus *bus);
29     void (* stop)(struct i2c_bus *bus);
30     int (* master_write)(struct i2c_bus *bus, int target, int address,
31             const uint8_t *data, int length);
32     int (* master_read)(struct i2c_bus *bus, int target, int address,
33             uint8_t *data, int length);
34 } i2c_fn;
35
36 typedef struct i2c_bus
37 {
38     const i2c_fn *fn;
39     char *tag;
40     void *data;
41     struct i2c_bus *next;
42 } i2c_bus;
43
44 i2c_bus *find_i2c_bus(const char *name);
45 int register_i2c_bus(const i2c_fn *fn, char *tag, void *data);
46
47 void i2c_start(struct i2c_bus *bus);
48 void i2c_stop(struct i2c_bus *bus);
49 int i2c_master_write(struct i2c_bus *bus, int target, int address,
50             const uint8_t *data, int length);
51 int i2c_master_read(struct i2c_bus *bus, int target, int address,
52             uint8_t *data, int length);
53 void init_i2c_nvram(const char *i2c_tag);
54
55 extern i2c_fn mpc107_i2c_fn;
56
57 #endif