FS_S5PC100触摸屏驱动移植
作者:曹忠明,华清远见嵌入式学院讲师。
触摸屏是现在消费电子主流的人机交互接口,这里我们针对FS_S5PC100来驱动一下触摸屏。
说明: “$”表示是在主机上执行,“#”表示在目标板执行
【环境】
1、 主机:Ubuntu 10.10发行版
        2、 目标机:FS_S5PC100平台
        3、 交叉编译工具:arm-none-linux-gnueabi-4.5.1
【步骤】
1、 修改driver/input/touchscreen/Kconfig
修改:
config TOUCHSCREEN_S3C2410
        tristate "Samsung S3C2410/generic touchscreen input driver"
        depends on ARCH_S3C2410 || SAMSUNG_DEV_TS
        select S3C_ADC
为:
config TOUCHSCREEN_S3C2410
        tristate "Samsung S3C2410/generic touchscreen input driver"
        depends on ARCH_S3C2410 || SAMSUNG_DEV_TS || ARCH_S5PC100
        select S3C_ADC
2、 修改arch/arm/mach-s5pc100/include/mach/map.h
添加如下内容:
#define SAMSUNG_PA_ADC (0xF3000000)
3、 修改arch/arm/plat-samsung/Kconfig
修改:
config SAMSUNG_DEV_ADC
        bool
        help
                Compile in platform device definition for ADC controller
        config SAMSUNG_DEV_TS
        bool
        help
                Common in platform device definitions for touchscreen device
为:
config SAMSUNG_DEV_ADC
        bool
        default y
        help
                Compile in platform device definition for ADC controller
        config SAMSUNG_DEV_TS
        bool
        default y
        help
                Common in platform device definitions for touchscreen device
4、 修改arch/arm/plat-samsung/adc.c
修改:
staticstructplatform_device_id s3c_adc_driver_ids[] = {
        {
        .name = "s3c24xx-adc",
        .driver_data = TYPE_S3C24XX,
        }, {
        .name = "s3c64xx-adc",
        .driver_data = TYPE_S3C64XX,
        },
        {}
        };
为:
staticstructplatform_device_id s3c_adc_driver_ids[] = {
        {
        .name = "s3c24xx-adc",
        .driver_data = TYPE_S3C24XX,
        }, {
        .name = "s3c64xx-adc",
        .driver_data = TYPE_S3C64XX,
        },{
        .name = "samsung-adc"
        .driver_data = TYPE_S3C64XX,
        },
        {}
        };
5、 修改driver/input/touchscreen/s3c2410_ts.c
在:
input_report_key(ts.input, BTN_TOUCH, 1);
下添加:
input_report_abs(ts.input, ABS_PRESSURE, 1);
在:
input_report_key(ts.input, BTN_TOUCH, 0);
下添加:
input_report_abs(ts.input, ABS_PRESSURE, 0);
在:
input_set_abs_params(ts.input, ABS_Y, 0, 0x3FF, 0, 0);
下添加:
input_set_abs_params(ts.input, ABS_PRESSURE, 0, 1, 0, 0);
6、 修改arch/arm/mach-s5pc100/mach-smdkc100.c
添加头文件:
#if defined(CONFIG_TOUCHSCREEN_S3C2410)
        #include <plat/ts.h>
        #endif
添加平台数据:
#if defined(CONFIG_TOUCHSCREEN_S3C2410)
        staticstruct s3c2410_ts_mach_info s5pc100_ts_cfg __initdata = {
                .delay = 20000,
                .presc = 49,
                .oversampling_shift = 2,
        };
        #endif
添加平台设备:
在结构体数组:
staticstructplatform_device *smdkc100_devices[] __initdata = {
                ……
                ……
         };
中添加如下内容:
#if defined(CONFIG_TOUCHSCREEN_S3C2410)
                &s3c_device_adc,
                &s3c_device_ts,
        #endif
在函数:
static void __init smdkc100_machine_init(void)
        {
                ……
        }
中添加如下内容:
#if defined(CONFIG_TOUCHSCREEN_S3C2410)
                s3c24xx_ts_set_platdata(&s5pc100_ts_cfg);
        #endif
7、 配置内核
$ make menuconfig
        Device Drivers --->
                Input device support --->
                        <*> Event interface
                        [*] Touchscreens --->
                                <*> Samsung S3C2410/generic touchscreen input driver
8、 编译内核并拷贝到tftpboot下
$ make zImage
        $ cp arch/arm/boot/zImage /tftpboo