注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

还东国的博客

行之苟有恒,久久自芬芳

 
 
 

日志

 
 

嵌入式开发实战3——uboot源码的修改之三修改初始化的代码  

2012-05-12 22:51:11|  分类: ARM开发 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
 

嵌入式开发实战3——uboot源码的修改之三修改初始化的代码

接着上面的来修改,将启动的部分修改完成后,就进入了初始化代码的修改,这个比较简单,只有两个文件需要动一下,他们分别是:

Lib_arm/board.c和原来自己建立的/mini2440/mini2440.c

先从第一个来说:

我们需要增加自己写的LED显示模块,并注释掉原有的部分。

#include <s3c2410.h> //ADD for LED

 

/*2012-05-12 fjf  cancel blue LED*/

#if 0

void inline __blue_LED_on(void) {}

void blue_LED_on(void) __attribute__((weak, alias("__blue_LED_on")));

void inline __blue_LED_off(void) {}

void blue_LED_off(void) __attribute__((weak, alias("__blue_LED_off")));

#endif

 

在static int display_banner (void)函数中增加并修改:

       /*------------------fjf 2012-05-12 region add led module---------------------*/

       #if defined(CONFIG_MINI2440_LED)

       struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();

       gpio->GPBDAT = 0x101; //fjf add set led

       #endif

       printf ("\n\n%s\n\n", version_string);

      printf (" modified by fpcfjf (fpcfjf@163.com)\n");

      printf (" start Linux forever!!\n\n");

       /*------------------endregion------------------------------------------------ */

 

其它的一些东西暂时可以不做修改。再来看mini2440.c的修改过程:

先增加头文件:

#include <video_fb.h>  /*2012-5-12 add include head file*/

然后对宏进行修改和增删:

#define M_PDIV 0x4

#define M_SDIV 0x1

#elif FCLK_SPEED==1 /* Fout = 202.8MHz */

/*2012-05-12 fjf  add LED------------------------------------------------*/

#if defined(CONFIG_S3C2410)

/* Fout = 202.8MHz */

#define M_MDIV 0xA1

#define M_PDIV 0x3

#define M_SDIV 0x1

#endif

 

#if defined(CONFIG_S3C2440)

/* Fout = 405MHz */

#define M_MDIV 0x7f

#define M_PDIV 0x2

#define M_SDIV 0x1

#endif

/*endregion-------------------------------------------------------------*/

#endif

#define USB_CLOCK 1

 

接下来:

#if USB_CLOCK==0

#define U_M_MDIV    0xA1

#define U_M_PDIV    0x3

#define U_M_SDIV    0x1

#elif USB_CLOCK==1

/*fjf 2012-5-12 add--------------------------------------------*/

#if defined(CONFIG_S3C2410)

#define U_M_MDIV    0x48

#define U_M_PDIV    0x3

#endif

#if defined(CONFIG_S3C2440)

#define U_M_MDIV 0x38

#define U_M_PDIV 0x2

#endif

/*fjf 2012-05-12 endregion--------------------------------------*/

#define U_M_SDIV    0x2

#endif

开始修改int board_init (void)函数中的内容:

    /* some delay between MPLL and UPLL */

    delay (8000);

 

    /* set up the I/O ports */

    gpio->GPACON = 0x007FFFFF;

    #if defined(CONFIG_MINI2440)          /*add and modify 2012-05-12 fjf*/

        gpio->GPBCON = 0x00295551;

    #else

    gpio->GPBCON = 0x00044556;

    #endif                                              /*up five rows*/

    gpio->GPBUP = 0x000007FF;

    gpio->GPCCON = 0xAAAAAAAA;

    gpio->GPCUP = 0xFFFFFFFF;             /*0000FFF--->FFFFFFFF  modify fjf 2012- 5-12*/

    gpio->GPDCON = 0xAAAAAAAA;

    gpio->GPDUP = 0xFFFFFFFF;            /*0000FFF--->FFFFFFFF  modify fjf 2012- 5-12*/

    gpio->GPECON = 0xAAAAAAAA;

    gpio->GPEUP = 0x0000FFFF;

    gpio->GPFCON = 0x000055AA;

    gpio->GPFUP = 0x000000FF;

    gpio->GPGCON = 0xFF95FF3A;

    gpio->GPGUP = 0x0000FFFF;

    gpio->GPHCON = 0x0016FAAA;

    gpio->GPHUP = 0x000007FF;

 

    gpio->EXTINT0=0x22222222;

    gpio->EXTINT1=0x22222222;

    gpio->EXTINT2=0x22222222;

 

    /* arch number of SMDK2410-Board */  /*mdofiy fjf   add judge macro */

    #if defined(CONFIG_S3C2410)

        gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;

    #endif

 

    /*region fjf 2012-5-12 ----------------------------------*/

    #if defined(CONFIG_S3C2440)

    /* arch number of S3C2440-Board */

        gd->bd->bi_arch_number = MACH_TYPE_MINI2440 ;

    #endif

    /*endregion---------------------------------------------------------------*/

    /* adress of boot parameters */

    gd->bd->bi_boot_params = 0x30000100;

 

    icache_enable();

    dcache_enable();

 

    /*fjf 2012-5-12 region ------------------------------------------*/

    #if defined(CONFIG_MINI2440_LED)

        gpio->GPBDAT = 0x00000181;

    #endif

 

    /*endregion--------------------------------------------------------------*/

新增下列代码在上述函数代码之后:

/*fjf 2012-5-12 ----------------------------------------------------------*/

#define MVAL (0)

#define MVAL_USED (0) //0=each frame 1=rate by MVAL

#define INVVDEN (1) //0=normal 1=inverted

#define BSWP (0) //Byte swap control

#define HWSWP (1) //Half word swap control

 

 

//TFT 240320

#define LCD_XSIZE_TFT_240320 (240)

#define LCD_YSIZE_TFT_240320 (320)

 

//TFT240320

#define HOZVAL_TFT_240320 (LCD_XSIZE_TFT_240320-1)

#define LINEVAL_TFT_240320 (LCD_YSIZE_TFT_240320-1)

 

//Timing parameter for NEC3.5"

#define VBPD_240320 (3)

#define VFPD_240320 (10)

#define VSPW_240320 (1)

 

#define HBPD_240320 (5)

#define HFPD_240320 (2)

#define HSPW_240320_NEC (36) //Adjust the horizontal displacement of thescreen :fpcfjf@163.com

#define HSPW_240320_TD (23) //64MB nand mini2440 is 36 ,128MB is 23

 //+ : --> - : <--

#define CLKVAL_TFT_240320 (3)

//FCLK=101.25MHz,HCLK=50.625MHz,VCLK=6.33MHz

 

 

void board_video_init(GraphicDevice *pGD)

{

struct s3c24x0_lcd * const lcd = s3c24x0_get_base_lcd();

struct s3c2410_nand * const nand = s3c2410_get_base_nand();

 /* FIXME: select LCM type by env variable */

 

 /* Configuration for GTA01 LCM on QT2410 */

 lcd->LCDCON1 = 0x00000378; /* CLKVAL=4, BPPMODE=16bpp, TFT, ENVID=0 */

 lcd->LCDCON2 =

(VBPD_240320<<24)|(LINEVAL_TFT_240320<<14)|(VFPD_240320<<6)|(VSPW_240320);

 lcd->LCDCON3 = (HBPD_240320<<19)|(HOZVAL_TFT_240320<<8)|(HFPD_240320);

 

 if ( (nand->NFCONF) & 0x08 ) {

 lcd->LCDCON4 = (MVAL<<8)|(HSPW_240320_TD);

 }

 else {

 lcd->LCDCON4 = (MVAL<<8)|(HSPW_240320_NEC);

 }

 

 lcd->LCDCON5 = 0x00000f09;

 lcd->LPCSEL = 0x00000000;

}

 

/*enregion---------------------------------------------------------*/

利用宏注释掉下列代码:

/*fjf 2012-05-12 cancel the next list code*/

#if 0

#if defined(CONFIG_CMD_NAND)

extern ulong nand_probe(ulong physadr);

 

static inline void NF_Reset(void)

{

    int i;

 

    NF_SetCE(NFCE_LOW);

    NF_Cmd(0xFF);       /* reset command */

    for(i = 0; i < 10; i++);    /* tWB = 100ns. */

    NF_WaitRB();        /* wait 200~500us; */

    NF_SetCE(NFCE_HIGH);

}

 

static inline void NF_Init(void)

{

#if 1

#define TACLS   0

#define TWRPH0  3

#define TWRPH1  0

#else

#define TACLS   0

#define TWRPH0  4

#define TWRPH1  2

#endif

 

    NF_Conf((1<<15)|(0<<14)|(0<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0));

    /*nand->NFCONF = (1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0); */

    /* 1  1    1     1,   1      xxx,  r xxx,   r xxx */

    /* En 512B 4step ECCR nFCE=H tACLS   tWRPH0   tWRPH1 */

 

    NF_Reset();

}

 

void nand_init(void)

{

    struct s3c2410_nand * const nand = s3c2410_get_base_nand();

 

    NF_Init();

#ifdef DEBUG

    printf("NAND flash probing at 0x%.8lX\n", (ulong)nand);

#endif

    printf ("%4lu MB\n", nand_probe((ulong)nand) >> 20);

}

#endif

#endif

 

在函数int board_eth_init(bd_t *bis)中增加网卡的初始化代码:

/*fjf 2012-05-12  add next three rows*/

#ifdef CONFIG_DRIVER_DM9000

    rc = dm9000_initialize(bis);

#endif

于是,至此为止,第二步也基本OK了。

继续努力!!!

  评论这张
 
阅读(1290)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017