您尚未登录。

楼主 #1 2020-05-09 21:01:13

缥缈九哥
会员
注册时间: 2020-05-09
已发帖子: 93
积分: 96

添加LTV350QV的FB驱动到基于linux-2.6.26的GEC2440开发板 --缥缈九哥

添加LTV350QV的FB驱动到基于linux-2.6.26的GEC2440开发板

1,编译配置内核
root@yuanxh-desktop:/home/yuanxh/s3c2410/linux-2.6.26-9g24x0# make menuconfig
进入配置菜单添加驱动到内核:
Device Drivers  --->
    Graphics support  ---> 
<*> Support for frame buffer devices  --->
<*>   S3C2410 LCD framebuffer support

2,修改arch/arm/mach-s3c2440/mach-smdk2440.c文件
root@yuanxh-desktop:/home/yuanxh/s3c2410/linux-2.6.26-9g24x0# vi arch/arm/mach-s3c2440/mach-smdk2440.c
把static struct s3c2410fb_display smdk2440_lcd_cfg __initdata 修改成:
// change by yuanxihua@21cn.com
static struct s3c2410fb_display smdk2440_lcd_cfg __initdata = {

  .lcdcon5 = S3C2410_LCDCON5_FRM565  |
     S3C2410_LCDCON5_INVVCLK  |
       S3C2410_LCDCON5_INVVLINE  |
     S3C2410_LCDCON5_INVVFRAME  |
//      S3C2410_LCDCON5_INVVD  |
//    S3C2410_LCDCON5_INVVDEN  |
//      S3C2410_LCDCON5_PWREN   |
//      S3C2410_LCDCON5_BSWP  |
       S3C2410_LCDCON5_HWSWP,

  .type  = S3C2410_LCDCON1_TFT,

  .width  = 320,
  .height  = 240,

  .pixclock = 270000, /* HCLK 60 MHz, divisor 10 */
  .xres  = 320,
  .yres  = 240,
  .bpp  = 16,
  .left_margin = 21,
  .right_margin = 14,
  .hsync_len  = 19,
  .upper_margin = 6,
  .lower_margin = 5,
  .vsync_len  = 4,
};

把static struct s3c2410fb_mach_info smdk2440_fb_info __initdata修改成:
// change by yuanxihua@21cn.com
  static struct s3c2410fb_mach_info smdk2440_fb_info __initdata = {
  .displays = &smdk2440_lcd_cfg,
  .num_displays = 1,
  .default_display = 0,

#if 1
  /* currently setup by downloader */
  .gpccon   = 0xaa9556a9,
  .gpccon_mask = 0xffffffff,
  .gpcup   = 0xffffffff,
  .gpcup_mask  = 0xffffffff,
  .gpdcon   = 0xaaaaaaaa,
  .gpdcon_mask = 0xffffffff,
  .gpdup   = 0xffffffff,
  .gpdup_mask  = 0xffffffff,
#endif

  .lpcsel   = 0,
};
把s3c24xx_init_clocks(16934400);修改成:
// s3c24xx_init_clocks(16934400);  // change by yuanxihua@21cn.com
s3c24xx_init_clocks(12000000);

3,修改include/asm-arm/arch-s3c2410/regs-lcd.h文件
root@yuanxh-desktop:/home/yuanxh/s3c2410/linux-2.6.26-9g24x0# vi include/asm-arm/arch-s3c2410/regs-lcd.h
把#define S3C2410_LCDCON1_MMODE    (1<<7)修改成:
//#define S3C2410_LCDCON1_MMODE    (1<<7)
#define S3C2410_LCDCON1_MMODE    (0<<7)   // change by yuanxihua@21cn.com

4,修改drivers/video/s3c2410fb.c文件
root@yuanxh-desktop:/home/yuanxh/s3c2410/linux-2.6.26-9g24x0# vi drivers/video/s3c2410fb.c
在第51行的/* useful functions */后添加:

 /************************************************/
 //LTV350QV_FOE_V0.0
 
 #define LTV350QV_FOE       0x1d   //device ID
 
 typedef struct _LTV350qv_spi_data_{
  unsigned char    Device_ID;   //ID of the device
  unsigned int   Index;    //index of register
  unsigned long   Structure;  //structure to be writed
 }LTV350QV_SPI_Data;
 
 //micro for LTV350QV_FOE
 #define CS_H     __raw_writel(__raw_readl(S3C2410_GPCDAT) |(1<< 8), S3C2410_GPCDAT)//MAKE_HIGH(LTV350QV_CS)
 #define CS_L     __raw_writel(__raw_readl(S3C2410_GPCDAT)&~(1<< 8), S3C2410_GPCDAT)//MAKE_LOW(LTV350QV_CS)
 #define SCLK_H   __raw_writel(__raw_readl(S3C2410_GPCDAT) |(1<< 9), S3C2410_GPCDAT)//MAKE_HIGH(LTV350QV_SCL)
 #define SCLK_L   __raw_writel(__raw_readl(S3C2410_GPCDAT)&~(1<< 9), S3C2410_GPCDAT)//MAKE_LOW(LTV350QV_SCL)
 #define SDI_H    __raw_writel(__raw_readl(S3C2410_GPCDAT) |(1<<10), S3C2410_GPCDAT)//MAKE_HIGH(LTV350QV_SDI)
 #define SDI_L    __raw_writel(__raw_readl(S3C2410_GPCDAT)&~(1<<10), S3C2410_GPCDAT)//MAKE_LOW(LTV350QV_SDI)
 #define RST_H    __raw_writel(__raw_readl(S3C2410_GPDDAT) |(1<< 0), S3C2410_GPDDAT)//MAKE_HIGH(LTV350QV_RST)
 #define RST_L    __raw_writel(__raw_readl(S3C2410_GPDDAT)&~(1<< 0), S3C2410_GPDDAT)//MAKE_LOW(LTV350QV_RST)
 
 //***************************************************************
 //**********these functions for SUMSUN LTV350QV TFT LCD****************
 //***************************************************************
 static void LTV350QV_Short_Delay(u_char time)
 {
  ndelay(150);
 }
 /*
 static void LTV350QV_Rst(void)
 {
  RST_L;
  mdelay(1);
  RST_H;
  mdelay(1);
 }
 */
 static void LTV350QV_Register_Write(LTV350QV_SPI_Data regdata)
 {
  u_char i,temp1;
  u_int temp2;
  u_long temp3;
  unsigned long flags;           
 
  //write index
  temp1=regdata.Device_ID<<2 | 0<<1 | 0<<0;  //register index
  temp2=regdata.Index;
  temp3=(temp1<<24) | (temp2<<8);
 
  local_irq_save(flags);
  
  CS_L;
  LTV350QV_Short_Delay(1);
  for(i=0;i<24;i++)
   {
    SCLK_L;
    if(temp3 & (1<<(31-i)) )   //if is H
     SDI_H;
    else
     SDI_L;
    LTV350QV_Short_Delay(1);   //setup time
    SCLK_H;
    LTV350QV_Short_Delay(1);   //hold time
   }
  CS_H;
  
  LTV350QV_Short_Delay(5);
  
  //write instruction
  temp1=regdata.Device_ID<<2 | 1<<1 | 0<<0; //instruction
  temp2=regdata.Structure;
  temp3=(temp1<<24) | (temp2<<8);
  
  CS_L;
  LTV350QV_Short_Delay(1);
  for(i=0;i<24;i++)
   {
    SCLK_L;
    if(temp3 & (1<<(31-i)) )   //if is H
     SDI_H;
    else
     SDI_L;
    LTV350QV_Short_Delay(1);
    SCLK_H;
    LTV350QV_Short_Delay(1);
   }
  CS_H;
 
  local_irq_restore(flags);
 }
 /****************************************
 *  *
 ****************************************/
 static void LTV350QV_Write(u_int index, u_int regdata)
 {
  LTV350QV_SPI_Data WriteData;
  
  WriteData.Device_ID = LTV350QV_FOE;
  WriteData.Index  = index;
  WriteData.Structure = regdata;
 
  LTV350QV_Register_Write(WriteData);
 }
 /****************************************
 *  *power ON sequence
 ****************************************/
 static void LTV350QV_Power_ON(void)
 { 
   LTV350QV_Write( 9, 0x0000);
   mdelay(150);
   LTV350QV_Write( 9, 0x4000);
   LTV350QV_Write(10, 0x2000);
   LTV350QV_Write( 9, 0x4055);
   mdelay(550);
   LTV350QV_Write( 1, 0x409d);
   LTV350QV_Write( 2, 0x0204);
  LTV350QV_Write( 3, 0x0100);
   LTV350QV_Write( 4, 0x3000);
   LTV350QV_Write( 5, 0x4003);
   LTV350QV_Write( 6, 0x000a);
   LTV350QV_Write( 7, 0x0021);
   LTV350QV_Write( 8, 0x0c00);
   LTV350QV_Write(10, 0x0103);
  LTV350QV_Write(11, 0x0301);
   LTV350QV_Write(12, 0x1f0f);
   LTV350QV_Write(13, 0x1f0f);
   LTV350QV_Write(14, 0x0707);
   LTV350QV_Write(15, 0x0307);
   LTV350QV_Write(16, 0x0707);
   LTV350QV_Write(17, 0x0000);
   LTV350QV_Write(18, 0x0004);
   LTV350QV_Write(19, 0x0000);
 
   mdelay(200);
   LTV350QV_Write( 9, 0x4a55);
   LTV350QV_Write( 5, 0x5003);
 }
 
 /**********************************
 *  *power OFF sequence
 **********************************/
 /*static void LTV350QV_Powen_OFF(void)
 {
  LTV350QV_Write( 9, 0x4055);// GON -> 0, POC -> 0
  LTV350QV_Write( 5, 0x4003);// DSC -> 0
   LTV350QV_Write(10, 0x0000);// VCOMG -> 0
   mdelay(20);
  LTV350QV_Write( 9, 0x4000);// AP[2:0] -> 000
 }*/
 static void s3c2440fb_init_ltv350qv(void)
 {
  __raw_writel(0xaa9556a9, S3C2410_GPCCON);  //Initialize VD[7:0],LCDVF[2:0],VM,VFRAME,VLINE,VCLK,LEND
              //LCDVF[0],[1],[2]---output;VD[0],[1],[2]----output.            
  __raw_writel(0xffffffff, S3C2410_GPCUP);   // Disable Pull-up register
    LTV350QV_Power_ON() ;     //init LCD model
  __raw_writel(0xaaaaaaaa, S3C2410_GPDCON);
  __raw_writel(0xffffffff, S3C2410_GPDUP);
 // __raw_writel(3, S3C2410_LCDINTMSK);    // MASK LCD Sub Interrupt
 // __raw_writel(0, S3C2410_TPAL);     // Disable Temp Palette
 // __raw_writel(0, S3C2410_LPCSEL);    // Disable LPC3600
 }
 
 

在static int s3c2410fb_init_registers(struct fb_info *info)的 return 0;前添加:
s3c2440fb_init_ltv350qv();

5, 编译内核生成驱动
root@yuanxh-desktop:/home/yuanxh/s3c2410/linux-2.6.26-9g24x0# make

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn