summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorTexas Instruments Auto Merger <lcpd_integration@list.ti.com>2022-05-31 11:43:32 -0500
committerTexas Instruments Auto Merger <lcpd_integration@list.ti.com>2022-05-31 11:43:32 -0500
commitcc13f3f3acad08038b76f5f26f66151c136d1eaf (patch)
treefd2809a2b066c50f542aa0ddf9fb8bf48c2638dd /include/linux
parent9e58028f945f077b3e0d7423c6af8938ec46a80a (diff)
parent9e1bb3744e2a336b1554ff355f8d3e545788e05f (diff)
Merged TI feature connectivity into ti-linux-5.10.y
TI-Feature: connectivity TI-Branch: connectivity-ti-linux-5.10.y * 'connectivity-ti-linux-5.10.y' of ssh://bitbucket.itg.ti.com/lcpdpublicdom/connectivity: (82 commits) arm64: dts: ti: k3-j721s2: Fix DSS clock IDs arm64: dts: ti: k3-am64-main: Remove support for HS400 speed mode arm64: dts: ti: k3-j7200-som: Describe hyperflash partition info arm64: dts: ti: k3-j7200-som: Describe OSPI flash partition info arm64: dts: ti: k3-j721e-sk: Describe OSPI flash partition info arm64: dts: ti: k3-j721e-som: Describe OSPI flash partition info arm64: dts: ti: k3-am642-sk: Add pinmux corresponding to main_uart0 Revert "usb: dwc3: Don't switch OTG -> peripheral if extcon is present" ti_config_fragments/audio_display.cfg: Enable FPDLink configs arch: arm64: dts: ti: Add FPDLink overlays for J721E media: i2c: add Sony IMX390 driver dt-bindings: media: Add bindings for Sony IMX390 media: cadence: csi2rx: configure DPHY before starting source stream media: cadence: csi2rx: plug the leak of DPHY device usage count media: cadence: csi2rx: handle external DPHY runtime PM better media: cadence: csi2rx: Add RAW12 formats media: ti: j721e-csi2rx: Add RAW12 formats media: ti: j721e-csi2rx: Set V4L2_SUBDEV_FL_MULTIPLEXED media: i2c: ds90ub960: Add 1.2 Gbps support media: i2c: add DS90UB953 driver ... Signed-off-by: Texas Instruments Auto Merger <lcpd_integration@list.ti.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/i2c-atr.h82
-rw-r--r--include/linux/i2c.h16
2 files changed, 98 insertions, 0 deletions
diff --git a/include/linux/i2c-atr.h b/include/linux/i2c-atr.h
new file mode 100644
index 000000000000..e015db668f44
--- /dev/null
+++ b/include/linux/i2c-atr.h
@@ -0,0 +1,82 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * drivers/i2c/i2c-atr.h -- I2C Address Translator
+ *
+ * Copyright (c) 2019 Luca Ceresoli <luca@lucaceresoli.net>
+ *
+ * Based on i2c-mux.h
+ */
+
+#ifndef _LINUX_I2C_ATR_H
+#define _LINUX_I2C_ATR_H
+
+#ifdef __KERNEL__
+
+#include <linux/i2c.h>
+#include <linux/mutex.h>
+
+struct i2c_atr;
+
+/**
+ * struct i2c_atr_ops - Callbacks from ATR to the device driver.
+ * @select: Ask the driver to select a child bus (optional)
+ * @deselect: Ask the driver to deselect a child bus (optional)
+ * @attach_client: Notify the driver of a new device connected on a child
+ * bus. The driver must choose an I2C alias, configure the
+ * hardware to use it and return it in `alias_id`.
+ * @detach_client: Notify the driver of a device getting disconnected. The
+ * driver must configure the hardware to stop using the
+ * alias.
+ *
+ * All these functions return 0 on success, a negative error code otherwise.
+ */
+struct i2c_atr_ops {
+ int (*select)(struct i2c_atr *atr, u32 chan_id);
+ int (*deselect)(struct i2c_atr *atr, u32 chan_id);
+ int (*attach_client)(struct i2c_atr *atr, u32 chan_id,
+ const struct i2c_board_info *info,
+ const struct i2c_client *client,
+ u16 *alias_id);
+ void (*detach_client)(struct i2c_atr *atr, u32 chan_id,
+ const struct i2c_client *client);
+};
+
+/*
+ * Helper to add I2C ATR features to a device driver.
+ */
+struct i2c_atr {
+ /* private: internal use only */
+
+ struct i2c_adapter *parent;
+ struct device *dev;
+ const struct i2c_atr_ops *ops;
+
+ void *priv;
+
+ struct i2c_algorithm algo;
+ struct mutex lock;
+ int max_adapters;
+
+ struct i2c_adapter *adapter[0];
+};
+
+struct i2c_atr *i2c_atr_new(struct i2c_adapter *parent, struct device *dev,
+ const struct i2c_atr_ops *ops, int max_adapters);
+void i2c_atr_delete(struct i2c_atr *atr);
+
+static inline void i2c_atr_set_clientdata(struct i2c_atr *atr, void *data)
+{
+ atr->priv = data;
+}
+
+static inline void *i2c_atr_get_clientdata(struct i2c_atr *atr)
+{
+ return atr->priv;
+}
+
+int i2c_atr_add_adapter(struct i2c_atr *atr, u32 chan_id);
+void i2c_atr_del_adapter(struct i2c_atr *atr, u32 chan_id);
+
+#endif /* __KERNEL__ */
+
+#endif /* _LINUX_I2C_ATR_H */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index a670ae129f4b..752f049faae9 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -561,6 +561,21 @@ struct i2c_lock_operations {
};
/**
+ * struct i2c_attach_operations - callbacks to notify client attach/detach
+ * @attach_client: Notify of new client being attached
+ * @detach_client: Notify of new client being detached
+ *
+ * Both ops are optional.
+ */
+struct i2c_attach_operations {
+ int (*attach_client)(struct i2c_adapter *adapter,
+ const struct i2c_board_info *info,
+ const struct i2c_client *client);
+ void (*detach_client)(struct i2c_adapter *adapter,
+ const struct i2c_client *client);
+};
+
+/**
* struct i2c_timings - I2C timing information
* @bus_freq_hz: the bus frequency in Hz
* @scl_rise_ns: time SCL signal takes to rise in ns; t(r) in the I2C specification
@@ -702,6 +717,7 @@ struct i2c_adapter {
/* data fields that are valid for all devices */
const struct i2c_lock_operations *lock_ops;
+ const struct i2c_attach_operations *attach_ops;
struct rt_mutex bus_lock;
struct rt_mutex mux_lock;