Project

General

Profile

How to access ADC inputs from Linux kernel/application

Added by Raja Vankam over 9 years ago

Hi,

I am looking for info on how to access/configure ADC inputs from MityArm. So far i have not been able to find anything.

I need to monitor ADC pins individually. Do you have any approach on how to proceed?

Regards,
Raja.


Replies (12)

RE: How to access ADC inputs from Linux kernel/application - Added by Gregory Gluszek over 9 years ago

Hi Raja,

From what I understand there currently is no individual driver we are aware of for accessing the ADC inputs. I've been told that the touchscreen driver (drivers/input/touchscreen/ti_tsadc.c) does access the ADC. So looking into that code may be the best route until we've had time to build our own driver.

\Greg

RE: How to access ADC inputs from Linux kernel/application - Added by Michael Karasoff over 7 years ago

Any updates on this? Any idea how to access the ADC from kernel version 3.2?

RE: How to access ADC inputs from Linux kernel/application - Added by Michael Karasoff over 7 years ago

I found the updated ADC driver code in the mityarm-linux-v3.2 branch. I merged in the ADC changes into AM335XPSP_04.06.00.02, the changes to the ti_adc driver, the #ifdef CONFIG_TOUCHSCREEN_TI_ADC changes in am33xx_register_tsc() in devices.c, and the call to am33xx_register_tsc() in baseboard-mityarm335x-devkit.c.

When I load the driver, I get this message: "Error: Driver 'ain' is already registered, aborting..."

Any idea why?

RE: How to access ADC inputs from Linux kernel/application - Added by Michael Karasoff over 7 years ago

Correction, I merged the ADC changes into cl_v3.2_AM335XPSP_04.06.00.07, not AM335XPSP_04.06.00.02.

Still the same problem though.

RE: How to access ADC inputs from Linux kernel/application - Added by Michael Karasoff over 7 years ago

Nevermind. The problem was on my end - merge error. :)

So I have the ADC driver loaded, and I have /sys/devices/platform/omap/ain/ain0 - /sys/devices/platform/omap/ain/ain7 . Do you have any tips on reading the ADC values?

Thanks,
Mike

RE: How to access ADC inputs from Linux kernel/application - Added by Jonathan Cormier over 7 years ago

I'm a little confused by your merging. cl_v3.2_AM335XPSP_04.06.00.07 is a tag and not a branch and is a on the mityarm-linux-v3.2 branch anyways just about a year older. Was there some reason you couldn't use the latest mityarm-linux-v3.2 commits? That branch has seen a good deal of bug fixes including some stability fixes for ubifs and nand.

Anyways the above isn't necessarily relevant to your adc troubles now that you have it working. I haven't used the ti_adc driver but I suspect you can just cat /sys/devices/platform/omap/ain/ain0 to get the adc values.

RE: How to access ADC inputs from Linux kernel/application - Added by Michael Karasoff over 7 years ago

Jonathan,

Can one not merge selected changes between two commits? Git is a powerful tool, but it hasn't redefined the word "merge" yet.

The reason I'm not using the latest mityarm-linux-v3.2: I forked off of cl_v3.2_AM335XPSP_04.06.00.07 quite a while ago, per the wiki instructions at the time which advised only to use that tag. I have gone on to make changes and bug fixes to suit my needs. Looking at the scope of the changes on mityarm-linux-v3.2, I'm a bit reticent to merge the tip of that branch back into my forked branch, which is working fine. Also, the mityarm-linux-v3.2 branch is missing bug fixes I need, notably the fix to the GPIO latency: https://support.criticallink.com/redmine/boards/28/topics/3152 . I can report that reading ADC under sysfs is not working on cl_v3.2_AM335XPSP_04.06.00.07, and after merging in the fixes from the tip of mityarm-linux-v3.2, reading ADC in sysfs does work.

My question regarding "tips" on the ADC goes beyond the cat of ain[0-7] files. Are there other ADC settings that can or should be tweak via the other files in under the /sys/bus/platform/drivers/ain/ path?

Mike

RE: How to access ADC inputs from Linux kernel/application - Added by Jonathan Cormier over 7 years ago

I asked to clarify and to hopefully learn something. My current understanding of what you did was to merge the mityarm-linux-v3.2 branch into your branch which was based off of the cl_v3.2_AM335XPSP_04.06.00.07 tag. This seems reasonable. Alternately you could have cherry-picked specific commits from our branch. This can work but makes life more difficult later if you ever want to do a merge. Let me know if there is another option I'm missing.

Also, the mityarm-linux-v3.2 branch is missing bug fixes I need, notably the fix to the GPIO latency: https://support.criticallink.com/redmine/boards/28/topics/3152

Thanks for bringing this up. This must have gotten buried. I'll check out this change and see about getting it pushed to our repo.

Heres TIs ADC Guide. I'm not sure if we have the updated "continuous mode" code they mention being available from the v3.2_AM335xPSP_04.06.00.10-rc1 branch. It probably wouldn't be too difficult to grab those patches from the ti repo.
http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver%27s_Guide

RE: How to access ADC inputs from Linux kernel/application - Added by Michael Karasoff over 7 years ago

Actually, I didn't run a "git merge". I'm forked, and my origin is my own repo. I set up a seperate remote for the critical link repo, then pulled the latest, then ran "git diff /remotes/cl/mityarm-linux-v3.2" and hand added the changes for just the ADC. At this point the safest for more.

RE: How to access ADC inputs from Linux kernel/application - Added by Jonathan Cormier over 7 years ago

Ahh interesting. You've effectively done a manual cherry-pick. That's okay whatever gets the job done. You probably could have done a merge without too much trouble but who knows.

RE: How to access ADC inputs from Linux kernel/application - Added by Michael Karasoff over 7 years ago

Not sure I see how this is a cherry pick. I don't think I've changed any history.

I appreciate that Critical Link has been keeping the kernel up to date. Even if I'm hesitent to git merge the changes it helps to at least see what has been fixed and manually apply fixes for the features I need.

Cheers!

RE: How to access ADC inputs from Linux kernel/application - Added by Jonathan Cormier over 7 years ago

The way the git cherry-pick command works is by taking a commit and applying it to your branch. It can be a handy tool.

You can following this page for updates on the 3.2 kernel. I try to update anytime we patch something big. Cl_v32_AM335XPSP_

    (1-12/12)
    Go to top
    Add picture from clipboard (Maximum size: 600 MB)