Linux2.6内核TouchScreen驱动移植(已测试)

在 linux2.6.14.1 中没有提供 s3c2410 的驱动,所以我们要新建驱动文件,从网上下载s3c2410_ts.c与s3c2410_ts.h两个文件,将s3c2410_ts.c 文件拷到 linux2.6.14.1/drivers/input/touchscreen 目录下,头文件则拷到源码包的include/asm/arch下,
   首先:我们需要修改 linux2.6.14/drivers/input/touchscreen 目录下的 makefile 文件,在文件的最后添加 :

obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o

第二:我们需要修改 linux2.6.14/ drivers/input/touchscreen/Kconfig 中添加:

     config TOUCHSCREEN_S3C2410

     tristate "Samsung S3C2410 touchscreen input driver"

     depends on ARCH_SMDK2410 && INPUT && INPUT_TOUCHSCREEN

     select SERIO

     help

     Say Y here if you have the s3c2410 touchscreen.

     If unsure, say N.

     To compile this driver as a module, choose M here: the

     module will be called s3c2410_ts.

    

config TOUCHSCREEN_S3C2410_DEBUG

     boolean "Samsung S3C2410 touchscreen debug messages"

     depends on TOUCHSCREEN_S3C2410

     help

     Select this if you want debug messages

修改完成以后,在我们配置内核的时候,就会增加关系s3c2410的触摸屏配置,我们选择上这些配置就可以把驱动增加进去了

Device drivers -->

          Input device support -->

                     Touchscreens -->

                      <*>Samsung S3C2410 touchscreen input driver

                      []Samsung s3c2410 touchscreen debug message

第三:在 /linux-2.6.14/arch/arm/mach-s3c2410/mach-smdk2410.c, 中增加如下内容:

#include

     static struct s3c2410_ts_mach_info s3c2410_ts_cfg __initdata = {

     .delay = 10000,

     //.divsc = 49, 原文有问题

    .presc = 49, //编译成功

     .oversampling_shift = 2,

     };

     在smdk2410_devices结构中,添加:

     &s3c_device_ts,

     在smdk2410_map_io函数中添加:

     set_s3c2410ts_info(&s3c2410_ts_cfg);

第四:在 /linux-2.6.14/ arch/arm/mach-s3c2410/devs.h 文件中添加:

     extern struct platform_device s3c_device_ts;

第五:在arch/arm/mach-s3c2410/devs.c文件中添加如下几行:

    /* Touchscreen */

#include

    static struct s3c2410_ts_mach_info s3c2410ts_info;

    void __init set_s3c2410ts_info(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
{

memcpy(&s3c2410ts_info,hard_s3c2410ts_info,sizeof(struct s3c2410_ts_mach_info));

}

EXPORT_SYMBOL(set_s3c2410ts_info);

struct platform_device s3c_device_ts = {

.name = "s3c2410-ts",

.id = -1,

.dev = {

.platform_data = &s3c2410ts_info,

}

};

EXPORT_SYMBOL(s3c_device_ts);


以上是参考网上的文章的,但仅此还不够,编译内核会出错,出错信息如下:
[arm@localhost linux-2.6.14.1]$ make zImage
  CHK     include/linux/version.h
make[1]: `include/asm-arm/mach-types.h' is up to date.
  CHK     include/linux/compile.h
  CHK     usr/initramfs_list
  CC      drivers/input/touchscreen/s3c2410_ts.o
drivers/input/touchscreen/s3c2410_ts.c: In function `touch_timer_fire':
drivers/input/touchscreen/s3c2410_ts.c:137: error: called object is not a function
drivers/input/touchscreen/s3c2410_ts.c:146: error: called object is not a function
drivers/input/touchscreen/s3c2410_ts.c: In function `stylus_action':
drivers/input/touchscreen/s3c2410_ts.c:189: error: called object is not a function
drivers/input/touchscreen/s3c2410_ts.c:193: error: called object is not a function
drivers/input/touchscreen/s3c2410_ts.c: In function `s3c2410ts_probe':
drivers/input/touchscreen/s3c2410_ts.c:254: error: called object is not a function
drivers/input/touchscreen/s3c2410_ts.c: In function `touch_timer_fire':
drivers/input/touchscreen/s3c2410_ts.c:137: warning: statement with no effect
drivers/input/touchscreen/s3c2410_ts.c:146: warning: statement with no effect
drivers/input/touchscreen/s3c2410_ts.c: In function `stylus_action':
drivers/input/touchscreen/s3c2410_ts.c:189: warning: statement with no effect
drivers/input/touchscreen/s3c2410_ts.c:193: warning: statement with no effect
drivers/input/touchscreen/s3c2410_ts.c: In function `s3c2410ts_probe':
drivers/input/touchscreen/s3c2410_ts.c:254: warning: statement with no effect
make[3]: *** [drivers/input/touchscreen/s3c2410_ts.o] Error 1
make[2]: *** [drivers/input/touchscreen] Error 2
make[1]: *** [drivers/input] Error 2
make: *** [drivers] Error 2
在 网上搜也找不到解决方法,后来又搜到了一篇触摸屏驱动移植的文章,里面有说要新建regs-adc.h这个头文件的(言下之意他的linux2.6里没有 这个),但我的里面有这个文件,经过对比,发现这个头文件里的一句:#define S3C2410_ADCTSC_XY_PST(x) (((x)&0x3)<<0),而我的2.6里自带的是#define S3C2410_ADCTSC_XY_PST (0x3<<0),改过之后,终于通过了,进入控制台后可以触摸了,并且可以看到这个触摸屏驱动在内核注册为 /dev/input/mouse0

你可能感兴趣的:(VC)