Commit 2b7a1b25 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev
Browse files

1. switch to pr_debug() 2. skip bad blocks

parent 23ab3441
Loading
Loading
Loading
Loading
+16 −17
Original line number Diff line number Diff line
@@ -27,12 +27,11 @@ static int is_badblock(struct mtd_info *mtd, loff_t offs, int allowbbt)
	unsigned int page = offs >> chip->page_shift;

	debug("    is_badblock(): offs=0x%08x block=%d page=%d\n",(int)offs,block,page);
	//chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
	//memset(chip->oob_poi, 0, mtd->oobsize);
	//chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
	chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
	memset(chip->oob_poi, 0, mtd->oobsize);
	chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);

	//return chip->oob_poi[0] != 0xff;
	return 0;
	return chip->oob_poi[0] != 0xff;
}

//dst or buf - destination in RAM
@@ -86,18 +85,18 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *buf)
		 * Check if we have crossed a block boundary, and if so
		 * check for bad block.
		 */
		//if (!(page % nand_page_per_block)) {
		//	/*
		//	 * Yes, new block. See if this block is good. If not,
		//	 * loop until we find a good block.
		//	 */
		//	while (is_badblock(&mtd, offs, 1)) {
		//		page = page + nand_page_per_block;
		//		/* Check we've reached the end of flash. */
		//		if (page >= mtd->size >> chip->page_shift)
		//			return -ENOMEM;
		//	}
		//}
		if (!(page % nand_page_per_block)) {
			/*
			 * Yes, new block. See if this block is good. If not,
			 * loop until we find a good block.
			 */
			while (is_badblock(&mtd, offs, 1)) {
				page = page + nand_page_per_block;
				/* Check we've reached the end of flash. */
				if (page >= mtd->size >> chip->page_shift)
					return -ENOMEM;
			}
		}
	}
	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -2839,7 +2839,7 @@ static u16 onfi_crc16(u16 crc, u8 const *p, size_t len)
static int nand_flash_detect_ext_param_page(struct mtd_info *mtd,
		struct nand_chip *chip, struct nand_onfi_params *p)
{
	printf("nand_flash_detect_ext_param_page\n");
	pr_debug("nand_flash_detect_ext_param_page\n");

	struct onfi_ext_param_page *ep;
	struct onfi_ext_section *s;
+2 −2
Original line number Diff line number Diff line
@@ -961,7 +961,7 @@ static void zynq_nand_read_buf(struct mtd_info *mtd, u8 *buf, int len)
static void zynq_nand_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
{

	printf("zynq_nand_write_buf(): len=%d buf=%d\n",(u32)len,(u32)buf);
	debug("zynq_nand_write_buf(): len=%d buf=%d\n",(u32)len,(u32)buf);

	struct nand_chip *chip = mtd->priv;
	const u32 *nand = chip->IO_ADDR_W;
@@ -1297,7 +1297,7 @@ void board_nand_init(void)
{
	struct nand_chip *nand = &nand_chip[0];

	printf("board_nand_init(): &nand_chip[0]=0x%08x\n",(u32)&nand_chip[0]);
	debug("board_nand_init(): &nand_chip[0]=0x%08x\n",(u32)&nand_chip[0]);

	if (zynq_nand_init(nand, 0))
		puts("ZYNQ NAND init failed\n");