u-boot移植到mini2440之三

三、第二阶段启动代码移植

1.S3C2440时钟工作频率设置

Index: mini2440.c
===================================================================
RCS file: /home/tracy/work/cvsroot/u-boot-2009.08/board/samsung/mini2440/mini2440.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- mini2440.c  10 Mar 2012 13:37:07 -0000      1.1
+++ mini2440.c  30 Mar 2012 12:52:18 -0000      1.2
@@ -36,9 +36,9 @@
 #define M_MDIV 0xC3
 #define M_PDIV 0x4
 #define M_SDIV 0x1
-#elif FCLK_SPEED==1            /* Fout = 202.8MHz */
-#define M_MDIV 0xA1
-#define M_PDIV 0x3
+#elif FCLK_SPEED==1            /* Fout = 400MHz */
+#define M_MDIV 0x5C
+#define M_PDIV 0x1
 #define M_SDIV 0x1
 #endif


@@ -49,8 +49,8 @@
 #define U_M_PDIV       0x3
 #define U_M_SDIV       0x1
 #elif USB_CLOCK==1
-#define U_M_MDIV       0x48
-#define U_M_PDIV       0x3
+#define U_M_MDIV       0x38
+#define U_M_PDIV       0x2
 #define U_M_SDIV       0x2
 #endif


@@ -103,7 +103,7 @@
        gpio->GPHUP = 0x000007FF;


        /* arch number of SMDK2410-Board */
-       gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
+       gd->bd->bi_arch_number = MACH_TYPE_MINI2440;


        /* adress of boot parameters */
        gd->bd->bi_boot_params = 0x30000100;

我这里将ARM核心的工作频率设置成400MHzUSB的时钟工作频率为48MHzMACH_TYPE_MINI2440u-boot中板子的机器码,一定要和linux中的机器码相对应。


2.时钟频率初始化部分

Index: timer.c
===================================================================
RCS file: /home/tracy/work/cvsroot/u-boot-2009.08/cpu/arm920t/s3c24x0/timer.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- timer.c     10 Mar 2012 13:18:21 -0000      1.1
+++ timer.c     30 Mar 2012 12:50:01 -0000      1.2
@@ -30,11 +30,11 @@
  */


 #include <common.h>
-#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB)
+#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440) || defined(CONFIG_TRAB)


 #if defined(CONFIG_S3C2400)
 #include <s3c2400.h>
-#elif defined(CONFIG_S3C2410)
+#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 #include <s3c2410.h>
 #endif


@@ -177,6 +177,7 @@
        tbclk = timer_load_val * 100;
 #elif defined(CONFIG_SBC2410X) || \
       defined(CONFIG_SMDK2410) || \
+      defined(CONFIG_MINI2440) || \
       defined(CONFIG_VCMA9)
        tbclk = CONFIG_SYS_HZ;
 #else
@@ -215,4 +216,4 @@
        /*NOTREACHED*/
 }


-#endif /* defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) */
+#endif /* defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440) || defined(CONFIG_TRAB) */

主要是添加S3C2440相关的宏定义。


3.读取时钟频率相关函数

还是时钟频率相关设定,前面只设置了ARM核心的时钟工作频率FCLKS3C2440HCLKPCLKS3C2410的分频是不一样的,所以需要对这部分进行修改,u-boot能不能启动起来,第一重要点就是看你时钟频率是否设置正确。

Index: speed.c
===================================================================
RCS file: /home/tracy/work/cvsroot/u-boot-2009.08/cpu/arm920t/s3c24x0/speed.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- speed.c     10 Mar 2012 13:18:21 -0000      1.1
+++ speed.c     30 Mar 2012 12:50:01 -0000      1.2
@@ -30,11 +30,11 @@
  */


 #include <common.h>
-#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB)
+#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440) || defined(CONFIG_TRAB)


 #if defined(CONFIG_S3C2400)
 #include <s3c2400.h>
-#elif defined(CONFIG_S3C2410)
+#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 #include <s3c2410.h>
 #endif


@@ -67,7 +67,14 @@
     p = ((r & 0x003F0) >> 4) + 2;
     s = r & 0x3;


+#ifdef CONFIG_S3C2440
+    if (pllreg == MPLL)
+        return((CONFIG_SYS_CLK_FREQ * m * 2) / (p << s));
+    else
+        return((CONFIG_SYS_CLK_FREQ * m) / (p << s));  
+#elif
     return((CONFIG_SYS_CLK_FREQ * m) / (p << s));
+#endif
 }


 /* return FCLK frequency */
@@ -81,7 +88,19 @@
 {
     S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();


+#ifdef CONFIG_S3C2440
+    if ((clk_power->CLKDIVN & 0x6) == 0x2) {
+       return(get_FCLK()/2);
+    } else if ((clk_power->CLKDIVN & 0x6) == 0x4) {
+       return((clk_power->CAMDIVN & 0x200) ? get_FCLK()/8 : get_FCLK()/4);
+    } else if ((clk_power->CLKDIVN & 0x6) == 0x6) {


4.S3C2440宏定义添加

Index: drivers/rtc/s3c24x0_rtc.c
===================================================================
RCS file: /home/tracy/work/cvsroot/u-boot-2009.08/drivers/rtc/s3c24x0_rtc.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 s3c24x0_rtc.c
--- drivers/rtc/s3c24x0_rtc.c   10 Mar 2012 13:18:21 -0000      1.1.1.1
+++ drivers/rtc/s3c24x0_rtc.c   29 Mar 2012 10:54:34 -0000
@@ -32,7 +32,7 @@


 #if defined(CONFIG_S3C2400)
 #include <s3c2400.h>
-#elif defined(CONFIG_S3C2410)
+#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 #include <s3c2410.h>
 #endif


Index: drivers/serial/serial_s3c24x0.c
===================================================================
RCS file: /home/tracy/work/cvsroot/u-boot-2009.08/drivers/serial/serial_s3c24x0.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 serial_s3c24x0.c
--- drivers/serial/serial_s3c24x0.c     10 Mar 2012 13:18:21 -0000      1.1.1.1
+++ drivers/serial/serial_s3c24x0.c     29 Mar 2012 10:03:40 -0000
@@ -21,7 +21,7 @@
 #include <common.h>
 #if defined(CONFIG_S3C2400) || defined(CONFIG_TRAB)
 #include <s3c2400.h>
-#elif defined(CONFIG_S3C2410)
+#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 #include <s3c2410.h>
 #endif


Index: include/s3c24x0.h
===================================================================
RCS file: /home/tracy/work/cvsroot/u-boot-2009.08/include/s3c24x0.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 s3c24x0.h
--- include/s3c24x0.h   10 Mar 2012 13:18:21 -0000      1.1.1.1
+++ include/s3c24x0.h   29 Mar 2012 15:27:42 -0000
@@ -82,7 +82,7 @@
        S3C24X0_REG32   PRIORITY;
        S3C24X0_REG32   INTPND;
        S3C24X0_REG32   INTOFFSET;
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
        S3C24X0_REG32   SUBSRCPND;
        S3C24X0_REG32   INTSUBMSK;

 #endif
@@ -92,11 +92,11 @@
 /* DMAS (see manual chapter 8) */
 typedef struct {
        S3C24X0_REG32   DISRC;
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
        S3C24X0_REG32   DISRCC;
 #endif
        S3C24X0_REG32   DIDST;
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
        S3C24X0_REG32   DIDSTC;
 #endif
        S3C24X0_REG32   DCON;
@@ -107,7 +107,7 @@
 #ifdef CONFIG_S3C2400
        S3C24X0_REG32   res[1];
 #endif
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
        S3C24X0_REG32   res[7];
 #endif
 } /*__attribute__((__packed__))*/ S3C24X0_DMA;
@@ -126,6 +126,9 @@
        S3C24X0_REG32   CLKCON;
        S3C24X0_REG32   CLKSLOW;
        S3C24X0_REG32   CLKDIVN;
+#ifdef CONFIG_S3C2440
+       S3C24X0_REG32   CAMDIVN;
+#endif
 } /*__attribute__((__packed__))*/ S3C24X0_CLOCK_POWER;




@@ -145,7 +148,7 @@
        S3C24X0_REG32   res[8];
        S3C24X0_REG32   DITHMODE;
        S3C24X0_REG32   TPAL;
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
        S3C24X0_REG32   LCDINTPND;
        S3C24X0_REG32   LCDSRCPND;
        S3C24X0_REG32   LCDINTMSK;
@@ -451,6 +454,56 @@
        S3C24X0_REG32   GSTATUS3;

        S3C24X0_REG32   GSTATUS4;
 #endif
+#ifdef CONFIG_S3C2440
+       S3C24X0_REG32   GPACON;
+       S3C24X0_REG32   GPADAT;
+       S3C24X0_REG32   res1[2];
+       S3C24X0_REG32   GPBCON;
+       S3C24X0_REG32   GPBDAT;
+       S3C24X0_REG32   GPBUP;
+       S3C24X0_REG32   res2;
+       S3C24X0_REG32   GPCCON;
+       S3C24X0_REG32   GPCDAT;
+       S3C24X0_REG32   GPCUP;
+       S3C24X0_REG32   res3;
+       S3C24X0_REG32   GPDCON;
+       S3C24X0_REG32   GPDDAT;
+       S3C24X0_REG32   GPDUP;
+       S3C24X0_REG32   res4;
+       S3C24X0_REG32   GPECON;
+       S3C24X0_REG32   GPEDAT;
+       S3C24X0_REG32   GPEUP;
+       S3C24X0_REG32   res5;
+       S3C24X0_REG32   GPFCON;
+       S3C24X0_REG32   GPFDAT;
+       S3C24X0_REG32   GPFUP;
+       S3C24X0_REG32   res6;
+       S3C24X0_REG32   GPGCON;
+       S3C24X0_REG32   GPGDAT;
+       S3C24X0_REG32   GPGUP;
+       S3C24X0_REG32   res7;
+       S3C24X0_REG32   GPHCON;
+       S3C24X0_REG32   GPHDAT;
+       S3C24X0_REG32   GPHUP;
+       S3C24X0_REG32   res8;
+
+       S3C24X0_REG32   MISCCR;
+       S3C24X0_REG32   DCLKCON;
+       S3C24X0_REG32   EXTINT0;
+       S3C24X0_REG32   EXTINT1;
+       S3C24X0_REG32   EXTINT2;
+       S3C24X0_REG32   EINTFLT0;
+       S3C24X0_REG32   EINTFLT1;
+       S3C24X0_REG32   EINTFLT2;
+       S3C24X0_REG32   EINTFLT3;

+       S3C24X0_REG32   GSTATUS4;
+#endif
 } /*__attribute__((__packed__))*/ S3C24X0_GPIO;

这部分修改主要是为了能够编译通过。所以这阶段移植主要有两点需要注意,一是时钟频率要设置正确。二是SDRAM相关数据要设置正确。只要这两点正确了,再加上添加能使u-boot编译通过的宏定义,u-boot启动起来是没有问题的。


5.将编译好的u-boot烧写到norflash中,u-boot成功启动。




转载于:https://www.cnblogs.com/phonegap/archive/2012/04/26/2536095.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值