How to read the LRADC on an i.MX23 programmatically?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to read the LRADC on an i.MX23 programmatically?

726 Views
littleBitsman
Contributor I

Hi, I haven’t really done low-level programming in the past so bear with me.

I have an MCIMX233CAG4C in a miniature computer in a mini-Linux computer and I want to read the value of an input attached to the LRADC on pin 108 (LRADC0). How can I accomplish this via code? I haven’t found anything about actually reading the values anywhere.

(Note: I need to be able to get the value in Rust, and FFI is fine with me if reading the LRADC isn’t possible directly from Rust)

Tags (1)
0 Kudos
Reply
6 Replies

687 Views
littleBitsman
Contributor I

I found that in the DTS (decompiled from the DTB), the LRADC is marked as disabled.

I'm not exactly sure how to re-enable it.

The kernel config says that the LRADC is enabled.

0 Kudos
Reply

654 Views
jimmychan
NXP TechSupport
NXP TechSupport

To enable it, mark the status of LRADC in DTS to "okay".

0 Kudos
Reply

631 Views
littleBitsman
Contributor I
I did that, along with copying some other settings from the torvalds/linux DTS with the LRADC in it (it was for i.MX23).
But now how do I actually read the LRADC?
I presume it has something to do with reading memory considering there is a setting for what memory register to put it at in the DTS.
0 Kudos
Reply

629 Views
littleBitsman
Contributor I
Also, this is the DTS I copied from (I skipped the clocks setting, set status to "okay", and added "mxs-lradc" to compatible)
https://github.com/torvalds/linux/blob/dc1c8034e31b14a2e5e212104ec508aec44ce1b9/arch/arm/boot/dts/nx...
0 Kudos
Reply

547 Views
jimmychan
NXP TechSupport
NXP TechSupport

You don't need to modify the imx23.dtsi.

 

for example: You just add the LRADC like this.

https://github.com/torvalds/linux/blob/dc1c8034e31b14a2e5e212104ec508aec44ce1b9/arch/arm/boot/dts/nx...

apbx@80040000 {
                    lradc@80050000 {
                                      status = "okay";
                                      fsl,lradc-touchscreen-wires = <4>;
                    };

And here is the driver.

https://github.com/torvalds/linux/blob/dc1c8034e31b14a2e5e212104ec508aec44ce1b9/drivers/mfd/mxs-lrad...

 

0 Kudos
Reply

595 Views
littleBitsman
Contributor I
And, the mxs-lradc driver already on that Linux image does not allow me to bind it to the LRADC, no matter what name I use (I tested "80050000.lradc", "lradc" and a couple others and all of them said "no such device).
Not sure if that is relevant
0 Kudos
Reply