hwmon: (ads7828) Make sample interval configurable
PATCH 1/1 hwmon: (ads7828) Make sample interval configurable
The default sample interval may be too slow for certain clients. This patch makes it configurable via the platform_data.
--- drivers/hwmon/ads7828.c | 11 ++++++++++- include/linux/platform_data/ads7828.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/hwmon/ads7828.c +10 -1
@@ -45,6 +45,9 @@#define ADS7828_EXT_VREF_MV_MIN 50/* External vref min value 0.05V */ #define ADS7828_EXT_VREF_MV_MAX 5250/* External vref max value 5.25V */ +/* Default sample interval */ +#define ADS7828_SAMPLE_INTERVAL (HZ + HZ / 2) +/* List of supported devices */ enum ads7828_chips { ads7828, ads7830 };
@@ -58,6 +61,7 @@ struct ads7828_data {bool diff_input;/* Differential input */ bool ext_vref;/* External voltage reference */ unsigned int vref_mv;/* voltage reference value */ +unsigned int sample_interval;/* sample interval */ u8 cmd_byte;/* Command byte without channel bits */ unsigned int lsb_resol;/* Resolution of the ADC sample LSB */ s32 (*read_channel)(const struct i2c_client *client,u8 command);
@@ -77,7 +81,7 @@ static struct ads7828_data *ads7828_update_device(struct device *dev)mutex_lock (&data->update_lock); -if (time_after (jiffies, data->last_updated +HZ +HZ /2 ) +if (time_after (jiffies, data->last_updated + data->sample_interval) || !data->valid) {unsigned int ch;dev_dbg (&client->dev,"Starting ads7828 update\n" );
@@ -147,6 +151,8 @@ static int ads7828_probe(struct i2c_client *client, data->ext_vref = pdata->ext_vref;if (data->ext_vref) data->vref_mv = pdata->vref_mv; +if (pdata->sample_interval) + data->sample_interval = pdata->sample_interval; }/* Bound Vref with min/max values if it was provided */
@@ -157,6 +163,9 @@ static int ads7828_probe(struct i2c_client *client,else data->vref_mv =ADS7828_INT_VREF_MV ; +if (!data->sample_interval) + data->sample_interval =ADS7828_SAMPLE_INTERVAL ; +/* ADS7828 uses 12-bit samples, while ADS7830 is 8-bit */ if (id->driver_data = ads7828) { data->lsb_resol =DIV_ROUND_CLOSEST (data->vref_mv *1000 ,4096 );
include/linux/platform_data/ads7828.h +2 -0
@@ -19,11 +19,13 @@* @diff_input: Differential input mode. * @ext_vref: Use an external voltage reference. * @vref_mv: Voltage reference value, if external. +* @sample_interval: Sample interval. */ struct ads7828_platform_data {bool diff_input;bool ext_vref;unsigned int vref_mv; +unsigned int sample_interval; };#endif /* _PDATA_ADS7828_H */
Signature · 7 lines
2.1.4 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 5 lines · Robert Rosengren
The default sample interval may be too slow for certain clients. This patch makes it configurable via the
platform_data.Signed-off-by Robert Rosengren <[email protected]>Signed-off-by Johan Adolfsson <[email protected]>
I am basically fine with the patch, though I would prefer replacing the entire update handling and chip access with regmap. Would you be interested in doing that ?
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 11 lines · Guenter Roeck
Quoted 5 lines · Robert Rosengren
The default sample interval may be too slow for certain clients. This patch makes it configurable via the
platform_data.Signed-off-by Robert Rosengren <[email protected]>Signed-off-by Johan Adolfsson <[email protected]>I am basically fine with the patch, though I would prefer replacing the entire update handling and chip access with regmap. Would you be interested in doing that ?
I sent a couple of patches a minute ago which should take care of the issue. Would be great if you can test it.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 11 lines · Guenter Roeck
Quoted 4 lines
I am basically fine with the patch, though I would prefer replacing the entire update handling and chip access with regmap. Would you be interested in doing that ?
I sent a couple of patches a minute ago which should take care of the issue. Would be great if you can test it.
Thanks,
Guenter
OK, great. I will look into your patch next week, since I'm currently out of office.
BR,
Robert
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 2 lines · Guenter Roeck
I sent a couple of patches a minute ago which should take care of the issue. Would be great if you can test it.
I applied the v2 versions of the patches for a quick test, but it was not successful. Haven't done any further investigation on what the problem might be, but when trying to read the sysfs driver I get "read
error: No such device or address".
The sysfs path have moved with the REGMAP settings, from /sys/bus/i2c/devices/<x>/in0_input to /sys/bus/i2c/devices/<x>/hwmon/hwmon0/in0_input.
Any ideas? Haven't had REGMAP configured in my kernel earlier, might it be some specific configuration I miss?
BR,
Robert
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
SGkgUm9iZXJ0LAoKTGUgVHVlc2RheSAyNyBKYW51YXJ5IDIwMTUgw6AgMDg6NTkgKzAxMDAsIFJv YmVydCBSb3NlbmdyZW4gYSDDqWNyaXQgOgo+IE9uIDAxLzE2LzIwMTUgMDc6MzAgUE0sIEd1ZW50 ZXIgUm9lY2sgd3JvdGU6Cj4gPiBJIHNlbnQgYSBjb3VwbGUgb2YgcGF0Y2hlcyBhIG1pbnV0ZSBh Z28gd2hpY2ggc2hvdWxkIHRha2UgY2FyZSBvZiB0aGUgaXNzdWUuCj4gPiBXb3VsZCBiZSBncmVh dCBpZiB5b3UgY2FuIHRlc3QgaXQuCj4gSSBhcHBsaWVkIHRoZSB2MiB2ZXJzaW9ucyBvZiB0aGUg cGF0Y2hlcyBmb3IgYSBxdWljayB0ZXN0LCBidXQgaXQgd2FzIAo+IG5vdCBzdWNjZXNzZnVsLiBI YXZlbid0IGRvbmUgYW55IGZ1cnRoZXIgaW52ZXN0aWdhdGlvbiBvbiB3aGF0IHRoZSAKPiBwcm9i bGVtIG1pZ2h0IGJlLCBidXQgd2hlbiB0cnlpbmcgdG8gcmVhZCB0aGUgc3lzZnMgZHJpdmVyIEkg Z2V0ICJyZWFkIAo+IGVycm9yOiBObyBzdWNoIGRldmljZSBvciBhZGRyZXNzIi4KPiAKPiBUaGUg c3lzZnMgcGF0aCBoYXZlIG1vdmVkIHdpdGggdGhlIFJFR01BUCBzZXR0aW5ncywgZnJvbSAKPiAv c3lzL2J1cy9pMmMvZGV2aWNlcy88eD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zdApsbS1zZW5zb3JzQGxtLXNlbnNvcnMub3JnCmh0dHA6Ly9saXN0cy5sbS1z ZW5zb3JzLm9yZy9tYWlsbWFuL2xpc3RpbmZvL2xtLXNlbnNvcnM
Guenter Roeck
maintainerQuoted 9 lines · Robert Rosengren
Quoted 2 lines · Guenter Roeck
I sent a couple of patches a minute ago which should take care of the issue. Would be great if you can test it.
I applied the v2 versions of the patches for a quick test, but it was not successful. Haven't done any further investigation on what the problem might be, but when trying to read the sysfs driver I get "read error: No such device or address".
The sysfs path have moved with the REGMAP settings, from /sys/bus/i2c/devices/<x>/in0_input to /sys/bus/i2c/devices/<x>/hwmon/hwmon0/in0_input.
Any ideas? Haven't had REGMAP configured in my kernel earlier, might it be some specific configuration I miss?
Did you configure REGMAP ? That would now be necessary.
The "official" sysfs path would be /sys/class/hwmon/hwmonX (hwmon0 in your case).
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter and Jean,
To sum up, my problems was related my kernel and hardware configuration, and it now works. Many thanks for your input!
However, the values retrieved from hwmon sysfs is not the same as before the regmap patch. Guenter, the byte swap for the regval retrieved by regmap_read. In what order is the bits returned from that function, because it seems as if I disabled that code I get values as I expect (i.e. before the regmap patch).
BR,
Robert
Quoted 8 lines · Robert Rosengren
Quoted 7 lines · Guenter Roeck
Quoted 2 lines
I sent a couple of patches a minute ago which should take care of the issue. Would be great if you can test it.
I applied the v2 versions of the patches for a quick test, but it was not successful. Haven't done any further investigation on what the problem might be, but when trying to read the sysfs driver I get "read error: No such device or address".
The sysfs path have moved with the REGMAP settings, from /sys/bus/i2c/devices/<x>/in0_input to /sys/bus/i2c/devices/<x>/hwmon/hwmon0/in0_input.
Quoted 7 lines
Quoted 2 lines
Any ideas? Haven't had REGMAP configured in my kernel earlier, might it be some specific configuration I miss?
Did you configure REGMAP ? That would now be necessary.
The "official" sysfs path would be/sys/class/hwmon/hwmonX(hwmon0 in your case).Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 6 lines · Robert Rosengren
Guenter and Jean,
To sum up, my problems was related my kernel and hardware configuration, and it now works. Many thanks for your input!
However, the values retrieved from hwmon sysfs is not the same as before the regmap patch. Guenter, the byte swap for the regval retrieved by
regmap_read. In what order is the bits returned from that function, because it seems as if I disabled that code I get values as I expect (i.e. before the regmap patch).
Trying to understand. Are you saying everything works as expected if you keep byte_swap set to false ?
That might well be, though it might mean that regmap has a bug in how it treats i2c word read operations. I'll have to look into it some more.
Can you send me your diffs on top of mine to help me understand what you changed ?
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Robert Rosengren
Guenter and Jean,
To sum up, my problems was related my kernel and hardware configuration, and it now works. Many thanks for your input!
Quoted 8 lines
Quoted 2 lines
However, the values retrieved from hwmon sysfs is not the same as before the regmap patch. Guenter, the byte swap for the regval retrieved by
regmap_read. In what order is the bits returned from that function, because it seems as if I disabled that code I get values as I expect (i.e. before the regmap patch).Trying to understand. Are you saying everything works as expected if you keep
byte_swapset to false ?That might well be, though it might mean that regmap has a bug in how it treats i2c word read operations. I'll have to look into it some more.
Remember that SMBus specifies that the LSB comes first (and i2c-core implement things that way) while real I2C devices typically send the MSB first. This has always caused confusion. This is why a lot of drivers need byte-swapping.
Signature · 7 lines
Jean Delvare SUSE L3 Support _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 11 lines · Jean Delvare
Quoted 10 lines · Guenter Roeck
Quoted 6 lines · Robert Rosengren
Guenter and Jean,
To sum up, my problems was related my kernel and hardware configuration, and it now works. Many thanks for your input!
However, the values retrieved from hwmon sysfs is not the same as before the regmap patch. Guenter, the byte swap for the regval retrieved by
regmap_read. In what order is the bits returned from that function, because it seems as if I disabled that code I get values as I expect (i.e. before the regmap patch).Trying to understand. Are you saying everything works as expected if you keep
byte_swapset to false ?
Quoted 9 lines
Quoted 3 lines
That might well be, though it might mean that regmap has a bug in how it treats i2c word read operations. I'll have to look into it some more.
Remember that SMBus specifies that the LSB comes first (and i2c-core implement things that way) while real I2C devices typically send the MSB first. This has always caused confusion. This is why a lot of drivers need byte-swapping.
regmap specifies "normal" i2c accesses as MSB first. When SMBus accesses are used, it specifies LSB first. I guess that means that regmap assumes the more common case of MSB first, meaning the driver would not need a byte swap since the chip reports data with MSB first.
I just hope I interpret it correctly this time.
There is also a configuration flag "val_format_endian" which can be set to REGMAP_ENDIAN_BIG or REGMAP_ENDIAN_LITTLE. Maybe that can be used as well if needed. Either case I'll wait for the samples before I send an updated version of the patch.
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 9 lines · Robert Rosengren
Quoted 2 lines · Guenter Roeck
I sent a couple of patches a minute ago which should take care of the issue. Would be great if you can test it.
I applied the v2 versions of the patches for a quick test, but it was not successful. Haven't done any further investigation on what the problem might be, but when trying to read the sysfs driver I get "read error: No such device or address".
The sysfs path have moved with the REGMAP settings, from /sys/bus/i2c/devices/<x>/in0_input to /sys/bus/i2c/devices/<x>/hwmon/hwmon0/in0_input.
Any ideas? Haven't had REGMAP configured in my kernel earlier, might it be some specific configuration I miss?
Robert,
Another thought: What is your kernel version, and what is your i2c controller ?
SMBus support was added to regmap only recently, so if your controller only supports SMBus (not raw i2c transactions), and you have an older kernel, this might not work. The driver should fail to instantiate in that case, though, if I recall correctly.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 8 lines · Robert Rosengren
Quoted 2 lines · Guenter Roeck
I sent a couple of patches a minute ago which should take care of the issue. Would be great if you can test it.
I applied the v2 versions of the patches for a quick test, but it was not successful. Haven't done any further investigation on what the problem might be, but when trying to read the sysfs driver I get "read error: No such device or address".
Quoted 7 lines
The sysfs path have moved with the REGMAP settings, from /sys/bus/i2c/devices/<x>/in0_input to /sys/bus/i2c/devices/<x>/hwmon/hwmon0/in0_input.
Any ideas? Haven't had REGMAP configured in my kernel earlier, might it be some specific configuration I miss?
My module test script at github.com/groeck/module-tests.git passes. Only downside is that it doesn't use real register values since I do not have a register dump.
I requested samples for both ads2828 and ads2830, so I should be able to test the code myself on real hardware in a couple of days.
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 5 lines · Robert Rosengren
The default sample interval may be too slow for certain clients. This patch makes it configurable via the
platform_data.Signed-off-by Robert Rosengren <[email protected]>Signed-off-by Johan Adolfsson <[email protected]>
Robert,
can you send me the output of i2cdump for this chip ? I would like to write a module test for the driver.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 11 lines · Guenter Roeck
Quoted 10 lines · Jean Delvare
Quoted 10 lines · Guenter Roeck
Quoted 9 lines
Quoted 9 lines · Robert Rosengren
Quoted 6 lines
Quoted 6 lines
Guenter and Jean,
To sum up, my problems was related my kernel and hardware configuration, and it now works. Many thanks for your input!
However, the values retrieved from hwmon sysfs is not the same as before the regmap patch. Guenter, the byte swap for the regval retrieved by
regmap_read. In what order is the bits returned from that function, because it seems as if I disabled that code I get values as I expect (i.e. before the regmap patch).Trying to understand. Are you saying everything works as expected if you keep
byte_swapset to false ?
Yes it works as expected, i.e. I can get values from sysfs. The problems I experienced was actually due to moving from an old ads7828-implementation where specific i2c addresses where scanned from the driver, and I first missed to set the correct i2c address for the new driver in the board info.
Quoted 15 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
That might well be, though it might mean that regmap has a bug in how it treats i2c word read operations. I'll have to look into it some more.
Remember that SMBus specifies that the LSB comes first (and i2c-core implement things that way) while real I2C devices typically send the MSB first. This has always caused confusion. This is why a lot of drivers need byte-swapping.
regmap specifies "normal" i2c accesses as MSB first. When SMBus accesses are used, it specifies LSB first. I guess that means that regmap assumes the more common case of MSB first, meaning the driver would not need a byte swap since the chip reports data with MSB first.
Quoted 9 lines
I just hope I interpret it correctly this time.
There is also a configuration flag "
val_format_endian" which can be set toREGMAP_ENDIAN_BIGorREGMAP_ENDIAN_LITTLE. Maybe that can be used as well if needed. Either case I'll wait for the samples before I send an updated version of the patch.Guenter
I tested the driver on 3.15 version of the kernel. Having looked in the git log of regmap.c and regmap-i2c.c, there has been some endianess-related patches going into the kernel in newer versions. Maybe that is the reason for me seeing this problem? I will try to look into that further.
I my test I only disabled following two lines of code
+ if (data->byte_swap)
+ regval = swab16(regval);
BR, Robert
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
My previous mail got blocked by mailing lists for some reasons, so trying once more. I apologize if spamming.
Quoted 52 lines · Robert Rosengren
Quoted 11 lines · Guenter Roeck
Quoted 10 lines · Jean Delvare
Quoted 10 lines · Guenter Roeck
Quoted 9 lines
Quoted 9 lines · Robert Rosengren
Quoted 6 lines
Quoted 6 lines
Guenter and Jean,
To sum up, my problems was related my kernel and hardware configuration, and it now works. Many thanks for your input!
However, the values retrieved from hwmon sysfs is not the same as before the regmap patch. Guenter, the byte swap for the regval retrieved by
regmap_read. In what order is the bits returned from that function, because it seems as if I disabled that code I get values as I expect (i.e. before the regmap patch).Trying to understand. Are you saying everything works as expected if you keep
byte_swapset to false ?Yes it works as expected, i.e. I can get values from sysfs. The problems I experienced was actually due to moving from an old ads7828-implementation where specific i2c addresses where scanned from the driver, and I first missed to set the correct i2c address for the new driver in the board info.
Quoted 15 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
That might well be, though it might mean that regmap has a bug in how it treats i2c word read operations. I'll have to look into it some more.
Remember that SMBus specifies that the LSB comes first (and i2c-core implement things that way) while real I2C devices typically send the MSB first. This has always caused confusion. This is why a lot of drivers need byte-swapping.
regmap specifies "normal" i2c accesses as MSB first. When SMBus accesses are used, it specifies LSB first. I guess that means that regmap assumes the more common case of MSB first, meaning the driver would not need a byte swap since the chip reports data with MSB first.
Quoted 9 lines
I just hope I interpret it correctly this time.
There is also a configuration flag "
val_format_endian" which can be set toREGMAP_ENDIAN_BIGorREGMAP_ENDIAN_LITTLE. Maybe that can be used as well if needed. Either case I'll wait for the samples before I send an updated version of the patch.Guenter
I tested the driver on 3.15 version of the kernel. Having looked in the git log of
regmap.candregmap-i2c.c, there has been some endianess-related patches going into the kernel in newer versions. Maybe that is the reason for me seeing this problem? I will try to look into that further.I my test I only disabled following two lines of code
(quoted diff) +2
-0+ if (data->byte_swap) + regval = swab16(regval);
Quoted 2 lines
BR, Robert
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerReview
Quoted 8 lines · Robert Rosengren
Quoted 1 line
I tested the driver on 3.15 version of the kernel. Having looked in the git log of
regmap.candregmap-i2c.c, there has been some endianess-related patches going into the kernel in newer versions. Maybe that is the reason for me seeing this problem? I will try to look into that further.I my test I only disabled following two lines of code
(quoted diff) +2
-0+ if (data->byte_swap) + regval = swab16(regval);
Can you possibly send me the output from i2cdump ? That might help figuring out what is going on.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 1 line · Guenter Roeck
Can you possibly send me the output from i2cdump ? That might help figuring out what is going on.
I don't have i2cdump (I suppose that you mean the lm-sensors tool) available for my hardware. I'll give it a go to compile it...
BR,
Robert
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 4 lines · Robert Rosengren
Quoted 1 line · Guenter Roeck
Can you possibly send me the output from i2cdump ? That might help figuring out what is going on.
I don't have i2cdump (I suppose that you mean the lm-sensors tool) available for my hardware. I'll give it a go to compile it...
Ah, don't bother then. I should hopefully get the samples in a couple of days.
Is your hardware big endian or little endian ?
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 1 line · Guenter Roeck
Ah, don't bother then. I should hopefully get the samples in a couple of days.
i2cdump was easily built, so here is the output:
0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f
00: 1301 1301 1301 1301 1301 1301 1301 1301 08: 4101 6901 6a01 6901 6901 6901 6901 6901 10: 0200 0100 0100 0100 0100 0100 0100 0100 18: 0100 0100 0100 0100 0100 0100 0100 0100 20: 0200 0100 0100 0100 0100 0100 0100 0100 28: 0100 0100 0100 0100 0100 0100 0100 0100 30: 0200 0100 0100 0100 0100 0100 0100 0100 38: 0100 0100 0100 0100 0100 0100 0100 0100 40: 0000 0000 0000 0000 0000 0000 0000 0000 48: 0000 0000 0000 0000 0000 0000 0000 0000 50: 0200 0100 0100 0100 0100 0100 0100 0100 58: 0100 0100 0100 0100 0100 0100 0200 0100 60: 0100 0100 0100 0100 0100 0100 0100 0100 68: 0100 0100 0100 0100 0100 0100 0100 0100 70: 0200 0100 0100 0100 0100 0100 0100 0100 78: 0100 0100 0100 0100 0100 0100 0100 0100 80: 6501 2401 1701 1401 1301 1301 1301 1301 88: 4201 6901 6901 6901 6901 6901 6901 6901 90: 0200 0100 0100 0100 0100 0100 0100 0100 98: 0100 0100 0100 0100 0100 0100 0100 0100
a0: 6701 2501 1901 1601 1501 1501 1501 1501
a8: 4401 6c01 6c01 6c01 6c01 6c01 6c01 6c01
b0: 0200 0100 0100 0100 0100 0100 0100 0100
b8: 0100 0100 0100 0100 0100 0100 0100 0100
c0: 0200 0100 0100 0100 0100 0100 0100 0100
c8: 0100 0100 0100 0100 0100 0100 0100 0100
d0: 0200 0100 0100 0100 0100 0100 0100 0100
d8: 0100 0100 0100 0100 0100 0100 0100 0100
e0: 6701 2801 1b01 1701 1601 1501 1501 1501
e8: 4401 6c01 6c01 6c01 6c01 6c01 6c01 6c01
f0: 0200 0100 0100 0100 0100 0100 0100 0100
f8: 0100 0100 0100 0100 0100 0100 0100 0100
I checked the value at 0x84 (channel 0, and using single-ended and external reference). I got 222 when reading from corresponding sysfs, and 0x131 * lsb_resolution (806) / 1000 is 222 in decimal. So it seems as data above is correct.
Is the data what you expected?
Quoted 2 lines
Is your hardware big endian or little endian ?
CONFIG_CPU_LITTLE_ENDIAN=y
BR,
Robert
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 38 lines · Robert Rosengren
Quoted 1 line · Guenter Roeck
Ah, don't bother then. I should hopefully get the samples in a couple of days.
i2cdump was easily built, so here is the output:
0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f00: 1301 1301 1301 1301 1301 1301 1301 1301 08: 4101 6901 6a01 6901 6901 6901 6901 6901 10: 0200 0100 0100 0100 0100 0100 0100 0100 18: 0100 0100 0100 0100 0100 0100 0100 0100 20: 0200 0100 0100 0100 0100 0100 0100 0100 28: 0100 0100 0100 0100 0100 0100 0100 0100 30: 0200 0100 0100 0100 0100 0100 0100 0100 38: 0100 0100 0100 0100 0100 0100 0100 0100 40: 0000 0000 0000 0000 0000 0000 0000 0000 48: 0000 0000 0000 0000 0000 0000 0000 0000 50: 0200 0100 0100 0100 0100 0100 0100 0100 58: 0100 0100 0100 0100 0100 0100 0200 0100 60: 0100 0100 0100 0100 0100 0100 0100 0100 68: 0100 0100 0100 0100 0100 0100 0100 0100 70: 0200 0100 0100 0100 0100 0100 0100 0100 78: 0100 0100 0100 0100 0100 0100 0100 0100 80: 6501 2401 1701 1401 1301 1301 1301 1301 88: 4201 6901 6901 6901 6901 6901 6901 6901 90: 0200 0100 0100 0100 0100 0100 0100 0100 98: 0100 0100 0100 0100 0100 0100 0100 0100
a0: 6701 2501 1901 1601 1501 1501 1501 1501
a8: 4401 6c01 6c01 6c01 6c01 6c01 6c01 6c01
b0: 0200 0100 0100 0100 0100 0100 0100 0100
b8: 0100 0100 0100 0100 0100 0100 0100 0100
c0: 0200 0100 0100 0100 0100 0100 0100 0100
c8: 0100 0100 0100 0100 0100 0100 0100 0100
d0: 0200 0100 0100 0100 0100 0100 0100 0100
d8: 0100 0100 0100 0100 0100 0100 0100 0100
e0: 6701 2801 1b01 1701 1601 1501 1501 1501
e8: 4401 6c01 6c01 6c01 6c01 6c01 6c01 6c01
f0: 0200 0100 0100 0100 0100 0100 0100 0100
f8: 0100 0100 0100 0100 0100 0100 0100 0100
Quoted 4 lines
I checked the value at
0x84(channel 0, and using single-ended and external reference). I got 222 when reading from corresponding sysfs, and0x131*lsb_resolution(806) / 1000 is 222 in decimal. So it seems as data above is correct.Is the data what you expected?
Yes and no. With the above data, the old version of the driver (non-regmap) works as expected. The driver supporting regmap, however, needs the byte swap to work correctly.
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 5 lines · Robert Rosengren
Quoted 3 lines
Is your hardware big endian or little endian ?
CONFIG_CPU_LITTLE_ENDIAN=y
Hi Robert,
I have another question: What is your i2c controller type ?
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 10 lines · Guenter Roeck
Quoted 5 lines · Robert Rosengren
Quoted 3 lines
Is your hardware big endian or little endian ?
CONFIG_CPU_LITTLE_ENDIAN=yHi Robert,
I have another question: What is your i2c controller type ?
Robert,
I now tried both 3.15 and 3.19-rc6. Both kernels require the byte swap code.
The only reason I can imagine why you don't need it in your code would be that your i2c controller does not support i2c functionality but only SMBus. This would be the case, for example, with the i801 controller. So it would be quite helpful to know which controller your system uses to access the ads7828.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Guenter Roeck
Quoted 3 lines · Robert Rosengren
Quoted 1 line
Is your hardware big endian or little endian ?
CONFIG_CPU_LITTLE_ENDIAN=y
Quoted 7 lines
Quoted 4 lines
Hi Robert,
I have another question: What is your i2c controller type ?
Robert,
I now tried both 3.15 and 3.19-rc6. Both kernels require the byte swap code.
Agrees, no difference for me when trying with 3.15 and 3.18 version.
The i2c is a bit-bang driver, specific for the hardware I am running on.
Quoted 10 lines
The only reason I can imagine why you don't need it in your code would be that your i2c controller does not support i2c functionality but only SMBus. This would be the case, for example, with the i801 controller. So it would be quite helpful to know which controller your system uses to access the ads7828.
Thanks,
Guenter
I tried your latest patch set (the 3 patches submitted last night) and it works fine for me. Great work!
Please change my Cc-tag in the patches to Reviewed-by or Tested-by (I have done both, but one tag is enough). Thanks :-)
BR,
Robert
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 29 lines · Robert Rosengren
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Guenter Roeck
Quoted 3 lines · Robert Rosengren
Quoted 1 line
Is your hardware big endian or little endian ?
CONFIG_CPU_LITTLE_ENDIAN=yQuoted 7 lines
Quoted 4 lines
Hi Robert,
I have another question: What is your i2c controller type ?
Robert,
I now tried both 3.15 and 3.19-rc6. Both kernels require the byte swap code.
Agrees, no difference for me when trying with 3.15 and 3.18 version.
The i2c is a bit-bang driver, specific for the hardware I am running on.
Quoted 10 lines
The only reason I can imagine why you don't need it in your code would be that your i2c controller does not support i2c functionality but only SMBus. This would be the case, for example, with the i801 controller. So it would be quite helpful to know which controller your system uses to access the ads7828.
Thanks,
Guenter
Quoted 6 lines
I tried your latest patch set (the 3 patches submitted last night) and it works fine for me. Great work!
Please change my Cc-tag in the patches to Reviewed-by or Tested-by (I have done both, but one tag is enough). Thanks :-)
I made it Reviewed-and-Tested-by.
Thanks a lot!
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors