S3C2440移植 u-boot-2016.11

移植完成后使用以下命令制作补丁文件:

make distclean
mv u-boot-2016.11 u-boot-2016.11_new
tar xjf u-boot-2016.11.tar.bz2
diff -urN u-boot-2016.11 u-boot-2016.11_new > u-boot-2016.11_new.patch
patch -p1 < ../u-boot-2016.11_new.patch

然后我们通过补丁文件来回顾一下修改的地方:

u-boot-2016.11/include/configs/smdk2410.h文件中:

添加CONFIG_S3C2440宏定义,DM9000网卡配置,内核启动参数。修改环境变量在Norflash中的地址,因为u-boot-2016.11 生成的bin文件大小有521KB,环境变量的存放地址要在bin文件后面。

-#define CONFIG_S3C2410		/* specifically a SAMSUNG S3C2410 SoC */
+#define CONFIG_S3C2440		/* specifically a SAMSUNG S3C2410 SoC */
 

-#define CONFIG_CS8900		/* we have a CS8900 on-board */
-#define CONFIG_CS8900_BASE	0x19000300
-#define CONFIG_CS8900_BUS16	/* the Linux driver does accesses as shorts */
+
+#define CONFIG_DRIVER_DM9000    1
+#define CONFIG_DM9000_BASE      0x20000000
+#define DM9000_IO               CONFIG_DM9000_BASE
+#define DM9000_DATA             (CONFIG_DM9000_BASE + 4)
+

 
 
+/* Booting Linux */
+#define CONFIG_BOOTARGS		"console=ttySAC0 root=/dev/medblock3 "
+#define CONFIG_BOOTCOMMAND        "nand read 30000000 0x0 0x200000;bootm 30000000"
 
 
 #define CONFIG_NETMASK		255.255.255.0
-#define CONFIG_IPADDR		10.0.0.110
-#define CONFIG_SERVERIP		10.0.0.1
+#define CONFIG_IPADDR		192.168.0.10
+#define CONFIG_SERVERIP		192.168.0.11
+
 

-#define CONFIG_SYS_MAX_FLASH_SECT	(19)
+#define CONFIG_SYS_MAX_FLASH_SECT	(256)
 
-#define CONFIG_ENV_ADDR			(CONFIG_SYS_FLASH_BASE + 0x070000)
+#define CONFIG_ENV_ADDR			(CONFIG_SYS_FLASH_BASE + 0x0F0000)
 #define CONFIG_ENV_IS_IN_FLASH
 #define CONFIG_ENV_SIZE			0x10000

u-boot-2016.11/arch/arm/cpu/arm920t/start.S文件中:

加入设置时钟和开启ICACHE

-	/* FCLK:HCLK:PCLK = 1:2:4 */
-	/* default FCLK is 120 MHz ! */
-	ldr	r0, =CLKDIVN
-	mov	r1, #3
-	str	r1, [r0]

+#define S3C2440_MPLL_400MHZ     ((0x5c<<12)|(0x01<<4)|(0x01))
+	/* 2. 设置时钟 */
+	ldr r0, =0x4c000014
+	//	mov r1, #0x03;			  // FCLK:HCLK:PCLK=1:2:4, HDIVN=1,PDIVN=1
+	mov r1, #0x05;			  // FCLK:HCLK:PCLK=1:4:8
+	str r1, [r0]
+
+	/* 如果HDIVN非0,CPU的总线模式应该从“fast bus mode”变为“asynchronous bus mode” */
+	mrc	p15, 0, r1, c1, c0, 0		/* 读出控制寄存器 */ 
+	orr	r1, r1, #0xc0000000			/* 设置为“asynchronous bus mode” */
+	mcr	p15, 0, r1, c1, c0, 0		/* 写入控制寄存器 */
+
+	/* MPLLCON = S3C2440_MPLL_200MHZ */
+	ldr r0, =0x4c000004
+	ldr r1, =S3C2440_MPLL_400MHZ
+	str r1, [r0]
+
+	/* 启动ICACHE */
+	mrc p15, 0, r0, c1, c0, 0		@ read control reg
+	orr r0, r0, #(1<<12)
+	mcr	p15, 0, r0, c1, c0, 0   	@ write it back
 #endif	/* CONFIG_S3C24X0 */

u-boot-2016.11/board/samsung/smdk2410/lowlevel_init.S文件中:

根据S3C2440手册,修改存储控制寄存器。

 SMRDATA:
-    .word (0+(B1_BWSCON<<4)+(B2_BWSCON<<8)+(B3_BWSCON<<12)+(B4_BWSCON<<16)+(B5_BWSCON<<20)+(B6_BWSCON<<24)+(B7_BWSCON<<28))
-    .word ((B0_Tacs<<13)+(B0_Tcos<<11)+(B0_Tacc<<8)+(B0_Tcoh<<6)+(B0_Tah<<4)+(B0_Tacp<<2)+(B0_PMC))
-    .word ((B1_Tacs<<13)+(B1_Tcos<<11)+(B1_Tacc<<8)+(B1_Tcoh<<6)+(B1_Tah<<4)+(B1_Tacp<<2)+(B1_PMC))
-    .word ((B2_Tacs<<13)+(B2_Tcos<<11)+(B2_Tacc<<8)+(B2_Tcoh<<6)+(B2_Tah<<4)+(B2_Tacp<<2)+(B2_PMC))
-    .word ((B3_Tacs<<13)+(B3_Tcos<<11)+(B3_Tacc<<8)+(B3_Tcoh<<6)+(B3_Tah<<4)+(B3_Tacp<<2)+(B3_PMC))
-    .word ((B4_Tacs<<13)+(B4_Tcos<<11)+(B4_Tacc<<8)+(B4_Tcoh<<6)+(B4_Tah<<4)+(B4_Tacp<<2)+(B4_PMC))
-    .word ((B5_Tacs<<13)+(B5_Tcos<<11)+(B5_Tacc<<8)+(B5_Tcoh<<6)+(B5_Tah<<4)+(B5_Tacp<<2)+(B5_PMC))
-    .word ((B6_MT<<15)+(B6_Trcd<<2)+(B6_SCAN))
-    .word ((B7_MT<<15)+(B7_Trcd<<2)+(B7_SCAN))
-    .word ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT)
-    .word 0x32
-    .word 0x30
-    .word 0x30
+    	.long 0x22011110	 //BWSCON
+	.long 0x00000700	 //BANKCON0
+	.long 0x00000700	 //BANKCON1
+	.long 0x00000700	 //BANKCON2
+	.long 0x00000700	 //BANKCON3  
+	.long 0x00000740	 //BANKCON4
+	.long 0x00000700	 //BANKCON5
+	.long 0x00018005	 //BANKCON6
+	.long 0x00018005	 //BANKCON7
+	.long 0x008C04F4	 // REFRESH
+	.long 0x000000B1	 //BANKSIZE
+	.long 0x00000030	 //MRSRB6

u-boot-2016.11/board/samsung/smdk2410/smdk2410.c文件中:

因在/start.S文件已经设置时钟,所以去掉本文件中设置时钟代码。另外开发板使用DM9000网卡,参考别的开发板,加入调用网卡初始化函数。

 	/* to reduce PLL lock time, adjust the LOCKTIME register */
-	writel(0xFFFFFF, &clk_power->locktime);

 	/* configure MPLL */
-	writel((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV,
-	       &clk_power->mpllcon);

 
+#ifdef CONFIG_DRIVER_DM9000
+	rc = dm9000_initialize(bis);
+#endif

u-boot-2016.11/drivers/mtd/jedec_flash.c文件中:

本开发板使用Norflash为MX29LV160DB,在结构体中加入该芯片的配置信息。

+	{
+		.mfr_id		= (u16)MX_MANUFACT,
+		.dev_id		= 0x2249,
+		.name		= "MXIC MX29LV160DB",
+		.uaddr		= {					 /* unlock addr */
+			[1] = MTD_UADDR_0x0555_0x02AA /* x16 */
+		},
+		.DevSize	= SIZE_1MiB,
+		.CmdSet		= P_ID_AMD_STD,
+		.NumEraseRegions= 4,
+		.regions	= {
+			ERASEINFO(16*1024, 1),
+			ERASEINFO(8*1024, 2),
+			ERASEINFO(32*1024, 1),
+			ERASEINFO(64*1024, 31),
+		}
+	},

u-boot-2016.11/drivers/mtd/nand/s3c2410_nand.c文件:

修改了hwcontrol()函数,添加了片选函数,在board_nand_init函数中初始化时序并使能nandFlash控制器。

-	if (ctrl & NAND_CTRL_CHANGE) {
-		ulong IO_ADDR_W = (ulong)nand;
-
-		if (!(ctrl & NAND_CLE))
-			IO_ADDR_W |= S3C2410_ADDR_NCLE;
-		if (!(ctrl & NAND_ALE))
-			IO_ADDR_W |= S3C2410_ADDR_NALE;
-
-		chip->IO_ADDR_W = (void *)IO_ADDR_W;
-
-		if (ctrl & NAND_NCE)
-			writel(readl(&nand->nfconf) & ~S3C2410_NFCONF_nFCE,
-			       &nand->nfconf);
-		else
-			writel(readl(&nand->nfconf) | S3C2410_NFCONF_nFCE,
-			       &nand->nfconf);
+	if (ctrl & NAND_CLE) {
+		writeb(cmd, &nand->nfcmd);	
 	}
+	else if(ctrl & NAND_ALE)
+	{
+		writeb(cmd, &nand->nfaddr);
 
-	if (cmd != NAND_CMD_NONE)
-		writeb(cmd, chip->IO_ADDR_W);
+	}
+	
 
+
+static void s3c24x0_nand_select_chip(struct mtd_info *mtd, int chipnr)
+{
+	struct s3c24x0_nand *nand_reg = s3c24x0_get_base_nand();
+
+	switch (chipnr) {
+	case -1:			/*取消选中*/
+		nand_reg->nfcont  |= (1<<1);
+		break;
+	case 0:	
+		nand_reg->nfcont  &= ~(1<<1); 
+		break;
+
+	default:
+		BUG();
+	}
+}
+
 int board_nand_init(struct nand_chip *nand)
 {

+/*
 	cfg = S3C2410_NFCONF_EN;
 	cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
 	cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1);
 	cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1);
+*/
+
+//初始化时序
+	cfg = ((tacls - 1)<<12) |((twrph0 - 1)<<8) |((twrph1 - 1)<<4);
+	
 	writel(cfg, &nand_reg->nfconf);
+//使能NAND FLASH控制器,初始化ECC,禁止片选
+	writel((1<<4)|(1<<1)|(1<<0), &nand_reg->nfcont);
 
 
-	nand->select_chip = NULL;
+	nand->select_chip = s3c24x0_nand_select_chip;
 


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值