Odroid XU4 Kernel module

Moderators: mdrjr, odroid

Odroid XU4 Kernel module

Unread postby wolver » Thu May 17, 2018 1:48 am

Hi everyone! I have a little problem. I want to write a kernel module which reads from ADC, How can I access ADC registers directly from kernel space? I've searched for a solution, but nothing seems to work. Also I've tried to read ADC value from "/sys/bus/iio/devices/iio:device0/in_voltage0_raw", but can't open it: vfs_read function is undefined. May be there is some example?
Thanks a lot!
wolver
 
Posts: 2
Joined: Thu May 17, 2018 1:42 am
languages_spoken: english
ODROIDs: Odroid XU4

Re: Odroid XU4 Kernel module

Unread postby odroid » Thu May 17, 2018 4:04 am

There is a physical address information for the ADC registers in this link.
https://wiki.odroid.com/odroid-xu4/appl ... e/gpio/adc
User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Odroid XU4 Kernel module

Unread postby wolver » Thu May 17, 2018 4:09 am

odroid wrote:There is a physical address information for the ADC registers in this link.
https://wiki.odroid.com/odroid-xu4/appl ... e/gpio/adc

I saw it, but how exactly should I access this memory? I mean what API functions to use?
wolver
 
Posts: 2
Joined: Thu May 17, 2018 1:42 am
languages_spoken: english
ODROIDs: Odroid XU4

Re: Odroid XU4 Kernel module

Unread postby odroid » Thu May 17, 2018 5:37 am

There are a few examples in Kernel 3.10
https://github.com/hardkernel/linux/tre ... hardkernel

But we don't use those kernel drivers in Kernel 4.9/4.14 any more since most users access the IO ports from user land software.
User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Odroid XU4 Kernel module

Unread postby tobetter » Thu May 17, 2018 9:25 am

Basically, you must use the function readl or writel in order to register map with proper register address which is mapped by the function devm_ioremap_resource. Unless kernel can be crashed when the register map is accessed.

Maybe you can read the function exynos_read_s3c64xx_ts if this meets your requirements. This function is to read touch value connected to ADC whenever an interrupt is triggered by touch. If you understand how ADC works, you could understand what happens in kernel driver to read ADC.
https://github.com/hardkernel/linux/blo ... adc.c#L544
tobetter
 
Posts: 2400
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1


Return to Ubuntu

Who is online

Users browsing this forum: boardt and 3 guests