Conversion not completing in imx_adc driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Conversion not completing in imx_adc driver

Jump to solution
1,391 Views
edkrohne
Contributor I

I'm trying to use the internal ADC driver in the imx-25. I'm running Linux 2.6.31 with the mxc additions. I've been able to configure the driver as a module, rebuild the kernel, and modules, and install the module.

The device (/dev/imx_adc) shows up and I'm able to issue the "init" and "deinit" ioctls. However, when trying to get a conversion of the general purpose channel 0, the driver initially hung; and the system required a hard reset to recover. Looking at the driver code, there are two while loops waiting on specific status events. I added some code to time out in 10 jiffies (100ms), and print out which of the loops got aborted. What isn't happening is the EOQ status bit is never getting set.

I've included the snippet from imx_adc_read_general below with my changes and debug statements:

enum IMX_ADC_STATUS imx_adc_read_general(unsigned short *result)
{
        unsigned long reg;
        unsigned int data_num = 0;
        unsigned long start;

        pr_debug("imx_adc_read_general\n");
        reg = __raw_readl(tsc_base + GCQCR);
        reg |= CQCR_FQS;
        __raw_writel(reg, tsc_base + GCQCR);

        pr_debug("  GCQCR = %08X\n", __raw_readl(tsc_base + GCQCR));
        pr_debug("  GCC0  = %08X\n", __raw_readl(tsc_base + GCC0));

        start = jiffies;

        while (!(__raw_readl(tsc_base + GCQSR) & CQSR_EOQ))
        {
                if (jiffies == start + 10)
                {
                        pr_debug("  GCQSR = %08X\n", __raw_readl(tsc_base + GCQSR));
                        pr_debug("  aborting EOQ loop\n");
                        break;
                }
                continue;
        }

After trying a conversion I get the following output from dmesg:

root@ublnx-arm-base:/lib/modules/2.6.31-SBT/kernel/drivers/mxc/adc# dmesg

imx_adc : imx_adc_open()

init adc

imx_adc_init()

MXC_CCM_CCTL = 2103C0008

convert adc

imx_adc_read_general

  GCQCR = 00000F06

  GCC0  = 100317DC

  GCQSR = 00002000

  aborting EOQ loop

deinit adc

imx_adc_deinit()

imx_adc : imx_adc_free()

Can anyone help with this. Has anyone ever successfully gotten a general purpose input to convert?

Ed

Tags (2)
0 Kudos
1 Solution
863 Views
jimmychan
NXP TechSupport
NXP TechSupport

Have you try the imx_adc_test in unit_test (imx-test package)?

View solution in original post

0 Kudos
3 Replies
863 Views
txsaluki
Contributor I

Here is what I have discovered, and hope this can help others.

Its seems the "lockup" of the a/d is related to fb0.  Since the a/d is tied to the touchscreen in the iMX25, you will need to add the tslib to get the a/d to work.  Or at least that's been my experience.

The driver is written with a couple of while loops that can cause the kernel to hang or appear to hang up.  I've seen some a/d conversions take upwards of a minute to complete when normally it should be just ms (or faster).  To get around this, you will need to issue a echo 0 > /sys/class/graphics/fb0/blank.  This will "unfreeze" the a/d.   You will also want to modify the while loops to exit with an error code (IMX_ADC_ERROR) so you won't get a kernel panic or stalled task message, if you have that compiled in.

0 Kudos
864 Views
jimmychan
NXP TechSupport
NXP TechSupport

Have you try the imx_adc_test in unit_test (imx-test package)?

0 Kudos
863 Views
txsaluki
Contributor I

I've seen this exact thing happen also, both in my code, and int he imx_adc_test program.

0 Kudos