移植u-boot 1.1.6到TQ2440开发板-第二阶段
移植u-boot 1.1.6到TQ2440开发板-第二阶段
增加uboot对TQ2440的代码支持
第一步:修改 SDRAM 配置,修改u-boot-1.1.6/board/TQ2440目录lowlevel_init.S文件
第54行
#define B1_BWSCON
#define B2_BWSCON
#define B3_BWSCON
#define B4_BWSCON
#define B5_BWSCON
#define B6_BWSCON
#define B7_BWSCON
第126行
#define REFCNT
第二步:时钟设置,S3c2440 的时钟计算公式和 s3c2410 不一样,对于 s3c2440 开发板,将 PCLK 设为
400Mhz ,分频比为 FCLK:HCLK:PCLK=1:4:8,有2种设定方法,我们使用简单的一种。
1、首先屏蔽原来 s3c2410 的时钟设置,修改 u-boot-1.1.6/cpu/arm920t/ 目录下 start.S 文件 148 行如下:
#if 0
#endif
2、修改 u-boot-1.1.6/cpu/arm920t/start.S ,将 stack_setup子程序搬到 relocate 子程序之前,因为所调用的 clock_init 函数需要用到堆栈。
stack_setup:
#ifdef CONFIG_USE_IRQ
#endif
bl
#ifndef CONFIG_SKIP_RELOCATE_UBOOT
relocate:
3、编写clock_init函数,board/TQ2440 目录下建议一个名为 boot_init.c 的文件,编写 colck_init 函数,同时加上一些声明和延时子函数
#include
#include
#define GSTATUS1
static inline void delay (unsigned long loops)
{
__asm__ volatile ("1: n"
"subs %0, %1, #1 n"
"bne 1b":"=r" (loops):"0" (loops));
}
#define S3C2440_MPLL_400MHZ
#define S3C2440_MPLL_200MHZ ((0x5c<12)|(0x01<4)|(0x02))
#define S3C2440_MPLL_100MHZ ((0x5c<12)|(0x01<4)|(0x03))
#define S3C2440_UPLL_96MHZ ((0x38<12)|(0x02<4)|(0x01))
#define S3C2440_UPLL_48MHZ ((0x38<12)|(0x02<4)|(0x02))
#define S3C2440_CLKdiv (0x05) // | (1<3))
#define S3C2440_CLKdiv188 0x04
#define S3C2440_CAMdivN188 ((0<8)|(1<9))
#define S3C2410_MPLL_200MHZ
#define S3C2410_UPLL_48MHZ ((0x28<12)|(0x01<4)|(0x02))
#define S3C2410_CLKdiv 0x03
void clock_init(void)
{
S3C24X0_CLOCK_POWER *clk_power = (S3C24X0_CLOCK_POWER *)0x4C000000;
if ((GSTATUS1 == 0x32410000)|| (GSTATUS1 == 0x32410002))
{
clk_power- >CLKdivN = S3C2410_CLKdiv;
__asm__("mrc
"orr r1,r1, #0xc0000000 n"
11
"mcr p15, 0, r1, c1, c0, 0 n"
:::"r1"
);
clk_power- >LOCKTIME = 0xFFFFFFFF;
clk_power- >UPLLCON = S3C2410_UPLL_48MHZ;
delay (4000);
clk_power- >MPLLCON = S3C2410_MPLL_200MHZ;
delay (8000);
}
else
{
clk_power- >CLKdivN = S3C2440_CLKdiv;
__asm__("mrc
"orr r1,r1, #0xc0000000 n"
"mcr p15, 0, r1, c1, c0, 0 n"
:::"r1"
);
clk_power- >LOCKTIME = 0xFFFFFFFF;
clk_power- >UPLLCON = S3C2440_UPLL_48MHZ;
delay (4000);
clk_power- >MPLLCON = S3C2440_MPLL_400MHZ;
delay (8000);
}
}
4、修改u-boot-1.1.6/board/TQ2440/TQ2440.c 文件中的 board_init 函数
int board_init (void)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
gpio- >GPACON = 0x007FFFFF;
gpio- >GPBCON = 0x00055555;
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 = 0xFF94FFBA;
gpio- >GPGUP = 0x0000FFEF;
gpio- >GPGDAT = gpio- >GPGDAT & (~(1<4)) | (1<4);
gpio- >GPHCON = 0x002AFAAA;
gpio- >GPHUP = 0x000007FF;
if ((gpio- >GSTATUS1 == 0x32410000) || (gpio- >GSTATUS1 == 0x32410002))
{
gd- >bd- >bi_arch_number = MACH_TYPE_SMDK2410;
}
else
{
gd- >bd- >bi_arch_number = MACH_TYPE_S3C2440;
}
gd- >bd- >bi_boot_params = 0x30000100;
icache_enable();
dcache_enable();
return 0;
}
5、修改u
移植u-boot16TQ244 相关文章:
- 移植u-boot 1.1.6到TQ2440开发板-第一阶段(11-26)
- 移植u-boot 1.1.6到TQ2440开发板-第三阶段(11-26)
- 移植u-boot 1.1.6到TQ2440开发板-第四阶段(11-26)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)