LCD driver

LCD 驱动的主要文件为:driver/video/samsung/下的s3c_mini6410.c   s3c_mini6410.h  s3cfb.c  s3cfb.h  s3cfb_fimd4x.c,s3cfb_fimd4x.h

arch/arm/mach-s3c64xx/include/mach/s3cfb.h,

arch/arm/plat-samsung/dev-fb.c(inux-2.6.36-android\arch\arm\plat-samsung\include\plat\fb.h s3c_fb_set_platdata(&mini6410_lcd_pdata); )

\linux-2.6.36-android\drivers\video\fbmem.c 这个文件比较的重要,其中在sys/class/下创建节点 graphics  ,由class_create()创建;在dev/目录下创建节点 graphics,由device_create()创建。

s3c_mini6410.h中的这些东西比较的有用,是根据LCD的数据手册和三星的主控的数据手册得来的

#define S3CFB_LCD_TYPE "H43"                    
#define S3CFB_VBP  (0x08) /* back porch */
#define S3CFB_VFP  (0x08) /* front porch */
#define S3CFB_VSW  (0x01) /* vsync width */
#define S3CFB_HBP  (0x28) /* back porch */
#define S3CFB_HFP  (0x05) /* front porch */
#define S3CFB_HSW  (0x01) /* hsync width */

#define S3CFB_HRES  480  /* horizon pixel  x resolition */
#define S3CFB_VRES  272  /* line cnt       y resolution */

#define S3CFB_CLKVAL  13    //三星手册计算而来
#define S3CFB_VIDCON1 (S3C_VIDCON1_IHSYNC_INVERT | S3C_VIDCON1_IVSYNC_INVERT)

 

串口打印有关LCD的信息:

S3C_LCD clock got enabled :: 133.000 Mhz
LCD TYPE :: Mini6410 will be initialized
Window[0] - FB1: map_video_memory: clear ff000000:0007f800
            FB1: map_video_memory: dma=5d780000 cpu=ff000000 size=0007f800
Window[0] - FB2: map_video_memory: clear ff03fc00:0003fc00
            FB2: map_video_memory: dma=5d7bfc00 cpu=ff03fc00 size=0003fc00
Console: switching to colour frame buffer device 60x34
fb0: s3cfb frame buffer device
Window[1] - FB1: map_video_memory: clear ff080000:0007f800
            FB1: map_video_memory: dma=5cc00000 cpu=ff080000 size=0007f800
Window[1] - FB2: map_video_memory: clear ff0bfc00:0003fc00
            FB2: map_video_memory: dma=5cc3fc00 cpu=ff0bfc00 size=0003fc00
fb1: s3cfb frame buffer device
Window[2] - FB1: map_video_memory: clear ff100000:0003fc00
            FB1: map_video_memory: dma=5d740000 cpu=ff100000 size=0003fc00
fb2: s3cfb frame buffer device
Window[3] - FB1: map_video_memory: clear ff140000:0003fc00
            FB1: map_video_memory: dma=5cc80000 cpu=ff140000 size=0003fc00
fb3: s3cfb frame buffer device
根据打印信息,内核依次加载的顺序为:

1、s3cfb.c 

int __devinit s3cfb_init(void)
{
return platform_driver_register(&s3cfb_driver);
}


2、s3c_mini6410.c 

 s3cfb_init_hw();这个函数被s3cfb.c 这个文件调用。


3、s3cfb_fimd4x.c

根据这种追踪,就可以很好地理解内核加载LCD驱动的全过程,掌握驱动的写法。

 

下面是网友的移植过程,我也参考了这个:

这次lcd和触摸屏智能一起移植了,主要是一线触摸的原因,它劫持了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                             // s3cfb.c编译执行的打印信息
LCD TYPE :: N43 will be initialized                                             //s3c_mini6410.c编译执行的打印信息

  // 一下均为s3cfb.c编译执行的打印信息

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后触摸屏也能用了。

 

PS:lcd驱动包含 三星控制器和驱动IC两个驱动 


总结:

有关LCD platform device 注册的过程在mach-mini6410.c 这个文件中完成,回调用arch/arm/plat-samsung/dev-fb.c这个文件中函数s3c_fb_set_platdata(&mini6410_lcd_pdata);

注册函数为:platform_add_devices(mini6410_devices, ARRAY_SIZE(mini6410_devices));

加载设备驱动的时候执行s3cfb.c中的int __devinit s3cfb_init(void)。

{
return platform_driver_register(&s3cfb_driver);
}

driver的绑定是通过driver core自动完成的,完成driver和device的匹配后以后会自动执行probe()函数,如果函数执行成功,则driver和device就绑定在一起了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值