1.新建开发板相应目录和文件
①在boad目录下添加my2440文件夹 ,拷贝smdk2410目录下所有文件,修改文件名把smdk2410.c改为my2440.c
在include/congfigs文件夹建立配置文件my2440.h(将smdk2410.h直接复制为my2440.h)
②修改两个Makefile
u-boot-1.1.6/Makefile
在 smdk2410_config : unconfig @$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 NULL s3c24x0
增加上
my2440_config : unconfig @$(MKCONFIG) $(@:_config=) arm arm920t my2440 NULL s3c24x0
u-boot-1.1.6/board/my2440/Makefile
COBJS := smdk2440.o flash.o
修改
COBJS := my2440.o flash.o
2.修改SDMRAM配置
board/my2440/lowlevel_init.s
#definr REFCNT 1113
改为
#definr REFCNT 0x4f4
3.增加对S3C2440的支持
修改board/my2440/my2440.c中的board_init函数
①定义S3C2440的MPLL,UPLL寄存器,将UPLL即UCLK设为48MHZ
/* S3C2440: Mpll,Upll = (2*m * Fin) / (p * 2^s)
* m = M (the value for divider M)+ 8, p = P (the value for divider P) + 2
*/
#define S3C2440_MPLL_400MHZ ((0x7f<<12)|(0x02<<4)|(0x01))
#define S3C2440_UPLL_48MHZ ((0x38<<12)|(0x02<<4)|(0x02))
#define S3C2440_CLKDIV 0x05 /* FCLK:HCLK:PCLK = 1:4:8 */
②开发板输入时钟为12MHZ (Iinclude/configs/my2440.h中的CONFIG_SYS_CLK_FREQ中定义)
③设置系统时钟
int board_init (void)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
/* 设置GPIO */
gpio->GPACON = 0x007FFFFF;
gpio->GPBCON = 0x00044555;
gpio->GPBUP = 0x000007FF;
gpio->GPCCON = 0xAAAAAAAA;
gpio->GPCUP = 0x0000FFFF;
gpio->GPDCON = 0xAAAAAAAA;
gpio->GPDUP = 0x0000FFFF;
gpio->GPECON = 0xAAAAAAAA;
gpio->GPEUP = 0x0000FFFF;
gpio->GPFCON = 0x000055AA;
gpio->GPFUP = 0x000000FF;
gpio->GPGCON = 0xFF95FFBA;
gpio->GPGUP = 0x0000FFFF;
gpio->GPHCON = 0x002AFAAA;
gpio->GPHUP = 0x000007FF;
/*同时支持S3C2410 and S3C2440*/
if ((gpio->GSTATUS1 == 0x32410000) || (gpio->GSTATUS1 == 0x32410002))
{
/*FCLK:HCLK:PCLK = 1:2:4*/
clk_power->CLKDIVN = S3C2410_CLKDIV;
/* 修改为异步总线模式 */
__asm__( "mrc p15, 0, r1, c1, c0, 0/n" /* read ctrl register */
"orr r1, r1, #0xc0000000/n" /* Asynchronous */
"mcr p15, 0, r1, c1, c0, 0/n" /* write ctrl register */
:::"r1"
);
/*设置PLL锁定时间 */
clk_power->LOCKTIME = 0xFFFFFF;
/* 配置 MPLL */
clk_power->MPLLCON = S3C2410_MPLL_200MHZ;
/*延时 */
delay (4000);
/* 配置 UPLL */
clk_power->UPLLCON = S3C2410_UPLL_48MHZ;
/* 延时 */
delay (8000);
/*机器类型ID,调用Linux内核时用到与内核相对应 */
gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
}
else
{
/* FCLK:HCLK:PCLK = 1:4:8 */
clk_power->CLKDIVN = S3C2440_CLKDIV;
/*修改为异步总线模式 */
__asm__( "mrc p15, 0, r1, c1, c0, 0/n" /* read ctrl register */
"orr r1, r1, #0xc0000000/n" /* Asynchronous */
"mcr p15, 0, r1, c1, c0, 0/n" /* write ctrl register */
:::"r1"
);
/*设置PLL锁定时间*/
clk_power->LOCKTIME = 0xFFFFFF;
/*配置 MPLL */
clk_power->MPLLCON = S3C2440_MPLL_400MHZ;
/* 延时 */
delay (4000);
/* 配置 UPLL */
clk_power->UPLLCON = S3C2440_UPLL_48MHZ;
/* 延时 */
delay (8000);
/* 机器类型ID,调用Linux内核时用到与内核相对应*/
gd->bd->bi_arch_number = MACH_TYPE_S3C2440;
}
/* 启动内核时参数存放位置,在构造标记列表时用到*/
gd->bd->bi_boot_params = 0x30000100;
icache_enable();
dcache_enable();
return 0;
}
4.针对S3C2410、S2C2440的不同修改获取系统时钟的函数(设置串口波特率时需要获得系统时钟)
在cpu/arm920t/s3c24X0/speed.c中修改
①增加一行DECLARE_GLOBAL_DATA_PTR;(这样才可以使用gd变量)
②修改get_PLLCLK函数
static ulong get_PLLCLK(int pllreg)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
ulong r, m, p, s;
if (pllreg == MPLL)
r = clk_power->MPLLCON;
else if (pllreg == UPLL)
r = clk_power->UPLLCON;
else
hang();
m = ((r & 0xFF000) >> 12) + 8;
p = ((r & 0x003F0) >> 4) + 2;
s = r & 0x3;
/* 同时支持 S3C2410 and S3C2440 */
if (gd->bd->bi_arch_number == MACH_TYPE_SMDK2410)
return((CONFIG_SYS_CLK_FREQ * m) / (p << s));
else
return((CONFIG_SYS_CLK_FREQ * m * 2) / (p << s)); /* S3C2440 */
}
③修改get_HCLK, get_PCLK:
/* for s3c2440 */
#define S3C2440_CLKDIVN_PDIVN (1<<0)
#define S3C2440_CLKDIVN_HDIVN_MASK (3<<1)
#define S3C2440_CLKDIVN_HDIVN_1 (0<<1)
#define S3C2440_CLKDIVN_HDIVN_2 (1<<1)
#define S3C2440_CLKDIVN_HDIVN_4_8 (2<<1)
#define S3C2440_CLKDIVN_HDIVN_3_6 (3<<1)
#define S3C2440_CLKDIVN_UCLK (1<<3)
#define S3C2440_CAMDIVN_CAMCLK_MASK (0xf<<0)
#define S3C2440_CAMDIVN_CAMCLK_SEL (1<<4)
#define S3C2440_CAMDIVN_HCLK3_HALF (1<<8)
#define S3C2440_CAMDIVN_HCLK4_HALF (1<<9)
#define S3C2440_CAMDIVN_DVSEN (1<<12)
/* return HCLK frequency */
ulong get_HCLK(void)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
unsigned long clkdiv;
unsigned long camdiv;
int hdiv = 1;
/* support both of S3C2410 and S3C2440 */
if (gd->bd->bi_arch_number == MACH_TYPE_SMDK2410)
return((clk_power->CLKDIVN & 0x2) ? get_FCLK()/2 : get_FCLK());
else
{
clkdiv = clk_power->CLKDIVN;
camdiv = clk_power->CAMDIVN;
/* 计算分频比 */
switch (clkdiv & S3C2440_CLKDIVN_HDIVN_MASK) {
case S3C2440_CLKDIVN_HDIVN_1:
hdiv = 1;
break;
case S3C2440_CLKDIVN_HDIVN_2:
hdiv = 2;
break;
case S3C2440_CLKDIVN_HDIVN_4_8:
hdiv = (camdiv & S3C2440_CAMDIVN_HCLK4_HALF) ? 8 : 4;
break;
case S3C2440_CLKDIVN_HDIVN_3_6:
hdiv = (camdiv & S3C2440_CAMDIVN_HCLK3_HALF) ? 6 : 3;
break;
}
return get_FCLK() / hdiv;
}
}
/* return PCLK frequency */
ulong get_PCLK(void)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
unsigned long clkdiv;
unsigned long camdiv;
int hdiv = 1;
/* support both of S3C2410 and S3C2440 */
if (gd->bd->bi_arch_number == MACH_TYPE_SMDK2410)
return((clk_power->CLKDIVN & 0x1) ? get_HCLK()/2 : get_HCLK());
else
{
clkdiv = clk_power->CLKDIVN;
camdiv = clk_power->CAMDIVN;
/* 计算分频比 */
switch (clkdiv & S3C2440_CLKDIVN_HDIVN_MASK) {
case S3C2440_CLKDIVN_HDIVN_1:
hdiv = 1;
break;
case S3C2440_CLKDIVN_HDIVN_2:
hdiv = 2;
break;
case S3C2440_CLKDIVN_HDIVN_4_8:
hdiv = (camdiv & S3C2440_CAMDIVN_HCLK4_HALF) ? 8 : 4;
break;
case S3C2440_CLKDIVN_HDIVN_3_6:
hdiv = (camdiv & S3C2440_CAMDIVN_HCLK3_HALF) ? 6 : 3;
break;
}
return get_FCLK() / hdiv / ((clkdiv & S3C2440_CLKDIVN_PDIVN)? 2:1);
}
}
5.选择NOR FLASH型号
配置文件include/configs/my2440.h中的默认型号为AM29LV400,而开发板中NOR FLASH型号为AM29LV800
修改如下:
#if 0
#define CONFIG_AMD_LV400 1
#endif
#define CONFIG_AMD_LV800 1
对于其它型号的NOR FLIASH,若符合CFI接口标准则可以使用driver/cfi_flash.c中的接口函数。关于使用cfi_flash.c函数的修改如下:
在include/configs/my2440.h中增加一行:
#define CFG_FLASH_CFI_DRIVER
在board/my2440/Makefile中
COBJS := my2440.o flash.o
改为
COBJS := my2440.o
6.支持串口xmodem协议
7.支持网卡芯片CS8900
8.支持NAND FLASH
9.支持烧写yaffs文件系统映象
10.其它配置参数修改方便使用
ifeq ($(ARCH),arm)
CROSS_COMPILE = arm-linux-
指定交叉编译器