From: Juergen Beisert <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Juergen Beisert <juergen@kreuzholzen.de>
Subject: [PATCH 3/5] S3C2440/NAND: Fix page address generation
Date: Sun, 6 Mar 2011 22:53:16 +0100 [thread overview]
Message-ID: <1299448398-5672-4-git-send-email-jbe@pengutronix.de> (raw)
In-Reply-To: <1299448398-5672-1-git-send-email-jbe@pengutronix.de>
From: Juergen Beisert <juergen@kreuzholzen.de>
A NAND page address consist of a collumn and row part. It depends on the NAND
type, how to handle both parts correctly. This patch tries to generate the
page address from a given page offset correctly. It also forces the collumn
part to '0', as the NAND boot routine reads full pages only.
Note: Page offset to page address conversion does only work for 512 or 2048
bytes per page NAND types.
Signed-off-by: Juergen Beisert <juergen@kreuzholzen.de>
---
drivers/mtd/nand/nand_s3c2410.c | 30 ++++++++++++++++++++++++++----
1 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/nand_s3c2410.c b/drivers/mtd/nand/nand_s3c2410.c
index 08330ed..e298771 100644
--- a/drivers/mtd/nand/nand_s3c2410.c
+++ b/drivers/mtd/nand/nand_s3c2410.c
@@ -497,13 +497,35 @@ static void __nand_boot_init wait_for_completion(void __iomem *host)
;
}
+/**
+ * Convert a page offset into a page address for the NAND
+ * @param host Where to write the address to
+ * @param offs Page's offset in the NAND
+ * @param ps Page size (512 or 2048)
+ * @param c Address cycle count (3, 4 or 5)
+ *
+ * Uses the offset of the page to generate a page address into the NAND. This
+ * differs when using a 512 byte or 2048 bytes per page NAND.
+ * The collumn part of the page address to be generated is always forced to '0'.
+ */
static void __nand_boot_init nfc_addr(void __iomem *host, uint32_t offs,
int ps, int c)
{
- send_addr(host, offs & 0xff);
- send_addr(host, (offs >> 9) & 0xff);
- send_addr(host, (offs >> 17) & 0xff);
- send_addr(host, (offs >> 25) & 0xff);
+ send_addr(host, 0); /* collumn part 1 */
+
+ if (ps == 512) {
+ send_addr(host, offs >> 9);
+ send_addr(host, offs >> 17);
+ if (c > 3)
+ send_addr(host, offs >> 25);
+ } else {
+ send_addr(host, 0); /* collumn part 2 */
+ send_addr(host, offs >> 11);
+ send_addr(host, offs >> 19);
+ if (c > 4)
+ send_addr(host, offs >> 27);
+ send_cmd(host, NAND_CMD_READSTART);
+ }
}
/**
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-03-06 21:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-06 21:53 [RFC/PATCH v2] S3C24xx: NAND management changes to support booting from NAND Juergen Beisert
2011-03-06 21:53 ` [PATCH 1/5] mini2440: Add more info about possible SDRAM and flash devices Juergen Beisert
2011-03-06 21:53 ` [PATCH 2/5] mini2440: Consider correct NAND page size for boot Juergen Beisert
2011-03-06 21:53 ` Juergen Beisert [this message]
2011-03-06 21:53 ` [PATCH 4/5] S3C2440/NAND: Re-enable the controller after NAND boot test Juergen Beisert
2011-03-06 21:53 ` [PATCH 5/5] S3C2440/NAND: Fix typo Juergen Beisert
2011-03-07 9:18 ` [RFC/PATCH v2] S3C24xx: NAND management changes to support booting from NAND Juergen Beisert
2011-03-07 9:40 ` Baruch Siach
2011-03-07 10:37 ` Juergen Beisert
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=1299448398-5672-4-git-send-email-jbe@pengutronix.de \
--to=jbe@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=juergen@kreuzholzen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox