summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-10-23 13:02:47 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2009-10-26 13:06:01 +0100
commita0446d65ca69da866c987c55c66007b89c8aa305 (patch)
treecd6040f93bae53a191611a5b84d1e4ccf8e018b4 /drivers
parentc90018407fabbfe649a46b7b5df775bfa35f414b (diff)
downloadbarebox-a0446d65ca69da866c987c55c66007b89c8aa305.tar.gz
barebox-a0446d65ca69da866c987c55c66007b89c8aa305.tar.xz
mxc_nand: simplify command processing
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/nand/nand_imx.c84
1 files changed, 35 insertions, 49 deletions
diff --git a/drivers/nand/nand_imx.c b/drivers/nand/nand_imx.c
index 6da3b738d5..8a2e58eb8f 100644
--- a/drivers/nand/nand_imx.c
+++ b/drivers/nand/nand_imx.c
@@ -263,7 +263,7 @@ static void __nand_boot_init send_page(struct imx_nand_host *host, u8 buf_id,
* This function requests the NANDFC to perform a read of the
* NAND device ID.
*/
-static void noinline send_read_id(struct imx_nand_host *host)
+static void send_read_id(struct imx_nand_host *host)
{
struct nand_chip *this = &host->nand;
u16 tmp;
@@ -633,17 +633,37 @@ static void imx_nand_command(struct mtd_info *mtd, unsigned command,
case NAND_CMD_STATUS:
host->buf_start = 0;
host->status_request = 1;
+ send_cmd(host, command);
+ mxc_do_addr_cycle(mtd, column, page_addr);
break;
case NAND_CMD_READ0:
- host->buf_start = column;
- break;
-
case NAND_CMD_READOOB:
- host->buf_start = column + mtd->writesize;
+ if (command == NAND_CMD_READ0)
+ host->buf_start = column;
+ else
+ host->buf_start = column + mtd->writesize;
+
if (host->pagesize_2k)
/* only READ0 is valid */
command = NAND_CMD_READ0;
+
+ send_cmd(host, command);
+ mxc_do_addr_cycle(mtd, column, page_addr);
+
+ if (host->pagesize_2k) {
+ /* send read confirm command */
+ send_cmd(host, NAND_CMD_READSTART);
+ /* read for each AREA */
+ send_page(host, 0, NFC_OUTPUT);
+ send_page(host, 1, NFC_OUTPUT);
+ send_page(host, 2, NFC_OUTPUT);
+ send_page(host, 3, NFC_OUTPUT);
+ } else
+ send_page(host, 0, NFC_OUTPUT);
+
+ memcpy32(host->data_buf, host->regs + MAIN_AREA0, mtd->writesize);
+ copy_spare(mtd, 1);
break;
case NAND_CMD_SEQIN:
@@ -672,6 +692,9 @@ static void imx_nand_command(struct mtd_info *mtd, unsigned command,
if (!host->pagesize_2k)
send_cmd(host, NAND_CMD_READ0);
}
+ send_cmd(host, command);
+ mxc_do_addr_cycle(mtd, column, page_addr);
+
break;
case NAND_CMD_PAGEPROG:
@@ -686,58 +709,21 @@ static void imx_nand_command(struct mtd_info *mtd, unsigned command,
send_page(host, 3, NFC_INPUT);
}
- break;
-
- case NAND_CMD_ERASE1:
- break;
- }
-
- /*
- * Write out the command to the device.
- */
- send_cmd(host, command);
-
- mxc_do_addr_cycle(mtd, column, page_addr);
-
- /*
- * Command post-processing step
- */
- switch (command) {
-
- case NAND_CMD_RESET:
- break;
-
- case NAND_CMD_READOOB:
- case NAND_CMD_READ0:
- if (host->pagesize_2k) {
- /* send read confirm command */
- send_cmd(host, NAND_CMD_READSTART);
- /* read for each AREA */
- send_page(host, 0, NFC_OUTPUT);
- send_page(host, 1, NFC_OUTPUT);
- send_page(host, 2, NFC_OUTPUT);
- send_page(host, 3, NFC_OUTPUT);
- } else {
- send_page(host, 0, NFC_OUTPUT);
- }
-
- memcpy32(host->data_buf, host->regs + MAIN_AREA0, mtd->writesize);
- copy_spare(mtd, 1);
-
+ send_cmd(host, command);
+ mxc_do_addr_cycle(mtd, column, page_addr);
break;
case NAND_CMD_READID:
+ send_cmd(host, command);
+ mxc_do_addr_cycle(mtd, column, page_addr);
host->buf_start = 0;
send_read_id(host);
break;
- case NAND_CMD_PAGEPROG:
- break;
-
- case NAND_CMD_STATUS:
- break;
-
+ case NAND_CMD_ERASE1:
case NAND_CMD_ERASE2:
+ send_cmd(host, command);
+ mxc_do_addr_cycle(mtd, column, page_addr);
break;
}
}