diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/i2c-mux.h | 4 | ||||
-rw-r--r-- | include/linux/i2c.h | 26 |
2 files changed, 30 insertions, 0 deletions
diff --git a/include/linux/i2c-mux.h b/include/linux/i2c-mux.h index 98ef73b7c8fd..43c40680d8c5 100644 --- a/include/linux/i2c-mux.h +++ b/include/linux/i2c-mux.h @@ -14,6 +14,7 @@ #ifdef __KERNEL__ #include <linux/bitops.h> +#include <linux/workqueue.h> struct i2c_mux_core { struct i2c_adapter *parent; @@ -27,6 +28,9 @@ struct i2c_mux_core { int (*select)(struct i2c_mux_core *, u32 chan_id); int (*deselect)(struct i2c_mux_core *, u32 chan_id); + struct mutex hold_lock; /* mutex for channel holding */ + struct delayed_work unhold_work; + int num_adapters; int max_adapters; struct i2c_adapter *adapter[]; diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 2ce3efbe9198..dc681a7196f7 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -20,6 +20,7 @@ #include <linux/irqdomain.h> /* for Host Notify IRQ */ #include <linux/of.h> /* for struct device_node */ #include <linux/swab.h> /* for swab16 */ +#include <linux/workqueue.h> #include <uapi/linux/i2c.h> extern struct bus_type i2c_bus_type; @@ -738,6 +739,13 @@ struct i2c_adapter { struct irq_domain *host_notify_domain; struct regulator *bus_regulator; + + /* + * These will be used by root adpaters only. For muxes, each mux core + * has these individually. + */ + struct mutex hold_lock; /* mutex for bus holding */ + struct delayed_work unhold_work; }; #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) @@ -1040,4 +1048,22 @@ static inline struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle ha } #endif /* CONFIG_ACPI */ +enum i2c_hold_msg_type { + I2C_HOLD_MSG_NONE, + I2C_HOLD_MSG_SET, + I2C_HOLD_MSG_RESET +}; + +static inline enum i2c_hold_msg_type i2c_check_hold_msg(u16 flags, u16 len, u16 *buf) +{ + if (flags & I2C_M_HOLD && len == sizeof(u16)) { + if (*buf) + return I2C_HOLD_MSG_SET; + + return I2C_HOLD_MSG_RESET; + } + + return I2C_HOLD_MSG_NONE; +} + #endif /* _LINUX_I2C_H */ |