mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Subject: [PATCH 03/12] mtd: atmel_nand: optimize read/write buffer functions
Date: Sat, 31 Dec 2011 16:21:29 +0100	[thread overview]
Message-ID: <1325344898-7076-3-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <20111231151655.GB945@game.jcrosoft.org>

For PIO NAND access functions, we use the features of the SMC:
 - no need to take into account the NAND bus width: SMC will deal with this
 - use of an IO memcpy on the NAND chip-select space is able to generate
   proper SMC behavior.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/mtd/nand/atmel_nand.c |   33 ++++++++-------------------------
 1 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index d539a25..731ec0b 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -148,30 +148,16 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
  */
 static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
 {
-	struct nand_chip	*nand_chip = mtd->priv;
+	struct nand_chip *chip = mtd->priv;
 
-	readsb(nand_chip->IO_ADDR_R, buf, len);
-}
-
-static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
-{
-	struct nand_chip	*nand_chip = mtd->priv;
-
-	readsw(nand_chip->IO_ADDR_R, buf, len / 2);
+	memcpy_fromio(buf, chip->IO_ADDR_R, len);
 }
 
 static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
 {
-	struct nand_chip	*nand_chip = mtd->priv;
+	struct nand_chip *chip = mtd->priv;
 
-	writesb(nand_chip->IO_ADDR_W, buf, len);
-}
-
-static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len)
-{
-	struct nand_chip	*nand_chip = mtd->priv;
-
-	writesw(nand_chip->IO_ADDR_W, buf, len / 2);
+	memcpy_toio(chip->IO_ADDR_W, buf, len);
 }
 
 /*
@@ -417,14 +403,11 @@ static int __init atmel_nand_probe(struct device_d *dev)
 
 	nand_chip->chip_delay = 20;		/* 20us command delay time */
 
-	if (host->board->bus_width_16) {	/* 16-bit bus width */
+	if (host->board->bus_width_16)		/* 16-bit bus width */
 		nand_chip->options |= NAND_BUSWIDTH_16;
-		nand_chip->read_buf = atmel_read_buf16;
-		nand_chip->write_buf = atmel_write_buf16;
-	} else {
-		nand_chip->read_buf = atmel_read_buf;
-		nand_chip->write_buf = atmel_write_buf;
-	}
+
+	nand_chip->read_buf = atmel_read_buf;
+	nand_chip->write_buf = atmel_write_buf;
 
 	atmel_nand_enable(host);
 
-- 
1.7.7


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2011-12-31 15:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-31 15:16 AT91: Pull Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 01/12] atmel: reference boards and Caloa boards bbt option enabled Jean-Christophe PLAGNIOL-VILLARD
2012-01-03  9:37   ` Sascha Hauer
2012-01-03 10:33     ` Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 02/12] ARM: import memcpy_from/toio and memset_io from linux Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2011-12-31 15:21 ` [PATCH 04/12] atmel_nand: drop dead code Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 05/12] at91: add sram memory devices Jean-Christophe PLAGNIOL-VILLARD
2012-01-04 13:42   ` Sascha Hauer
2011-12-31 15:21 ` [PATCH 06/12] at91sam9263ek: add nor partition Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 07/12] at91sam9x: switch lowlevel init to c Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 08/12] at91/gpio: simplify resources Jean-Christophe PLAGNIOL-VILLARD
2012-01-04 13:40   ` Sascha Hauer
2012-01-04 18:01     ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-04 18:05     ` Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 09/12] usb-a926x: add led support Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 10/12] usb-a926x: add dfu support Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 11/12] at91_udc: update vbus param only if updated Jean-Christophe PLAGNIOL-VILLARD
2011-12-31 15:21 ` [PATCH 12/12] usb-a926x: update defconfig Jean-Christophe PLAGNIOL-VILLARD

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=1325344898-7076-3-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    --cc=nicolas.ferre@atmel.com \
    /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