summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2013-11-05 17:44:09 +0100
committerStefan Agner <stefan.agner@toradex.com>2013-11-05 17:44:09 +0100
commitec0f9c52c0cf3ed7318fbaa3e6e2fc80c9433034 (patch)
tree31a87bbf5c02d82ef069abdb1d04a9bf18bf279a
parente5cb84471bc3d38ef5d8070abbdf0bc0ceb9d2bf (diff)
mvf_adc: support all 32 channels
Enable support for all 32 ADC channels, even the internal one. This is needed to read out the internal temperature since the sensor is at channel 26.
-rw-r--r--drivers/misc/mvf_adc.c8
-rw-r--r--include/linux/mvf_adc.h18
2 files changed, 22 insertions, 4 deletions
diff --git a/drivers/misc/mvf_adc.c b/drivers/misc/mvf_adc.c
index f65e82fbbb64..5935d507451a 100644
--- a/drivers/misc/mvf_adc.c
+++ b/drivers/misc/mvf_adc.c
@@ -70,7 +70,7 @@ struct data {
bool flag;
};
-struct data data_array[7];
+struct data data_array[32];
#define adc_dbg(_adc, msg...) dev_dbg(&(_adc)->pdev->dev, msg)
@@ -548,9 +548,11 @@ static long adc_ioctl(struct file *file, unsigned int cmd,
return -ENOTTY;
if (copy_from_user(&feature, (struct adc_feature *)argp,
- sizeof(feature))) {
+ sizeof(feature)))
return -EFAULT;
- }
+
+ if (feature.channel > 31)
+ return -EINVAL;
switch (cmd) {
case ADC_INIT:
diff --git a/include/linux/mvf_adc.h b/include/linux/mvf_adc.h
index c1b0b1d0075d..93f464ff9343 100644
--- a/include/linux/mvf_adc.h
+++ b/include/linux/mvf_adc.h
@@ -83,7 +83,7 @@
#define ADC_HC1 0x04/* Control register for hardware triggers 1 */
#define IRQ_EN 0x80
-#define ADCHC0(x) ((x)&0xF)
+#define ADCHC0(x) ((x)&0x1F)
#define AIEN1 0x00000080
#define COCOA 0x00000000
@@ -177,6 +177,22 @@ enum adc_channel {
ADC13,
ADC14,
ADC15,
+ ADC16,
+ ADC17,
+ ADC18,
+ ADC19,
+ ADC20,
+ ADC21,
+ ADC22,
+ ADC23,
+ ADC24,
+ ADC25,
+ ADC26,
+ ADC27,
+ ADC28,
+ ADC29,
+ ADC30,
+ ADC31,
};
struct adc_feature {