LRADC on A20

73 views
Skip to first unread message

Paolo Cremonese

unread,
Jan 1, 2021, 5:52:36 AM1/1/21
to linux-sunxi
Hi All,
I need to use ADC0 of A20 using kernel 5.8
With old kernels (3.4) I had to add sun4i-keyboard module.
In new kernels, I have seen that the device tree has a node called lradc which should load the driver sun4i-lradc-keys

The driver is built, but it is not in the modules.builtin file.
Enabling the lradc node in the device tree the module is not loaded.
loading it using insmod the driver seems inactive.

What I'm doing of wrong ?

Thanks in advance,
Paolo Cremonese

Nazım Gediz AYDINDOĞMUŞ

unread,
Jan 4, 2021, 2:44:27 AM1/4/21
to crem...@teledata-i.com, linux-sunxi

Hello Paolo,

Can you please send the content of your DTS file, and output of dmesg
and lsmod, if you are still working on it. I can give it a try for you.

Regards,
Gediz

Ing. Paolo Cremonese

unread,
Jan 4, 2021, 10:16:23 AM1/4/21
to Nazım Gediz AYDINDOĞMUŞ, linux-sunxi
Hello Gediz,
thank you for your kind reply.
in attachment the files describing the device tree.
lradc is noted in the .dtsi and is disabled for default: to enable it I'm using the overlay lradc_enable.dtbo (the source is lradc-enable.dts)
the dmesg and lsmod outputs are in the related .txt
Thank you again for your time.
Best regards,
Paolo Cremonese
.
dmesg.txt
lradc-enable.dtbo
lradc-enable.dts
sun7i-a20.dtsi
sun7i-a20-olinuxino-lime.dts
lsmod.txt

Nazım Gediz AYDINDOĞMUŞ

unread,
Jan 5, 2021, 2:02:05 AM1/5/21
to Ing. Paolo Cremonese, linux-sunxi
On 4.01.2021 18:16, Ing. Paolo Cremonese wrote:
> Hello Gediz,
> thank you for your kind reply.
> in attachment the files describing the device tree.
> lradc is noted in the .dtsi and is disabled for default: to enable it
> I'm using the overlay lradc_enable.dtbo (the source is lradc-enable.dts)
> the dmesg and lsmod outputs are in the related .txt
> Thank you again for your time.
> Best regards,
> Paolo Cremonese

You're welcome.

I did not see any obvious warning/error in dmesg output. I'm not very
familiar with DTBO files but compared "lradc-enable.dts" to valid ones
and it looks okay. But I'd still somehow check if overlay is
recognized/loaded properly. That's not your case but, even if module is
built in to the kernel, it obviously does not start with a missing lradc
node.

I've set LRADC node status to "disabled" in the DTS to test it and there
were no complaints about LRADC in the dmesg. Of course, I could not see
the device under "/dev/input/eventX" anymore using "evtest" after
disabling it.

If you have compiled the kernel yourself, I'd recommend to check if
CONFIG_KEYBOARD_SUN4I_LRADC is enabled. Otherwise, looking at
"/proc/configz.gz" may help.

I've tested the following on my device which has an A13. Their LRADC is
probably identical. Maybe the output may help as a reference.

# grep lradc /lib/modules/5.10.1/modules.builtin
kernel/drivers/input/keyboard/sun4i-lradc-keys.ko

# dmesg | grep lradc
[ 1.597213] input: 1c22800.lradc as
/devices/platform/soc/1c22800.lradc/input/input0

Regards,
Gediz

Sertac Tüllük

unread,
Jan 5, 2021, 4:30:47 AM1/5/21
to Nazım Gediz AYDINDOĞMUŞ, Ing. Paolo Cremonese, linux-sunxi
I wish to add my two-cents:

There is a way to check if the DTB / DTBO is really recognised / in-use by kernel:


I don't know if this is really valid for LRADC driver, but one can basically see like:

sudo apt-get install device-tree-compiler
dtc -I fs -O dts /sys/firmware/devicetree/base

Nazım Gediz AYDINDOĞMUŞ <gediz.ay...@genemek.com>, 5 Oca 2021 Sal, 10:02 tarihinde şunu yazdı:
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/linux-sunxi/f9d9406e3e7b4c74819adfc2d97b7927%40genemek.com.


--
Sertac TULLUK
Electronics Engineer

Nazım Gediz AYDINDOĞMUŞ

unread,
Jan 5, 2021, 5:27:44 AM1/5/21
to Sertac Tüllük, Ing. Paolo Cremonese, linux-sunxi
On 5.01.2021 12:30, Sertac Tüllük wrote:
> I wish to add my two-cents:
>
> There is a way to check if the DTB / DTBO is really recognised / in-use
> by kernel:
>
> https://unix.stackexchange.com/questions/265890/is-it-possible-to-get-the-information-for-a-device-tree-using-sys-of-a-running

Today I learned... That's really good to know. So I've tried it.
Apparently there's a directory (or a node? perhaps a tree?) for LRADC.
Full path for it is:
|/proc/device-tree/soc/lradc@1c22800|

"ls" yields the following result:
|# ls /proc/device-tree/soc/lradc@1c22800/
button-1000 button-200 interrupts reg vref-supply
button-1200 compatible name status
#|

An even better thing for Paolo is that it would be guaranteed to know
that if an overlay file is actually loaded. I've simple tweaked "status"
property of the DTS and it's really easy to check like this.

|# cat /proc/device-tree/soc/lradc@1c22800/status
disabled

# cat /proc/device-tree/soc/lradc@1c22800/status
okay|

Apparently most of the files contain binary data, and I've used hexdump
to view them, fyi.

Thanks, by the way. I hope it'd also help Paolo :)

> I don't know if this is really valid for LRADC driver, but one can
> basically see like:
>
> |sudo apt-get install device-tree-compiler dtc -I fs -O dts
> /sys/firmware/devicetree/base|

Ing. Paolo Cremonese

unread,
Jan 7, 2021, 6:19:53 AM1/7/21
to Nazım Gediz AYDINDOĞMUŞ, Sertac Tüllük, linux-sunxi
Thank you so much for your precious suggestions!

Best Regards,
Paolo Cremonese
Reply all
Reply to author
Forward
0 new messages