summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2010-12-23 22:03:54 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:41:51 -0800
commit0017a945ba2e0ecdb73657dac435fc83a74dd70e (patch)
tree24fcdfc4ce689d61511865319f61fe4ea899f0c1
parent3e0b2a7672850563bca024d9b64ed0c44c6c9a4d (diff)
[ARM]tegra:i2c: Adding i2c slave support apis.
To support the i2c slave functionality in the kernel, adding the framework so that chip specific slave driver can be plugged in. Adding slave adapter and alogithms in framework so that slave bus driver can register chip specific driver. Original-Change-Id: Ie002dbd3b021f70814b455471e66a5da378ab3e9 Reviewed-on: http://git-master/r/14206 Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com> Tested-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-by: Alok Chauhan <alokc@nvidia.com> Reviewed-by: Scott Williams <scwilliams@nvidia.com> Original-Change-Id: I92b6bc4f3953a9edc7f9414a65b69005d2bbf8db Rebase-Id: R13abe740fa88a76747dcbcd42ffc9f74a504f7c5
-rw-r--r--drivers/i2c/Kconfig10
-rw-r--r--drivers/i2c/Makefile1
-rwxr-xr-xdrivers/i2c/i2c-slave.c282
-rwxr-xr-xinclude/linux/i2c-slave.h258
-rw-r--r--include/linux/i2c.h1
5 files changed, 552 insertions, 0 deletions
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 5f13c62e64b4..c4b583dc2567 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -60,6 +60,16 @@ config I2C_MUX
source drivers/i2c/muxes/Kconfig
+config I2C_SLAVE
+ bool "I2C slave driver support"
+ default n
+ help
+ Say Y here if you want the I2C slave functionality in the driver.
+ The external system will be master and the system on which this
+ driver is running act as i2c slave.
+ This drivers supports read/write data from master devices through
+ I2C.
+
config I2C_HELPER_AUTO
bool "Autoselect pertinent helper modules"
default y
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index beee6b2d361d..da6e2b084e4c 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_I2C) += i2c-core.o
obj-$(CONFIG_I2C_SMBUS) += i2c-smbus.o
obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o
obj-$(CONFIG_I2C_MUX) += i2c-mux.o
+obj-$(CONFIG_I2C_SLAVE) += i2c-slave.o
obj-y += algos/ busses/ muxes/
ccflags-$(CONFIG_I2C_DEBUG_CORE) := -DDEBUG
diff --git a/drivers/i2c/i2c-slave.c b/drivers/i2c/i2c-slave.c
new file mode 100755
index 000000000000..755a51944869
--- /dev/null
+++ b/drivers/i2c/i2c-slave.c
@@ -0,0 +1,282 @@
+/*
+ * i2c-slave.c - a device driver for the iic-slave bus interface.
+ *
+ * Copyright (c) 2009-2011, NVIDIA Corporation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/i2c-slave.h>
+struct i2c_slave_priv {
+ struct i2c_adapter master_adap;
+ struct i2c_slave_adapter *slave_adap;
+ struct i2c_algorithm master_algo;
+};
+
+/**
+ * i2c_slave_send - Sends data to master. When master issues a read cycle, the
+ * data is sent by the slave.
+ * This function copies the client data into the slave tx buffer and return to
+ * client. This is not a blocking call. Data will be sent to master later once
+ * slave got the master-ready cycle transfer.
+ * if there is no sufficient space to write the client buffer, it will return
+ * error. it will not write partial data.
+ * @client: Handle to i2c-slave client.
+ * @buf: Data that will be written to the master
+ * @count: How many bytes to write.
+ *
+ * Returns negative errno, or else the number of bytes written.
+ */
+int i2c_slave_send(struct i2c_client *client, const char *buf, int count)
+{
+ struct i2c_adapter *adap = client->adapter;
+ struct i2c_slave_priv *priv = adap->algo_data;
+
+ if (!(adap->algo->functionality(adap) & I2C_FUNC_I2C_SLAVE_SUPPORT))
+ BUG();
+
+ if (priv->slave_adap->slv_algo->slave_send)
+ return priv->slave_adap->slv_algo->slave_send(priv->slave_adap,
+ buf, count);
+ return -ENODEV;
+}
+EXPORT_SYMBOL(i2c_slave_send);
+
+/**
+ * i2c_slave_get_tx_status - Get amount of data available in tx buffer. If there
+ * is still data in tx buffer then wait for given time to transfer complete
+ * for a give timeout.
+ * @client: Handle to i2c-slave client.
+ * @timeout_ms: Time to wait for transfer to complete.
+ *
+ * Returns negative errno, or else the number of bytes remaining in tx buffer.
+ */
+int i2c_slave_get_tx_status(struct i2c_client *client, int timeout_ms)
+{
+ struct i2c_adapter *adap = client->adapter;
+ struct i2c_slave_priv *priv = adap->algo_data;
+
+ if (!(adap->algo->functionality(adap) & I2C_FUNC_I2C_SLAVE_SUPPORT))
+ BUG();
+
+ if (priv->slave_adap->slv_algo->slave_get_tx_status)
+ return priv->slave_adap->slv_algo->slave_get_tx_status(
+ priv->slave_adap, timeout_ms);
+ return -ENODEV;
+}
+EXPORT_SYMBOL(i2c_slave_get_tx_status);
+
+/**
+ * i2c_slave_recv - Receive data from master. The data receive from master is
+ * stored on slave rx buffer. When this api will be called, the data will be
+ * copied from the slave rx buffer to client buffer. If requested amount (count)
+ * of data is not available then it will wait for either min_count to be receive
+ * or timeout whatever first.
+ *
+ * if timeout_ms = 0, then wait for min_count data to be read.
+ * if timoue_ms non zero then wait for the data till timeout happen.
+ * @client: Handle to i2c-slave client.
+ * @buf: Data that will be read from the master
+ * @count: How many bytes to read.
+ * @min_count: Block till read min_count of data.
+ * @timeout_ms: Time to wait for read to be complete.
+ *
+ * Returns negative errno, or else the number of bytes read.
+ */
+int i2c_slave_recv(struct i2c_client *client, char *buf, int count,
+ int min_count, int timeout_ms)
+{
+ struct i2c_adapter *adap = client->adapter;
+ struct i2c_slave_priv *priv = adap->algo_data;
+
+ if (!(adap->algo->functionality(adap) & I2C_FUNC_I2C_SLAVE_SUPPORT))
+ BUG();
+
+ if (priv->slave_adap->slv_algo->slave_recv)
+ return priv->slave_adap->slv_algo->slave_recv(priv->slave_adap,
+ buf, count, min_count, timeout_ms);
+
+ return -ENODEV;
+}
+EXPORT_SYMBOL(i2c_slave_recv);
+
+/**
+ * i2c_slave_start - Start the i2c slave to receive/transmit data.
+ * After this i2c controller starts responding master.
+ * The dummy-char will send to master if there is no data to send on slave tx
+ * buffer.
+ * @client: Handle to i2c-slave client.
+ * @dummy_char: Data which will be send to master if there is no data to be send
+ * in slave tx buffer.
+ *
+ * Returns negative errno, or else 0 for success.
+ */
+int i2c_slave_start(struct i2c_client *client, unsigned char dummy_char)
+{
+ struct i2c_adapter *adap = client->adapter;
+ struct i2c_slave_priv *priv = adap->algo_data;
+ int slave_add;
+ int is_10bit_addr;
+
+ if (!(adap->algo->functionality(adap) & I2C_FUNC_I2C_SLAVE_SUPPORT))
+ BUG();
+ slave_add = client->addr;
+ is_10bit_addr = (client->flags & I2C_CLIENT_TEN) ? 1 : 0;
+ if (priv->slave_adap->slv_algo->slave_start)
+ return priv->slave_adap->slv_algo->slave_start(priv->slave_adap,
+ slave_add, is_10bit_addr, dummy_char);
+ return -ENODEV;
+}
+EXPORT_SYMBOL(i2c_slave_start);
+
+/**
+ * i2c_slave_stop - Stop slave to receive/transmit data.
+ * After this i2c controller stops responding master.
+ * @client: Handle to i2c-slave client.
+ * @is_buffer_clear: Reset the tx and rx slave buffer or not.
+ */
+void i2c_slave_stop(struct i2c_client *client, int is_buffer_clear)
+{
+ struct i2c_adapter *adap = client->adapter;
+ struct i2c_slave_priv *priv = adap->algo_data;
+
+ if (!(adap->algo->functionality(adap) & I2C_FUNC_I2C_SLAVE_SUPPORT))
+ BUG();
+
+ if (priv->slave_adap->slv_algo->slave_stop)
+ return priv->slave_adap->slv_algo->slave_stop(priv->slave_adap,
+ is_buffer_clear);
+}
+EXPORT_SYMBOL(i2c_slave_stop);
+
+/**
+ * i2c_slave_flush_buffer - Flush the receive and transmit buffer.
+ * @client: Handle to i2c-slave client.
+ * @is_flush_tx_buffer: Reset the tx slave buffer or not.
+ * @is_flush_rx_buffer: Reset the rx slave buffer or not.
+ *
+ * Returns negative errno, or else 0 for success.
+ */
+int i2c_slave_flush_buffer(struct i2c_client *client,
+ int is_flush_tx_buffer, int is_flush_rx_buffer)
+{
+ struct i2c_adapter *adap = client->adapter;
+ struct i2c_slave_priv *priv = adap->algo_data;
+
+ if (!(adap->algo->functionality(adap) & I2C_FUNC_I2C_SLAVE_SUPPORT))
+ BUG();
+
+ if (priv->slave_adap->slv_algo->slave_flush_buffer)
+ return priv->slave_adap->slv_algo->slave_flush_buffer(
+ priv->slave_adap, is_flush_tx_buffer,
+ is_flush_rx_buffer);
+
+ return -ENODEV;
+}
+EXPORT_SYMBOL(i2c_slave_flush_buffer);
+
+/**
+ * i2c_slave_get_nack_cycle - Get the number of master read cycle on which
+ * dummy char sent. This is the way to find that how much cycle slave sent the
+ * NACK packet.
+ *
+ * @client: Handle to i2c-slave client.
+ * @is_cout_reset: Reset the nack count or not.
+ *
+ * Returns negative errno, or else 0 for success.
+ */
+int i2c_slave_get_nack_cycle(struct i2c_client *client,
+ int is_cout_reset)
+{
+ struct i2c_adapter *adap = client->adapter;
+ struct i2c_slave_priv *priv = adap->algo_data;
+
+ if (!(adap->algo->functionality(adap) & I2C_FUNC_I2C_SLAVE_SUPPORT))
+ BUG();
+
+ if (priv->slave_adap->slv_algo->slave_get_nack_cycle)
+ return priv->slave_adap->slv_algo->slave_get_nack_cycle(
+ priv->slave_adap, is_cout_reset);
+
+ return -ENODEV;
+}
+EXPORT_SYMBOL(i2c_slave_get_nack_cycle);
+
+static u32 i2c_slave_func(struct i2c_adapter *adap)
+{
+ return I2C_FUNC_I2C_SLAVE_SUPPORT;
+}
+
+int i2c_add_slave_adapter(struct i2c_slave_adapter *slv_adap, bool force_nr)
+{
+ struct i2c_slave_priv *priv;
+ int ret;
+
+ priv = kzalloc(sizeof(struct i2c_slave_priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ /* Set up private adapter data */
+ priv->slave_adap = slv_adap;
+ slv_adap->parent_data = priv;
+
+ priv->master_algo.functionality = i2c_slave_func;
+
+ /* Now fill out new adapter structure */
+ snprintf(priv->master_adap.name, sizeof(priv->master_adap.name),
+ "i2c-%d-slave", slv_adap->nr);
+ priv->master_adap.owner = THIS_MODULE;
+ priv->master_adap.class = slv_adap->class;
+ priv->master_adap.id = slv_adap->id;
+ priv->master_adap.algo = &priv->master_algo;
+ priv->master_adap.algo_data = priv;
+ priv->master_adap.dev.parent = &slv_adap->dev;
+
+ if (force_nr) {
+ priv->master_adap.nr = slv_adap->nr;
+ ret = i2c_add_numbered_adapter(&priv->master_adap);
+ } else {
+ ret = i2c_add_adapter(&priv->master_adap);
+ }
+ if (ret < 0) {
+ dev_err(&slv_adap->dev,
+ "failed to add slave-adapter (error=%d)\n", ret);
+ kfree(priv);
+ return ret;
+ }
+
+ dev_info(&slv_adap->dev, "Added slave i2c bus %d\n",
+ i2c_adapter_id(&priv->master_adap));
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(i2c_add_slave_adapter);
+
+int i2c_del_slave_adapter(struct i2c_slave_adapter *slv_adap)
+{
+ struct i2c_slave_priv *priv = slv_adap->parent_data;
+ int ret;
+
+ ret = i2c_del_adapter(&priv->master_adap);
+ if (ret < 0)
+ return ret;
+ kfree(priv);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(i2c_del_slave_adapter);
diff --git a/include/linux/i2c-slave.h b/include/linux/i2c-slave.h
new file mode 100755
index 000000000000..168671dc2df7
--- /dev/null
+++ b/include/linux/i2c-slave.h
@@ -0,0 +1,258 @@
+/*
+ * i2c-slave.h - definitions for the i2c-slave-bus interface
+ *
+ * Copyright (c) 2009-2011, NVIDIA Corporation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* ------------------------------------------------------------------------- */
+
+#ifndef _LINUX_I2C_SLAVE_H
+#define _LINUX_I2C_SLAVE_H
+
+#include <linux/types.h>
+#ifdef __KERNEL__
+/* --- General options ------------------------------------------------ */
+
+struct i2c_client;
+struct i2c_slave_algorithm;
+struct i2c_slave_adapter;
+#if defined(CONFIG_I2C_SLAVE) && defined(CONFIG_I2C)
+
+/**
+ * i2c_slave_send - Sends data to master. When master issues a read cycle, the
+ * data is sent by the slave.
+ * This function copies the client data into the slave tx buffer and return to
+ * client. This is not a blocking call. Data will be sent to master later once
+ * slave got the master-ready cycle transfer.
+ * if there is no sufficient space to write the client buffer, it will return
+ * error. it will not write partial data.
+ * @client: Handle to i2c-slave client.
+ * @buf: Data that will be written to the master
+ * @count: How many bytes to write.
+ *
+ * Returns negative errno, or else the number of bytes written.
+ */
+extern int i2c_slave_send(struct i2c_client *client, const char *buf,
+ int count);
+
+/**
+ * i2c_slave_get_tx_status - Get amount of data available in tx buffer. If there
+ * is still data in tx buffer then wait for given time to transfer complete
+ * for a give timeout.
+ * @client: Handle to i2c-slave client.
+ * @timeout_ms: Time to wait for transfer to complete.
+ *
+ * Returns negative errno, or else the number of bytes remaining in tx buffer.
+ */
+extern int i2c_slave_get_tx_status(struct i2c_client *client, int timeout_ms);
+
+/**
+ * i2c_slave_recv - Receive data from master. The data received from master is
+ * stored on slave rx buffer. When this api will be called, the data will be
+ * copied from the slave rx buffer to client buffer. If requested amount (count)
+ * of data is not available then it will wait for either min_count to be receive
+ * or timeout whatever first.
+ *
+ * if timeout_ms = 0, then wait for min_count data to be read.
+ * if timoue_ms non zero then wait for the data till timeout happen.
+ * @client: Handle to i2c-slave client.
+ * @buf: Data that will be read from the master
+ * @count: How many bytes to read.
+ * @min_count: Block till read min_count of data.
+ * @timeout_ms: Time to wait for read to be complete.
+ *
+ * Returns negative errno, or else the number of bytes read.
+ */
+extern int i2c_slave_recv(struct i2c_client *client, char *buf, int count,
+ int min_count, int timeout_ms);
+
+/**
+ * i2c_slave_start - Start the i2c slave to receive/transmit data.
+ * After this i2c controller starts responding master.
+ * The dummy-char will send to master if there is no data to send on slave tx
+ * buffer.
+ * @client: Handle to i2c-slave client.
+ * @dummy_char: Data which will be send to master if there is no data to be send
+ * in slave tx buffer.
+ *
+ * Returns negative errno, or else 0 for success.
+ */
+extern int i2c_slave_start(struct i2c_client *client, unsigned char dummy_char);
+
+/**
+ * i2c_slave_stop - Stop slave to receive/transmit data.
+ * After this i2c controller stops responding master.
+ * @client: Handle to i2c-slave client.
+ * @is_buffer_clear: Reset the tx and rx slave buffer or not.
+ */
+extern void i2c_slave_stop(struct i2c_client *client, int is_buffer_clear);
+
+/**
+ * i2c_slave_flush_buffer - Flush the receive and transmit buffer.
+ * @client: Handle to i2c-slave client.
+ * @is_flush_tx_buffer: Reset the tx slave buffer or not.
+ * @is_flush_rx_buffer: Reset the rx slave buffer or not.
+ *
+ * Returns negative errno, or else 0 for success.
+ */
+extern int i2c_slave_flush_buffer(struct i2c_client *client,
+ int is_flush_tx_buffer, int is_flush_rx_buffer);
+
+/**
+ * i2c_slave_get_nack_cycle - Get the number of master read cycle on which
+ * dummy char sent. This is the way to find that how much cycle slave sent the
+ * NACK packet.
+ *
+ * @client: Handle to i2c-slave client.
+ * @is_cout_reset: Reset the nack count or not.
+ *
+ * Returns negative errno, or else 0 for success.
+ */
+extern int i2c_slave_get_nack_cycle(struct i2c_client *client,
+ int is_cout_reset);
+
+
+/**
+ * i2c_add_slave_adapter - Add slave adapter.
+ *
+ * @slv_adap: Slave adapter.
+ * @force_nr: Adapter number.
+ *
+ * Returns negative errno, or else 0 for success.
+ */
+extern int i2c_add_slave_adapter(struct i2c_slave_adapter *slv_adap,
+ bool force_nr);
+
+/**
+ * i2c_del_slave_adapter - Delete slave adapter.
+ *
+ * @slv_adap: Slave adapter.
+ *
+ * Returns negative errno, or else 0 for success.
+ */
+extern int i2c_del_slave_adapter(struct i2c_slave_adapter *slv_adap);
+
+#endif /* I2C_SLAVE */
+
+/*
+ * i2c_slave_adapter is the structure used to identify a physical i2c bus along
+ * with the access algorithms necessary to access it.
+ */
+struct i2c_slave_adapter {
+ struct module *owner;
+ unsigned int id;
+ unsigned int class; /* classes to allow probing for */
+ /* the algorithm to access the i2c-slave bus */
+ const struct i2c_slave_algorithm *slv_algo;
+ void *algo_data;
+ void *parent_data;
+
+ /* data fields that are valid for all devices */
+ u8 level; /* nesting level for lockdep */
+ struct mutex bus_lock;
+
+ int timeout; /* in jiffies */
+ int retries;
+ struct device dev; /* the adapter device */
+
+ int nr;
+ char name[48];
+ struct completion dev_released;
+};
+
+static inline void *i2c_get_slave_adapdata(const struct i2c_slave_adapter *dev)
+{
+ return dev_get_drvdata(&dev->dev);
+}
+
+static inline void i2c_set_slave_adapdata(struct i2c_slave_adapter *dev,
+ void *data)
+{
+ dev_set_drvdata(&dev->dev, data);
+}
+
+/*
+ * The following struct are for those who like to implement new i2c slave
+ * bus drivers:
+ * i2c_slave_algorithm is the interface to a class of hardware solutions which
+ * can be addressed using the same bus algorithms.
+ */
+struct i2c_slave_algorithm {
+ /* Start the slave to receive/transmit data.
+ * The dummy-char will send to master if there is no data to send on
+ * slave tx buffer.
+ */
+ int (*slave_start)(struct i2c_slave_adapter *slv_adap, int addr,
+ int is_ten_bit_addr, unsigned char dummy_char);
+
+ /* Stop slave to receive/transmit data.
+ * Required information to reset the slave rx and tx buffer to reset
+ * or not.
+ */
+ void (*slave_stop)(struct i2c_slave_adapter *slv_adap,
+ int is_buffer_clear);
+
+ /*
+ * Send data to master. The data will be copied on the slave tx buffer
+ * and will send to master once master initiates the master-read cycle.
+ * Function will return immediately once the buffer copied into slave
+ * tx buffer.
+ * Client will not wait till data is sent to master.
+ * This function will not copy data partially. If sufficient space is
+ * not available, it will return error.
+ */
+ int (*slave_send)(struct i2c_slave_adapter *slv_adap, const char *buf,
+ int count);
+
+ /*
+ * Get amount of data available in tx buffer. If there is still data in
+ * tx buffer wait for given time to get slave tx buffer emptied.
+ * returns number of data available in slave tx buffer.
+ */
+ int (*slave_get_tx_status)(struct i2c_slave_adapter *slv_adap,
+ int timeout_ms);
+
+ /*
+ * Receive data to master. The data received from master is stored on
+ * slave rx buffer. When this api will be called, the data will be
+ * coped from the slave rx buffer to client buffer. If requested (count)
+ * data is not available then it will wait for either min_count to be
+ * receive or timeout whatever first.
+ *
+ * if timeout_ms = 0, then wait for min_count data to be read.
+ * if timoue_ms non zero then wait for the data till timeout happen.
+ * returns number of bytes read as positive integer otherwise error.
+ */
+ int (*slave_recv)(struct i2c_slave_adapter *slv_adap, char *buf,
+ int count, int min_count, int timeout_ms);
+
+ /* Flush the receive and transmit buffer.
+ */
+ int (*slave_flush_buffer)(struct i2c_slave_adapter *slv_adap,
+ int is_flush_tx_buffer, int is_flush_rx_buffer);
+
+ /* Get the number of dummy char cycle.
+ * Get the number of master read cycle on which dummy character has
+ * been sent.
+ * This can be treat as NACK cycle from slave side.
+ * Pass option whether count need to be reset or not.
+ */
+ int (*slave_get_nack_cycle)(struct i2c_slave_adapter *slv_adap,
+ int is_cout_reset);
+};
+#endif /* __KERNEL__ */
+#endif /* _LINUX_I2C_SLAVE_H */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index a6c652ef516d..0bd9ea2b62ea 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -540,6 +540,7 @@ struct i2c_msg {
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
+#define I2C_FUNC_I2C_SLAVE_SUPPORT 0x10000000 /* i2c slave support */
#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
I2C_FUNC_SMBUS_WRITE_BYTE)