All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [v3 PATCH 08/12] spl, nand, atmel_nand: add erase one block function
Date: Fri, 31 Oct 2014 08:31:02 +0100	[thread overview]
Message-ID: <1414740666-13337-9-git-send-email-hs@denx.de> (raw)
In-Reply-To: <1414740666-13337-1-git-send-email-hs@denx.de>

erase one nand block in spl code. keep it simple, as size matters
This is used on the upcoming taurus spl support.

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Bo Shen <voice.shen@atmel.com>

---

Changes in v3:
add Acked-by from Scott Wood
add Reviewed-by from Bo Shen

Changes in v2:
add comment from scott wood:
- move nand_erase_one into "include/nand.h" and rename it
  to spl_nand_erase_one

 drivers/mtd/nand/atmel_nand.c | 33 +++++++++++++++++++++++++++++++++
 include/nand.h                |  1 +
 2 files changed, 34 insertions(+)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index d506e42..d6d6f85 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -1274,6 +1274,39 @@ static int nand_read_page(int block, int page, void *dst)
 
 	return 0;
 }
+
+int spl_nand_erase_one(int block, int page)
+{
+	struct nand_chip *this = mtd.priv;
+	void (*hwctrl)(struct mtd_info *mtd, int cmd,
+			unsigned int ctrl) = this->cmd_ctrl;
+	int page_addr;
+
+	if (nand_chip.select_chip)
+		nand_chip.select_chip(&mtd, 0);
+
+	page_addr = page + block * CONFIG_SYS_NAND_PAGE_COUNT;
+	hwctrl(&mtd, NAND_CMD_ERASE1, NAND_CTRL_CLE | NAND_CTRL_CHANGE);
+	/* Row address */
+	hwctrl(&mtd, (page_addr & 0xff), NAND_CTRL_ALE | NAND_CTRL_CHANGE);
+	hwctrl(&mtd, ((page_addr >> 8) & 0xff),
+	       NAND_CTRL_ALE | NAND_CTRL_CHANGE);
+#ifdef CONFIG_SYS_NAND_5_ADDR_CYCLE
+	/* One more address cycle for devices > 128MiB */
+	hwctrl(&mtd, (page_addr >> 16) & 0x0f,
+	       NAND_CTRL_ALE | NAND_CTRL_CHANGE);
+#endif
+
+	hwctrl(&mtd, NAND_CMD_ERASE2, NAND_CTRL_CLE | NAND_CTRL_CHANGE);
+	udelay(2000);
+
+	while (!this->dev_ready(&mtd))
+		;
+
+	nand_deselect();
+
+	return 0;
+}
 #else
 static int nand_read_page(int block, int page, void *dst)
 {
diff --git a/include/nand.h b/include/nand.h
index fc735d1..15e31ab 100644
--- a/include/nand.h
+++ b/include/nand.h
@@ -167,3 +167,4 @@ __attribute__((noreturn)) void nand_boot(void);
 #define ENV_OFFSET_SIZE 8
 int get_nand_env_oob(nand_info_t *nand, unsigned long *result);
 #endif
+int spl_nand_erase_one(int block, int page);
-- 
1.8.3.1

  parent reply	other threads:[~2014-10-31  7:31 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-31  7:30 [U-Boot] [v3 PATCH 0/12] arm, at91, spl: add spl support for the taurus and corvus boards Heiko Schocher
2014-10-31  7:30 ` [U-Boot] [v3 PATCH 01/12] spi, atmel: move CONFIG_SYS_SPI_WRITE_TOUT into common header Heiko Schocher
2014-10-31 11:18   ` Jagan Teki
2014-11-06  0:22   ` Andreas Bießmann
2014-11-17 12:15   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2014-10-31  7:30 ` [U-Boot] [v3 PATCH 02/12] arm, at91: add spi dataflash support for the taurus board Heiko Schocher
2014-10-31 10:48   ` Jagan Teki
2014-10-31 12:31     ` Heiko Schocher
2014-11-05 23:36       ` Andreas Bießmann
2014-11-06  6:48         ` Jagan Teki
2014-11-05 23:26   ` Andreas Bießmann
2014-11-17 12:15   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2014-10-31  7:30 ` [U-Boot] [v3 PATCH 03/12] arm, at91, mpddrc: fix typo in ddr2_init() Heiko Schocher
2014-11-17 12:15   ` [U-Boot] [U-Boot,v3,03/12] " Andreas Bießmann
2014-10-31  7:30 ` [U-Boot] [v3 PATCH 04/12] arm, at91: compile mpddrc ram init code also for AT91SAM9M10G45 Heiko Schocher
2014-11-17 12:15   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2014-10-31  7:30 ` [U-Boot] [v3 PATCH 05/12] arm, at91: add missing ddr2 cr register MPDDRC_CR_EBISHARE define Heiko Schocher
2014-11-17 12:15   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2014-10-31  7:31 ` [U-Boot] [v3 PATCH 06/12] spl, nand: add option to boot raw u-boot.bin image only Heiko Schocher
2014-11-17 12:15   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2014-10-31  7:31 ` [U-Boot] [v3 PATCH 07/12] mtd: atmel_nand: add missign include Heiko Schocher
2014-10-31  7:43   ` Bo Shen
2014-10-31  8:02     ` Heiko Schocher
2014-11-05 23:38       ` Andreas Bießmann
2014-11-17 12:16   ` [U-Boot] [U-Boot,v3,07/12] mtd: atmel_nand: add missing include Andreas Bießmann
2014-10-31  7:31 ` Heiko Schocher [this message]
2014-11-06  0:12   ` [U-Boot] [v3 PATCH 08/12] spl, nand, atmel_nand: add erase one block function Andreas Bießmann
2014-11-17 12:16   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2014-10-31  7:31 ` [U-Boot] [v3 PATCH 09/12] spl, mtd, nand, atmel_nand: invert device ready pin logic Heiko Schocher
2014-11-17 12:16   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2014-10-31  7:31 ` [U-Boot] [v3 PATCH 10/12] arm, spl, at91: add at91sam9260 and at91sam9g45 spl support Heiko Schocher
2014-11-06  0:17   ` Andreas Bießmann
2014-11-17 12:16   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2014-10-31  7:31 ` [U-Boot] [v3 PATCH 11/12] arm, at91, spl: add spl support for the taurus board Heiko Schocher
2014-11-17 12:16   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2014-10-31  7:31 ` [U-Boot] [v3 PATCH 12/12] arm, spl, at91: add spl support for the corvus board Heiko Schocher
2014-11-06  0:20   ` Andreas Bießmann
2014-11-17 12:16   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2014-11-06  0:24 ` [U-Boot] [v3 PATCH 0/12] arm, at91, spl: add spl support for the taurus and corvus boards Andreas Bießmann
2014-11-06  7:10   ` Heiko Schocher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1414740666-13337-9-git-send-email-hs@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.