aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-samsung/adc.c
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2010-01-30 12:01:48 -0500
committerBen Dooks <ben-linux@fluff.org>2010-02-02 20:55:04 -0500
commit91492b4a04586e7cb191c72de9d1b22545a3ce16 (patch)
tree326e6e522f0edee936a31e1e2b83df0db0fa73c1 /arch/arm/plat-samsung/adc.c
parentcf9814eb6d83f066d5db63f4144598e9c6ca2951 (diff)
ARM: SAMSUNG: Add support for 12bit ADC
The S3C64XX SoC series support 12bit ADC data, enable this and mask the data accordingly. Signed-off-by: Maurus Cuelenaere <mcuelenaere@gmail.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/plat-samsung/adc.c')
-rw-r--r--arch/arm/plat-samsung/adc.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/arch/arm/plat-samsung/adc.c b/arch/arm/plat-samsung/adc.c
index c7659b7378b1..81caf2135721 100644
--- a/arch/arm/plat-samsung/adc.c
+++ b/arch/arm/plat-samsung/adc.c
@@ -262,6 +262,7 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw)
262{ 262{
263 struct adc_device *adc = pw; 263 struct adc_device *adc = pw;
264 struct s3c_adc_client *client = adc->cur; 264 struct s3c_adc_client *client = adc->cur;
265 enum s3c_cpu_type cpu = platform_get_device_id(adc->pdev)->driver_data;
265 unsigned long flags; 266 unsigned long flags;
266 unsigned data0, data1; 267 unsigned data0, data1;
267 268
@@ -276,9 +277,17 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw)
276 277
277 client->nr_samples--; 278 client->nr_samples--;
278 279
280 if (cpu == TYPE_S3C64XX) {
281 /* S3C64XX ADC resolution is 12-bit */
282 data0 &= 0xfff;
283 data1 &= 0xfff;
284 } else {
285 data0 &= 0x3ff;
286 data1 &= 0x3ff;
287 }
288
279 if (client->convert_cb) 289 if (client->convert_cb)
280 (client->convert_cb)(client, data0 & 0x3ff, data1 & 0x3ff, 290 (client->convert_cb)(client, data0, data1, &client->nr_samples);
281 &client->nr_samples);
282 291
283 if (client->nr_samples > 0) { 292 if (client->nr_samples > 0) {
284 /* fire another conversion for this */ 293 /* fire another conversion for this */
@@ -295,7 +304,7 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw)
295 } 304 }
296 305
297exit: 306exit:
298 if (platform_get_device_id(adc->pdev)->driver_data == TYPE_S3C64XX) { 307 if (cpu == TYPE_S3C64XX) {
299 /* Clear ADC interrupt */ 308 /* Clear ADC interrupt */
300 writel(0, adc->regs + S3C64XX_ADCCLRINT); 309 writel(0, adc->regs + S3C64XX_ADCCLRINT);
301 } 310 }
@@ -308,6 +317,7 @@ static int s3c_adc_probe(struct platform_device *pdev)
308 struct adc_device *adc; 317 struct adc_device *adc;
309 struct resource *regs; 318 struct resource *regs;
310 int ret; 319 int ret;
320 unsigned tmp;
311 321
312 adc = kzalloc(sizeof(struct adc_device), GFP_KERNEL); 322 adc = kzalloc(sizeof(struct adc_device), GFP_KERNEL);
313 if (adc == NULL) { 323 if (adc == NULL) {
@@ -354,8 +364,12 @@ static int s3c_adc_probe(struct platform_device *pdev)
354 364
355 clk_enable(adc->clk); 365 clk_enable(adc->clk);
356 366
357 writel(adc->prescale | S3C2410_ADCCON_PRSCEN, 367 tmp = adc->prescale | S3C2410_ADCCON_PRSCEN;
358 adc->regs + S3C2410_ADCCON); 368 if (platform_get_device_id(pdev)->driver_data == TYPE_S3C64XX) {
369 /* Enable 12-bit ADC resolution */
370 tmp |= S3C64XX_ADCCON_RESSEL;
371 }
372 writel(tmp, adc->regs + S3C2410_ADCCON);
359 373
360 dev_info(dev, "attached adc driver\n"); 374 dev_info(dev, "attached adc driver\n");
361 375