分类: LINUX
2013-01-31 23:26:29
触摸屏驱动也是参考这篇文章:http://www.cnblogs.com/zuobaozhu/archive/2012/05/13/2498092.html#_Toc324535492 所以以下#####################内的文字纯属复制这位网友的,当然编译时有些小错误,不过都是很容易解决的,本人打字慢,就不提了。 ##################################################
以下copy 是指需要飞凌提供的内核里的驱动源码, dev-ts.c ts 板载初始化和platform 资源初始化 文件。
arch/arm/mach-s3c64xx/mach-smdk6410.c
注销掉头文件 #include
添加头文件 #include
copy arch/arm/mach-s3c64xx/include/mach/ts.h 到目标内核目录
copy arch/arm/mach-s3c64xx/dev-ts.c 到目标内核目录在 arch/arm/mach-s3c64xx/Makefile 中添加
obj-$(CONFIG_TOUCHSCREEN_S3C) += dev-ts.o
在里面 添加宏定义arch/arm/mach-s3c64xx/dev-ts.c
#define SZ_256 0x00000100
添加头文件#include
添加 ts 设备初始化 ,在smdk6410_machine_init () 结构体中
//s3c24xx_ts_set_platdata(NULL);
s3c_ts_set_platdata(&s3c_ts_platform);
添加结构体s3c_ts_platform
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,
};
把飞凌官方的s3c-tc.c拷贝到drivers/input/touchscreen/这里建议拷贝他3.0的系统的
修改 drivers/input/touchscreen/Makefile
添加 obj-$(CONFIG_TOUCHSCREEN_S3C) += s3c-ts.o
修改 drivers/input/tourch/screen/Kconfig
添加 config TOUCHSCREEN_S3C
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.
注释掉arch/arm/plat-samsung/devs.c里面大概1223到1277行的如下代码:
/* Touchscreen */
//#ifdef CONFIG_PLAT_S3C24XX
/*static struct resource s3c_ts_resource[] = {
[0] = DEFINE_RES_MEM(S3C24XX_PA_ADC, S3C24XX_SZ_ADC),
[1] = DEFINE_RES_IRQ(IRQ_TC),
};
struct platform_device s3c_device_ts = {
.name = "s3c2410-ts",
.id = -1,
.dev.parent = &s3c_device_adc.dev,
.num_resources = ARRAY_SIZE(s3c_ts_resource),
.resource = s3c_ts_resource,
};
void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
{
s3c_set_platdata(hard_s3c2410ts_info,
sizeof(struct s3c2410_ts_mach_info), &s3c_device_ts);
}
*/
//#endif /* CONFIG_PLAT_S3C24XX */
/*#ifdef CONFIG_SAMSUNG_DEV_TS
static struct resource s3c_ts_resource[] = {
[0] = DEFINE_RES_MEM(SAMSUNG_PA_ADC, SZ_256),
[1] = DEFINE_RES_IRQ(IRQ_TC),
};
*/
/*static struct s3c2410_ts_mach_info default_ts_data __initdata = {
.delay = 10000,
.presc = 49,
.oversampling_shift = 2,
};
struct platform_device s3c_device_ts = {
.name = "s3c64xx-ts",
.id = -1,
.num_resources = ARRAY_SIZE(s3c_ts_resource),
.resource = s3c_ts_resource,
};
void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *pd)
{
if (!pd)
pd = &default_ts_data;
s3c_set_platdata(pd, sizeof(struct s3c2410_ts_mach_info),
&s3c_device_ts);
}
*/
//#endif /* CONFIG_SAMSUNG_DEV_TS */
在arch/arm/ plat-samsung/include/plat/regs-adc.h的后面添加以下代码:
#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)
#endif /* __ASM_ARCH_REGS_ADC_H */
配置内核:
System Type --->
[*] ADC common driver support
Device Drivers --->
Input device support --->
[*] Touchscreens --->
<*> S3C touchscreen driver (只选这一个,其他的不要选)
<*> Event interface
如果触摸屏驱动没有问题的会就会出现以下驱动信息:
S3C Touchscreen driver, (c) 2008 Samsung Electronics
S3C TouchScreen got loaded successfully : 12 bits
input: S3C TouchScreen as /devices/virtual/input/input0
#################################################
按照这位网友的操作移植后开机出现:
S3C Touchscreen driver, (c) 2008 Samsung Electronics
s3c-ts s3c-ts: s3c_ts.c: Could not allocate ts IRQ_ADC !
s3c-ts: probe of s3c-ts failed with error -5
TS申请不到IRQ,被adc资源占用了。
于是,找到arch/arm/plat-samsung/adc.c
ret = request_irq(adc->irq, s3c_adc_irq, 0, dev_name(dev), adc);改为:
ret = request_irq(adc->irq, s3c_adc_irq, IRQF_SHARED, dev_name(dev), adc);//zxd
重新编译启动后显示:
S3C Touchscreen driver, (c) 2008 Samsung Electronics
S3C TouchScreen got loaded successfully : 12 bits
input: S3C TouchScreen as /devices/virtual/input/input0
但是点击触摸屏的时候又会出现:
s3c_adc:s3c64xx_adc_irq:s3c-adc-irq:no adc pending的问题。
重新改回ret = request_irq(adc->irq, s3c_adc_irq, 0, dev_name(dev), adc);
配置内核,取消
System Type --->
[ ] ADC common driver support
再编译下载,解决上面的问题。