diff options
author | Antony Pavlov <antonynpavlov@gmail.com> | 2015-11-19 01:23:55 +0300 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-11-19 08:58:26 +0100 |
commit | c3859ce93c2dc9b182b2335bc881ad2485d00ba0 (patch) | |
tree | ecba60146f9a82a0d619aace3dc8bf9a0e59d1bd /include/i2c | |
parent | a07652deb47b283c4875fd4fdf76defe68c9d89f (diff) | |
download | barebox-c3859ce93c2dc9b182b2335bc881ad2485d00ba0.tar.gz barebox-c3859ce93c2dc9b182b2335bc881ad2485d00ba0.tar.xz |
i2c: import multiplexed I2C bus core support from linux kernel
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/i2c')
-rw-r--r-- | include/i2c/i2c-mux.h | 40 | ||||
-rw-r--r-- | include/i2c/i2c.h | 6 |
2 files changed, 45 insertions, 1 deletions
diff --git a/include/i2c/i2c-mux.h b/include/i2c/i2c-mux.h new file mode 100644 index 0000000000..80223996da --- /dev/null +++ b/include/i2c/i2c-mux.h @@ -0,0 +1,40 @@ +/* + * + * i2c-mux.h - functions for the i2c-bus mux support + * + * Copyright (c) 2008-2009 Rodolfo Giometti <giometti@linux.it> + * Copyright (c) 2008-2009 Eurotech S.p.A. <info@eurotech.it> + * Michael Lawnick <michael.lawnick.ext@nsn.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _LINUX_I2C_MUX_H +#define _LINUX_I2C_MUX_H + +/* + * Called to create a i2c bus on a multiplexed bus segment. + * The mux_dev and chan_id parameters are passed to the select + * and deselect callback functions to perform hardware-specific + * mux control. + */ +struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, + struct device_d *mux_dev, + void *mux_priv, u32 force_nr, u32 chan_id, + int (*select) (struct i2c_adapter *, + void *mux_dev, u32 chan_id), + int (*deselect) (struct i2c_adapter *, + void *mux_dev, u32 chan_id)); + +void i2c_del_mux_adapter(struct i2c_adapter *adap); + +#endif /* _LINUX_I2C_MUX_H */ diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h index 3fab76d9f6..8f7aae9666 100644 --- a/include/i2c/i2c.h +++ b/include/i2c/i2c.h @@ -245,7 +245,11 @@ extern struct list_head i2c_adapter_list; extern struct i2c_client * i2c_new_dummy(struct i2c_adapter *adap, u16 address); - +/* Return the adapter number for a specific adapter */ +static inline int i2c_adapter_id(struct i2c_adapter *adap) +{ + return adap->nr; +} extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num); extern int i2c_master_send(struct i2c_client *client, const char *buf, int count); |