Skip to contentSkip to conversation

mfd: Fixed unconditional reset of the ADC reading enable bits

PATCH Superseded Robin van der Gracht 2 participants 2 messages Nov 28, 2011 Multifunction devices (MFD)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mfd: Fixed unconditional reset of the ADC reading enable bits

When the ADC is being prepared for a single or multiple channel reading, the adc0 register is reconfigured without taking the lithium cell, charge current and battery current reading enable bits into account. Which results in clearing the bits.

---

V2: Maskes now merged to a single mask

 drivers/mfd/mc13xxx-core.c  |    4 ++--
 include/linux/mfd/mc13xxx.h |   10 +++++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/mfd/mc13xxx-core.c +2 -2
index e9619ac..5315999 100644
@@ -615,13 +615,13 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
 		break;
 
 	case MC13XXX_ADC_MODE_SINGLE_CHAN:
-		adc0 |= old_adc0 & MC13XXX_ADC0_TSMOD_MASK;
+		adc0 |= old_adc0 & MC13XXX_ADC0_CONFIG_MASK;
 		adc1 |= (channel & 0x7) << MC13XXX_ADC1_CHAN0_SHIFT;
 		adc1 |= MC13XXX_ADC1_RAND;
 		break;
 
 	case MC13XXX_ADC_MODE_MULT_CHAN:
-		adc0 |= old_adc0 & MC13XXX_ADC0_TSMOD_MASK;
+		adc0 |= old_adc0 & MC13XXX_ADC0_CONFIG_MASK;
 		adc1 |= 4 << MC13XXX_ADC1_CHAN1_SHIFT;
 		break;
 
include/linux/mfd/mc13xxx.h +9 -1
index 3816c2f..c5011d4 100644
@@ -172,7 +172,10 @@ struct mc13xxx_platform_data {
 #define MC13XXX_ADC_MODE_SINGLE_CHAN	2
 #define MC13XXX_ADC_MODE_MULT_CHAN	3
 
-#define MC13XXX_ADC0		43
+#define MC13XXX_ADC0			43
+#define MC13XXX_ADC0_LICELLCON		(1 << 0)
+#define MC13XXX_ADC0_CHRGICON		(1 << 1)
+#define MC13XXX_ADC0_BATICON		(1 << 2)
 #define MC13XXX_ADC0_ADREFEN		(1 << 10)
 #define MC13XXX_ADC0_TSMOD0		(1 << 12)
 #define MC13XXX_ADC0_TSMOD1		(1 << 13)
@@ -184,4 +187,9 @@ struct mc13xxx_platform_data {
 					MC13XXX_ADC0_TSMOD1 | \
 					MC13XXX_ADC0_TSMOD2)
 
+#define MC13XXX_ADC0_CONFIG_MASK	(MC13XXX_ADC0_TSMOD_MASK | \
+					MC13XXX_ADC0_LICELLCON | \
+					MC13XXX_ADC0_CHRGICON | \
+					MC13XXX_ADC0_BATICON)
+
 #endif /* ifndef __LINUX_MFD_MC13XXX_H */
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH v2 1/1 mfd: Fixed unconditional reset of the ADC reading enable bits

Quoted 39 lines · Robin van der Gracht

When the ADC is being prepared for a single or multiple channel reading, the adc0 register is reconfigured without taking the lithium cell, charge current and battery current reading enable bits into account. Which results in clearing the bits.

---

V2: Maskes now merged to a single mask

 drivers/mfd/mc13xxx-core.c  |    4 ++--
 include/linux/mfd/mc13xxx.h |   10 +++++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/mfd/mc13xxx-core.c +2 -2
index e9619ac..5315999 100644
@@ -615,13 +615,13 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
 		break;
 
 	case MC13XXX_ADC_MODE_SINGLE_CHAN:
-		adc0 |= old_adc0 & MC13XXX_ADC0_TSMOD_MASK;
+		adc0 |= old_adc0 & MC13XXX_ADC0_CONFIG_MASK;
 		adc1 |= (channel & 0x7) << MC13XXX_ADC1_CHAN0_SHIFT;
 		adc1 |= MC13XXX_ADC1_RAND;
 		break;
 
 	case MC13XXX_ADC_MODE_MULT_CHAN:
-		adc0 |= old_adc0 & MC13XXX_ADC0_TSMOD_MASK;
+		adc0 |= old_adc0 & MC13XXX_ADC0_CONFIG_MASK;
 		adc1 |= 4 << MC13XXX_ADC1_CHAN1_SHIFT;
 		break;
 
include/linux/mfd/mc13xxx.h +0 -0
index 3816c2f..c5011d4 100644

include/linux/mfd/mc13xxx.h struct mc13xxx_platform_data { · line 175

Quoted 5 lines
include/linux/mfd/mc13xxx.h +1 -1
@@ -172,7 +172,10 @@ struct mc13xxx_platform_data {
 #define MC13XXX_ADC_MODE_SINGLE_CHAN	2
 #define MC13XXX_ADC_MODE_MULT_CHAN	3
 
-#define MC13XXX_ADC0		43
+#define MC13XXX_ADC0			43

If you keep the line as is (i.e. only two tabs) you can have my Ack. (The indention is then identical with the one used in drivers/mfd/mc13xxx-core.c, register offsets appear further to the left than the masks of the registers.)

Best regards
Uwe

Quoted 20 lines
include/linux/mfd/mc13xxx.h +8 -0
+#define MC13XXX_ADC0_LICELLCON		(1 << 0)
+#define MC13XXX_ADC0_CHRGICON		(1 << 1)
+#define MC13XXX_ADC0_BATICON		(1 << 2)
 #define MC13XXX_ADC0_ADREFEN		(1 << 10)
 #define MC13XXX_ADC0_TSMOD0		(1 << 12)
 #define MC13XXX_ADC0_TSMOD1		(1 << 13)
@@ -184,4 +187,9 @@ struct mc13xxx_platform_data {
 					MC13XXX_ADC0_TSMOD1 | \
 					MC13XXX_ADC0_TSMOD2)
 
+#define MC13XXX_ADC0_CONFIG_MASK	(MC13XXX_ADC0_TSMOD_MASK | \
+					MC13XXX_ADC0_LICELLCON | \
+					MC13XXX_ADC0_CHRGICON | \
+					MC13XXX_ADC0_BATICON)
+
 #endif /* ifndef __LINUX_MFD_MC13XXX_H */
Signature · 1 line
1.7.4.1
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |