summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-12-08 08:27:37 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-12-08 08:27:37 +0100
commita2b318fe2142f6032040a0702887086071b05ff6 (patch)
tree80b478302aa2fb9178c8cfaeb53e4a652d43bcf2 /include
parenta59ae014e14cecaef5e6ead8083f3dfc16dc7280 (diff)
parentcf694d44da75f4aba02e5030fa71e469d2c5acc9 (diff)
downloadbarebox-a2b318fe2142f6032040a0702887086071b05ff6.tar.gz
barebox-a2b318fe2142f6032040a0702887086071b05ff6.tar.xz
Merge branch 'for-next/i2c'
Diffstat (limited to 'include')
-rw-r--r--include/i2c/at24.h1
-rw-r--r--include/i2c/i2c-mux.h40
-rw-r--r--include/i2c/i2c.h23
3 files changed, 63 insertions, 1 deletions
diff --git a/include/i2c/at24.h b/include/i2c/at24.h
index 1013308459..44a64a0e16 100644
--- a/include/i2c/at24.h
+++ b/include/i2c/at24.h
@@ -30,6 +30,7 @@ struct at24_platform_data {
#define AT24_FLAG_READONLY 0x40 /* sysfs-entry will be read-only */
#define AT24_FLAG_IRUGO 0x20 /* sysfs-entry will be world-readable */
#define AT24_FLAG_TAKE8ADDR 0x10 /* take always 8 addresses (24c00) */
+#define AT24_FLAG_BANK_BIT_2 0x08 /* blank select at bit 2 (vs lsb) */
};
#endif /* _LINUX_AT24_H */
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 12e4827755..33a4791c96 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -121,15 +121,28 @@ struct i2c_adapter {
struct i2c_bus_recovery_info *bus_recovery_info;
};
+#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
struct i2c_client {
struct device_d dev;
struct i2c_adapter *adapter;
unsigned short addr;
+ void *driver_data; /* Driver data, set and get with
+ dev_set/get_drvdata */
};
#define to_i2c_client(a) container_of(a, struct i2c_client, dev)
+static inline void *i2c_get_clientdata(const struct i2c_client *dev)
+{
+ return dev->driver_data;
+}
+
+static inline void i2c_set_clientdata(struct i2c_client *dev, void *data)
+{
+ dev->driver_data = data;
+}
+
/*flags for the client struct: */
#define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */
#define I2C_CLIENT_SCCB 0x9000 /* Use Omnivision SCCB protocol */
@@ -235,13 +248,21 @@ extern int i2c_add_numbered_adapter(struct i2c_adapter *adapter);
struct i2c_adapter *i2c_get_adapter(int busnum);
struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node);
+extern struct list_head i2c_adapter_list;
+#define for_each_i2c_adapter(adap) \
+ list_for_each_entry(adap, &i2c_adapter_list, list)
+
/* For devices that use several addresses, use i2c_new_dummy() to make
* client handles for the extra addresses.
*/
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);