How to compile an ADC drive for 3.12 linux kernel

Ezequiel Netto
Hi,

I`m noob on mini2440, and I`m working on linux 3.12 for mini2440, but I
need to install the ADC driver on it.

Can some give me some light?

davef
What do you mean by "I'm working on linux 3.12"?

If you are really working on customising your own 3.12 then I think you
would know where to look.

Do you want to know which boxes to tick in the menus?

Ezequiel Netto
Attachment: mini2440_adc.c (4.25 KB)
Thanks for reply.

I`m not using the Linux kernel 2.6 provided on micro2440 DVD. I`m using a
3.12 version, made on Buildroot.

Then I can't compile this ADC driver code (attached), provided on Friendly
arm DVD too. I believe that it's happening because I'm using another
version of kernel linux. Am I right?

So, There are any way to compile this code? or I must make my own ADC
driver? 

I need to read ADC (AIN0).

davef
I wouldn't expect the ADC driver to change for different kernel versions.

What do you mean it won't compile?  Show us the errors.  Which toolchain
are you using?

Are you aware that you have to do a lot of patching to get the mini2440 to
work with the mainline kernel?

Search <buserror> on Google and maybe even here.

Are you just starting out on this adventure?

Ezequiel Netto
Thanks again for reply.

Yeah, I`m just starting out on this adventure :). And I have been learned
in last days about it. So I will try to be more clear:

I`m using the Micro2440. I have used the Buildroot to build my 3.12 kernel,
and it`s run up ok. But I cant read the AIN(0~7), because I dont have the
drive. So I tried two solutions found here on FriendlyArm forum:

1. I dont have the ADC drive: /dev/adc. Then I`m trying to create it using
the file mini2440_adc.c (attached in last message). But I got error when I
try to compile it by the Buildroot "make"(I included the "s3c24xx-adc.h"
file): 

"drivers/char/mini2440_adc.c:41:1: warning: data definition has no type or
storage class [enabled by default]
drivers/char/mini2440_adc.c:41:1: warning: type defaults to ‘int’ in
declaration of ‘DECLARE_MUTEX’ [-Wimplicit-int]
drivers/char/mini2440_adc.c:41:1: warning: parameter names (without types)
in function declaration [enabled by default]
drivers/char/mini2440_adc.c: In function ‘adcdone_int_handler’:
drivers/char/mini2440_adc.c:77:3: error: ‘TASK_INTERRUPTIBLE’ undeclared
(first use in this function)
drivers/char/mini2440_adc.c:77:3: note: each undeclared identifier is
reported only once for each function it appears in
drivers/char/mini2440_adc.c: In function ‘s3c2410_adc_read’:
drivers/char/mini2440_adc.c:88:20: error: ‘ADC_LOCK’ undeclared (first use
in this function)
drivers/char/mini2440_adc.c:91:3: error: ‘TASK_INTERRUPTIBLE’ undeclared
(first use in this function)
drivers/char/mini2440_adc.c:91:3: error: implicit declaration of function
‘signal_pending’ [-Werror=implicit-function-declaration]
drivers/char/mini2440_adc.c:91:3: error: implicit declaration of function
‘schedule’ [-Werror=implicit-function-declaration]
drivers/char/mini2440_adc.c: At top level:
drivers/char/mini2440_adc.c:193:1: error: ‘ADC_LOCK’ undeclared here (not
in a function)
"

2. I cannot see /sys/devices/platform/s3c24xx-adc/s3c-hwmon/ on my
mini2440. Here is what I find:

/sys/devices/platform/s3c24xx-adc/
driver/      modalias     power/   s3c2440-ts/  subsystem/   uevent

I`ve tried to configure the Buildroot to generate it, checking all of this:

CONFIG_S3C_ADC=y
CONFIG_S3C_DEV_HWMON=y
CONFIG_HWMON=y
CONFIG_SENSORS_S3C=y
CONFIG_SENSORS_S3C_RAW=y

But Still the ".../s3c-hwmon/" folder didn`t was created =/.

So, What I am missing here? I`m on the right way?

davef
All warnings and errors ... I would check that all the #included files are
actually on your system and where they are expected, especially:

#include "s3c24xx-adc.h"

davef
Just confirmed on my 3.7 kernel version using the mini2440 BSP from
Pengutronix has all those entries.  I have 3.12 on the computer at home, so
can't check if things have changed.

Just checking ... which processor is on your micro2440?

If your "adventure" is a learning experience stay with Buildroot, I am sure
you will get there in the end.  If you just want to get something working
on the platform I would suggest looking through the Pengutronix info.

The mini2440 series is not supported in mainline.  Have you got access to
all the patches that need to be applied?

Ezequiel Netto
Updating... 

My micro2440`s processor is s3c2440

I already solve the "mini2440_adc.c" errors on compile, and "make" was just
fine. But the "/dev/adc" was not created.

I do not have the option to change from Buildroot.

What do you mean by "The mini2440 series isn`t supported in mainline"?

Ezequiel Netto
Attachment: mini2440_adc.c (4.27 KB)
My updated ADC driver for 3.12 kernel that was compiled, with no errors.

davef
OK on the uP.  Sorry, it is the mini2541 that is the current replacement
for the mini2440 and that has a S3C2541 in it.

The mainline kernel (kernel.org) may have a defconfig for the mini2440 but
as I recall many things didn't work in it.  Maybe that situation changed as
I haven't been keeping my eye on progress in the area.

I have been using the Pengutronix BSP for 3-4 years now and someone
maintains that for me :)

I don't have a /dev/adc
 
What happened to your:

/sys/devices/ problem?

davef
Are you using udev?  Look in /lib

Ezequiel Netto
Yes, I`m using udev:

# ls /lib
ld-uClibc-0.9.33.2.so   libgcc_s.so.1           librt.so.0
ld-uClibc.so.0          libm-0.9.33.2.so        libuClibc-0.9.33.2.so
libblkid.so.1           libm.so.0               libudev.so.0
libblkid.so.1.1.0       libnsl-0.9.33.2.so      libudev.so.0.13.1
libc.so.0               libnsl.so.0             libutil-0.9.33.2.so
libcrypt-0.9.33.2.so    libpthread-0.9.33.2.so  libutil.so.0
libcrypt.so.0           libpthread.so.0         libuuid.so.1
libdl-0.9.33.2.so       libresolv-0.9.33.2.so   libuuid.so.1.3.0
libdl.so.0              libresolv.so.0          modules
libgcc_s.so             librt-0.9.33.2.so       udev

About my "/sys/devices/" problem, I still cant see the "s3c-hwmon" folder:

# ls /sys/devices/platform/s3c24xx-adc/
driver      modalias    power       s3c2440-ts  subsystem   uevent

davef
In your kernel configuration have you got TOUCHSCREEN_S3C2410 = y  ?

Look in:

Device drivers
-> Input device support 
  -> Generic input layer (Input = [y])
    -> Touchscreens (INPUT_TOUCHSCREEN = [y])

Ezequiel Netto
Yeah, it`s already checked.

davef
Ah, just remembered ... have you got

VT_CONSOLE [y] 

I think it either drags in the following or might be required:

FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
FRAMEBUFFER_CONSOLE
SERIAL_SAMSUNG_CONSOLE
HW_CONSOLE
CONSOLE_TRANSLATIONS
DUMMY_CONSOLE
SERIAL_CORE_CONSOLE

Ezequiel Netto
Yeah, all of them are checked too.

davef
Well, I have just about run out of suggestions. Maybe, read through the ADC
section in 

OSELAS.BSP-Pengutronix-Mini2440-Quickstart.pdf 

at

http://www.pengutronix.de/oselas/bsp/pengutronix/mini2440_bsp_en.html

Ezequiel Netto
And I am grateful for your help =]

Do you know anything about "modify the Mini2440 platform file in the kernel
to register the "s3c_device_hwmon" device at run-time"?
this might be my problem.

davef
Kernel modules can either be compiled in, that is when you do [y] or sit
waiting for you to insert them at run time [m].

To see which ones are [m] invoke the command:

lsmod (to list them)

Modules are inserted with the insmod command and removed by the rmmod
command.

You also want to read about <modprobe>.  I think it is another way of
inserting and removing modules.

I have done one example kernel module, so I don't know much more than that.