1 第一种 nand 的片选设置不对,默认的nand cs是 cs0, 但定制板的nand cs是cs2,需要更改nand 的cs,以及和cs相关的寄存器的初始化的 操作。
diff --git a/pmon-ls2k-master/Targets/LS2K/conf/ls2k b/pmon-ls2k-master/Targets/LS2K/conf/ls2k
index 43ebfca..3ece49f 100755
--- a/pmon-ls2k-master/Targets/LS2K/conf/ls2k
+++ b/pmon-ls2k-master/Targets/LS2K/conf/ls2k
@@ -272,7 +272,7 @@ select inet
select nand
select cmd_xyzmodem
#select spinand_mt29f
-select m25p80
+#select m25p80
#select can
select yaffsfs
@@ -332,8 +332,8 @@ option DDR_PARAM_018="0x2828282816100000"
#option DDR_RESET_REVERT
###czc
option CONFIG_LS2K_NAND
-option CONFIG_SPINAND_SOFTBCH
-select nand_bch
+#option CONFIG_SPINAND_SOFTBCH
+#select nand_bch
#rmoption AUTO_DDR_CONFIG
#rmoption DDR_S1
#rmoption DDR_PARAM_018
diff --git a/pmon-ls2k-master/Targets/LS2K/conf/ls2k.dts b/pmon-ls2k-master/Targets/LS2K/conf/ls2k.dts
index 4e35a71..e2a9a25 100644
--- a/pmon-ls2k-master/Targets/LS2K/conf/ls2k.dts
+++ b/pmon-ls2k-master/Targets/LS2K/conf/ls2k.dts
@@ -131,7 +131,7 @@
interrupts = <20 21>;
interrupt-names = "macirq", "eth_wake_irq";
mac-address = [ 64 48 48 48 48 60 ];/* [>mac 64:48:48:48:48:60 <]*/
- phy-mode = "rgmii";
+ phy-mode = "rgmii-id";
bus_id = <0x0>;
phy_addr = <0xffffffff>;
dma-mask = <0xffffffff 0xffffffff>;
@@ -620,7 +620,7 @@
dmas = <&dma0 1>;
dma-names = "nand_rw";
dma-mask = <0xffffffff 0xffffffff>;
-
+ nand-cs = <0x2>;
number-of-parts = <0x2>;
partition@0 {
diff --git a/pmon-ls2k-master/Targets/LS2K/include/pmon_target.h b/pmon-ls2k-master/Targets/LS2K/include/pmon_target.h
index aed8e5d..7187ae1 100755
--- a/pmon-ls2k-master/Targets/LS2K/include/pmon_target.h
+++ b/pmon-ls2k-master/Targets/LS2K/include/pmon_target.h
@@ -77,11 +77,11 @@ extern int mtd_rescan(char *,char *);
#if NNAND
#ifndef FASTUP
#define TGT_DEFENV PMON_SPEC \
- {"mtdparts","nand-flash:50M(rootfs1),50M(rootfs2),20M(cfg),20M(log),-(other)",0,&mtd_rescan}, \
+ {"mtdparts","nand-flash:60M(rootfs1),50M(rootfs2),20M(cfg),20M(log),-(other)",0,&mtd_rescan}, \
{"bootdelay","3",0,0}
#else
#define TGT_DEFENV PMON_SPEC \
- {"mtdparts","nand-flash:50M(rootfs1),50M(rootfs2),20M(cfg),20M(log),-(other)",0,&mtd_rescan}, \
+ {"mtdparts","nand-flash:60M(rootfs1),50M(rootfs2),20M(cfg),20M(log),-(other)",0,&mtd_rescan}, \
{"bootdelay","1",0,0}
#endif
#else
diff --git a/pmon-ls2k-master/sys/dev/nand/ls2k-nand.c b/pmon-ls2k-master/sys/dev/nand/ls2k-nand.c
index e023c79..c8c5fae 100644
--- a/pmon-ls2k-master/sys/dev/nand/ls2k-nand.c
+++ b/pmon-ls2k-master/sys/dev/nand/ls2k-nand.c
@@ -180,7 +180,7 @@ enum {
#define DMA_RD_STU_SHIF 4 /* dma read data status */
#define DMA_WR_STU_SHIF 8 /* dma write data status */
-#define NAND_USE_CS 0
+#define NAND_USE_CS 2
/* DMA Descripter */
struct ls2k_nand_dma_desc {
@@ -222,6 +222,7 @@ struct ls2k_nand_info {
size_t data_size; /* data size in FIFO */
unsigned int seqin_column;
unsigned int seqin_page_addr;
+ int cs, cs0;
};
static void *_dma_alloc_coherent(size_t size,
@@ -280,6 +281,8 @@ static int ls2k_nand_waitfunc(struct mtd_info *mtd, struct nand_chip *this)
static void ls2k_nand_select_chip(struct mtd_info *mtd, int chip)
{
+struct ls2k_nand_info *info = mtd->priv;
+ info->cs = (chip == -1)? info->cs0 : info->cs0 + chip;
return;
}
@@ -287,14 +290,15 @@ static int ls2k_nand_dev_ready(struct mtd_info *mtd)
{
return 1;
}
-
+static const char cap2cs[16] = {[0]=16,[1]=17,[2]=18,[3]=19,[4]=19,[5]=19,[6]=20,[7]=21,[9]=14,[10]=15,[11]=16,[12]=17,[13]=18};
static void nand_setup(struct ls2k_nand_info *info,
int cmd, int addr_c, int addr_r, int param, int op_num)
{
+ unsigned int addr_cs = info->cs*(1UL<<cap2cs[(param>>CHIP_CAP_SHIFT)&0xf]);
writel(param, REG(NAND_PARAM_REG));
writel(op_num, REG(NAND_OP_NUM_REG));
writel(addr_c, REG(NAND_ADDRC_REG));
- writel(addr_r|(0x10000*NAND_USE_CS), REG(NAND_ADDRR_REG));
+ writel(addr_r|addr_cs, REG(NAND_ADDRR_REG));
writel(0, REG(NAND_CMD_REG));
writel(0, REG(NAND_CMD_REG));
writel(cmd, REG(NAND_CMD_REG));
@@ -695,7 +699,7 @@ int ls2k_nand_init()
this = &info->nand_chip;
mtd->priv = info;
-
+ info->cs0 = NAND_USE_CS;
info->desc_addr = (u64) dma_alloc_coherent(&pdev->dev,
MAX_BUFF_SIZE, &info->desc_addr_phys, GFP_KERNEL);
info->dma_ask = (u64) dma_alloc_coherent(&pdev->dev,
2 第二种是系统下报ecc错误,第一种和上述一样,要改cs的操作,还有一种比较操蛋了,是系统的镜像大小超过了50M,且从mtd1启动,但mtd1只有50M,这种情况要把mtd1改大,改成60M就可以了。