Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1431051 > unrolled thread
| Started by | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| First post | 2016-06-25 05:00 +0200 |
| Last post | 2016-06-25 17:10 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[RFT PATCH] regmap-i2c: Only use I2C_FUNC_I2C if val_bits == 8 Guenter Roeck <linux@roeck-us.net> - 2016-06-25 05:00 +0200
Re: [RFT PATCH] regmap-i2c: Only use I2C_FUNC_I2C if val_bits == 8 Mark Brown <broonie@kernel.org> - 2016-06-25 13:40 +0200
Re: [RFT PATCH] regmap-i2c: Only use I2C_FUNC_I2C if val_bits == 8 Guenter Roeck <linux@roeck-us.net> - 2016-06-25 17:10 +0200
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2016-06-25 05:00 +0200 |
| Subject | [RFT PATCH] regmap-i2c: Only use I2C_FUNC_I2C if val_bits == 8 |
| Message-ID | <rNLZ8-8gc-1@gated-at.bofh.it> |
On chips with a register value size of 16 bits, I2C block reads will
typically not return the expected values. Instead, returned values
are most likely undefined if an operation crosses a register boundary.
This can be observed, for example, with a TMP102 connected to an omap
i2c controller. With this chip, the initial regmap read operation to fill
the register cache looks as follows (debug log from modified kernel).
omap_i2c 48070000.i2c: MSG[0]: add=0x0048, len: 1, flags: 0x0
omap_i2c 48070000.i2c: [0] 0x00
omap_i2c 48070000.i2c: MSG[1]: add=0x0048, len: 8, flags: 0x1
omap_i2c 48070000.i2c: [0] 0x23
omap_i2c 48070000.i2c: [1] 0xa0
omap_i2c 48070000.i2c: [2] 0xff
omap_i2c 48070000.i2c: [3] 0xff
omap_i2c 48070000.i2c: [4] 0xff
omap_i2c 48070000.i2c: [5] 0xff
omap_i2c 48070000.i2c: [6] 0xff
omap_i2c 48070000.i2c: [7] 0xff
Reported-by: Nishanth Menon <nm@ti.com>
Cc: Nishanth Menon <nm@ti.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
Nishanth,
it would be great if you can test this patch, to see if it solves the problem
you had observed. Please note that https://patchwork.kernel.org/patch/9191185/
needs to be applied first (it is available in next-20160624).
drivers/base/regmap/regmap-i2c.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/base/regmap/regmap-i2c.c b/drivers/base/regmap/regmap-i2c.c
index 4735318f4268..f319e6829816 100644
--- a/drivers/base/regmap/regmap-i2c.c
+++ b/drivers/base/regmap/regmap-i2c.c
@@ -257,7 +257,8 @@ static struct regmap_bus regmap_i2c_smbus_i2c_block = {
static const struct regmap_bus *regmap_get_i2c_bus(struct i2c_client *i2c,
const struct regmap_config *config)
{
- if (i2c_check_functionality(i2c->adapter, I2C_FUNC_I2C))
+ if (config->val_bits == 8 &&
+ i2c_check_functionality(i2c->adapter, I2C_FUNC_I2C))
return ®map_i2c;
else if (config->val_bits == 8 && config->reg_bits == 8 &&
i2c_check_functionality(i2c->adapter,
--
2.5.0
[toc] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-06-25 13:40 +0200 |
| Message-ID | <rNU6l-4TK-5@gated-at.bofh.it> |
| In reply to | #1431051 |
[Multipart message — attachments visible in raw view] — view raw
On Fri, Jun 24, 2016 at 07:53:53PM -0700, Guenter Roeck wrote: > On chips with a register value size of 16 bits, I2C block reads will > typically not return the expected values. Instead, returned values > are most likely undefined if an operation crosses a register boundary. No, this just isn't true in general - if a device has trouble with bulk reads it needs to set use_sigle_rw in the config to disable them. Device limitations with bulk reads are a per device thing and are orthogonal to the value size, being more to do with the age and quality of the register map implementation than anything else.
[toc] | [prev] | [next] | [standalone]
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2016-06-25 17:10 +0200 |
| Message-ID | <rNXnA-71S-5@gated-at.bofh.it> |
| In reply to | #1431119 |
On 06/25/2016 04:34 AM, Mark Brown wrote: > On Fri, Jun 24, 2016 at 07:53:53PM -0700, Guenter Roeck wrote: > >> On chips with a register value size of 16 bits, I2C block reads will >> typically not return the expected values. Instead, returned values >> are most likely undefined if an operation crosses a register boundary. > > No, this just isn't true in general - if a device has trouble with bulk > reads it needs to set use_sigle_rw in the config to disable them. > Device limitations with bulk reads are a per device thing and are > orthogonal to the value size, being more to do with the age and quality > of the register map implementation than anything else. > Ok, thanks for letting me know. I'll try that. Guenter
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web