fix adc to voltage calculation in da9052 power driver
PATCH 1/1 fix adc to voltage calculation in da9052 power driver
The ADC resolution of the PMIC is 10-bits, this means that the maximum possible value is 1023 and not the 1024 as in the code.
---
This patch is relative to linux-next repository tag next-20131218
drivers/power/da9052-battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/da9052-battery.c +1 -1
@@ -178,7 +178,7 @@ struct da9052_battery {static inline int volt_reg_to_mV (int value) { -return ((value *1000 ) /512 ) +2500 ; +return DIV_ROUND_CLOSEST (value *2000 ,1023 ) +2500 ; }static inline int ichg_reg_to_mA (int value)
Signature · 7 lines
end-of-patch for fix adc to voltage calculation in da9052 power driver V1 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 2 lines · Anthony Olech
The ADC resolution of the PMIC is 10-bits, this means that the maximum possible value is 1023 and not the 1024 as in the code.
The conversion from register value to mV depends on the ADC's LSB, not its range. So the maximum value which can be represented is irrelevant.
Quoted 21 lines
Signed-off-by Anthony Olech <[email protected]>---
This patch is relative to linux-next repository tag next-20131218drivers/power/da9052-battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/power/da9052-battery.c +1
-1@@ -178,7 +178,7 @@ struct da9052_battery {static inline int volt_reg_to_mV (int value) { -return ((value *1000 ) /512 ) +2500 ; +return DIV_ROUND_CLOSEST (value *2000 ,1023 ) +2500 ; }static inline int ichg_reg_to_mA (int value)
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 9 lines
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: 18 December 2013 15:33
To: Opensource [Anthony Olech]
Cc: Anton Vorontsov; David Woodhouse; David Dajun Chen; open list; open list:HARDWARE MONITORING
Subject: Re: [lm-sensors] [PATCH V1] fix adc to voltage calculation in da9052 power driver
On Wed, 18 Dec 2013 15:21:13 +0000, Anthony Olech wrote:
Quoted 4 lines
Quoted 2 lines
The ADC resolution of the PMIC is 10-bits, this means that the maximum possible value is 1023 and not the 1024 as in the code.
The conversion from register value to mV depends on the ADC's LSB, not its range. So the maximum value which can be represented is irrelevant.
thanks for the speedy response, but the converted value returned by the function does depend on the scaling.
For example take the two cases where value in 0x1F0, then the erroneous previous calculation yields 3469 and the new corrected calculation yields 3470
So please apply the patch as it truly fixes an error.
many thanks
Tony Olech
Quoted 9 lines
Quoted 9 lines
Signed-off-by Anthony Olech <[email protected]>---
This patch is relative to linux-next repository tag next-20131218drivers/power/da9052-battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/power/da9052-battery.cindex f8f4c0f..8f0f259 100644drivers/power/da9052-battery.c +0
-0
Quoted 8 lines
drivers/power/da9052-battery.c struct da9052_battery { · line 181
Quoted 6 lines
drivers/power/da9052-battery.c +1
-1@@ -178,7 +178,7 @@ struct da9052_battery {static inline int volt_reg_to_mV (int value) { -return ((value *1000 ) /512 ) +2500 ; +return DIV_ROUND_CLOSEST (value *2000 ,1023 ) +2500 ; }static inline int ichg_reg_to_mA (int value)--
Jean Delvare
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 14 lines · Opensource [Anthony Olech]
Quoted 9 lines
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: 18 December 2013 15:33
To: Opensource [Anthony Olech]
Cc: Anton Vorontsov; David Woodhouse; David Dajun Chen; open list; open list:HARDWARE MONITORING
Subject: Re: [lm-sensors] [PATCH V1] fix adc to voltage calculation in da9052 power driver
On Wed, 18 Dec 2013 15:21:13 +0000, Anthony Olech wrote:Quoted 4 lines
Quoted 2 lines
The ADC resolution of the PMIC is 10-bits, this means that the maximum possible value is 1023 and not the 1024 as in the code.
The conversion from register value to mV depends on the ADC's LSB, not its range. So the maximum value which can be represented is irrelevant.
Quoted 8 lines
thanks for the speedy response, but the converted value returned by the function does depend on the scaling.
For example take the two cases where value in
0x1F0, then the erroneous previous calculation yields 3469 and the new corrected calculation yields 3470So please apply the patch as it truly fixes an error.
AFAICS the previous calculation should return 3468. Replacing the division by 512 with DIV_ROUND_CLOSEST would return 3469, and the new calculation would return 3470.
Still, an ADC would typically have an LSB. Question here is what that LSB is (in mV), or in other words what the maximim voltage represented by 0x3ff is. Current assumption is that it is 1.9531 mV or 2000/1024, which admittedly is odd. It might be 2000/1023 = 1.9550 mV, or it might be 2 mV.
Thanks,
Guenter
Quoted 22 lines
many thanks
Tony Olech
Quoted 9 lines
Quoted 9 lines
Signed-off-by Anthony Olech <[email protected]>---
This patch is relative to linux-next repository tag next-20131218drivers/power/da9052-battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/power/da9052-battery.cindex f8f4c0f..8f0f259 100644drivers/power/da9052-battery.c +0
-0Quoted 8 lines
drivers/power/da9052-battery.c struct da9052_battery { · line 181
Quoted 6 lines
drivers/power/da9052-battery.c +1
-1@@ -178,7 +178,7 @@ struct da9052_battery {static inline int volt_reg_to_mV (int value) { -return ((value *1000 ) /512 ) +2500 ; +return DIV_ROUND_CLOSEST (value *2000 ,1023 ) +2500 ; }static inline int ichg_reg_to_mA (int value)--
Jean Delvare
Quoted 5 lines
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 31 lines
-----Original Message-----
From: Guenter Roeck [mailto:[email protected]] On Behalf Of Guenter Roeck
Sent: 18 December 2013 17:24
To: Opensource [Anthony Olech]
Cc: Jean Delvare; open list:HARDWARE MONITORING; Anton Vorontsov; David Woodhouse; open list; David Dajun Chen
Subject: Re: [lm-sensors] [PATCH V1] fix adc to voltage calculation in da9052 power driverQuoted 9 lines · Opensource [Anthony Olech]
Quoted 9 lines
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: 18 December 2013 15:33
To: Opensource [Anthony Olech]
Cc: Anton Vorontsov; David Woodhouse; David Dajun Chen; open list; open list:HARDWARE MONITORING
Subject: Re: [lm-sensors] [PATCH V1] fix adc to voltage calculation in da9052 power driver On Wed, 18 Dec 2013 15:21:13 +0000, Anthony Olech wrote:Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
The ADC resolution of the PMIC is 10-bits, this means that the maximum possible value is 1023 and not the 1024 as in the code.
The conversion from register value to mV depends on the ADC's LSB, not its range. So the maximum value which can be represented is
irrelevant.
Quoted 6 lines
thanks for the speedy response, but the converted value returned by the function does depend on the scaling.
For example take the two cases where value in0x1F0, then the erroneous previous calculation yields 3469 and the new corrected calculation yields 3470
So please apply the patch as it truly fixes an error.
Quoted 7 lines
AFAICS the previous calculation should return 3468. Replacing the division by 512 with
DIV_ROUND_CLOSESTwould return 3469, and the new calculation would return 3470.
Still, an ADC would typically have an LSB. Question here is what that LSB is (in mV), or in other words what the maximim voltage represented by0x3ffis. Current assumption is that it is 1.9531 mV or 2000/1024, which admittedly is odd. It might be 2000/1023 = 1.9550 mV, or it might be 2 mV.
the maximum voltage represented by 0x3ff is 2000 mV, so the existing code is incorrect and the patch is to correct the error.
many thanks for your comment,
Tony Olech
Quoted 20 lines
Thanks,
GuenterQuoted 18 lines
many thanks
Tony OlechQuoted 16 lines
Quoted 10 lines
Signed-off-by: Anthony Olech <[email protected]>
This patch is relative to linux-next repository tag next-20131218drivers/power/da9052-battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git
a/drivers/power/da9052-battery.cb/drivers/power/da9052-battery.cindex f8f4c0f..8f0f259 100644drivers/power/da9052-battery.c struct da9052_battery { static inline int · line 181
Quoted 5 lines
drivers/power/da9052-battery.c +1
-1@@ -178,7 +178,7 @@ struct da9052_battery { static inline int volt_reg_to_mV(int value) { -return ((value *1000 ) /512 ) +2500 ; +return DIV_ROUND_CLOSEST (value *2000 ,1023 ) +2500 ; }static inline int ichg_reg_to_mA (int value)Jean Delvare
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
SGkgQW50aG9ueSwKCk9uIFRodSwgMTkgRGVjIDIwMTMgMTQ6MTM6MDkgKzAwMDAsIE9wZW5zb3Vy Y2UgW0FudGhvbnkgT2xlY2hdIHdyb3RlOgo+ID4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0K PiA+IEZyb206IEd1ZW50ZXIgUm9lY2sgW21haWx0bzpncm9lY2s3QGdtYWlsLmNvbV0gT24gQmVo YWxmIE9mIEd1ZW50ZXIKPiA+IFJvZWNrCj4gPiBTZW50OiAxOCBEZWNlbWJlciAyMDEzIDE3OjI0 Cj4gPiBUbzogT3BlbnNvdXJjZSBbQW50aG9ueSBPbGVjaF0KPiA+IENjOiBKZWFuIERlbHZhcmU7 IG9wZW4gbGlzdDpIQVJEV0FSRSBNT05JVE9SSU5HOyBBbnRvbiBWb3JvbnRzb3Y7Cj4gPiBEYXZp ZCBXb29kaG91c2U7IG9wZW4gbGlzdDsgRGF2aWQgRGFqdW4gQ2hlbgo+ID4gU3ViamVjdDogUmU6 IFtsbS1zZW5zb3JzXSBbUEFUQ0ggVjFdIGZpeCBhZGMgdG8gdm9sdGFnZSBjYWxjdWxhdGlvbiBp biBkYTkwNTIKPiA+IHBvd2VyIGRyaXZlcgo+ID4gT24gV2VkLCBEZWMgMTgsIDIwMTMgYXQgMDM6 NDU6MzJQTSArMDAwMCwgT3BlbnNvdXJjZSBbQW50aG9ueSBPbGVjaF0KPiA+IHdyb3RlOgo+ID4g PiA+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tCj4gPiA+ID4gRnJvbTogSmVhbiBEZWx2YXJl IFttYWlsdG86a2hhbGlAbGludXgtZnIub3JnXQo+ID4gPiA+IFNlbnQ6IDE4IERlY2VtYmVyIDIw MTMgMTU6MzMKPiA+ID4gPiBUbzogT3BlbnNvdXJjZSBbQW50aG9ueSBP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NhbGVkIGRvd24gdG8K Zml0IGluIHRoZSBBREMncyByYW5nZSwgeW91IG5lZWQgYXQgbGVhc3Qgb25lIHJlc2lzdG9yLCB3 aGljaCBpbiBiZXN0CmNhc2VzIHdpbGwgaGF2ZSBhIDElIGFjY3VyYXRlIHZhbHVlIChrbm93biBh cyB0b2xlcmFuY2UuKSBUaGF0J3MgdGVuCnRpbWVzIHRoZSBMU0Igb2YgeW91ciAxMC1iaXQgQURD LCBhdCB3aGljaCBwb2ludCAvIDEwMjMgb3IgLyAxMDI0CnJlYWxseSBtYWtlcyBubyBwcmFjdGlj YWwgZGlmZmVyZW5jZS4gU3ViLXBlcmNlbnQgdG9sZXJhbnQgcmVzaXN0b3JzIGFyZQpleHBlbnNp dmUgYW5kIHJhcmUgaW4gY29uc3VtZXIgZWxlY3Ryb25pY3MgaW4gbXkgZXhwZXJpZW5jZS4KCi0t IApKZWFuIERlbHZhcmUKCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fCmxtLXNlbnNvcnMgbWFpbGluZyBsaXN0CmxtLXNlbnNvcnNAbG0tc2Vuc29ycy5vcmcK aHR0cDovL2xpc3RzLmxtLXNlbnNvcnMub3JnL21haWxtYW4vbGlzdGluZm8vbG0tc2Vuc29ycw=
Quoted 2 lines · Jean Delvare
Hi Anthony,
[ ... ]
Quoted 11 lines
BTW, you (and we) probably shouldn't waste too much energy on this. ADCs are only accurate to some degree anyway. If you take the components connected to the input into consideration, the accuracy gets even worse. For example, if the input voltage must be scaled down to fit in the ADC's range, you need at least one resistor, which in best cases will have a 1% accurate value (known as tolerance.) That's ten times the LSB of your 10-bit ADC, at which point / 1023 or / 1024 really makes no practical difference. Sub-percent tolerant resistors are expensive and rare in consumer electronics in my experience.
True, but on the other side (and after looking into the datasheet) the driver already calculated the voltage on adc4..6 correctly, so unless you disagree I would like to apply the hwmon patch to -next for consistency.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 23 lines
-----Original Message-----
From: Guenter Roeck [mailto:[email protected]] On Behalf Of Guenter Roeck
Sent: 19 December 2013 18:11
To: Jean Delvare
Cc: Opensource [Anthony Olech]; [email protected]; Anton Vorontsov; David Woodhouse; [email protected]; David Dajun Chen
Subject: Re: [lm-sensors] [PATCH V1] fix adc to voltage calculation in da9052 power driverQuoted 2 lines · Jean Delvare
Hi Anthony,
[ ... ]
Quoted 9 lines
BTW, you (and we) probably shouldn't waste too much energy on this. ADCs are only accurate to some degree anyway. If you take the components connected to the input into consideration, the accuracy gets even worse. For example, if the input voltage must be scaled down to fit in the ADC's range, you need at least one resistor, which in best cases will have a 1% accurate value (known as tolerance.) That's ten times the LSB of your 10-bit ADC, at which point / 1023 or / 1024 really makes no practical difference. Sub-percent tolerant resistors are expensive and rare in consumer electronics in my experience.
Quoted 5 lines
True, but on the other side (and after looking into the datasheet) the driver already calculated the voltage on adc4..6 correctly, so unless you disagree I would like to apply the hwmon patch to -next for consistency. Thanks,
Guenter
OK, thanks,
Tony Olech
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Guenter, hi Anthony,
Quoted 11 lines · Guenter Roeck
Quoted 9 lines · Jean Delvare
BTW, you (and we) probably shouldn't waste too much energy on this. ADCs are only accurate to some degree anyway. If you take the components connected to the input into consideration, the accuracy gets even worse. For example, if the input voltage must be scaled down to fit in the ADC's range, you need at least one resistor, which in best cases will have a 1% accurate value (known as tolerance.) That's ten times the LSB of your 10-bit ADC, at which point / 1023 or / 1024 really makes no practical difference. Sub-percent tolerant resistors are expensive and rare in consumer electronics in my experience.
Quoted 4 lines
True, but on the other side (and after looking into the datasheet) the driver already calculated the voltage on adc4..6 correctly, so unless you disagree I would like to apply the hwmon patch to -next for consistency.
The datasheet isn't the best quality I've seen. The gain values mentioned to not even match the formulas in the same cell... But I can't object to implementing conversions the way the datasheet says, no matter how suspicious.
I don't really know what tree the patch is based on. Anthony said linux-next but I can't see ichg_reg_to_mA there.
If volt_reg_to_mv is updated then you certainly want to update vbbat_reg_to_mv the same way, as it diverges from the datasheet just the same.
Also, please update Documentation/hwmon/da9052 so that the documentation matches the actual driver code.
I really would like to hear what David Dajun Chen has to say about that. He must have had a reason to use different conversions formulas than the datasheet specifies.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 19 lines · Jean Delvare
Hi Guenter, hi Anthony,
Quoted 11 lines · Guenter Roeck
Quoted 9 lines · Jean Delvare
BTW, you (and we) probably shouldn't waste too much energy on this. ADCs are only accurate to some degree anyway. If you take the components connected to the input into consideration, the accuracy gets even worse. For example, if the input voltage must be scaled down to fit in the ADC's range, you need at least one resistor, which in best cases will have a 1% accurate value (known as tolerance.) That's ten times the LSB of your 10-bit ADC, at which point / 1023 or / 1024 really makes no practical difference. Sub-percent tolerant resistors are expensive and rare in consumer electronics in my experience.
Quoted 4 lines
True, but on the other side (and after looking into the datasheet) the driver already calculated the voltage on adc4..6 correctly, so unless you disagree I would like to apply the hwmon patch to -next for consistency.
Quoted 8 lines
The datasheet isn't the best quality I've seen. The gain values mentioned to not even match the formulas in the same cell... But I can't object to implementing conversions the way the datasheet says, no matter how suspicious.
I don't really know what tree the patch is based on. Anthony said linux-next but I can't see
ichg_reg_to_mAthere.
I didn't check the power patch, but the hwmon patch applied cleanly to the current upstream.
Quoted 4 lines
If
volt_reg_to_mvis updated then you certainly want to updatevbbat_reg_to_mvthe same way, as it diverges from the datasheet just the same.
He is doing that in the hwmon patch. I don't see vbbat_reg_to_mv() in the power driver, at least not in the upstream version.
Quoted 3 lines
Also, please update
Documentation/hwmon/da9052so that the documentation matches the actual driver code.
You are right, that needs to be updated as well.
Quoted 4 lines
I really would like to hear what David Dajun Chen has to say about that. He must have had a reason to use different conversions formulas than the datasheet specifies.
Hmm ... if this was done on purpose, I'd like to see a comment somewhere describing why the formula in the datasheet isn't used, to avoid this kind of back-and-forth in the future.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors