Forums » Software Development »
Is ADC supported in the 3.2 Linux build?
Added by alex peck over 9 years ago
I need a single ADC input for an ambient light sensor, and would like to use one of the pins not needed by the MitySom 335x dev kit touch screen, ain7.
What do I need to do under the current Linux to get a single reading from this pin? The Linux is an unmodified version of the current release: " mitysom-335x 3.2.0-00219-ga97f8f1 #32 Tue Jun 17 13:58:58 EDT 2014 armv7l"
do I need to rebuild the kernel?
Thanks,
Alex Peck
Replies (1)
RE: Is ADC supported in the 3.2 Linux build? - Added by Bob Duke over 9 years ago
Alex,
The main documentation for this is provided by TI: http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver%27s_Guide
First check to see if /sys/devices/platform/omap/ain/ain[0-7]
exist on your booted system. If they do, please refer to the TI docs for how to read each pin.
If those entries are not present, you will need to rebuild the kernel. Our default mityarm-335x-devkit_defconfig
includes the TI ADC driver, but you will need to setup the proper platform data to initialize the driver.
Please refer to the "Platform data" section of the TI guide for the updates required in the baseboard file. For testing, you can edit the Critical Link baseboard file that is located at arch/arm/mach-omap2/baseboard-mityarm335x-devkit.c
.
To use the ADC inputs as inputs, they recommend adding the adc_data am335x_adc_data
struct (with .adc_channels = 8
) to the baseboard file and then adding the .adc_init
field to the mfd_tscadc_board am335x_tscadc
struct.
Finally, for good form (it may not be necessary), you should define the pinmux for ain7. You can search for ain0 in the baseboard file for an example.
Once you've updated the baseboard file, you can compile the kernel using our kernel documentation: https://support.criticallink.com/redmine/projects/armc8-platforms/wiki/Linux_Kernel
Now you can boot the new kernel to test the ADC. Please refer to the "One Shot" section of the TI documentation. I think that is what you will need for your application.
After you test your kernel and confirm everything is working, if you want to create your own separate baseboard file for your project you can use these instructions: https://support.criticallink.com/redmine/projects/armc8-platforms/wiki/Creating_a_custom_baseboard