第三章第九节 LCD触摸移植 打开mach-ok6410.c: zhuzhaoqi@zhuzhaoqi-desktop:~/Linux/linux-3.8.3/arch/arm/mach-s3c64xx$ vim mach-ok6410.c 在mach-ok6410.c中添加ts.h头文件: #include 将dev-ts.c文件拷贝至/linux-3.8.3/arch/arm/mach-s3c64xx/目录下: zhuzhaoqi@zhuzhaoqi-desktop:~/Linux/linux-3.8.3/arch/arm/mach-s3c64xx$ ll dev-ts.c -rwxr-xr-x 1 zhuzhaoqi zhuzhaoqi 1552 2013-04-14 00:14 dev-ts.c* 同时在dev-ts.c文件中添加: #include 将ts.h文件拷贝至/linux-3.8.3/arch/arm/mach-s3c64xx/include/mach目录下: zhuzhaoqi@zhuzhaoqi-desktop:~/Linux/linux-3.8.3/arch/arm/mach-s3c64xx/include/mach$ ll ts.h -rwxr-xr-x 1 zhuzhaoqi zhuzhaoqi 916 2013-04-14 00:15 ts.h* 在/linux-3.8.3/arch/arm/mach-s3c64xx/目录下的Makefile文件中添加: obj-$(CONFIG_TOUCHSCREEN_S3C) += dev-ts.o 进入mach-ok6410.c文件添加触摸初始化数据: static struct s3c_ts_mach_info s3c_ts_platform __initdata = { .delay = 10000, .presc = 49, .oversampling_shift = 2, .resol_bit = 12, .s3c_adc_con = ADC_TYPE_2, }; 并且在mach-ok6410.c文件中添加初始化函数: static void __init ok6410_machine_init(void) { …… #if 0 s3c24xx_ts_set_platdata(NULL); #endif s3c_ts_set_platdata(&s3c_ts_platform); …… } 将s3c-ts.c文件拷贝至/linux-3.8.3/drivers/input/touchscreen/目录下: zhuzhaoqi@zhuzhaoqi-desktop:~/Linux/linux-3.8.3/drivers/input/touchscreen$ ls s3c-ts.c s3c-ts.c 在/linux-3.8.3/drivers/input/touchscreen/目录下的Makefile添加: obj-$(CONFIG_TOUCHSCREEN_S3C) += s3c-ts.o 在/linux-3.8.3/arch/arm/plat-samsung/include/plat/目录下添加s3c-ts.c文件所需的ADC部分控制寄存器的宏定义: /*----------------- Common definitions for S3C ----------------*/ /* The following definitions will be applied to S3C24XX, S3C64XX, S5PC1XX. */ /*-------------------------------------------------------------*/ #define S3C_ADCREG(x) (x) #define S3C_ADCCON S3C_ADCREG(0x00) #define S3C_ADCTSC S3C_ADCREG(0x04) #define S3C_ADCDLY S3C_ADCREG(0x08) #define S3C_ADCDAT0 S3C_ADCREG(0x0C) #define S3C_ADCDAT1 S3C_ADCREG(0x10) #define S3C_ADCUPDN S3C_ADCREG(0x14) #define S3C_ADCCLRINT S3C_ADCREG(0x18) #define S3C_ADCMUX S3C_ADCREG(0x1C) #define S3C_ADCCLRWK S3C_ADCREG(0x20) /* ADCCON Register Bits */ #define S3C_ADCCON_RESSEL_10BIT (0x0<<16) #define S3C_ADCCON_RESSEL_12BIT (0x1<<16) #define S3C_ADCCON_ECFLG (1<<15) #define S3C_ADCCON_PRSCEN (1<<14) #define S3C_ADCCON_PRSCVL(x) (((x)&0xFF)<<6) #define S3C_ADCCON_PRSCVLMASK (0xFF<<6) #define S3C_ADCCON_SELMUX(x) (((x)&0x7)<<3) #define S3C_ADCCON_SELMUX_1(x) (((x)&0xF)<<0) #define S3C_ADCCON_MUXMASK (0x7<<3) #define S3C_ADCCON_RESSEL_10BIT_1 (0x0<<3) #define S3C_ADCCON_RESSEL_12BIT_1 (0x1<<3) #define S3C_ADCCON_STDBM (1<<2) #define S3C_ADCCON_READ_START (1<<1) #define S3C_ADCCON_ENABLE_START (1<<0) #define S3C_ADCCON_STARTMASK (0x3<<0) /* ADCTSC Register Bits */ #define S3C_ADCTSC_UD_SEN (1<<8) #define S3C_ADCTSC_YM_SEN (1<<7) #define S3C_ADCTSC_YP_SEN (1<<6) #define S3C_ADCTSC_XM_SEN (1<<5) #define S3C_ADCTSC_XP_SEN (1<<4) #define S3C_ADCTSC_PULL_UP_DISABLE (1<<3) #define S3C_ADCTSC_AUTO_PST (1<<2) #define S3C_ADCTSC_XY_PST(x) (((x)&0x3)<<0) /* ADCDAT0 Bits */ #define S3C_ADCDAT0_UPDOWN (1<<15) #define S3C_ADCDAT0_AUTO_PST (1<<14) #define S3C_ADCDAT0_XY_PST (0x3<<12) #define S3C_ADCDAT0_XPDATA_MASK (0x03FF) #define S3C_ADCDAT0_XPDATA_MASK_12BIT (0x0FFF) /* ADCDAT1 Bits */ #define S3C_ADCDAT1_UPDOWN (1<<15) #define S3C_ADCDAT1_AUTO_PST (1<<14) #define S3C_ADCDAT1_XY_PST (0x3<<12) #define S3C_ADCDAT1_YPDATA_MASK (0x03FF) #define S3C_ADCDAT1_YPDATA_MASK_12BIT (0x0FFF) 在/Linux/linux-3.8.3/include/linux目录下的interrupt.h文件添加: #define IRQF_SAMPLE_RANDOM 0x00000040 并在/linux-3.8.3/drivers/input/touchscreen/目录下的Kconfig添加LCD触摸配置: config TOUCHSCREEN_S3C tristate "S3C touchscreen driver" depends on ARCH_S3C2410 || ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX default y help Say Y here to enable the driver for the touchscreen on the S3C SMDK board. If unsure, say N. To compile this driver as a module, choose M here: the module will be called s3c_ts. 修改完成,执行make menuconfig,进行LCD触摸配置: Device Drivers ---> Input device support ---> Touchscreens ---> <*> S3C touchscreen driver System Type ---> ADC common driver support Device Drivers ---> Input device support ---> <*> Event interface LCD的显示和触摸配置完成之后执行make uImage命令: …… LD vmlinux.o arch/arm/plat-samsung/built-in.o:(.data+0x878): multiple definition of `s3c_device_ts' arch/arm/mach-s3c64xx/built-in.o:(.data+0x34e0): first defined here …… 出现多重定义错误,则在/linux-3.8.3/arch/arm/plat-samsung目录下的devs.c注释掉s3c_device_ts即可: //--->zzq #undef CONFIG_SAMSUNG_DEV_TS //<---zzq #ifdef CONFIG_SAMSUNG_DEV_TS 如果还有错误,则可根据错误追溯源头进行修改。 zhuzhaoqi@zhuzhaoqi-desktop:~/Linux/linux-3.8.3$ make uImage …… Image Name: Linux-3.8.3 Created: Sun Apr 14 01:47:28 2013 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2156336 Bytes = 2105.80 kB = 2.06 MB Load Address: 50008000 Entry Point: 50008040 Image arch/arm/boot/uImage is ready 将生成的uImage拷贝至tftp目录下: zhuzhaoqi@zhuzhaoqi-desktop:~/Linux/linux-3.8.3/arch/arm/boot$ cp uImage /tftpboot/ 使用tftp进行烧写、调试内核。 zhuzhaoqi@zhuzhaoqi-desktop:/tftpboot$ ls uImage zhuzhaoqi@zhuzhaoqi-desktop:/tftpboot$ tftp tftp> 启动ok6410开发平台,停在U-Boot烧写内核: zzq6410 >>> tftp 0x50008000 uImage dm9000 i/o: 0x18000300, id: 0x90000a46 DM9000: running in 16 bit mode MAC: 00:40:5c:26:0a:5b operating at 100M full duplex mode Using dm9000 device TFTP from server 192.168.1.187; our IP address is 192.168.1.100 Filename 'uImage'. Load address: 0x50008000 Loading: ###################################################################################################################################################################################################################################################################################################################################################################################################################################### done Bytes transferred = 2156400 (20e770 hex) 烧写完成之后启动内核: zzq6410 >>>bootm 0x50008000 ## Booting kernel from Legacy Image at 50008000 ... Image Name: Linux-3.8.3 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2156336 Bytes = 2.1 MiB Load Address: 50008000 Entry Point: 50008040 Verifying Checksum ... OK XIP Kernel Image ... OK OK Starting kernel ... Starting kernel ... Uncompressing Linux... done, booting the kernel. …… S3C_LCD clock got enabled :: 133.250 Mhz LCD TYPE :: LTE480WV will be initialized …… S3C Touchscreen driver, (c) 2008 Samsung Electronics S3C TouchScreen got loaded successfully : 12 bits input: S3C TouchScreen as /devices/virtual/input/input0 …… 从串口的信息输出可知LCD的显示和触摸驱动成功。
|