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.

adc: read error: Device or resource busy

1.cat /sys/bus/iio/devices/iio\:device0/in_voltage1_raw

cat: read error: Device or resource busy

Why do I get this error? what is the solution?

2. ls -al /sys/bus/iio/devices/iio\:device0/
drwxr-xr-x    3 root     root             0 Jan  1  1970 .
drwxr-xr-x    4 root     root             0 Jan  1  1970 ..
-r--r--r--    1 root     root          4096 Mar 31 02:34 dev
-rw-r--r--    1 root     root          4096 Mar 31 02:34 in_voltage0_raw
-rw-r--r--    1 root     root          4096 Mar 31 02:34 in_voltage1_raw
-r--r--r--    1 root     root          4096 Mar 31 02:34 name
drwxr-xr-x    2 root     root             0 Mar 31 02:34 power
lrwxrwxrwx    1 root     root             0 Jan  1  1970 subsystem -> ../../../../../bus/iio
-rw-r--r--    1 root     root          4096 Jan  1  1970 uevent

3. In .config file,

a. CONFIG_MFD_TI_AM335X_TSCADC=y

b. CONFIG_TI_ADC081C=y

c. CONFIG_TI_AM335X_ADC=y

4. dts entry

&tscadc {
        status = "okay";
/*0 - LED_BIN
  1 - DISP_TEMP
*/
        adc {
                ti,adc-channels = <0 1>;
        };  
};

5. I'm using SDK7.0 ti filesystem

Regards,

Gangadhar

  • Make sure no background process or other running app has this file opened. Check with "ps".

    Best regards,
    Miroslav

  • I tried lsof | grep in_voltage1_raw and found n_voltage1_raw is not opened. ps does not support -ef or -ax  options in ti filesystem as it uses busybox.

    Regards,

    Gangadhar

  • Gangadhar,

     

    Have you taken a look at the PSP User Guide:

    http://processors.wiki.ti.com/index.php/AM335x_PSP_User%27s_Guide

     

    In particular, here's the ADC Driver's Guide which may be useful to resolve your issue:

    http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver%27s_Guide

     

    Regards,
    Mark

     

  • Gangadhar,

    Also, I noticed you have TSCADC & ADC081C enabled in .config file. These ADCs are only used on the EVM & not the custom board. I think the .config file should be changed as follows:

    3. In .config file,

    a. CONFIG_MFD_TI_AM335X_TSCADC=n

    b. CONFIG_TI_ADC081C=n

    c. CONFIG_TI_AM335X_ADC=y

    Regards,
    Mark

  • Mark,

    Still it does not work.

    1.I removed

    CONFIG_MFD_TI_AM335X_TSCADC=n

    CONFIG_TI_ADC081C=n and found no device entry in /sys.

    2. I had only CONFIG_MFD_TI_AM335X_TSCADC, with this I get device or resource busy error.

    3. I had only CONFIG_TI_ADC081C and found no device entry in /sys.

    4. I did

    root@am335x-evm:/etc/rc5.d# mv S97matrix-gui-2.0 K97matrix-gui-2.0 but could not get it to work

     

    Regards,

    Gangadhar

  • Gangadhar,

    I noticed you’re trying to read a single ADC value. The ADC Driver guide states that to read a single value, the ADC must be configured for one-shot mode.

    Can you check to see if it is configured for one-shot mode, if not then try configuring in one-shot mode & then try reading the value?

    cat /sys/bus/iio/devices/iio\:device0/in_voltage1_raw

     

     

    Also, please attach your board-am335xevm.c file.

    Regards,

    Mark

  • Hi Gangadhar,

    There is a bug in the ADC IIO driver and here is a patch 

    6740.0001-iio-ti_am335x_adc-Fix-unecessary-restrictions-on-ADC.diff
    From fa15f2236fdd76f450cc41aee93d5934c23f9706 Mon Sep 17 00:00:00 2001
    From: Jeff Lance <j-lance1@ti.com>
    Date: Thu, 24 Apr 2014 10:51:16 -0500
    Subject: [PATCH] iio: ti_am335x_adc: Fix unecessary restrictions on ADC input
     selection
    
    Franklin Cooper found that there are limitations on the order of
    channels you select when setting up the ADC in the device tree bindings.
    You must select channel 7 first followed in reverse sequential order:
    6 5 4 3 2 1 0.  You can select any number of inputs but they must start
    with 7 and count backwards. This bug looks like it may have stemmed from
    a documentation issue.  The TRM indicates bits 19-16 of the FIFO1DATA
    register report back the channel that captured the data, when actually,
    it is the step number. Now if we modify tiadc_read_raw() to compare the
    expected step id with the FIFO1DATA register bits 19-16, there are no
    longer any restrictions on order when selecting channels in the Device Tree.
    
    Before the fix, if you wanted to select 4 channels, they had to be:
    {4 5 6 7}, otherwise you would get (EBUSY) return values on any
    channels that did not follow the restriction.  Now any combination of
    (0 - 7) will work. Of course it depends on if you are using the
    touchscreen and what channels are available for ADC.
    
    Signed-off-by: Jeff Lance <j-lance1@ti.com>
    ---
     drivers/iio/adc/ti_am335x_adc.c |    5 ++---
     1 file changed, 2 insertions(+), 3 deletions(-)
    
    diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
    index 95b43e9..cb991ea 100644
    --- a/drivers/iio/adc/ti_am335x_adc.c
    +++ b/drivers/iio/adc/ti_am335x_adc.c
    @@ -158,7 +158,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
     		int *val, int *val2, long mask)
     {
     	struct tiadc_device *adc_dev = iio_priv(indio_dev);
    -	int i, map_val;
    +	int i;
     	unsigned int fifo1count, read, stepid;
     	u32 step = UINT_MAX;
     	bool found = false;
    @@ -179,7 +179,6 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
     			return -EAGAIN;
     		}
     	}
    -	map_val = chan->channel + TOTAL_CHANNELS;
     
     	/*
     	 * When the sub-system is first enabled,
    @@ -209,7 +208,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
     		stepid = read & FIFOREAD_CHNLID_MASK;
     		stepid = stepid >> 0x10;
     
    -		if (stepid == map_val) {
    +		if (stepid == step) {
     			read = read & FIFOREAD_DATA_MASK;
     			found = true;
     			*val = read;
    -- 
    1.7.9.5
    
    
    that fixes this issue. Currently the ADC driver is built as a module so after applying this patch to the kernel you will need to rebuild the kernel modules and install the new modules onto the filesystem.

    If you need help with the above steps let me know and I can point you to some documentation or provide instructions.

  • I have similar issue, do you have any solution? Following patch is unusable because step on line 208 is undefined variable. I will be very appreciated for any help
  • 1. Check whether you've correct configuration as discussed in this post.
    2. The patch by Franklin worked for me. I use linux3.12. Check your version. You can also apply manually.
    3. Also have a look at this post - e2e.ti.com/.../405565


    Regards,
    Gangadhar
  • this patch (applying manually) is working in 3.15 after adding loop for step variable determination from 3.12 driver, thank you
  • "Hi Gangadhar,

    There is a bug in the ADC IIO driver and here is a patch 6740.0001-iio-ti_am335x_adc-Fix-unecessary-restrictions-on-ADC.diff that fixes this issue. Currently the ADC driver is built as a module so after applying this patch to the kernel you will need to rebuild the kernel modules and install the new modules onto the filesystem.

    If you need help with the above steps let me know and I can point you to some documentation or provide instructions."

    I would very much appreciate some direction for this.

    I am running 4.1.10-ti-r21 and cannot read in continuous mode: "cat in_voltage0_raw: Device or resource busy"