aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/i2c.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index f17da50402a4..243d1a1d78b2 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -449,6 +449,48 @@ int i2c_recover_bus(struct i2c_adapter *adap);
449int i2c_generic_gpio_recovery(struct i2c_adapter *adap); 449int i2c_generic_gpio_recovery(struct i2c_adapter *adap);
450int i2c_generic_scl_recovery(struct i2c_adapter *adap); 450int i2c_generic_scl_recovery(struct i2c_adapter *adap);
451 451
452/**
453 * struct i2c_adapter_quirks - describe flaws of an i2c adapter
454 * @flags: see I2C_AQ_* for possible flags and read below
455 * @max_num_msgs: maximum number of messages per transfer
456 * @max_write_len: maximum length of a write message
457 * @max_read_len: maximum length of a read message
458 * @max_comb_1st_msg_len: maximum length of the first msg in a combined message
459 * @max_comb_2nd_msg_len: maximum length of the second msg in a combined message
460 *
461 * Note about combined messages: Some I2C controllers can only send one message
462 * per transfer, plus something called combined message or write-then-read.
463 * This is (usually) a small write message followed by a read message and
464 * barely enough to access register based devices like EEPROMs. There is a flag
465 * to support this mode. It implies max_num_msg = 2 and does the length checks
466 * with max_comb_*_len because combined message mode usually has its own
467 * limitations. Because of HW implementations, some controllers can actually do
468 * write-then-anything or other variants. To support that, write-then-read has
469 * been broken out into smaller bits like write-first and read-second which can
470 * be combined as needed.
471 */
472
473struct i2c_adapter_quirks {
474 u64 flags;
475 int max_num_msgs;
476 u16 max_write_len;
477 u16 max_read_len;
478 u16 max_comb_1st_msg_len;
479 u16 max_comb_2nd_msg_len;
480};
481
482/* enforce max_num_msgs = 2 and use max_comb_*_len for length checks */
483#define I2C_AQ_COMB BIT(0)
484/* first combined message must be write */
485#define I2C_AQ_COMB_WRITE_FIRST BIT(1)
486/* second combined message must be read */
487#define I2C_AQ_COMB_READ_SECOND BIT(2)
488/* both combined messages must have the same target address */
489#define I2C_AQ_COMB_SAME_ADDR BIT(3)
490/* convenience macro for typical write-then read case */
491#define I2C_AQ_COMB_WRITE_THEN_READ (I2C_AQ_COMB | I2C_AQ_COMB_WRITE_FIRST | \
492 I2C_AQ_COMB_READ_SECOND | I2C_AQ_COMB_SAME_ADDR)
493
452/* 494/*
453 * i2c_adapter is the structure used to identify a physical i2c bus along 495 * i2c_adapter is the structure used to identify a physical i2c bus along
454 * with the access algorithms necessary to access it. 496 * with the access algorithms necessary to access it.
@@ -474,6 +516,7 @@ struct i2c_adapter {
474 struct list_head userspace_clients; 516 struct list_head userspace_clients;
475 517
476 struct i2c_bus_recovery_info *bus_recovery_info; 518 struct i2c_bus_recovery_info *bus_recovery_info;
519 const struct i2c_adapter_quirks *quirks;
477}; 520};
478#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) 521#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
479 522