| |
 |
|
 |
 |
|
 |
移植U-Boot.1.2.0到友善之臂SBC2440V4(S3C2440AL)(1)
|
|
|
移植U-Boot.1.2.0到友善之臂SBC2440V4(S3C2440AL)(1)
首先,U-Boot1.2.0还没有支持s3c2440,这次移植是用2410的文件稍作修改而成的。其实2440和2410的区别主要是2440的主频更高,增加了摄像头接口和AC‘97音频接口;寄存器方面,除了新增模块的寄存器外,移植所要注意的是NAND FlASH控制器的寄存器有较大的变化、芯片的时钟频率控制寄存器(芯片PLL的寄存器)有一定的变化。其他寄存器基本是兼容的。
一、在U-Boot中建立自己的开发板类型,并测试编译。 我为开发板取名叫: tekkaman2440
0 在工作目录下解压U-Boot。 $tar zxvf u-boot.git.tar.gz
1 进入U-Boot目录,修改Makefile $cd u-boot.git/ $vi Makefile #为tekkaman2440建立编译项
sbc2410x_config: unconfig @$(MKCONFIG) $(@:_config=) arm arm920t sbc2410x NULL s3c24x0
tekkaman2440_config : unconfig @$(MKCONFIG) $(@:_config=) arm arm920t tekkaman2440 tekkaman s3c24x0 各项的意思如下: arm: CPU的架构(ARCH) arm920t: CPU的类型(CPU),其对应于cpu/arm920t子目录。 tekkaman2440: 开发板的型号(BOARD),对应于board/tekkaman/tekkaman2440目录。 tekkaman: 开发者/或经销商(vender)。 s3c24x0: 片上系统(SOC)。
同时在“ifndef CROSS_COMPILE ”之前 加上自己交叉编译器的路径,比如我使用crosstool-0.43制作的基于2.6.22.2内核和gcc-4.1.0-glibc-2.3.2的ARM9TDMI交叉编译器,则:
CROSS_COMPILE=/home/tekkaman/working/crosstool-gcc410-k26222/gcc-4.1.0-glibc-2.3.2/arm-9tdmi-linux-gnu/bin/arm-9tdmi-linux-gnu-
2 在/board子目录中建立自己的开发板tekkaman2440目录
由于我在上一步板子的 开发者/或经销商(vender)中填了 tekkaman ,所以开发板tekkaman2440目录一定要建在/board子目录中的tekkaman目录下 ,否则编译会出错。
$cd board$mkdir tekkaman tekkaman/tekkaman2440 $cp -arf sbc2410x/* tekkaman/tekkaman2440/ $cd tekkaman/tekkaman2440 $mv sbc2410x.c tekkaman2440.c 还要记得修改自己的开发板tekkaman2440目录下的Makefile文件,不然编译时会出错: COBJS := tekkaman2440.o flash.o $vi Makefile
3 在include/configs/中建立配置头文件 $cd ../../.. $cp include/configs/sbc2410x.h include/configs/tekkaman2440.h
4 测试编译能否成功 $make tekkaman2440_config Configuring for tekkaman2440 board... (如果出现: $ make tekkaman2440_config Makefile:1927: *** 遗漏分隔符 。 停止。 请在U-boot的根目录下的Makefile的
@$(MKCONFIG) $(@:_config=) arm arm920t tekkaman2440 tekkaman) 前加上“Tab”键) $make
我到这一步测试交叉编译成功!!
                            
二、修改U-Boot中的文件,以匹配友善之臂SBC2440V4。 1 修改/cpu/arm920t/start.S
(0)修改寄存器地址定义 /* turn off the watchdog */ #if defined(CONFIG_S3C2400) # define pWTCON 0x15300000 # define INTMSK 0x14400008 /* Interupt-Controller base addresses */ # define CLKDIVN 0x14800014 /* clock divisor register */ #elif defined(CONFIG_S3C2410)|| defined(CONFIG_S3C2440) # define pWTCON 0x53000000 # define INTMSK 0x4A000008 /* Interupt-Controller base addresses */ # define INTSUBMSK 0x4A00001C # define CLKDIVN 0x4C000014 /* clock divisor register */ #endif
(1)修改中断禁止部分
#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440) ldr r0, =pWTCON mov r1, #0x0 str r1, [r0]
/* * mask all IRQs by setting all bits in the INTMR - default */ mov r1, #0xffffffff ldr r0, =INTMSK str r1, [r0] # if defined(CONFIG_S3C2410) ldr r1, =0x7ff //根据2410芯片手册,INTSUBMSK有11位可用, //vivi也是0x7ff,不知为什么U-Boot一直没改过来。 ldr r0, =INTSUBMSK str r1, [r0] # endif # if defined(CONFIG_S3C2440) ldr r1, =0x7fff //根据2440芯片手册,INTSUBMSK有15位可用 ldr r0, =INTSUBMSK str r1, [r0] # endif
(2)修改时钟设置(2440的主频可达533MHz,但是我设到533MHz时系统很不稳定,不知是不是SDRAM和总线配置的影响,所以现在先设到405MHz,以后在改进。)
/* FCLK:HCLK:PCLK = 1:4:8 */ ldr r0, =CLKDIVN mov r1, #5 str r1, [r0] mrc p15, 0, r1, c1, c0, 0 /*read ctrl register tekkaman*/ orr r1, r1, #0xc0000000 /*Asynchronous tekkaman*/ mcr p15, 0, r1, c1, c0, 0 /*write ctrl register tekkaman*/
#if defined(CONFIG_S3C2440) /*now, CPU clock is 405.00 Mhz tekkaman*/ mov r1, #CLK_CTL_BASE /* tekkaman*/ mov r2, #MDIV_405 /* mpll_405mhz tekkaman*/ add r2, r2, #PSDIV_405 /* mpll_405mhz tekkaman*/ str r2, [r1, #0x04] /* MPLLCON tekkaman */ #endif #if defined(CONFIG_S3C2410) /*now, CPU clock is 202.8 Mhz tekkaman*/ mov r1, #CLK_CTL_BASE /* tekkaman*/ mov r2, #MDIV_200 /* mpll_200mhz tekkaman*/ add r2, r2, #PSDIV_200 /* mpll_200mhz tekkaman*/ str r2, [r1, #0x04] /* MPLLCON tekkaman */#endif#endif /* CONFIG_S3C2400 || CONFIG_S3C2410|| CONFIG_S3C2440 */
红色部分是我添加的,利用vivi的代码,将其设为405.00MHz 并在前面加上:
#elif defined(CONFIG_S3C2410) # define pWTCON 0x53000000 # define INTMSK 0x4A000008 /* Interupt-Controller base addresses */ # define INTSUBMSK 0x4A00001C # define CLKDIVN 0x4C000014 /* clock divisor register */ #define CLK_CTL_BASE 0x4C000000 /* tekkaman */ #if defined(CONFIG_S3C2440) #define MDIV_405 0x7f << 12 /* tekkaman */ #define PSDIV_405 0x21 /* tekkaman */ #endif #if defined(CONFIG_S3C2410) #define MDIV_200 0xa1 << 12 /* tekkaman */ #define PSDIV_200 0x31 /* tekkaman */ #endif #endif
(3)将从Flash启动改成从NAND Flash启动。(特别注意:这和2410的程序有不同,不可混用!!!是拷贝vivi的代码。) 将以下U-Boot的重定向语句段: #ifndef CONFIG_SKIP_RELOCATE_UBOOT relocate: /* relocate U-Boot to RAM */ adr r0, _start /* r0 <- current position of code */ ldr r1, _TEXT_BASE /* test if we run from flash or RAM */ cmp r0, r1 /* don't reloc during debug */ beq stack_setup
ldr r2, _armboot_start ldr r3, _bss_start sub r2, r3, r2 /* r2 <- size of armboot */ add r2, r0, r2 /* r2 <- source end address */
copy_loop: ldmia r0!, {r3-r10} /* copy from source address [r0] */ stmia r1!, {r3-r10} /* copy to target address [r1] */ cmp r0, r2 /* until source end addreee [r2] */ ble copy_loop #endif /* CONFIG_SKIP_RELOCATE_UBOOT */ 替换成:
#ifdef CONFIG_S3C2440_NAND_BOOT @tekkaman@@@@@@@@@@@@@@@@SSSSSSSSSSSSS @ reset NAND mov r1, #NAND_CTL_BASE ldr r2, =( (7<<12)|(7<<8)|(7<<4)|(0<<0) ) str r2, [r1, #oNFCONF] ldr r2, [r1, #oNFCONF]
ldr r2, =( (1<<4)|(0<<1)|(1<<0) ) @ Active low CE Control str r2, [r1, #oNFCONT] ldr r2, [r1, #oNFCONT]
ldr r2, =(0x6) @ RnB Clear str r2, [r1, #oNFSTAT] ldr r2, [r1, #oNFSTAT] mov r2, #0xff @ RESET command strb r2, [r1, #oNFCMD]
mov r3, #0 @ wait nand1: add r3, r3, #0x1 cmp r3, #0xa blt nand1
nand2: ldr r2, [r1, #oNFSTAT] @ wait ready tst r2, #0x4 beq nand2
ldr r2, [r1, #oNFCONT] orr r2, r2, #0x2 @ Flash Memory Chip Disable str r2, [r1, #oNFCONT]
@ get read to call C functions (for nand_read()) ldr sp, DW_STACK_START @ setup stack pointer mov fp, #0 @ no previous frame, so fp=0
@ copy U-Boot to RAM ldr r0, =TEXT_BASE mov r1, #0x0 mov r2, #0x20000 bl nand_read_ll tst r0, #0x0 beq ok_nand_read
bad_nand_read: loop2: b loop2 @ infinite loop
ok_nand_read: @ verify mov r0, #0 ldr r1, =TEXT_BASE mov r2, #0x400 @ 4 bytes * 1024 = 4K-bytes go_next: ldr r3, [r0], #4 ldr r4, [r1], #4 teq r3, r4 bne notmatch subs r2, r2, #4 beq stack_setup bne go_next
notmatch: loop3: b loop3 @ infinite loop
#endif @ CONFIG_S3C2440_NAND_BOOT @tekkaman@@@@@@@@@@@@@@@@@@EEEEEEEEE
在“ldr pc, _start_armboot”之前加入:
@ LED1 on u-boot stage 1 is ok! mov r1, #GPIO_CTL_BASE add r1, r1, #oGPIO_B ldr r2,=0x155aa str r2, [r1, #oGPIO_CON] mov r2, #0xff str r2, [r1, #oGPIO_UP] mov r2, #0x1c0 str r2, [r1, #oGPIO_DAT]
修改目的:如果看到只有LED1亮了,说明U-Boot的第一阶段已完成!
在 “ _start_armboot: .word start_armboot ” 后加入: .align 2 DW_STACK_START: .word STACK_BASE+STACK_SIZE-4
2 在board/tekkaman/tekkaman2440加入NAND Flash读函数文件,拷贝vivi中的nand_read.c文件到此文件夹即可:
#include <config.h>
#define __REGb(x) (*(volatile unsigned char *)(x)) #define __REGi(x) (*(volatile unsigned int *)(x)) #define NF_BASE 0x4e000000
#define NFCONF __REGi(NF_BASE + 0x0) #define NFCONT __REGi(NF_BASE + 0x4) #define NFCMD __REGb(NF_BASE + 0x8) #define NFADDR __REGb(NF_BASE + 0xC) #define NFDATA __REGb(NF_BASE + 0x10) #define NFSTAT __REGb(NF_BASE + 0x20)
//#define GPDAT __REGi(GPIO_CTL_BASE+oGPIO_F+oGPIO_DAT)
#define NAND_CHIP_ENABLE (NFCONT &= ~(1<<1)) #define NAND_CHIP_DISABLE (NFCONT |= (1<<1)) #define NAND_CLEAR_RB (NFSTAT |= (1<<2)) #define NAND_DETECT_RB { while(! (NFSTAT&(1<<2)) );}
#define BUSY 4 inline void wait_idle(void) { while(!(NFSTAT & BUSY)); NFSTAT |= BUSY; }
#define NAND_SECTOR_SIZE 512 #define NAND_BLOCK_MASK (NAND_SECTOR_SIZE - 1)
/* low level nand read function */ int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size) { int i, j;
if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) { return -1; /* invalid alignment */ }
NAND_CHIP_ENABLE;
for(i=start_addr; i < (start_addr + size);) { /* READ0 */ NAND_CLEAR_RB; NFCMD = 0;
/* Write Address */ NFADDR = i & 0xff; NFADDR = (i >> 9) & 0xff; NFADDR = (i >> 17) & 0xff; NFADDR = (i >> 25) & 0xff;
NAND_DETECT_RB;
for(j=0; j < NAND_SECTOR_SIZE; j++, i++) { *buf = (NFDATA & 0xff); buf++; } } NAND_CHIP_DISABLE; return 0; }
注意:s3c2410与s3c2440的Nand Flash控制器寄存器不同,不能混用!!
3 修改board/tekkaman/tekkaman2440/Makefile文件 ...... OBJS := tekkaman2440.o nand_read.o flash.o ......
4 修改include/configs/tekkaman2440.h文件,添加如下内容(注意:s3c2410与s3c2440的Nand Flash控制器寄存器不同,不能混用!!): ...... /* * Nandflash Boot */ #define CONFIG_S3C2440_NAND_BOOT 1 #define STACK_BASE 0x33f00000 #define STACK_SIZE 0x8000 //#define UBOOT_RAM_BASE 0x33f80000 /* NAND Flash Controller */ #define NAND_CTL_BASE 0x4E000000 #define bINT_CTL(Nb) __REG(INT_CTL_BASE + (Nb)) /* Offset */ #define oNFCONF 0x00 #define oNFCONT 0x04 #define oNFCMD 0x08 #define oNFADDR 0x0c #define oNFDATA 0x10 #define oNFSTAT 0x20 #define oNFECC 0x2c
/* GPIO */ #define GPIO_CTL_BASE 0x56000000 #define oGPIO_B 0x10 #define oGPIO_CON 0x0 /* R/W, Configures the pins of the port */ #define oGPIO_DAT 0x4 /* R/W, Data register for port */ #define oGPIO_UP 0x8 /* R/W, Pull-up disable register */ #endif /* __CONFIG_H */
5 修改board/tekkaman/tekkaman2440/lowlevel_init.S文件 依照开发板的内存区的配置情况, 修改board/tekkaman/tekkaman2440/lowlevel_init.S文件,我利用友善之臂提供的vivi源码里的信息做了如下更改: ...... /* REFRESH parameter */ #define REFEN 0x1 /* Refresh enable */ #define TREFMD 0x0 /* CBR(CAS before RAS)/Auto refresh */ #define Trp 0x2 /* 4clk */ #define Trc 0x3 /* 7clk */ #define Tchr 0x2 /* 3clk */ #define REFCNT 1012 ......
6 修改/board/tekkaman/tekkaman2440/tekkaman2440.c 因为友善之臂SBC2440和smdk2410的GPIO连接有所不同,修改其对GPIO和PLL的配置(请参阅友善之臂SBC2440的硬件说明和2440芯片手册): ......
#elif FCLK_SPEED==1 /* Fout = 405MHz */ //#define M_MDIV 0x5c //#define M_PDIV 0x4 //#define M_SDIV 0x0 #define M_MDIV 0x7f #define M_PDIV 0x2 #define 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
......
/* set up the I/O ports */ gpio->GPACON = 0x007FFFFF; //gpio->GPBCON = 0x00044556; gpio->GPBCON = 0x00055556;
...... /* arch number of S3C2440 -Board */ gd->bd->bi_arch_number = MACH_TYPE_S3C2440 ;
/* adress of boot parameters */
gd->bd->bi_boot_params = 0x30000100;
icache_enable();
dcache_enable();
gpio->GPBDAT = 0x180; //tekkamanninja
//int board_init (void)设置完成后,LED1和LED2会亮起!
return 0;
}
7 为了实现NAND Flash的读写,再次修改/include/configs/tekkaman2440.h (请格外注意:如果编译时报错,在Linux下用KWrite等有高亮显示的文本编辑器看看文件的注释是不是为注释应有的颜色(KWrite中为灰色),如果不是,则将注释删除。因为#define后面的注释被认为是程序的一部分。建议注释和#define分行写) ...... /* * High Level Configuration Options * (easy to change) */ #define CONFIG_ARM920T 1 /* This is an ARM920T Core */ #define CONFIG_S3C2440 1 /* in a SAMSUNG S3C2440 SoC */ #define CONFIG_tekkaman2440 1 /* on a SAMSUNG tekkaman2440 Board */ ...... /*********************************************************** * Command definition ***********************************************************/ #define CONFIG_COMMANDS \ (CONFIG_CMD_DFL | \ CFG_CMD_CACHE | \ CFG_CMD_NAND | \ CFG_CMD_NET | \ /*CFG_CMD_EEPROM |*/ \ /*CFG_CMD_I2C |*/ \ /*CFG_CMD_USB |*/ \ CFG_CMD_PING | \ CFG_CMD_ENV | \ CFG_CMD_REGINFO | \ CFG_CMD_DATE | \ CFG_CMD_DHCP | \ CFG_CMD_ELF)
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */ #include <cmd_confdefs.h> #define CFG_LONGHELP /* undef to save memory */
#define CFG_PROMPT "[Tekkaman2440]#" /*Monitor Command Prompt */ #define CFG_CBSIZE 256 /* Console I/O Buffer Size */ ...... #define CFG_LOAD_ADDR 0x30008000 /* default load address */
...... /* Timeout for Flash Write */
#define CFG_ENV_IS_IN_NAND 1 #define CFG_ENV_OFFSET 0X20000 //#define ENV_IS_EMBEDDED 1 #define CFG_NAND_LEGACY
#define CFG_ENV_SIZE 0x10000 /* Total Size of Environment Sector */ /*---------------------------------------------------------------------- * NAND flash settings */ #if (CONFIG_COMMANDS & CFG_CMD_NAND) #define CFG_NAND_BASE 0x4E000000 /* NandFlash控制器在SFR区起始寄存器地址 */ #define CFG_MAX_NAND_DEVICE 1 /* 支持的最在Nand Flash数据 */ #define SECTORSIZE 512 /* 1页的大小 */ #define NAND_SECTOR_SIZE SECTORSIZE #define NAND_BLOCK_MASK 511 /* 页掩码 */ #define ADDR_COLUMN 1 /* 一个字节的Column地址 */
#define ADDR_PAGE 3 /* 3字节的页块地址!!!!!*/ #define ADDR_COLUMN_PAGE 4 /* 总共4字节的页块地址!!!!! */ #define NAND_ChipID_UNKNOWN 0x00 /* 未知芯片的ID号 */ #define NAND_MAX_FLOORS 1 #define NAND_MAX_CHIPS 1 /* Nand Flash命令层底层接口函数 */ #define WRITE_NAND_COMMAND(d, adr) {rNFCMD = d;}
#define WRITE_NAND_ADDRESS(d, adr) {rNFADDR = d;}
#define WRITE_NAND(d, adr) {rNFDATA = d;}
#define READ_NAND(adr) (rNFDATA)
#define NAND_WAIT_READY(nand) {while(!(rNFSTAT&(1<<0)));}
#define NAND_DISABLE_CE(nand) {rNFCONT |= (1<<1);}
#define NAND_ENABLE_CE(nand) {rNFCONT &= ~(1<<1);}
#define WRITE_NAND_COMMANDW(d, adr) NF_CmdW(d)
/* the following functions are NOP's because S3C24X0 handles this in hardware */
#define NAND_CTL_CLRALE(nandptr) #define NAND_CTL_SETALE(nandptr) #define NAND_CTL_CLRCLE(nandptr) #define NAND_CTL_SETCLE(nandptr) /* 允许Nand Flash写校验 */ #define CONFIG_MTD_NAND_VERIFY_WRITE 1 ......
#define rNFCONF (*(volatile unsigned int *)0x4e000000)
#define rNFCONT (*(volatile unsigned int *)0x4e000004)
#define rNFCMD (*(volatile unsigned char *)0x4e000008)
#define rNFADDR (*(volatile unsigned char *)0x4e00000c)
#define rNFDATA (*(volatile unsigned char *)0x4e000010)
#define rNFSTAT (*(volatile unsigned int *)0x4e000020)
#define rNFECC (*(volatile unsigned int *)0x4e00002c)
#endif /* __CONFIG_H */
|
回目录 移植U-Boot.1.2.0到友善之臂SBC2440V4(S3C2440AL)
|
|
发表于: 2007-10-09,修改于: 2007-11-26 15:46,已浏览4122次,有评论0条
推荐
投诉
|
|
 |
|
 |
|  |
|
 |
 |
|
 |
网友评论
 |
|
 |
 |
网友:
homewood
| 时间:2007-10-30 19:47:18 IP地址:58.68.132.★ |
|
|
|
出现笔误:(多了)
static inline void NF_Cont(u16 cont)
{
|
|
|
|
 |
|
 |
 |
|
 |
 |
网友:
本站网友 | 时间:2008-01-22 00:02:02 IP地址:58.60.63.★ |
|
|
|
你好,首先很感谢你文章的分享,我现在也出现了这样的问题:
U-Boot 1.1.4 (Jan 21 2008 - 01:28:30)
U-Boot code: 33F80000 -> 33F99A50 BSS: -> 33F9DC30
RAM Configuration:
Bank #0: 30000000 64 MB
Flash: 2 MB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
dm9000 not found at 0x18000300 id: 0x00000000
MAC: 00:00:00:00:00:00
could not establish link
SMDK2410 #
找不到网卡,lowlevel_init.s的bank3默认接网卡,我的实验箱也是接bank3的,所以我没修改,按你文章的做法,屏蔽CS8900的宏定义,并添加改以下宏:
在smdk2410.h中添加版主上面所说的宏:
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE 0x18000300
#define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE+4)
#define CONFIG_DM9000_USE_16BIT
然后在board.c原来用到CS89000的地方相应添加如下内容:
#ifdef CONFIG_DRIVER_DM9000
extern int eth_init(bd_t * bd);
#endif
#ifdef CONFIG_DRIVER_DM9000
eth_init(gd->bd);
#endif
烧去后,就出现找不到DM9000,是不是还有什么地方没修改,请指导,谢谢!!!
Blog作者的回复:
你好,我觉得可能是的你的硬件连接和我不一样。我没看过你的原理图不好讲,你可以将原理图发给我。我再帮你看看。
|
|
|
|
|
 |
|
 |
 |
|
 |
 |
网友:
lili1984
| 时间:2008-02-20 14:19:47 IP地址:221.200.197.★ |
|
|
|
我是楼上的,我的问题还是没解决啊……
这个是我的tekkaman2440.c,完全复制了您的代码啊~
而且我在tekkaman2440.h里的确定义了CFG_NAND_LEGACY宏啊,为什么U-BOOT还是在/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c中找NF_Read、NF_Write等的定义啊??
/*
* (C) Copyright 2002
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Marius Groeger <mgroeger@sysgo.de>
*
* (C) Copyright 2002
* David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
*
* (C) Copyright 2005
* JinHua Luo, GuangDong Linux Center, <luo.jinhua@gd-linux.com>
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include <s3c2410.h>
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
#include <linux/mtd/nand.h>
#endif
/* ------------------------------------------------------------------------- */
#define FCLK_SPEED 1
#if FCLK_SPEED==0 /* Fout = 203MHz, Fin = 12MHz for Audio */
#define M_MDIV 0xC3
#define M_PDIV 0x4
#define M_SDIV 0x1
#elif FCLK_SPEED==1 /* Fout = 405MHz */
#define M_MDIV 0x7f
#define M_PDIV 0x2
#define M_SDIV 0x1
#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
#define U_M_MDIV 0x38
#define U_M_PDIV 0x2
#define U_M_SDIV 0x2
#endif
static inline void delay (unsigned long loops)
{
__asm__ volatile ("1:\n"
"subs %0, %1, #1\n"
"bne 1b":"=r" (loops):"0" (loops));
}
/*
* Miscellaneous platform dependent initialisations
*/
int board_init (void)
{
DECLARE_GLOBAL_DATA_PTR;
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
/* to reduce PLL lock time, adjust the LOCKTIME register */
clk_power->LOCKTIME = 0xFFFFFF;
/* configure MPLL */
clk_power->MPLLCON = ((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV);
/* some delay between MPLL and UPLL */
delay (4000);
/* configure UPLL */
clk_power->UPLLCON = ((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV);
/* some delay between MPLL and UPLL */
delay (8000);
/* set up the I/O ports */
gpio->GPACON = 0x007FFFFF;
gpio->GPBCON = 0x00055556;
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 = 0xFF95FF3A;
gpio->GPGUP = 0x0000FFFF;
gpio->GPHCON = 0x0016FAAA;
gpio->GPHUP = 0x000007FF;
gpio->EXTINT0=0x22222222;
gpio->EXTINT1=0x22222222;
gpio->EXTINT2=0x22222222;
/* arch number of S3C2440-Board */
gd->bd->bi_arch_number = MACH_TYPE_S3C2440;
/* adress of boot parameters */
gd->bd->bi_boot_params = 0x30000100;
icache_enable();
dcache_enable();
gpio->GPBDAT = 0x180;
return 0;
}
int dram_init (void)
{
DECLARE_GLOBAL_DATA_PTR;
gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
return 0;
}
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
typedef enum {
NFCE_LOW,
NFCE_HIGH
} NFCE_STATE;
static inline void NF_Conf(u16 conf)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
nand->NFCONF = conf;
}
static inline void NF_Cont(u16 cont)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
nand->NFCONT = cont;
}
static inline void NF_Cmd(u8 cmd)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
nand->NFCMD = cmd;
}
static inline void NF_CmdW(u8 cmd)
{
NF_Cmd(cmd);
udelay(1);
}
static inline void NF_Addr(u8 addr)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
nand->NFADDR = addr;
}
static inline void NF_SetCE(NFCE_STATE s)
{
S3C2410_NAND * const nand = S3C2410_GetBas | | | | |