aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Olech <anthony.olech.opensource@diasemi.com>2013-12-18 10:15:31 -0500
committerGuenter Roeck <linux@roeck-us.net>2014-01-15 00:36:31 -0500
commitc09088d934c1e1672be8b3cfe3ba4f40ab2bf13e (patch)
treeccecdb9e0c835bb9d36e6b800eed08f9fd9eb713
parent9fb6c9c73b11bef65ba80a362547fd116c1e1c9d (diff)
hwmon: (da9052) Fix adc to voltage calculation
The ADC resolution of the PMIC is 10-bits, this means that the maximum possible value is 1023 and not the 1024 as originally in the code. Signed-off-by: Anthony Olech <anthony.olech.opensource@diasemi.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/da9052-hwmon.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c
index 960fac3fb166..afd31042b452 100644
--- a/drivers/hwmon/da9052-hwmon.c
+++ b/drivers/hwmon/da9052-hwmon.c
@@ -45,7 +45,7 @@ static const char * const input_names[] = {
45/* Conversion function for VDDOUT and VBAT */ 45/* Conversion function for VDDOUT and VBAT */
46static inline int volt_reg_to_mv(int value) 46static inline int volt_reg_to_mv(int value)
47{ 47{
48 return DIV_ROUND_CLOSEST(value * 1000, 512) + 2500; 48 return DIV_ROUND_CLOSEST(value * 2000, 1023) + 2500;
49} 49}
50 50
51/* Conversion function for ADC channels 4, 5 and 6 */ 51/* Conversion function for ADC channels 4, 5 and 6 */
@@ -57,7 +57,7 @@ static inline int input_reg_to_mv(int value)
57/* Conversion function for VBBAT */ 57/* Conversion function for VBBAT */
58static inline int vbbat_reg_to_mv(int value) 58static inline int vbbat_reg_to_mv(int value)
59{ 59{
60 return DIV_ROUND_CLOSEST(value * 2500, 512); 60 return DIV_ROUND_CLOSEST(value * 5000, 1023);
61} 61}
62 62
63static inline int da9052_enable_vddout_channel(struct da9052 *da9052) 63static inline int da9052_enable_vddout_channel(struct da9052 *da9052)