From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 6/6] nor m25p80: implement fast read
Date: Tue, 31 Jul 2012 19:59:16 +0200 [thread overview]
Message-ID: <1343757556-11897-7-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1343757556-11897-1-git-send-email-s.hauer@pengutronix.de>
The fast read command is needed for spi speeds > 25MHz, so use it for
higher speeds.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/nor/m25p80.c | 12 ++++++++----
drivers/nor/m25p80.h | 10 +---------
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/nor/m25p80.c b/drivers/nor/m25p80.c
index 4b62e93..daaf60c 100644
--- a/drivers/nor/m25p80.c
+++ b/drivers/nor/m25p80.c
@@ -267,6 +267,7 @@ ssize_t m25p80_read(struct cdev *cdev, void *buf, size_t count, loff_t offset,
struct spi_transfer t[2];
struct spi_message m;
ssize_t retlen;
+ int fast_read = 0;
/* sanity checks */
if (!count)
@@ -275,6 +276,9 @@ ssize_t m25p80_read(struct cdev *cdev, void *buf, size_t count, loff_t offset,
if (offset + count > flash->size)
return -EINVAL;
+ if (flash->spi->max_speed_hz >= 25000000)
+ fast_read = 1;
+
spi_message_init(&m);
memset(t, 0, (sizeof t));
@@ -283,7 +287,7 @@ ssize_t m25p80_read(struct cdev *cdev, void *buf, size_t count, loff_t offset,
* Should add 1 byte DUMMY_BYTE.
*/
t[0].tx_buf = flash->command;
- t[0].len = m25p_cmdsz(flash) + FAST_READ_DUMMY_BYTE;
+ t[0].len = m25p_cmdsz(flash) + fast_read;
spi_message_add_tail(&t[0], &m);
t[1].rx_buf = buf;
@@ -303,12 +307,12 @@ ssize_t m25p80_read(struct cdev *cdev, void *buf, size_t count, loff_t offset,
*/
/* Set up the write data buffer. */
- flash->command[0] = OPCODE_READ;
+ flash->command[0] = fast_read ? OPCODE_FAST_READ : OPCODE_NORM_READ;
m25p_addr2cmd(flash, offset, flash->command);
spi_sync(flash->spi, &m);
- retlen = m.actual_length - m25p_cmdsz(flash) - FAST_READ_DUMMY_BYTE;
+ retlen = m.actual_length - m25p_cmdsz(flash) - fast_read;
return retlen;
}
@@ -756,7 +760,7 @@ static int m25p_probe(struct device_d *dev)
}
flash = xzalloc(sizeof *flash);
- flash->command = xmalloc(MAX_CMD_SIZE + FAST_READ_DUMMY_BYTE);
+ flash->command = xmalloc(MAX_CMD_SIZE);
flash->spi = spi;
dev->priv = (void *)flash;
diff --git a/drivers/nor/m25p80.h b/drivers/nor/m25p80.h
index ce48ba7..34bf2e2 100644
--- a/drivers/nor/m25p80.h
+++ b/drivers/nor/m25p80.h
@@ -34,15 +34,7 @@
/* Define max times to check status register before we give up. */
#define MAX_READY_WAIT 40 /* M25P16 specs 40s max chip erase */
-#define MAX_CMD_SIZE 5
-
-#ifdef CONFIG_M25PXX_USE_FAST_READ
-#define OPCODE_READ OPCODE_FAST_READ
-#define FAST_READ_DUMMY_BYTE 1
-#else
-#define OPCODE_READ OPCODE_NORM_READ
-#define FAST_READ_DUMMY_BYTE 0
-#endif
+#define MAX_CMD_SIZE 6
#define SPI_NAME_SIZE 32
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2012-07-31 17:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-31 17:59 [PATCH] m25p80 spi flash updates Sascha Hauer
2012-07-31 17:59 ` [PATCH 1/6] nor m25p80: remove progression bar Sascha Hauer
2012-07-31 17:59 ` [PATCH 2/6] nor m25p80: remove unused variables Sascha Hauer
2012-07-31 17:59 ` [PATCH 3/6] nor m25p80: refactor chip erase Sascha Hauer
2012-07-31 17:59 ` [PATCH 4/6] nor m25p80: align start and end to erase blocks Sascha Hauer
2012-07-31 17:59 ` [PATCH 5/6] nor m25p80: optimize erase Sascha Hauer
2012-07-31 17:59 ` Sascha Hauer [this message]
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=1343757556-11897-7-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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