Commit 14674e70119ea01549ce593d8901a797f8a90f74
Committed by
Jean Delvare
1 parent
838bfa6049
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
i2c: Split I2C_M_NOSTART support out of I2C_FUNC_PROTOCOL_MANGLING
Since there are uses for I2C_M_NOSTART which are much more sensible and standard than most of the protocol mangling functionality (the main one being gather writes to devices where something like a register address needs to be inserted before a block of data) create a new I2C_FUNC_NOSTART for this feature and update all the users to use it. Also strengthen the disrecommendation of the protocol mangling while we're at it. In the case of regmap-i2c we remove the requirement for mangling as I2C_M_NOSTART is the only mangling feature which is being used. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Showing 9 changed files with 25 additions and 10 deletions Side-by-side Diff
Documentation/i2c/functionality
... | ... | @@ -18,9 +18,9 @@ |
18 | 18 | adapters typically can not do these) |
19 | 19 | I2C_FUNC_10BIT_ADDR Handles the 10-bit address extensions |
20 | 20 | I2C_FUNC_PROTOCOL_MANGLING Knows about the I2C_M_IGNORE_NAK, |
21 | - I2C_M_REV_DIR_ADDR, I2C_M_NOSTART and | |
22 | - I2C_M_NO_RD_ACK flags (which modify the | |
23 | - I2C protocol!) | |
21 | + I2C_M_REV_DIR_ADDR and I2C_M_NO_RD_ACK | |
22 | + flags (which modify the I2C protocol!) | |
23 | + I2C_FUNC_NOSTART Can skip repeated start sequence | |
24 | 24 | I2C_FUNC_SMBUS_QUICK Handles the SMBus write_quick command |
25 | 25 | I2C_FUNC_SMBUS_READ_BYTE Handles the SMBus read_byte command |
26 | 26 | I2C_FUNC_SMBUS_WRITE_BYTE Handles the SMBus write_byte command |
... | ... | @@ -49,6 +49,9 @@ |
49 | 49 | I2C_FUNC_SMBUS_EMUL Handles all SMBus commands than can be |
50 | 50 | emulated by a real I2C adapter (using |
51 | 51 | the transparent emulation layer) |
52 | + | |
53 | +In kernel versions prior to 3.5 I2C_FUNC_NOSTART was implemented as | |
54 | +part of I2C_FUNC_PROTOCOL_MANGLING. | |
52 | 55 | |
53 | 56 | |
54 | 57 | ADAPTER IMPLEMENTATION |
Documentation/i2c/i2c-protocol
... | ... | @@ -49,7 +49,9 @@ |
49 | 49 | Modified transactions |
50 | 50 | ===================== |
51 | 51 | |
52 | -We have found some I2C devices that needs the following modifications: | |
52 | +The following modifications to the I2C protocol can also be generated, | |
53 | +with the exception of I2C_M_NOSTART these are usually only needed to | |
54 | +work around device issues: | |
53 | 55 | |
54 | 56 | Flag I2C_M_NOSTART: |
55 | 57 | In a combined transaction, no 'S Addr Wr/Rd [A]' is generated at some |
... | ... | @@ -59,6 +61,11 @@ |
59 | 61 | If you set the I2C_M_NOSTART variable for the first partial message, |
60 | 62 | we do not generate Addr, but we do generate the startbit S. This will |
61 | 63 | probably confuse all other clients on your bus, so don't try this. |
64 | + | |
65 | + This is often used to gather transmits from multiple data buffers in | |
66 | + system memory into something that appears as a single transfer to the | |
67 | + I2C device but may also be used between direction changes by some | |
68 | + rare devices. | |
62 | 69 | |
63 | 70 | Flags I2C_M_REV_DIR_ADDR |
64 | 71 | This toggles the Rd/Wr flag. That is, if you want to do a write, but |
drivers/base/regmap/regmap-i2c.c
... | ... | @@ -42,7 +42,7 @@ |
42 | 42 | /* If the I2C controller can't do a gather tell the core, it |
43 | 43 | * will substitute in a linear write for us. |
44 | 44 | */ |
45 | - if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_PROTOCOL_MANGLING)) | |
45 | + if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_NOSTART)) | |
46 | 46 | return -ENOTSUPP; |
47 | 47 | |
48 | 48 | xfer[0].addr = i2c->addr; |
drivers/i2c/algos/i2c-algo-bit.c
... | ... | @@ -608,7 +608,7 @@ |
608 | 608 | |
609 | 609 | static u32 bit_func(struct i2c_adapter *adap) |
610 | 610 | { |
611 | - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | | |
611 | + return I2C_FUNC_I2C | I2C_FUNC_NOSTART | I2C_FUNC_SMBUS_EMUL | | |
612 | 612 | I2C_FUNC_SMBUS_READ_BLOCK_DATA | |
613 | 613 | I2C_FUNC_SMBUS_BLOCK_PROC_CALL | |
614 | 614 | I2C_FUNC_10BIT_ADDR | I2C_FUNC_PROTOCOL_MANGLING; |
drivers/i2c/busses/i2c-nuc900.c
... | ... | @@ -502,7 +502,8 @@ |
502 | 502 | /* declare our i2c functionality */ |
503 | 503 | static u32 nuc900_i2c_func(struct i2c_adapter *adap) |
504 | 504 | { |
505 | - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING; | |
505 | + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_NOSTART | | |
506 | + I2C_FUNC_PROTOCOL_MANGLING; | |
506 | 507 | } |
507 | 508 | |
508 | 509 | /* i2c bus registration info */ |
drivers/i2c/busses/i2c-s3c2410.c
... | ... | @@ -626,7 +626,8 @@ |
626 | 626 | /* declare our i2c functionality */ |
627 | 627 | static u32 s3c24xx_i2c_func(struct i2c_adapter *adap) |
628 | 628 | { |
629 | - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING; | |
629 | + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_NOSTART | | |
630 | + I2C_FUNC_PROTOCOL_MANGLING; | |
630 | 631 | } |
631 | 632 | |
632 | 633 | /* i2c bus registration info */ |
drivers/input/joystick/as5011.c
drivers/video/matrox/matroxfb_maven.c
... | ... | @@ -1243,6 +1243,7 @@ |
1243 | 1243 | |
1244 | 1244 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_WORD_DATA | |
1245 | 1245 | I2C_FUNC_SMBUS_BYTE_DATA | |
1246 | + I2C_FUNC_NOSTART | | |
1246 | 1247 | I2C_FUNC_PROTOCOL_MANGLING)) |
1247 | 1248 | goto ERROR0; |
1248 | 1249 | if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) { |
include/linux/i2c.h
... | ... | @@ -541,7 +541,7 @@ |
541 | 541 | __u16 flags; |
542 | 542 | #define I2C_M_TEN 0x0010 /* this is a ten bit chip address */ |
543 | 543 | #define I2C_M_RD 0x0001 /* read data, from slave to master */ |
544 | -#define I2C_M_NOSTART 0x4000 /* if I2C_FUNC_PROTOCOL_MANGLING */ | |
544 | +#define I2C_M_NOSTART 0x4000 /* if I2C_FUNC_NOSTART */ | |
545 | 545 | #define I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */ |
546 | 546 | #define I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */ |
547 | 547 | #define I2C_M_NO_RD_ACK 0x0800 /* if I2C_FUNC_PROTOCOL_MANGLING */ |
548 | 548 | |
... | ... | @@ -554,8 +554,9 @@ |
554 | 554 | |
555 | 555 | #define I2C_FUNC_I2C 0x00000001 |
556 | 556 | #define I2C_FUNC_10BIT_ADDR 0x00000002 |
557 | -#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_NOSTART etc. */ | |
557 | +#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_IGNORE_NAK etc. */ | |
558 | 558 | #define I2C_FUNC_SMBUS_PEC 0x00000008 |
559 | +#define I2C_FUNC_NOSTART 0x00000010 /* I2C_M_NOSTART */ | |
559 | 560 | #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ |
560 | 561 | #define I2C_FUNC_SMBUS_QUICK 0x00010000 |
561 | 562 | #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 |