Skip to content

Commit 14674e7

Browse files
broonieJean Delvare
authored andcommitted
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>
1 parent 838bfa6 commit 14674e7

9 files changed

Lines changed: 25 additions & 10 deletions

File tree

‎Documentation/i2c/functionality‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ For the most up-to-date list of functionality constants, please check
1818
adapters typically can not do these)
1919
I2C_FUNC_10BIT_ADDR Handles the 10-bit address extensions
2020
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
2424
I2C_FUNC_SMBUS_QUICK Handles the SMBus write_quick command
2525
I2C_FUNC_SMBUS_READ_BYTE Handles the SMBus read_byte command
2626
I2C_FUNC_SMBUS_WRITE_BYTE Handles the SMBus write_byte command
@@ -50,6 +50,9 @@ A few combinations of the above flags are also defined for your convenience:
5050
emulated by a real I2C adapter (using
5151
the transparent emulation layer)
5252

53+
In kernel versions prior to 3.5 I2C_FUNC_NOSTART was implemented as
54+
part of I2C_FUNC_PROTOCOL_MANGLING.
55+
5356

5457
ADAPTER IMPLEMENTATION
5558
----------------------

‎Documentation/i2c/i2c-protocol‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ a byte read, followed by a byte write:
4949
Modified transactions
5050
=====================
5151

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:
5355

5456
Flag I2C_M_NOSTART:
5557
In a combined transaction, no 'S Addr Wr/Rd [A]' is generated at some
@@ -60,6 +62,11 @@ We have found some I2C devices that needs the following modifications:
6062
we do not generate Addr, but we do generate the startbit S. This will
6163
probably confuse all other clients on your bus, so don't try this.
6264

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.
69+
6370
Flags I2C_M_REV_DIR_ADDR
6471
This toggles the Rd/Wr flag. That is, if you want to do a write, but
6572
need to emit an Rd instead of a Wr, or vice versa, you set this

‎drivers/base/regmap/regmap-i2c.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int regmap_i2c_gather_write(void *context,
4242
/* If the I2C controller can't do a gather tell the core, it
4343
* will substitute in a linear write for us.
4444
*/
45-
if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_PROTOCOL_MANGLING))
45+
if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_NOSTART))
4646
return -ENOTSUPP;
4747

4848
xfer[0].addr = i2c->addr;

‎drivers/i2c/algos/i2c-algo-bit.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
608608

609609
static u32 bit_func(struct i2c_adapter *adap)
610610
{
611-
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
611+
return I2C_FUNC_I2C | I2C_FUNC_NOSTART | I2C_FUNC_SMBUS_EMUL |
612612
I2C_FUNC_SMBUS_READ_BLOCK_DATA |
613613
I2C_FUNC_SMBUS_BLOCK_PROC_CALL |
614614
I2C_FUNC_10BIT_ADDR | I2C_FUNC_PROTOCOL_MANGLING;

‎drivers/i2c/busses/i2c-nuc900.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ static int nuc900_i2c_xfer(struct i2c_adapter *adap,
502502
/* declare our i2c functionality */
503503
static u32 nuc900_i2c_func(struct i2c_adapter *adap)
504504
{
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;
506507
}
507508

508509
/* i2c bus registration info */

‎drivers/i2c/busses/i2c-s3c2410.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,8 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
626626
/* declare our i2c functionality */
627627
static u32 s3c24xx_i2c_func(struct i2c_adapter *adap)
628628
{
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;
630631
}
631632

632633
/* i2c bus registration info */

‎drivers/input/joystick/as5011.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ static int __devinit as5011_probe(struct i2c_client *client,
231231
}
232232

233233
if (!i2c_check_functionality(client->adapter,
234+
I2C_FUNC_NOSTART |
234235
I2C_FUNC_PROTOCOL_MANGLING)) {
235236
dev_err(&client->dev,
236237
"need i2c bus that supports protocol mangling\n");

‎drivers/video/matrox/matroxfb_maven.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ static int maven_probe(struct i2c_client *client,
12431243

12441244
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_WORD_DATA |
12451245
I2C_FUNC_SMBUS_BYTE_DATA |
1246+
I2C_FUNC_NOSTART |
12461247
I2C_FUNC_PROTOCOL_MANGLING))
12471248
goto ERROR0;
12481249
if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) {

‎include/linux/i2c.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ struct i2c_msg {
541541
__u16 flags;
542542
#define I2C_M_TEN 0x0010 /* this is a ten bit chip address */
543543
#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 */
545545
#define I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */
546546
#define I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */
547547
#define I2C_M_NO_RD_ACK 0x0800 /* if I2C_FUNC_PROTOCOL_MANGLING */
@@ -554,8 +554,9 @@ struct i2c_msg {
554554

555555
#define I2C_FUNC_I2C 0x00000001
556556
#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. */
558558
#define I2C_FUNC_SMBUS_PEC 0x00000008
559+
#define I2C_FUNC_NOSTART 0x00000010 /* I2C_M_NOSTART */
559560
#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
560561
#define I2C_FUNC_SMBUS_QUICK 0x00010000
561562
#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000

0 commit comments

Comments
 (0)