From: Jagan Teki <jteki@openedev.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 06/12] mtd: dataflash: Use spi_write_then_read
Date: Fri, 12 Feb 2016 14:06:11 +0530 [thread overview]
Message-ID: <1455266174-3240-7-git-send-email-jteki@openedev.com> (raw)
In-Reply-To: <1455266174-3240-1-git-send-email-jteki@openedev.com>
Use spi_write_then_read call from spi layer for
dataflash write and then read calling.
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: York Sun <york.sun@nxp.com>
Cc: Haikun Wang <haikun.wang@freescale.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
drivers/mtd/spi-nor/sf_dataflash.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/spi-nor/sf_dataflash.c b/drivers/mtd/spi-nor/sf_dataflash.c
index 722ab7e..525af0a 100644
--- a/drivers/mtd/spi-nor/sf_dataflash.c
+++ b/drivers/mtd/spi-nor/sf_dataflash.c
@@ -84,12 +84,12 @@ struct dataflash {
static inline int dataflash_status(struct spi_slave *spi)
{
int ret;
- u8 status;
+ u8 cmd = OP_READ_STATUS, status;
/*
* NOTE: at45db321c over 25 MHz wants to write
* a dummy byte after the opcode...
*/
- ret = spi_flash_cmd(spi, OP_READ_STATUS, &status, 1);
+ ret = spi_write_then_read(spi, &cmd, 1, NULL, &status, 1);
return ret ? -EIO : status;
}
@@ -171,7 +171,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
command[0], command[1], command[2], command[3],
pageaddr);
- status = spi_flash_cmd_write(spi, command, 4, NULL, 0);
+ status = spi_write_then_read(spi, command, 4, NULL, NULL, 0);
if (status < 0) {
debug("%s: erase send command error!\n", mtd->name);
return -EIO;
@@ -247,7 +247,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
command[3] = (uint8_t)(addr >> 0);
/* plus 4 "don't care" bytes, command len: 4 + 4 "don't care" bytes */
- status = spi_flash_cmd_read(spi, command, 8, buf, len);
+ status = spi_write_then_read(spi, command, 8, NULL, buf, len);
if (status >= 0) {
*retlen = len - 8;
status = 0;
@@ -327,7 +327,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
debug("TRANSFER: (%x) %x %x %x\n",
command[0], command[1], command[2], command[3]);
- status = spi_flash_cmd_write(spi, command, 4, NULL, 0);
+ status = spi_write_then_read(spi, command, 4, NULL, NULL, 0);
if (status < 0) {
debug("%s: write(<pagesize) command error!\n",
mtd->name);
@@ -352,8 +352,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
debug("PROGRAM: (%x) %x %x %x\n",
command[0], command[1], command[2], command[3]);
- status = spi_flash_cmd_write(spi, command,
- 4, writebuf, writelen);
+ status = spi_write_then_read(spi, command, 4,
+ writebuf, NULL, writelen);
if (status < 0) {
debug("%s: write send command error!\n", mtd->name);
return -EIO;
@@ -376,8 +376,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
debug("COMPARE: (%x) %x %x %x\n",
command[0], command[1], command[2], command[3]);
- status = spi_flash_cmd_write(spi, command,
- 4, writebuf, writelen);
+ status = spi_write_then_read(spi, command, 4,
+ writebuf, NULL, writelen);
if (status < 0) {
debug("%s: write(compare) send command error!\n",
mtd->name);
@@ -519,6 +519,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi)
uint8_t id[5];
uint32_t jedec;
struct flash_info *info;
+ u8 cmd = CMD_READ_ID;
int status;
/*
@@ -530,7 +531,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi)
* That's not an error; only rev C and newer chips handle it, and
* only Atmel sells these chips.
*/
- tmp = spi_flash_cmd(spi, CMD_READ_ID, id, sizeof(id));
+ tmp = spi_write_then_read(spi, &cmd, 1, NULL, id, sizeof(id));
if (tmp < 0) {
printf("dataflash: error %d reading JEDEC ID\n", tmp);
return ERR_PTR(tmp);
--
1.9.1
next prev parent reply other threads:[~2016-02-12 8:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-12 8:36 [U-Boot] [PATCH 00/12] mtd: dataflash: Add UCLASS_MTD Jagan Teki
2016-02-12 8:36 ` [U-Boot] [PATCH 01/12] mtd: spi-nor: Copy sf_dataflash Jagan Teki
2016-02-12 16:55 ` york sun
2016-02-12 17:51 ` Jagan Teki
2016-02-12 19:12 ` york sun
2016-02-12 19:28 ` Simon Glass
2016-02-12 19:31 ` Simon Glass
2016-02-12 8:36 ` [U-Boot] [PATCH 02/12] mtd: dataflash: Remove unneeded spi data Jagan Teki
2016-02-12 8:36 ` [U-Boot] [PATCH 03/12] mtd: dataflash: Move flash id detection into jedec_probe Jagan Teki
2016-02-12 8:36 ` [U-Boot] [PATCH 04/12] mtd: dataflash: Fix add_dataflash return logic Jagan Teki
2016-02-12 8:36 ` [U-Boot] [PATCH 05/12] mtd: dataflash: Add UCLASS_MTD support Jagan Teki
2016-02-12 8:36 ` Jagan Teki [this message]
2016-02-12 8:36 ` [U-Boot] [PATCH 07/12] mtd: dataflash: Drop sf_internal.h Jagan Teki
2016-02-12 8:36 ` [U-Boot] [PATCH 08/12] mtd: dataflash: Minor cleanups Jagan Teki
2016-02-12 8:36 ` [U-Boot] [PATCH 09/12] mtd: Rename sf_dataflash.c to mtd_dataflash.c Jagan Teki
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=1455266174-3240-7-git-send-email-jteki@openedev.com \
--to=jteki@openedev.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox