S5PV210(TQ210)学习笔记——LCD驱动编写
时间:11-28
来源:互联网
点击:
网上S5PV210内核移植的文章不是很多,而描述2440和6410内核移植的文章多数是讲如何移植,而非手动编写,但是,韦东山老师的视频中讲述了如何从头编写LCD驱动,当然是以2440为例的,我看过视频之后在TQ210平台上进行了实验,实验成功,详细的原理部分以我现在的水平还难以表达清楚。下载是我自己写的代码,适用于TQ210的7寸电容屏。
- #include
- #include
- #include
- #include
- staticstructfb_info*lcd_info;
- unsignedlongpseudo_palette[16];
- unsignedlong*display_control;
- volatileunsignedlong*gpf0con;
- volatileunsignedlong*gpf1con;
- volatileunsignedlong*gpf2con;
- volatileunsignedlong*gpf3con;
- volatileunsignedlong*gpd0con;
- volatileunsignedlong*gpd0dat;
- volatileunsignedlong*vidcon0;
- volatileunsignedlong*vidcon1;
- volatileunsignedlong*vidtcon0;
- volatileunsignedlong*vidtcon1;
- volatileunsignedlong*vidtcon2;
- volatileunsignedlong*wincon0;
- volatileunsignedlong*vidosd0a;
- volatileunsignedlong*vidosd0b;
- volatileunsignedlong*vidosd0c;
- volatileunsignedlong*vidw00add0b0;
- volatileunsignedlong*vidw00add1b0;
- volatileunsignedlong*shodowcon;
- structclk*lcd_clk;
- staticinlineunsignedintchan_to_field(unsignedintchan,structfb_bitfield*bf)
- {
- chan&=0xffff;
- chan>>=16-bf->length;
- returnchan
offset; - }
- staticintlcdfb_setcolreg(unsignedintregno,unsignedintred,
- unsignedintgreen,unsignedintblue,
- unsignedinttransp,structfb_info*info)
- {
- unsignedintval;
- if(regno>16)
- return1;
- /*用red,green,blue三原色构造出val*/
- val=chan_to_field(red,&info->var.red);
- val|=chan_to_field(green,&info->var.green);
- val|=chan_to_field(blue,&info->var.blue);
- //((u32*)(info->pseudo_palette))[regno]=val;
- pseudo_palette[regno]=val;
- return0;
- }
- staticstructfb_opslcd_fbops={
- .owner=THIS_MODULE,
- .fb_setcolreg=lcdfb_setcolreg,
- .fb_fillrect=cfb_fillrect,
- .fb_copyarea=cfb_copyarea,
- .fb_imageblit=cfb_imageblit,
- };
- staticintlcd_init(void){
- intret;
- /*分配fb_info*/
- lcd_info=framebuffer_alloc(0,NULL);
- if(lcd_info==NULL){
- printk(KERN_ERR"allocframebufferfailed!");
- return-ENOMEM;
- }
- /*配置fb_info各成员*/
- /*fix*/
- strcpy(lcd_info->fix.id,"s5pv210_lcd");
- lcd_info->fix.smem_len=800*480*4;
- lcd_info->fix.type=FB_TYPE_PACKED_PIXELS;
- lcd_info->fix.visual=FB_VISUAL_TRUECOLOR;
- lcd_info->fix.line_length=800*4;
- /*var*/
- lcd_info->var.xres=800;
- lcd_info->var.yres=480;
- lcd_info->var.xres_virtual=800;
- lcd_info->var.yres_virtual=480;
- lcd_info->var.bits_per_pixel=32;
- lcd_info->var.red.offset=16;
- lcd_info->var.red.length=8;
- lcd_info->var.green.offset=8;
- lcd_info->var.green.length=8;
- lcd_info->var.blue.offset=0;
- lcd_info->var.blue.length=8;
- lcd_info->var.activate=FB_ACTIVATE_NOW;
- lcd_info->screen_size=800*480*4;
- lcd_info->pseudo_palette=pseudo_palette;
- lcd_info->fbops=&lcd_fbops;
- /*配置硬件资源*/
- /*映射内存*/
- display_control=ioremap(0xe0107008,4);
- gpf0con=ioremap(0xE0200120,4);
- gpf1con=ioremap(0xE0200140,4);
- gpf2con=ioremap(0xE0200160,4);
- gpf3con=ioremap(0xE0200180,4);
- gpd0con=ioremap(0xE02000A0,4);
- gpd0dat=ioremap(0xE02000A4,4);
- vidcon0=ioremap(0xF8000000,4);
- vidcon1=ioremap(0xF8000004,4);
- vidtcon0=ioremap(0xF8000010,4);
- vidtcon1=ioremap(0xF8000014,4);
- vidtcon2=ioremap(0xF8000018,4);
- wincon0=ioremap(0xF8000020,4);
- vidosd0a=ioremap(0xF8000040,4);
- vidosd0b=ioremap(0xF8000044,4);
- vidosd0c=ioremap(0xF8000048,4);
- vidw00add0b0=ioremap(0xF80000A0,4);
- vidw00add1b0=ioremap(0xF80000D0,4);
- shodowcon=ioremap(0xF8000034,4);
- /*配置GPIO*/
- *gpf0con=0x22222222;
- *gpf1con=0x22222222;
- *gpf2con=0x22222222;
- *gpf3con=0x22222222;
- *gpd0con&=~0xf;
- *gpd0con|=0x1;
- *gpd0dat|=1<0;
- *display_control=2<0;
- /*使能时钟*/
- lcd_clk=clk_get(NULL,"lcd");
- if(!lcd_clk||IS_ERR(lcd_clk)){
- printk(KERN_INFO"failedtogetlcdclocksource");
- }
- clk_enable(lcd_clk);
- /*配置LCD控制器*/
- *vidcon0=(4<6)|(1<4);
- *vidcon1=(1<6)|(1<5)|(1<4);
- *vidtcon0=(17<16)|(26<8)|(4<0);
- *vidtcon1=(40<16)|(214<8)|(4<0);
- *vidtcon2=(479<11)|(799<0);
- *wincon0&=~(0xf<2);
- *wincon0|=(0xb<2);
- *vidosd0a=(0<11)|(0<0);
- *vidosd0b=(799<11)|(479<0);
- *vidosd0c=480*800;
- //物理地址
- lcd_info->lcd_info->scree
S5PV210LCD驱动编 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)