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.

use adc with am335x

Hi ,

We are using am335x evm in our custom board and we are using

linux-3.2.0-psp04.06.00.08.sdk

 source code in our board.we have APDS-9007 ambient light sensor connected as input to the ADC AIN0 pin on processor. we want to use pin AIN0 of am335x inbuilt adc on am335x.we downloaded the ti_adc driver from arago-project in our kernel source code.we made the neccessary changes in our kernel board file using the guide http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver%27s_Guide.

the folder /sys/bus/iio/devices/ not showing any devices in our filesystem ,i had compile my ti_adc as kernel inbuilt driver and also tried using ti_adc as module.

following are the board file changes  in arch/arm/mach-omap2/board-am335xevm.c

static struct adc_data am335x_adc_data = { 
.adc_channels = 1,
};

static struct mfd_tscadc_board tscadc = {
.adc_init = &am335x_adc_data,
};

static struct pinmux_config adc_pin_mux[] = {
{"ain0.ain0", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
{"ain2.ain2", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
{"vrefp.vrefp", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
{"vrefn.vrefn", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
{NULL, 0},
};

when we are inserting driver as module using insmod ,we got the following logs

[ 34.819580] ti_adc: module is from the staging directory, the quality is unknown, you have been warned.

to access adc on am335x is there setting of pin mux we have to do ?

you have any reference code or guide how to use ADC 1 input pin only and how we can read output?

Thanks and Regards

Pavan

  • Hi, Pavan,

    Sorry, but we don't support the am335x in the Audio Converter forum. Let me move your post to the AM335x forum for you.

    -d2

  • Hi Pavan,

    Raw ADC is not supported in your version of the SDK/PSP (info). It is supported in the next version of the SDK/PSP.

    Best regards,
    Miroslav

  • Thanks  Don Dapkus and Miroslav for your quick response.

       if raw ADC is not supported in our psp version,we can download next version of psp but after that which are the files i need to include in my current psp for raw adc support.

       is that possible to include raw adc support of next release into my current version or we will have to use only next release version for raw adc support?

       we have done all the required changes according to my hardware in my current version of psp that's why its very lengthy procedure for us to use another version?

    Regards

    Pavan 

  • Hi Pavan,

    It is possible to apply only the needed patches for Raw ADC support. Here is a link to the git repository of the Arago Linux project. You can search for the patches between version tags v3.2_AM335xPSP_04.06.00.08 and v3.2_AM335xPSP_04.06.00.09-rc2. However I recommend using the latest stable PSP release (currently v3.2_AM335xPSP_04.06.00.09-rc2), because otherwise you may introduce bugs to your system. You can then rebase all your custom board patches to the latest official release using the "git rebase" command.

    Best regards,
    Miroslav

  • Hi Miroslav,

         we downloaded and now we are using latest psp04.06.00.09,we have done all the required changes according to our hardware,i have updated the board file arch/arm/mach-omap2/board-amm335xevm.c for the tscadc initialization.we dont want to use touchscreen we are using only AIN0 pin of the processor.we have our ambient light sensor input connected to AIN0,following is our board file chages.

    static struct adc_data am335x_adc_data = {

    .adc_channels = 0,
    };

    static struct mfd_tscadc_board tscadc = {
    // .tsc_init = &am335x_touchscreen_data,
    .adc_init = &am335x_adc_data,
    };

    static void mfd_tscadc_init(int evm_id, int profile)
    {
    int err;

    static void mfd_tscadc_init(int evm_id, int profile)
    {
    int err;

    err = am33xx_register_mfd_tscadc(&tscadc);
    if (err)
    pr_err("failed to register touchscreen device\n");


    }

    static struct evm_dev_cfg beaglebone_dev_cfg[] = {
    {mii1_init, DEV_ON_BASEBOARD, PROFILE_ALL},
    {usb0_init, DEV_ON_BASEBOARD, PROFILE_NONE},
    {usb1_init, DEV_ON_BASEBOARD, PROFILE_NONE},
    {mmc1_wl12xx_init,DEV_ON_BASEBOARD, PROFILE_ALL},
    {mmc0_init, DEV_ON_BASEBOARD, PROFILE_NONE},
    {i2c2_init, DEV_ON_BASEBOARD, PROFILE_NONE},
    {wl12xx_init,DEV_ON_BASEBOARD, PROFILE_ALL},
    {em357_init, DEV_ON_BASEBOARD, PROFILE_ALL},
    {uart1_init, DEV_ON_BASEBOARD, PROFILE_ALL},

    {mfd_tscadc_init, DEV_ON_BASEBOARD, PROFILE_ALL},

    {NULL, 0, 0},

    };

     we made the above changes and trying to boot the board,we got the following errors while booting,

    [ 0.346710] Unable to handle kernel NULL pointer dereference at virtual address 00000000
    [ 0.355316] pgd = c0004000
    [ 0.358154] [00000000] *pgd=00000000
    [ 0.361938] Internal error: Oops: 5 [#1]
    [ 0.366088] Modules linked in:
    [ 0.369293] CPU: 0 Not tainted (3.2.0 #1)
    [ 0.373901] PC is at ti_tscadc_probe+0x44/0x32c
    [ 0.378692] LR is at platform_drv_probe+0x1c/0x20
    [ 0.383666] pc : [<c0406b1c>] lr : [<c0221f04>] psr: a0000013
    [ 0.383666] sp : cf81de38 ip : cf81de70 fp : cf81de6c
    [ 0.395751] r10: cf81c000 r9 : c06345c0 r8 : 00000000
    [ 0.401275] r7 : c060eef8 r6 : c062e830 r5 : cf9d5a00 r4 : cf9d5a08
    [ 0.408142] r3 : 00000000 r2 : 00000000 r1 : 00000001 r0 : cf9d5a00
    [ 0.415039] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
    [ 0.422729] Control: 10c5387d Table: 80004019 DAC: 00000015
    [ 0.428802] Process swapper (pid: 1, stack limit = 0xcf81c2f0)
    [ 0.434936] Stack: (0xcf81de38 to 0xcf81e000)
    [ 0.439544] de20: 00000000 cf81c000
    [ 0.448150] de40: cf81de5c cf9d5a08 c0656940 c062e830 c060eef8 00000000 c06345c0 cf81c000
    [ 0.456787] de60: cf81de7c cf81de70 c0221f04 c0406ae4 cf81deac cf81de80 c0220918 c0221ef4
    [ 0.465423] de80: cf81deac cf81de90 c02227a8 cf9d5a08 c060eef8 cf9d5a3c cf9d2540 00000000
    [ 0.474029] dea0: cf81decc cf81deb0 c0220bb8 c0220870 c0220b24 00000000 c060eef8 c0220b24
    [ 0.482666] dec0: cf81def4 cf81ded0 c021f674 c0220b30 cf806ef8 cf9d2870 c01c4944 c060eef8
    [ 0.491302] dee0: c060eef8 c060e120 cf81df04 cf81def8 c0220540 c021f634 cf81df34 cf81df08
    [ 0.499908] df00: c0220194 c0220528 c04f2c40 cf81df18 c060eef8 c05cb5a0 c05af320 00000013
    [ 0.508544] df20: 00000000 cf81c000 cf81df5c cf81df38 c02210d4 c0220018 c05cb398 c05cb5a0
    [ 0.517181] df40: c05af320 00000013 00000000 cf81c000 cf81df6c cf81df60 c02222c4 c0221060
    [ 0.525787] df60: cf81df7c cf81df70 c05af334 c0222284 cf81dfd4 cf81df80 c0008760 c05af32c
    [ 0.534423] df80: c0074a34 c00f3f9c c05af320 00000000 cf81dfb4 3231c9f8 00000037 00000000
    [ 0.543060] dfa0: cf81dfbc 0000018c c05fb460 c05cb398 c05cb5a0 c0040e54 00000013 00000000
    [ 0.551696] dfc0: 00000000 00000000 cf81dff4 cf81dfd8 c058f88c c0008650 00000000 00000000
    [ 0.560302] dfe0: 00000000 c058f808 00000000 cf81dff8 c0040e54 c058f814 11482864 4600a22a
    [ 0.568939] Backtrace:
    [ 0.571533] [<c0406ad8>] (ti_tscadc_probe+0x0/0x32c) from [<c0221f04>] (platform_drv_probe+0x1c/0x20)
    [ 0.581237] [<c0221ee8>] (platform_drv_probe+0x0/0x20) from [<c0220918>] (driver_probe_device+0xb4/0x2c0)
    [ 0.591339] [<c0220864>] (driver_probe_device+0x0/0x2c0) from [<c0220bb8>] (__driver_attach+0x94/0x98)
    [ 0.601165] r8:00000000 r7:cf9d2540 r6:cf9d5a3c r5:c060eef8 r4:cf9d5a08
    [ 0.608245] [<c0220b24>] (__driver_attach+0x0/0x98) from [<c021f674>] (bus_for_each_dev+0x4c/0x94)
    [ 0.617706] r6:c0220b24 r5:c060eef8 r4:00000000 r3:c0220b24
    [ 0.623687] [<c021f628>] (bus_for_each_dev+0x0/0x94) from [<c0220540>] (driver_attach+0x24/0x28)
    [ 0.632934] r6:c060e120 r5:c060eef8 r4:c060eef8
    [ 0.637817] [<c022051c>] (driver_attach+0x0/0x28) from [<c0220194>] (bus_add_driver+0x188/0x270)
    [ 0.647094] [<c022000c>] (bus_add_driver+0x0/0x270) from [<c02210d4>] (driver_register+0x80/0x144)
    [ 0.656555] [<c0221054>] (driver_register+0x0/0x144) from [<c02222c4>] (platform_driver_register+0x4c/0x60)
    [ 0.666839] [<c0222278>] (platform_driver_register+0x0/0x60) from [<c05af334>] (ti_tscadc_driver_init+0x14/0x1c)
    [ 0.677581] [<c05af320>] (ti_tscadc_driver_init+0x0/0x1c) from [<c0008760>] (do_one_initcall+0x11c/0x184)
    [ 0.687683] [<c0008644>] (do_one_initcall+0x0/0x184) from [<c058f88c>] (kernel_init+0x84/0x120)
    [ 0.696868] [<c058f808>] (kernel_init+0x0/0x120) from [<c0040e54>] (do_exit+0x0/0x65c)
    [ 0.705200] r5:c058f808 r4:00000000
    [ 0.708984] Code: e5932004 e5933000 e3520000 15922000 (e5933000)
    [ 0.715515] ---[ end trace 11d529bee0e840c0 ]---
    [ 0.720397] Kernel panic - not syncing: Attempted to kill init!
    [ 0.726654] Backtrace:
    [ 0.729248] [<c0018084>] (dump_backtrace+0x0/0x10c) from [<c040ee0c>] (dump_stack+0x18/0x1c)
    [ 0.738159] r6:cf81bc00 r5:c05003b0 r4:c06355c8 r3:c05ee74c
    [ 0.744140] [<c040edf4>] (dump_stack+0x0/0x1c) from [<c040f048>] (panic+0x64/0x194)
    [ 0.752227] [<c040efe4>] (panic+0x0/0x194) from [<c0041404>] (do_exit+0x5b0/0x65c)
    [ 0.760223] r3:cf81bc00 r2:cf81dc38 r1:cf81dc38 r0:c05003b0
    [ 0.766235] r7:00000001
    [ 0.768920] [<c0040e54>] (do_exit+0x0/0x65c) from [<c0018360>] (die+0x11c/0x2c8)
    [ 0.776702] r7:00000001
    [ 0.779388] [<c0018244>] (die+0x0/0x2c8) from [<c040ee6c>] (__do_kernel_fault.part.4+0x5c/0x7c)
    [ 0.788604] [<c040ee10>] (__do_kernel_fault.part.4+0x0/0x7c) from [<c001aaf0>] (do_page_fault+0x1e4/0x1fc)
    [ 0.798797] r7:cf81bc00 r3:cf81ddf0
    [ 0.802581] [<c001a90c>] (do_page_fault+0x0/0x1fc) from [<c001ac34>] (do_translation_fault+0xa0/0xa8)
    [ 0.812316] [<c001ab94>] (do_translation_fault+0x0/0xa8) from [<c00083b0>] (do_DataAbort+0x3c/0xa4)
    [ 0.821868] r7:00000000 r6:c05d272c r5:c001ab94 r4:00000005
    [ 0.827880] [<c0008374>] (do_DataAbort+0x0/0xa4) from [<c00145d8>] (__dabt_svc+0x38/0x60)
    [ 0.836517] Exception stack(0xcf81ddf0 to 0xcf81de38)
    [ 0.841827] dde0: cf9d5a00 00000001 00000000 00000000
    [ 0.850494] de00: cf9d5a08 cf9d5a00 c062e830 c060eef8 00000000 c06345c0 cf81c000 cf81de6c
    [ 0.859130] de20: cf81de70 cf81de38 c0221f04 c0406b1c a0000013 ffffffff
    [ 0.866119] r8:00000000 r7:cf81de24 r6:ffffffff r5:a0000013 r4:c0406b1c
    [ 0.873199] [<c0406ad8>] (ti_tscadc_probe+0x0/0x32c) from [<c0221f04>] (platform_drv_probe+0x1c/0x20)
    [ 0.882934] [<c0221ee8>] (platform_drv_probe+0x0/0x20) from [<c0220918>] (driver_probe_device+0xb4/0x2c0)
    [ 0.893066] [<c0220864>] (driver_probe_device+0x0/0x2c0) from [<c0220bb8>] (__driver_attach+0x94/0x98)
    [ 0.902862] r8:00000000 r7:cf9d2540 r6:cf9d5a3c r5:c060eef8 r4:cf9d5a08
    [ 0.909973] [<c0220b24>] (__driver_attach+0x0/0x98) from [<c021f674>] (bus_for_each_dev+0x4c/0x94)
    [ 0.919433] r6:c0220b24 r5:c060eef8 r4:00000000 r3:c0220b24
    [ 0.925445] [<c021f628>] (bus_for_each_dev+0x0/0x94) from [<c0220540>] (driver_attach+0x24/0x28)
    [ 0.934722] r6:c060e120 r5:c060eef8 r4:c060eef8
    [ 0.939605] [<c022051c>] (driver_attach+0x0/0x28) from [<c0220194>] (bus_add_driver+0x188/0x270)
    [ 0.948883] [<c022000c>] (bus_add_driver+0x0/0x270) from [<c02210d4>] (driver_register+0x80/0x144)
    [ 0.958374] [<c0221054>] (driver_register+0x0/0x144) from [<c02222c4>] (platform_driver_register+0x4c/0x60)
    [ 0.968658] [<c0222278>] (platform_driver_register+0x0/0x60) from [<c05af334>] (ti_tscadc_driver_init+0x14/0x1c)
    [ 0.979400] [<c05af320>] (ti_tscadc_driver_init+0x0/0x1c) from [<c0008760>] (do_one_initcall+0x11c/0x184)
    [ 0.989532] [<c0008644>] (do_one_initcall+0x0/0x184) from [<c058f88c>] (kernel_init+0x84/0x120)
    [ 0.998718] [<c058f808>] (kernel_init+0x0/0x120) from [<c0040e54>] (do_exit+0x0/0x65c)
    [ 1.007080] r5:c058f808 r4:00000000

    when we are commenting the function mfd_tscadc_init then board is booting well.

    how to debug this probelm?any suggestion?

    Regards

    Pavan

  • Hi Pavan,

    There seems to either be a bug with the ADC driver, or an incorrect wiki description. You shouldn't completely disable the TSC. Please try the following board file configuration:


    static struct tsc_data am335x_touchscreen_data  = {
        .wires  = 0,
        .x_plate_resistance = 200,
        .steps_to_configure = 5,
    };

    static struct adc_data am335x_adc_data = {
        .adc_channels = 8,
    };

    static struct mfd_tscadc_board tscadc = {
        .tsc_init = &am335x_touchscreen_data,
        .adc_init = &am335x_adc_data,
    };

    I'm simply setting the tsc_init.wires element to 0 rather than commenting out the whole structure. Otherwise this element of the structure is not initialized, so the kernel crashes when trying to dereference a pointer to it.

    When I do this, the kernel starts normally and then when I insmod the ti_adc.ko kernel module everything works OK:

    root@am335x-evm:/# ls -la /sys/bus/iio/devices/iio\:device0/
    drwxr-xr-x    3 root     root            0 Apr 11 12:57 .
    drwxr-xr-x    4 root     root            0 Jan  1  2000 ..
    -r--r--r--    1 root     root         4096 Apr 11 12:57 dev
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage0_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage1_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage2_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage3_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage4_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage5_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage6_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage7_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 name
    drwxr-xr-x    2 root     root            0 Apr 11 12:57 power
    lrwxrwxrwx    1 root     root            0 Apr 11 12:57 subsystem -> ../../../../../../bus/iio
    -rw-r--r--    1 root     root         4096 Apr 11 12:57 uevent

    P.S. Why are your adc_channels set to 0?

    Best regards,
    Miroslav

  • Hi Miroslav,

    Thanks for your response.

    we are using this ti link as guide http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver's_Guide...


    P.S. Why are your adc_channels set to 0?

     ----we might be wrong but we are using only AIN0 pin as input and our remaining pins are floating  thats we are using .adc_channel=0.

    i will try your configuration and get back to you.

    I have enable the drivers/staging/iio/adc/ti_adc.c and drivers/input/touchscreen/ti_tsc.c is there any driver in new psp i need to enable ?

    Regards

    Pavan

     

  • Hi Pavan,

    The ADC channels are AIN0-AIN7. If you wish to use only AIN1, then you should set the .adc_channels element of the am335x_adc_data structure to 1.

    .adc_channels = 1;

    With the latest PSP, just follow the wiki page steps with the exception that you shouldn't comment out the TSC structure (like I stated in my previous post). Just set the number of wires for the TSC to 0. The other difference is that you want to use only channel AIN0, so just set adc_channels = 1.

    Please update the post when you have tried this.

    Best regards,
    Miroslav

  • Hi Miroslav,

    Thank you very much.

    we got adc working.after setting recommended configuration,got the following output

    root@beaglebone:/home# ls -al /sys/bus/iio/devices/iio\:device0/
    total 0
    drwxr-xr-x 3 root root 0 Mar 7 13:24 .
    drwxr-xr-x 4 root root 0 Jan 1 1970 ..
    -r--r--r-- 1 root root 4096 Mar 7 13:26 dev
    -r--r--r-- 1 root root 4096 Mar 7 13:26 in_voltage0_raw
    -r--r--r-- 1 root root 4096 Mar 7 13:26 name
    drwxr-xr-x 2 root root 0 Mar 7 13:26 power
    lrwxrwxrwx 1 root root 0 Mar 7 13:24 subsystem -> ../../../../../../bus/iio
    -rw-r--r-- 1 root root 4096 Mar 7 13:24 uevent

    Regards

    Pavan

  • Pavan,

    I  got the output  as you posted.

    but why can't  show 'mode' as below:

    -rw-r--r--    1 root     root         4096 Jan  1 00:00 mode

    and I can't  read a single ADC output, why?

    root@am335x-evm:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
    0

    thanks!

  • Hi jacky,

    The "mode" element of the device structure is part of the

    The reason why the "mode" element of the device structure is missing and the contents of your /sys/bus/iio/devices/iio\:device0/ are different from what is shown in the AM335x ADC Driver's guide, is that some of the contents of this particular wiki page are ahead of the v3.2_AM335xPSP_04.06.00.09-rc2 PSP release which comes with the latest SDK. There are patches in the development branch (v3.2-staging), uploaded between tags v3.2_AM335xPSP_04.06.00.09-rc2 and v3.2_AM335xPSP_04.06.00.10-rc1. The patches are:

    2013-02-12
    Patil, Rachna
    IIO: ti_adc: Add support for ADC continuous mode

    2013-02-12
    Patil, Rachna
    input: ti_tsc: Enable shared IRQ for TSC

    2013-02-12
    Patil, Rachna
    IIO: ADC: ti_adc: Fix wrong samples received on 1st...

    2013-02-12
    Patil, Rachna
    IIO: ADC: ti_adc: Reflect the correct analog input...

    2013-02-12
    Patil, Rachna
    MFD: ti_tscadc: disable TSC control register bits when...

    2013-02-12
    Patil, Rachna
    MFD: ti_tscadc: register children only when they are...

    2013-02-12
    Patil, Rachna
    ARM: OMAP2+: AM335x: Update defconfig with ADC support

    2013-02-12
    Patil, Rachna
    ARM: OMAP2+: AM335X: Add ADC platform data

    The new PSP version is not yet officially released. However you can download and apply these patches if you want to check out the new features they add. Keep in mind, though, that the branch is still in development, so bugs may still be present.

    Regarding the wrong ADC readings issue, can you please tell me which pin and which platform are you using for your tests? When using both touch screen and 4 ADC channels with the configuration from the AM335x ADC Driver's guide wiki page, signals AIN0-AIN3 are used for the LCD display and signals AIN4-AIN7 are used as the ADC channels. Please make sure you are applying voltage to the correct ADC input pin. You can check the schematics of the TI supported boards for the correct connector pins - links to the schematic files can be found in this section.

    I tested reading the ADC values for in_voltage0_raw (signal AIN4) which is expanded to pin 2 from connector J8 located on the AM335x EMV daughter board and the readings are correct. I followed the instructions from the AM335x ADC Driver's guide wiki page without applying the missing patches.

    Best regards,
    Miroslav

  • Hi Miroslav,

     Thank you very much!

    I test reading  battery valtage using ADC on my custom am335x board.

    I don't use  touch screen and use singal AIN0  as the ADC channel.

    Best regards.

    Jacky


  • Miroslav,

    I always get  the value ' 0 '.    I don't use the patches.

    my schematics is as below, thanks.

  • Hi Pavan,

    I am trying make adc work on am335x custom board. I followed the steps mentioned in the above posts. But after booting I am getting bootlog same as you mentioned in your post on Mar 13 2013 03:34 AM. I tried with adc_channels = 1(trying to read from ain6 only) and adc_channels=8 with TSC structure in place with wires = 0. How did you solve this? What was missed when you got this error?

  • Hi Pradeep,

                     if you wish to use only AIN6 then try with following configuration,

                 
    static struct tsc_data am335x_touchscreen_data  = {
        .wires  = 0,
        .x_plate_resistance = 200,
        .steps_to_configure = 5,
    };

    static struct adc_data am335x_adc_data = {
        .adc_channels = 6,
    };

    static struct mfd_tscadc_board tscadc = {
        .tsc_init = &am335x_touchscreen_data,
        .adc_init = &am335x_adc_data,
    };

    don't disable the tsc structure otherwise it will crash,After doing this you can see the device iio:device0,

    root@beaglebone:/home# ls -al /sys/bus/iio/devices/iio\:device0/
    total 0
    drwxr-xr-x 3 root root 0 Mar 7 13:24 .
    drwxr-xr-x 4 root root 0 Jan 1 1970 ..
    -r--r--r-- 1 root root 4096 Mar 7 13:26 dev
    -r--r--r-- 1 root root 4096 Mar 7 13:26 in_voltage0_raw
    -r--r--r-- 1 root root 4096 Mar 7 13:26 name
    drwxr-xr-x 2 root root 0 Mar 7 13:26 power
    lrwxrwxrwx 1 root root 0 Mar 7 13:24 subsystem -> ../../../../../../bus/iio
    -rw-r--r-- 1 root root 4096 Mar 7 13:24 uevent

    Please let me know when u tried this configuration.

    Regards

    Pavan


  • Hi Pavan, It was issue with file system because of which I was getting error. It worked with .adc_channels = 1. With .adc_channels = 8 also works. Thanks for your time. Regards, Pradeep
  • Good day Miroslav,

    I'm using a beaglebone board (Rev A6a) and have downloaded the latest SDK 6.00.00.00.00 (linux-3.2.0-psp04.06.00.11) . I can't seem to get the ADC working correctly, ie. can't access /iio\;device0/.

    I have 3 analog source channels on AIN0,AIN2 and AIN3 (input level of all is below 1.7V). I've changed the board file as you suggested above and also build a kernel module (ti_adc.ko) and loaded it with insmod  (then verified with lsmod) . But still when I type in "ls -la /sys/bus/iio/devices/iio\:device0/" I get  "No such file or directory".

    Is there perhaps an initialization step I'm missing? or something relating to the beaglebone perhaps?

    Your help would be much appreciated.

    Kind Regards,
    Cobus van der Merwe

  • Hi Cobus,

    Using the Beaglebone black and SDK 6.0 (PSP 04.06.00.11)able to see the ADC entries entry in the sys:

    - I just followed the ADC drivers docs from the wiki below:
    http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver%27s_Guide

    I added the below line in beagleboneblack_dev_cfg[] of the board-am335xevm.c:
              {mfd_tscadc_init,            DEV_ON_BASEBOARD, PROFILE_ALL}
    See as well:
    http://e2e.ti.com/support/arm/sitara_arm/f/791/p/260624/914357.aspx#914357

    Apart from this I did not have to patch any code.

    - On the target I just load the module:

    root@am335x-evm:/lib/modules/3.2.0/kernel/drivers/staging/iio/adc# insmod ti_adc.ko

    [  182.737792] ti_adc: module is from the staging directory, the quality is unknown, you have been warned.

    [  182.749114] tiadc tiadc: attached adc driver

    and get:

    root@am335x-evm:/lib/modules/3.2.0/kernel/drivers/staging/iio/adc# ls -la /sys/bus/iio/devices/iio\:device0/
    drwxr-xr-x    5 root     root             0 Jun 26 19:12 .
    drwxr-xr-x    4 root     root             0 Jun 26 19:09 ..
    drwxr-xr-x    2 root     root             0 Jun 26 19:14 buffer
    -r--r--r--    1 root     root          4096 Jun 26 19:14 dev
    -r--r--r--    1 root     root          4096 Jun 26 19:14 in_voltage4_raw
    -r--r--r--    1 root     root          4096 Jun 26 19:14 in_voltage5_raw
    -r--r--r--    1 root     root          4096 Jun 26 19:14 in_voltage6_raw
    -r--r--r--    1 root     root          4096 Jun 26 19:14 in_voltage7_raw
    -rw-r--r--    1 root     root          4096 Jun 26 19:14 mode
    -r--r--r--    1 root     root          4096 Jun 26 19:14 name
    drwxr-xr-x    2 root     root             0 Jun 26 19:14 power
    drwxr-xr-x    2 root     root             0 Jun 26 19:14 scan_elements
    lrwxrwxrwx    1 root     root             0 Jun 26 19:12 subsystem -> ../../../../../../bus/iio
    -rw-r--r--    1 root     root          4096 Jun 26 19:12 uevent

    Anthony