[acme-dev] SF.net SVN: acme-dev:[74] kernel-stuff/adc-driver/at91-adc.c

Revision: 74
          http://acme-dev.svn.sourceforge.net/acme-dev/?rev=74&view=rev
Author:   claudyus
Date:     2010-09-24 10:07:45 +0000 (Fri, 24 Sep 2010)

Log Message:
-----------
[adc] prevent internal pull-up on adc channel

This is a patch to disconnect internal pull-up on ADC channel before conversion.

Thanks to: Bertrand Colau

Modified Paths:
--------------
    kernel-stuff/adc-driver/at91-adc.c

Modified: kernel-stuff/adc-driver/at91-adc.c
===================================================================
--- kernel-stuff/adc-driver/at91-adc.c  2010-09-24 10:07:25 UTC (rev 73)
+++ kernel-stuff/adc-driver/at91-adc.c  2010-09-24 10:07:45 UTC (rev 74)
@@ -1,7 +1,7 @@
 /*
  *     Driver for ADC on Atmel AT91 SoC Family
  *
- *     Copyright (R) 2010 Claudio Mignanti - c.mignanti@xxxxxxxxx
+ *     Copyright (C) 2010 Claudio Mignanti - c.mignanti@xxxxxxxxx
  *     Based on http://www.at91.com/forum/viewtopic.php/p,9409/#p9409
  *
  *     Copyright (C) 2010 Stefano Barbato - stefano@xxxxxxxxxxxx
@@ -18,7 +18,6 @@
  *     it under the terms of the GNU General Public License as published by
  *     the Free Software Foundation.
  *
- * $Id$
  * ---------------------------------------------------------------------------
 */
 
@@ -59,9 +58,10 @@
 
 struct clk                                     *at91_adc_clk;
 void __iomem                           *at91_adc_base;
-static struct cdev     *at91_adc_cdev  = NULL;
-static dev_t                            at91_adc_devno = 0;
-static struct class *at91_adc_class = NULL;
+void __iomem                           *at91_pioc_base;
+static struct cdev                     *at91_adc_cdev  = NULL;
+static dev_t                           at91_adc_devno  = 0;
+static struct class                    *at91_adc_class = NULL;
 
 static int at91_adc_read_chan(int chan){
        int val, sr;
@@ -69,6 +69,9 @@
        if(chan<0 || chan>3){
                return -EINVAL;
        }
+       /* disable pull-up resistor */
+       iowrite32(1 << chan, at91_pioc_base + 0x60);
+
        at91_adc_write(AT91_ADC_CHER,AT91_ADC_CH(chan));                        
//Enable Channel
        at91_adc_write(AT91_ADC_CR,AT91_ADC_START);                             
        //Start the ADC
        
@@ -260,9 +263,15 @@
        at91_adc_base = ioremap(AT91SAM9260_BASE_ADC,SZ_256);
        if(!at91_adc_base){
                status=-ENODEV;
-               goto fail_no_iomem;
+               goto fail_no_iomem_adc;
        }
 
+       at91_pioc_base = ioremap(AT91_BASE_SYS + AT91_PIOC,SZ_512);
+       if(!at91_pioc_base){
+               status=-ENODEV;
+               goto fail_no_iomem_pioc;
+       }
+
        status = platform_device_register(&at91_adc_device);
        if(status){
                goto fail_no_dev;
@@ -296,7 +305,9 @@
        platform_device_unregister(&at91_adc_device);
 fail_no_dev:
        iounmap(at91_adc_base);
-fail_no_iomem:
+fail_no_iomem_pioc:
+       iounmap(at91_pioc_base);
+fail_no_iomem_adc:
        clk_disable(at91_adc_clk);
        clk_put(at91_adc_clk);
        return status;
@@ -307,6 +318,7 @@
        at91_adc_cdev_teardown();
        platform_device_unregister(&at91_adc_device);
        iounmap(at91_adc_base);
+       iounmap(at91_pioc_base);
 
        clk_disable(at91_adc_clk);
        clk_put(at91_adc_clk);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

Other related posts:

  • » [acme-dev] SF.net SVN: acme-dev:[74] kernel-stuff/adc-driver/at91-adc.c - claudyus