This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x ADC hangs SDK8

Hi All,

Recently we migrate from SDK6 (kernel 3.2.0) to SDK8 (kernel 3.14.26), and I have a problem with config ADC (no TouchScreen, only ADC) into DT.

I need to config AIN5 and AIN6 in One-shot Mode.

With old kernel it work fine with config:

static struct adc_data am335x_adc_data = { 
    .adc_channels = 8,
};
static struct mfd_tscadc_board tscadc = {
    .adc_init = &am335x_adc_data,
};
static void adc_init(void)
{
    int err;
    pr_info("Enable ADC...\n");
    err = am33xx_register_mfd_tscadc(&tscadc);
    if (err)
        pr_err("failed to register ADC/Touchscreen device\n");
}

My device tree for kernel 3.14:

#include "am33xx.dtsi"

&tscadc {
	status = "okay";
	adc {
		ti,adc-channels = <5 6 7>;
	};
};

I tried to use as in old kernel:

echo "oneshot" > /sys/bus/iio/devices/iio\:device0/mode
cat /sys/bus/iio/devices/iio\:device0/in_voltage5_raw

On first read in_voltage5_raw cat print follow error: "Resource temporarily unavailable", on second read it hangs.

I try to debug adc driver (drivers/iio/adc/ti_am335x_adc.c), and the drivet hang on call function am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en);

Also I found the following related to this topic: https://e2e.ti.com/support/arm/sitara_arm/f/791/p/413600/1468952, but can't find solution for my problem.


into menuconfig I have enabled:

CONFIG_MFD_TI_AM335X_TSCADC=y
CONFIG_TI_AM335X_ADC=y

Can someone help me with ADC configuration (or help me to solve hang problem)?

  • Hi Biser,

    I checked my configuration is exactly as in Your recommendation (Driver Configuration), also Device Tree looks like in Your recommendation, but it not work.

    The driver hang on function am335x_tsc_se_set_once (see my question).
    It may need to initialize any clk something else?
  • Hi all,

    I found solution for may problem. We have 2 types of boards with and witout adc, and I run my tests on board without ADC (VDDA_ADC not connected), and conversion not starting.

    On first read we have IDLE state into REG_ADCFSM, configure ADC, but conversion not started and adc return -EAGAIN.

    On second read, adc stepts are already configured, and driver wait idle (into REG_ADCFSM) to reconfigure steps for new conversion, but.. because adc not powered (not running), we will not have idle state, and driver pending event inf cycle.

    For solve this bug, I change follow lines into file drivers/mfd/ti_am335x_tscadc.c:

    --- a/drivers/mfd/ti_am335x_tscadc.c    2015-05-05 09:50:49.654710300 +0300
    +++ b/drivers/mfd/ti_am335x_tscadc.c       2015-05-21 11:33:26.581552200 +0300
    @@ -64,6 +64,7 @@ void am335x_tsc_se_set_cache(struct ti_t
     }
     EXPORT_SYMBOL_GPL(am335x_tsc_se_set_cache);
    
    +#define GET_ADC_TIMEOUT_US 500000 //500ms
     static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
     {
            DEFINE_WAIT(wait);
    @@ -82,7 +83,7 @@ static void am335x_tscadc_need_adc(struc
                                    TASK_UNINTERRUPTIBLE);
                    spin_unlock_irq(&tsadc->reg_lock);
    
    -               schedule();
    +               schedule_timeout(usecs_to_jiffies(GET_ADC_TIMEOUT_US));
    
                    spin_lock_irq(&tsadc->reg_lock);
                    finish_wait(&tsadc->reg_se_wait, &wait);
    

    I change function schedule with schedule_timeout, in case the ADC does not running (ie not powered) adc driver return -EAGAIN (no hang system)