SM501顯卡驅動移植
http://www.sinklow.com/blog/article.asp?id=187
1. 修改fbmem.c代碼檔案
將廠商提供的voyager.c和voyager.h檔案放入linux/drivers/video目錄中
修改linux/drivers/video目錄中的fbmem.c檔案
在fb_drivers結構申明之前加入如下代碼:
extern int voyager_init(void);
在fb_drivers結構中,添加如下代碼:
#ifdef CONFIG_FB_VOYAGER
/*
* Silicon Motion, Inc. VOYAGER frame buffer device.
*/
{ "voyager", voyager_init, NULL },
#endif
2. 修改"Makefile"和"Config.in"
修改linux/drivers/video目錄下的"Makefile"檔案,在申明驅動的地區加入如下內容:
obj-$(CONFIG_FB_VOYAGER) += voyager.o
修改linux/drivers/video目錄下的"Config.in"檔案,加入如下內容:
bool ' Silicon Motion, Inc. VOYAGER graphics console' CONFIG_FB_VOYAGER
3. 修改與開發板相關的核心及驅動代碼
當前開發板使用PXA255晶片,與驅動中測試的Accelent開發板晶片相同,當前開發板使用的片選訊號為CS5,SM501的SDRAM為4M。屏為12.1寸液晶,屏使用的參數為800 X 600,16BPP。
修改voyager.h:
屏的參數
#define SCREEN_X_RES 800
#define SCREEN_Y_RES 600
#define SCREEN_BPP 16
#define isACCELENT 1 /*開啟Accelent板的代碼*/
#define FB_PHYSICAL_ADDR 0x14000000 /*CS5的起始地址為SDRAM的地址*/
#define REG_PHYSICAL_ADDR 0x17E00000 /*CS5的最後2M為SM501寄存器地址*/
修改voyager.c的voyager_init函數:
u_long smem_size的值改為4M
將針對ACCELENT代碼修改為適合當前開發板,修改如下:
#if isACCELENT
{
MSC2 &= 0x0000ffff;
MSC2 |= 0x92040000; // 0x92340000
MDREFR |= 0x01010000; // Set free running clock and SDCLK[1] to 100MHz
LCCR0 |= LCCR0_DIS; // BIT:10 DISABLE lcd CONTROLLER
GAFR2_L = (GAFR2_L & ~0x30000000) | 0x20000000;
GAFR0_U = (GAFR0_U & ~0x30) | 0x10;
GAFR1_U = (GAFR1_U & ~0xf) | 0xa;
}
#endif //isACCELENT
修改arch/arm/mach-pxa/xhyper255.c,映射物理地址
在xhyper255_io_desc結構中,添加
{ 0xF0700000, 0x14000000, 0x00400000, DOMAIN_IO,0,1,0,0}, // CS5 : SM501 SDRAM
{ 0xF0C00000, 0x17E00000, 0x00200000, DOMAIN_IO,0,1,0,0}, // CS5 : SM501 REG
注:因產商驅動代碼的測試平台基於PXA255晶片,和當前開發板相似,所以相應的寄存器代碼改動較少。SM501與顯示驅動相關的寄存器主要在System Configuration和Display Controller中,具體數值參見《SM501 MMCC Databook》。
4. 配置核心參數
開啟"Character devices"中的
"Virtual Terminal"
"Support for console on virtual terminal"
開啟"Console drivers"下"Frame-buffer support"中的
"Support for frame buffer devices (EXPERIMENTAL)"
"Silicon Motion, Inc. VOYAGER graphics console"
"Advanced low level driver options"
"Monochrome support"
"2 bpp packed pixels support"
"4 bpp packed pixels support"
"8 bpp packed pixels support"
"16 bpp packed pixels support"
"24 bpp packed pixels support"
"32 bpp packed pixels support"
"Select compiled-in fonts"
"VGA 8x8 font"
註:本驅動移植基於Linux2.4.18版本的核心。
附:測試Frame Buffer的一個應用程式 FBTools