LCD driver porting

Publisher:星光小狐狸Latest update time:2016-12-05 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

2.6.14 kernel, according to the posts on the Internet, the workload is not very large, now let's sort out the ideas, let's start with the hardware, the LCD model I use is LTV350QV-F04. 320×240, here 320×240 is the number of pixels, 320 is horizontal, 240 is vertical. Let's ignore the control signal, let's take a look at the data line, that is, the RGB (red green and blue) line, the hardware connection here determines the LCD's BPP, 16BPP or 24BPP, my development board uses a 5:6:5 16BPP connection. For the relationship between BPP and connection, please refer to pages 387-390 of the 2410 manual.

       Next, we need to configure the registers related to the LCD. For this part of the configuration, please refer to the description of the LCD control register starting from p397 of 2410. The following code is made by a hero on the Internet. I will use it to explain the register initialization method:

Add the following content to /linux/arch/arm/mach-s3c2410/mach-smdk2410.c.

static struct s3c2410fb_mach_info smdk2410_lcdcfg __initdata = {

.regs = {

   .lcdcon1 = S3C2410_LCDCON1_TFT16BPP | \    

     S3C2410_LCDCON1_TFT | \

     S3C2410_LCDCON1_CLKVAL(0x03),       

   .lcdcon2 = S3C2410_LCDCON2_VBPD(3) | \

     S3C2410_LCDCON2_LINEVAL(239) | \

     S3C2410_LCDCON2_VFPD(5) | \

     S3C2410_LCDCON2_VSPW(15),

   .lcdcon3 = S3C2410_LCDCON3_HBPD(5) | \

     S3C2410_LCDCON3_HOZVAL(319) | \

     S3C2410_LCDCON3_HFPD(15),

   .lcdcon4 = S3C2410_LCDCON4_MVAL(13) | \

     S3C2410_LCDCON4_HSPW(8),

   .lcdcon5 = S3C2410_LCDCON5_FRM565 |

     S3C2410_LCDCON5_INVVLINE |

     S3C2410_LCDCON5_INVVFRAME |

     S3C2410_LCDCON5_PWREN |

     S3C2410_LCDCON5_HWSWP,

},

.lpcsel = 0xf82,

.gpccon = 0xaa955699,

.gpccon_mask = 0xffc003cc,

.gpcup = 0x0000ffff,

.gpcup_mask = 0xffffffff,

.gpdcon = 0xaa95aaa1,

.gpdcon_mask = 0xffc0fff0,

.gpdup = 0x0000faff,

.gpdup_mask = 0xffffffff,

.fixed_syncs = 1,

.width = 320,

.height = 240,

.xres = {

   .min = 320,

   .max = 320,

   .defval = 320,

},

.yres = {

   .max = 240,

   .min = 240,

   .defval = 240,

},

.bpp = {

   .min = 16,

   .max = 16,

   .defval = 16,

},

};First of all, we should be thankful that the kernel provides us with the s3c2410fb_mach_info structure (the structure is defined in /include/asm/arch-s3c2410/fb.h), so that we can simply add the relevant parameters (this reminds me of my undergraduate days when I knew nothing, but I still did experiments with a test box). For LCDCON1, the first two items are not much to say, but the last item about CLKVAL is very important. The driver that comes with my development board sets this value to 10, and a guy from Huaheng said that for 320×240 boards, it is generally set to 7. Let's try setting it to 10 first.

Let's look at LCDCON2 again. The LCD manual does not have typical values ​​for the four values ​​of VBPD, VFPD, VSPW, and LINEVAL. So I had to refer to the original driver. The original driver is as follows: lcdcon2: LCD2_VBPD(3) | LCD2_VFPD(5) | LCD2_VSPW(15). No LINEVAL value is assigned. Is there no such item in the 2.4 kernel, or is the default setting sufficient? Let's look at the LINEVAL in the manual.

LINEVAL [23:14] TFT/STN: These bits determine the vertical size of the LCD panel. 0000000000 (initial) This insurance is still added. Similarly, in LCDCON3, there is no shadow of HOZVAL, so it is also added. The others are the same as this hero's, including LCDCON4 and LCDCON5.

The next lpcsel is used to determine whether to use the lpc3600 chip. I don't seem to need to choose it. Set it to zero first and then ask if there is any problem.

The following is the configuration of the GPIO port. These GPIO ports are multi-function IOs. Here they are configured as VDn. According to my development board, GPCCON can be configured as all a, because except for the 16 pins used for LCD, the others are idle and there is no need to spend time on them. I don't know what GPCCON_MASK is for? Most posts have all f. GPCUP is the pull-up resistor function, which I don't need, so I have all f.

I don't know what fixed_syncs is. The built-in driver has a syncs of 0, so it is also set to 0 here. The rest is self-explanatory.

Next is to add the initialization code, still in mach-smdk2410.c, add the following code:

static void __init sdmk2410_lcdinit(void)

                            {

                                set_s3c2410fb_info(&smdk2410_lcdcfg __initdata );

                            }

Then add LCD initialization in MACHINE_START(SMDK2410, "SMDK2410").

.init_machine = sdmk2410_lcdinit,

Some people also added set_s3c2410fb_info(&smdk2410_lcdcfg __initdata ); directly to static void __init smdk2410_map_io(void), which I think is more reasonable. The next step is to add the necessary header files:

#include

#include

#include

#include

#include

#include

//#include

//#include

//#include

#include

#include

#include

#include

#include

#include

#include

#include

OK, I'm going to start compiling the kernel!!!

Note that some of the header files I provided will cause compilation errors. For any header file that causes errors, just comment it out. My friend said that just adding fb.h will do the trick, but I didn't try it. I just commented out the header files that caused the errors. Then I saw the little penguin.


Reference address:LCD driver porting

Previous article:Summary of clock frequency based on S3C2410
Next article:s3c2410 startup code analysis

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号