From: Juergen Beisert <juergen@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxx> --- 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@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox