Chinaunix首页 | 论坛 | 博客
  • 博客访问: 97782
  • 博文数量: 38
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 384
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-06 16:52
文章分类

全部博文(38)

文章存档

2014年(38)

我的朋友

分类: 嵌入式

2014-04-08 20:00:03

1.修改arch/arm/mach-s3c64xx/mach-ok6410.c中关于LCD的部分程序:

点击(此处)折叠或打开

  1. static struct s3c2410_platform_nand ok6410_nand_info = {
  2.     .tacls        = 25,
  3.     .twrph0        = 55,
  4.     .twrph1        = 40,
  5.     .nr_sets    = ARRAY_SIZE(ok6410_nand_sets),
  6.     .sets        = ok6410_nand_sets,
  7. };

  8. static struct s3c_fb_pd_win ok6410_lcd_type0_fb_win = {
  9.     .max_bpp    = 32,
  10.     .default_bpp    = 16,
  11.     .xres        = 480,
  12.     .yres        = 272,
  13. };

  14. static struct fb_videomode ok6410_lcd_type0_timing = {
  15.     /* 4.3" 480x272 */
  16.     .left_margin    = 3,
  17.     .right_margin    = 5,
  18.     .upper_margin    = 3,
  19.     .lower_margin    = 3,
  20.     .hsync_len    = 42,
  21.     .vsync_len    = 12,
  22.     .xres        = 480,
  23.     .yres        = 272,
  24. };
  25. /*对于4.3寸屏 这部分没有用,所以屏蔽掉了
  26. static struct s3c_fb_pd_win ok6410_lcd_type1_fb_win = {
  27.     .max_bpp    = 32,
  28.     .default_bpp    = 16,
  29.     .xres        = 800,
  30.     .yres        = 480,
  31. };

  32. static struct fb_videomode ok6410_lcd_type1_timing = {
  33.     //7.0" 800x480
  34.     .left_margin    = 8,
  35.     .right_margin    = 13,
  36.     .upper_margin    = 7,
  37.     .lower_margin    = 5,
  38.     .hsync_len    = 3,
  39.     .vsync_len    = 1,
  40.     .xres        = 800,
  41.     .yres        = 480,
  42. };*/

  43. static struct s3c_fb_platdata ok6410_lcd_pdata[] __initdata = {
  44.     {
  45.         .setup_gpio    = s3c64xx_fb_gpio_setup_24bpp,
  46.         .vtiming    = &ok6410_lcd_type0_timing,
  47.         .win[0]        = &ok6410_lcd_type0_fb_win,
  48.         .vidcon0    = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  49.         .vidcon1    = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  50.     }, /*{
  51.         .setup_gpio    = s3c64xx_fb_gpio_setup_24bpp,
  52.         .vtiming    = &ok6410_lcd_type1_timing,
  53.         .win[0]        = &ok6410_lcd_type1_fb_win,
  54.         .vidcon0    = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  55.         .vidcon1    = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  56.     },*/
  57.     { },
  58. };

  59. static void ok6410_lcd_power_set(struct plat_lcd_data *pd,
  60.                  unsigned int power)
  61. {
  62.     /*if (power)
  63.         gpio_direction_output(S3C64XX_GPE(0), 1);
  64.     else
  65.         gpio_direction_output(S3C64XX_GPE(0), 0);*/
  66.     if (power) {
  67.             gpio_direction_output(S3C64XX_GPF(13), 1);
  68.             gpio_direction_output(S3C64XX_GPF(15), 1);

  69.             /* fire nRESET on power up */
  70.             gpio_direction_output(S3C64XX_GPN(5), 0);
  71.             //msleep(10);
  72.             gpio_direction_output(S3C64XX_GPN(5), 1);
  73.             //msleep(1);
  74.         }
  75.     else {
  76.             gpio_direction_output(S3C64XX_GPF(15), 0);
  77.             gpio_direction_output(S3C64XX_GPF(13), 0);
  78.         }
  79. }

  80. static struct plat_lcd_data ok6410_lcd_power_data = {
  81.     .set_power    = ok6410_lcd_power_set,
  82. };

  83. static struct platform_device ok6410_lcd_powerdev = {
  84.     .name            = "platform-lcd",
  85.     .dev.parent        = &s3c_device_fb.dev,
  86.     .dev.platform_data    = &ok6410_lcd_power_data,
  87. };

  88. static struct platform_device *ok6410_devices[] __initdata = {
  89.     &ok6410_device_eth,
  90.     &s3c_device_hsmmc0,
  91.     &s3c_device_hsmmc1,
  92.     &s3c_device_ohci,
  93.     &s3c_device_nand,
  94.     &s3c_device_fb,
  95.     &ok6410_lcd_powerdev,
  96.     &s3c_device_adc,
  97.     &s3c_device_ts,
  98. };

  99. static struct map_desc smdk6410_iodesc[] = {
  100.     {
  101.     /* LCD support */
  102.     .virtual = (unsigned long)S3C_VA_LCD,
  103.     .pfn = __phys_to_pfn(S3C_PA_FB),
  104.     .length = SZ_16K,
  105.     .type = MT_DEVICE,
  106.     },
  107. };

  108. static void __init ok6410_map_io(void)
  109. {
  110.     u32 tmp;

  111.     s3c64xx_init_io(smdk6410_iodesc, ARRAY_SIZE(smdk6410_iodesc));
  112.     s3c24xx_init_clocks(12000000);
  113.     s3c24xx_init_uarts(ok6410_uartcfgs, ARRAY_SIZE(ok6410_uartcfgs));

  114.     /* set the LCD type */
  115.     tmp = __raw_readl(S3C64XX_SPCON);
  116.     tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
  117.     tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
  118.     __raw_writel(tmp, S3C64XX_SPCON);

  119.     /* remove the LCD bypass */
  120.     tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
  121.     tmp &= ~MIFPCON_LCD_BYPASS;
  122.     __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
  123. }

  124. /*
  125.  * ok6410_features string
  126.  *
  127.  * 0-9 LCD configuration
  128.  *
  129.  */
  130. static char ok6410_features_str[12] __initdata = "0";

  131. static int __init ok6410_features_setup(char *str)
  132. {
  133.     if (str)
  134.         strlcpy(ok6410_features_str, str,
  135.             sizeof(ok6410_features_str));
  136.     return 1;
  137. }

  138. __setup("ok6410=", ok6410_features_setup);

  139. #define FEATURE_SCREEN (1 << 0)

  140. struct ok6410_features_t {
  141.     int done;
  142.     int lcd_index;
  143. };

  144. static void ok6410_parse_features(
  145.         struct ok6410_features_t *features,
  146.         const char *features_str)
  147. {
  148.     const char *fp = features_str;

  149.     features->done = 0;
  150.     features->lcd_index = 0;

  151.     while (*fp) {
  152.         char f = *fp++;

  153.         switch (f) {
  154.         case '0'...'9':    /* tft screen */
  155.             if (features->done & FEATURE_SCREEN) {
  156.                 printk(KERN_INFO "OK6410: '%c' ignored, "
  157.                     "screen type already set\n", f);
  158.             } else {
  159.                 int li = f - '0';
  160.                 if (li >= ARRAY_SIZE(ok6410_lcd_pdata))
  161.                     printk(KERN_INFO "OK6410: '%c' out "
  162.                         "of range LCD mode\n", f);
  163.                 else {
  164.                     features->lcd_index = li;
  165.                 }
  166.             }
  167.             features->done |= FEATURE_SCREEN;
  168.             break;
  169.         }
  170.     }
  171. }

  172. static void __init ok6410_machine_init(void)
  173. {
  174.     u32 cs1;
  175.     struct ok6410_features_t features = { 0 };

  176.     printk(KERN_INFO "OK6410: Option string ok6410=%s\n",
  177.             ok6410_features_str);

  178.     /* Parse the feature string */
  179.     ok6410_parse_features(&features, ok6410_features_str);

  180.     printk(KERN_INFO "OK6410: selected LCD display is %dx%d\n",
  181.         ok6410_lcd_pdata[features.lcd_index].win[0]->xres,
  182.         ok6410_lcd_pdata[features.lcd_index].win[0]->yres);

  183.     s3c_nand_set_platdata(&ok6410_nand_info);
  184.     s3c_fb_set_platdata(&ok6410_lcd_pdata[features.lcd_index]);
  185.     s3c24xx_ts_set_platdata(NULL);


  186.     s3c_sdhci0_set_platdata(&ok6410_hsmmc0_pdata);
  187.     s3c_sdhci1_set_platdata(&ok6410_hsmmc1_pdata);

  188.     /* configure nCS1 width to 16 bits */

  189.     cs1 = __raw_readl(S3C64XX_SROM_BW) &
  190.         ~(S3C64XX_SROM_BW__CS_MASK << S3C64XX_SROM_BW__NCS1__SHIFT);
  191.     cs1 |= ((1 << S3C64XX_SROM_BW__DATAWIDTH__SHIFT) |
  192.         (1 << S3C64XX_SROM_BW__WAITENABLE__SHIFT) |
  193.         (1 << S3C64XX_SROM_BW__BYTEENABLE__SHIFT)) <<
  194.             S3C64XX_SROM_BW__NCS1__SHIFT;
  195.     __raw_writel(cs1, S3C64XX_SROM_BW);

  196.     /* set timing for nCS1 suitable for ethernet chip */

  197.     __raw_writel((0 << S3C64XX_SROM_BCX__PMC__SHIFT) |
  198.         (6 << S3C64XX_SROM_BCX__TACP__SHIFT) |
  199.         (4 << S3C64XX_SROM_BCX__TCAH__SHIFT) |
  200.         (1 << S3C64XX_SROM_BCX__TCOH__SHIFT) |
  201.         (13 << S3C64XX_SROM_BCX__TACC__SHIFT) |
  202.         (4 << S3C64XX_SROM_BCX__TCOS__SHIFT) |
  203.         (0 << S3C64XX_SROM_BCX__TACS__SHIFT), S3C64XX_SROM_BC1);

  204.     gpio_request(S3C64XX_GPF(15), "LCD power");
  205.     gpio_request(S3C64XX_GPE(0), "LCD power");

  206.     platform_add_devices(ok6410_devices, ARRAY_SIZE(ok6410_devices));
  207. }

2.添加lcd的驱动
    2.1将厂家提供的源代码linux3.0.1中的drviers/video/samsung拷贝到drviers/video/目录下
    2.2将厂家提供的源代码linux3.0.1中的arch/arm/plat-samsung/include/plat文件夹中的regs-fb-v4.h和regs-fb.h拷贝到arch/arm/plat-samsung/include/plat目录下

    2.3将厂家提供的源代码linux3.0.1中的arch/arm/mach-s3c64xx/include/mach文件夹中的regs-fb.h和regs-lcd.h拷贝到arch/arm/mach-s3c64xx/include/mach目录下
    2.4修改drviers/video/samsung/s3cfb.c,把996行的int __devinit s3cfb_init(void)修改为int __init s3cfb_init(void)。(原因不知,不改要报错
  
3.修改drviers/video/的Kconfig文件,在文件中加入source "drivers/video/samsung/Kconfig"
    修改修改drviers/video/的Makefie文件,再最后一行添加:obj-$(CONFIG_FB_S3C_EXT) += samsung/
    在arch/arm/plat-samsung/include/plat/map-base.h里面添加#define S3C_VA_LCD S3C_ADDR(0x01100000) /* LCD */
    在include/generated/atuoconfig.h里面添加#define CONFIG_FB_S3C_EXT_NUM 4
    把drivers/video/samsung/s3cfb_fimd4x.c里面的
                s3c6410_pm_do_save(s3c_lcd_save, ARRAY_SIZE(s3c_lcd_save));改成s3c_pm_do_save(s3c_lcd_save, ARRAY_SIZE(s3c_lcd_save));
                s3c6410_pm_do_restore(s3c_lcd_save, ARRAY_SIZE(s3c_lcd_save));改成s3c_pm_do_restore(s3c_lcd_save, ARRAY_SIZE(s3c_lcd_save));  

4.配置内核:
    Device Drivers ---> 

        Graphics support ---> 
    
            <*> S3C Framebuffer Support (eXtended)(修改Kconfig之后才有这个选) 
                        Select LCD Type (4.3 inch 480x272 TFT LCD) ---> 
                                (X) 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 
                        [*] Enable Double Buffering 

            <*> Support for frame buffer devices ---> (里面的都空选) 

            [ ] Backlight & LCD device support ---> 

            Console display driver support ---> 
                        <*> Framebuffer Console support 
            [*] Bootup logo --->(显示小企鹅) 
                        [*] Standard 224-color Linux logo

5.重新make uImage烧写后,可以看到如下信息,并且屏幕上显示出了小企鹅的图片

点击(此处)折叠或打开

  1. io scheduler noop registered
  2. io scheduler deadline registered
  3. io scheduler cfq registered (default)
  4. S3C_LCD clock got enabled :: 133.250 Mhz
  5. LCD TYPE :: LTE480WV will be initialized
  6. failed to request GPE for lcd reset control
  7. Window[0] - FB1: map_video_memory: clear d0856000:0007f800
  8.             FB1: map_video_memory: dma=5f980000 cpu=d0856000 size=0007f800
  9. Window[0] - FB2: map_video_memory: clear d0895c00:0003fc00
  10.             FB2: map_video_memory: dma=5f9bfc00 cpu=d0895c00 size=0003fc00
  11. Console: switching to colour frame buffer device 60x34
  12. fb0: s3cfb frame buffer device
  13. Window[1] - FB1: map_video_memory: clear d08d7000:0007f800
  14.             FB1: map_video_memory: dma=5fa00000 cpu=d08d7000 size=0007f800
  15. Window[1] - FB2: map_video_memory: clear d0916c00:0003fc00
  16.             FB2: map_video_memory: dma=5fa3fc00 cpu=d0916c00 size=0003fc00
  17. fb1: s3cfb frame buffer device
  18. Window[2] - FB1: map_video_memory: clear d0958000:0003fc00
  19.             FB1: map_video_memory: dma=5fa80000 cpu=d0958000 size=0003fc00
  20. fb2: s3cfb frame buffer device
  21. Window[3] - FB1: map_video_memory: clear d0999000:0003fc00
  22.             FB1: map_video_memory: dma=5fac0000 cpu=d0999000 size=0003fc00
  23. fb3: s3cfb frame buffer device
  24. Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
  25. s3c6400-uart.0: ttySAC0 at MMIO 0x7f005000 (irq = 69) is a S3C6400/10
  26. console [ttySAC0] enabled

6.TS的移植参考http://blog.chinaunix.net/uid-28382924-id-3485011.html    
    另外,还要修改两个地方,在/include/linux/interruput.h文件中添加#define IRQF_SAMPLE_RANDOM 0x00000040
    为防止在后期的tslib移植中不出现selected device is not a touchscreen I understand问题,把/include/uapl/linux/input.h中的#define EV_VERSION 0x010001改为#define EV_VERSION  0x010001
阅读(1295) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~