主题 : linux-2.6.38到tiny6410的移植手册(连载3)__ LCD&触摸屏 复制链接 | 浏览器收藏 | 打印
一路走好,下辈子再也不做程序员
级别: 侠客
UID: 32071
精华: 6
发帖: 38
金钱: 490 两
威望: 98 点
贡献值: 6 点
综合积分: 196 分
注册时间: 2010-11-09
最后登录: 2019-10-18
楼主  发表于: 2011-07-31 21:45

 linux-2.6.38到tiny6410的移植手册(连载3)__ LCD&触摸屏

管理提醒: 本帖被 xoom 执行加亮操作(2011-08-11)
linux-2.6.38到tiny6410的移植手册(连载1)__nand flash
http://www.aiothome.net/read.php?tid-14196-fpage-2.html

linux-2.6.38到tiny6410的移植手册(连载2)__网卡&NF
http://www.aiothome.net/read.php?tid-14211.html

linux-2.6.38到tiny6410的移植手册(连载3)__ LCD&触摸屏
http://www.aiothome.net/read.php?tid=14261

linux-2.6.38到tiny6410的移植手册(连载4)__USB设备
http://www.aiothome.net/read.php?tid=14462

这次lcd和触摸屏智能一起移植了,至于原因明天在开一贴详细说明,http://www.aiothome.net/read.php?tid-14273.html
主要是一线触摸的原因,它劫持了lcd的背光控制,这个花了我三天时间呀才发现, 友善真是的。。。。

先弄lcd屏吧

vi arch/arm/plat-samsung/include/plat/map-base.h
第39行
增加
#define S3C_VA_LCD     S3C_ADDR(0x01100000)    /* LCD */

从友善的源码中将arch/arm/mach-s3c64xx/include/mach/regs-lcd.h拷贝过来

从友善的源码中将drivers/video/samsung整个文件夹拷贝过来,是不是有点拿来主义,呵呵

vi drivers/video/Kconfig
第2068行增加
source "drivers/video/samsung/Kconfig"

vi drivers/video/Makefile
120行增加
obj-$(CONFIG_FB_S3C_EXT)      += samsung/

vi arch/arm/mach-s3c64xx/mach-mini6410.c
48行增加
#include <linux/delay.h>

136行mini6410_lcd_power_set函数里的内容改成
        if (power) {
                gpio_direction_output(S3C64XX_GPF(13), 1);          //GPF13是USBpower用的,与lcd无关
                gpio_direction_output(S3C64XX_GPF(15), 1);          //GPF15是是真正的一线控制线连PWM1

                /* fire nRESET on power up */
                gpio_direction_output(S3C64XX_GPN(5), 0);          //GPN5好像与lcd也无关,先copy吧
                msleep(10);
                gpio_direction_output(S3C64XX_GPN(5), 1);
                msleep(1);
        } else {
                gpio_direction_output(S3C64XX_GPF(15), 0);
                gpio_direction_output(S3C64XX_GPF(13), 0);
        }
190行
增加
   {
                /* LCD support */
                .virtual    = (unsigned long)S3C_VA_LCD,
                .pfn        = __phys_to_pfn(S3C_PA_FB),
                .length     = SZ_16K,
                .type       = MT_DEVICE,
        },
437行增加
    gpio_request(S3C64XX_GPN(5), "LCD power");

    gpio_request(S3C64XX_GPF(13), "LCD power");

去掉gpio_request(S3C64XX_GPE(0), "LCD power");

make menuconfig
  Power management options  --->
    [ ] Power Management support   一定要去掉,不然会有
drivers/video/samsung/s3cfb_fimd4x.c:1440:2: error: implicit declaration of function 's3c6410_pm_do_save'的错误,郁闷了半天

<*> Support for frame buffer devices  --->  
     < >   Samsung S3C framebuffer support                              
        <*>   S3C Framebuffer Support (eXtended)                          
                Select LCD Type (4.3 inch 480x272 TFT LCD)  --->        
        <*>   Advanced options for S3C Framebuffer                      
                Select BPP(Bits Per Pixel) (16 BPP)  --->              
        (4)   Number of Framebuffers                                
        [ ]       Enable Virtual Screen (NEW)                            
        [*]       Enable Double Buffering                  
  [ ] Backlight & LCD device support  --->

  Console display driver support  --->
    <*> Framebuffer Console support    这个也一定要选,不然会有
drivers/built-in.o:(.data+0x174): undefined reference to `soft_cursor'的错误,其中解决这些错误花了我不少时间。
  
  [*] Bootup logo  --->                                                
      [ ]   Standard black and white Linux logo                        
      [ ]   Standard 16-color Linux logo                                
      [*]   Standard 224-color Linux logo
其他的默认就行

这时lcd的驱动其实已经移植好了,引导信息也正常,如
S3C_LCD clock got enabled :: 133.000 Mhz
LCD TYPE :: N43 will be initialized
Window[0] - FB1: map_video_memory: clear ff600000:0007f800
            FB1: map_video_memory: dma=5d780000 cpu=ff600000 size=0007f800
Window[0] - FB2: map_video_memory: clear ff63fc00:0003fc00
            FB2: map_video_memory: dma=5d7bfc00 cpu=ff63fc00 size=0003fc00
Console: switching to colour frame buffer device 60x34
fb0: s3cfb frame buffer device
Window[1] - FB1: map_video_memory: clear ff680000:0007f800
            FB1: map_video_memory: dma=5cc00000 cpu=ff680000 size=0007f800
Window[1] - FB2: map_video_memory: clear ff6bfc00:0003fc00
            FB2: map_video_memory: dma=5cc3fc00 cpu=ff6bfc00 size=0003fc00
fb1: s3cfb frame buffer device
Window[2] - FB1: map_video_memory: clear ff700000:0003fc00
            FB1: map_video_memory: dma=5d740000 cpu=ff700000 size=0003fc00
fb2: s3cfb frame buffer device
Window[3] - FB1: map_video_memory: clear ff740000:0003fc00
            FB1: map_video_memory: dma=5cc80000 cpu=ff740000 size=0003fc00
fb3: s3cfb frame buffer device

但lcd屏却没有反应,百思不得其解。后来终于发现了,过程明天在说
先做一线触摸的驱动

拷贝
arch/arm/mach-s3c64xx/dev-ts-mini6410.c
arch/arm/mach-s3c64xx/include/mach/ts.h
arch/arm/plat-samsung/include/plat/regs-adc.h
drivers/input/touchscreen/mini6410_1wire_host.c
drivers/input/touchscreen/mini6410-ts.c
drivers/input/touchscreen/ts-if.c
到相应目录

vi arch/arm/mach-s3c64xx/Makefile
末尾增加
obj-$(CONFIG_TOUCHSCREEN_MINI6410)  += dev-ts-mini6410.o

vi drivers/input/touchscreen/Makefile
末尾加入
obj-$(CONFIG_TOUCHSCREEN_MINI6410)    += mini6410-ts.o
obj-$(CONFIG_TOUCHSCREEN_1WIRE)        += mini6410_1wire_host.o
obj-$(CONFIG_FB_S3C_EXT_TFT800480)    += ts-if.o
obj-$(CONFIG_FB_S3C_EXT_TFT480272)    += ts-if.o
obj-$(CONFIG_FB_S3C_EXT_X240320)    += ts-if.o

vi drivers/input/touchscreen/Kconfig
190行左右加入
config TOUCHSCREEN_MINI6410
        tristate "S3C touchscreen driver for Mini6410"
        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
          FriendlyARM Mini6410 development board.

          If unsure, say N.

          To compile this driver as a module, choose M here: the
          module will be called mini6410-ts.

config TOUCHSCREEN_1WIRE
        tristate "Mini6410 1-Wire host and Touch Screen Driver"
        depends on MACH_MINI6410
        help
          Say Y here to enable the 1-Wire host and Touch Screen driver for
          FriendlyARM Mini6410 development board.

          If unsure, say N.

          To compile this driver as a module, choose M here: the
          module will be called mini6410_1wire_host.




vi arch/arm/mach-s3c64xx/mach-mini6410.c
44行 将#include <plat/ts.h>
   改成#include <mach/ts.h>

320行将
static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
        .delay                  = 10000,
        .presc                  = 49,
        .oversampling_shift     = 2,
};
改成
static struct s3c_ts_mach_info s3c_ts_platform __initdata = {
        .delay                  = 0xFFFF,
        .presc                  = 0xFF,
        .oversampling_shift     = 2,
        .resol_bit              = 12,
        .s3c_adc_con    = ADC_TYPE_2,
};

436行将
s3c24xx_ts_set_platdata(&s3c_ts_platform);
改成 s3c_ts_set_platdata(&s3c_ts_platform);

vi arch/arm/plat-samsung/Makefile
60行
注释掉obj-$(CONFIG_SAMSUNG_DEV_TS)   += dev-ts.o
不然会有multiple definition of `s3c_device_ts'的错误很奇怪,友善的源码CONFIG_SAMSUNG_DEV_TS=n,而我的源码出来后CONFIG_SAMSUNG_DEV_TS=y,还改不掉。。

vi drivers/input/touchscreen/mini6410-ts.c
增加头文件#include<linux/sched.h>  奇怪的是友善的mini6410-ts.c
里没这个头文件也能找到需要的东西。。。

   Input device support  --->
        [*]   Touchscreens  --->  
              <*>   S3C touchscreen driver for Mini6410          
                <*>   Mini6410 1-Wire host and Touch Screen Driver

lcd好用了,开机出现了那只小企鹅,挂NFS后触摸屏也能用了。
[ 此帖被prettybxp在2011-08-09 23:11重新编辑 ]
一路走好,下辈子再也不做程序员