linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: b32955@freescale.com (Huang Shijie)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 10/10] MTD/GPMI : change the code for new DMA interface
Date: Thu, 19 Jan 2012 14:16:07 +0800	[thread overview]
Message-ID: <1326953767-24155-11-git-send-email-b32955@freescale.com> (raw)
In-Reply-To: <1326953767-24155-1-git-send-email-b32955@freescale.com>

Please read more comment in the mxs-dma.h.

In the new GPMI version(0x05010000 used by MX6Q/MX50), we should
set the WAIT4END bit in the middle one of this chain,
which enables the BCH module and reads out the NAND page.
If we do not do this, a DMA timeout occurs. This bug has been
catched in the MX6Q board.

We have changed the DMA interface to fix the bug, now use the new
interface.

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 drivers/mtd/nand/gpmi-nand/gpmi-lib.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
index 5b73ae5..84abd49 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
@@ -842,7 +842,7 @@ int gpmi_send_command(struct gpmi_nand_data *this)
 	sg_init_one(sgl, this->cmd_buffer, this->command_length);
 	dma_map_sg(this->dev, sgl, 1, DMA_TO_DEVICE);
 	desc = channel->device->device_prep_slave_sg(channel,
-					sgl, 1, DMA_MEM_TO_DEV, 1);
+				sgl, 1, DMA_MEM_TO_DEV, MXS_DMA_F_LASTONE);
 	if (!desc) {
 		pr_err("step 2 error\n");
 		return -1;
@@ -884,7 +884,7 @@ int gpmi_send_data(struct gpmi_nand_data *this)
 	/* [2] send DMA request */
 	prepare_data_dma(this, DMA_TO_DEVICE);
 	desc = channel->device->device_prep_slave_sg(channel, &this->data_sgl,
-						1, DMA_MEM_TO_DEV, 1);
+					1, DMA_MEM_TO_DEV, MXS_DMA_F_LASTONE);
 	if (!desc) {
 		pr_err("step 2 error\n");
 		return -1;
@@ -920,7 +920,7 @@ int gpmi_read_data(struct gpmi_nand_data *this)
 	/* [2] : send DMA request */
 	prepare_data_dma(this, DMA_FROM_DEVICE);
 	desc = channel->device->device_prep_slave_sg(channel, &this->data_sgl,
-						1, DMA_DEV_TO_MEM, 1);
+					1, DMA_DEV_TO_MEM, MXS_DMA_F_LASTONE);
 	if (!desc) {
 		pr_err("step 2 error\n");
 		return -1;
@@ -967,7 +967,8 @@ int gpmi_send_page(struct gpmi_nand_data *this,
 
 	desc = channel->device->device_prep_slave_sg(channel,
 					(struct scatterlist *)pio,
-					ARRAY_SIZE(pio), DMA_TRANS_NONE, 0);
+					ARRAY_SIZE(pio), DMA_TRANS_NONE,
+					MXS_DMA_F_WAIT4END);
 	if (!desc) {
 		pr_err("step 2 error\n");
 		return -1;
@@ -987,6 +988,7 @@ int gpmi_read_page(struct gpmi_nand_data *this,
 	struct dma_async_tx_descriptor *desc;
 	struct dma_chan *channel = get_dma_chan(this);
 	int chip = this->current_chip;
+	unsigned long flags;
 	u32 pio[6];
 
 	/* [1] Wait for the chip to report ready. */
@@ -1029,9 +1031,14 @@ int gpmi_read_page(struct gpmi_nand_data *this,
 	pio[3] = geo->page_size;
 	pio[4] = payload;
 	pio[5] = auxiliary;
+
+	/* If the GPMI is new version, set MXS_DMA_F_WAIT4END here. */
+	flags = MXS_DMA_F_APPEND;
+	if (this->gpmi_version == GPMI_VERSION_0501)
+		flags |= MXS_DMA_F_WAIT4END;
 	desc = channel->device->device_prep_slave_sg(channel,
 					(struct scatterlist *)pio,
-					ARRAY_SIZE(pio), DMA_TRANS_NONE, 1);
+					ARRAY_SIZE(pio), DMA_TRANS_NONE, flags);
 	if (!desc) {
 		pr_err("step 2 error\n");
 		return -1;
@@ -1048,9 +1055,10 @@ int gpmi_read_page(struct gpmi_nand_data *this,
 		| BF_GPMI_CTRL0_ADDRESS(address)
 		| BF_GPMI_CTRL0_XFER_COUNT(geo->page_size);
 	pio[1] = 0;
+	pio[2] = 0;
 	desc = channel->device->device_prep_slave_sg(channel,
 				(struct scatterlist *)pio, 2,
-				DMA_TRANS_NONE, 1);
+				DMA_TRANS_NONE, MXS_DMA_F_LASTONE);
 	if (!desc) {
 		pr_err("step 3 error\n");
 		return -1;
-- 
1.7.0.4

  parent reply	other threads:[~2012-01-19  6:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-19  6:15 [PATCH 00/10] patch set about the MXS-DMA Huang Shijie
2012-01-19  6:15 ` [PATCH 01/10] MXS-DMA : move the mxs-dma.h to a more common place Huang Shijie
2012-01-19  8:58   ` Wolfram Sang
2012-01-19 11:20     ` Mark Brown
2012-01-19 13:04   ` Shawn Guo
2012-01-19  6:15 ` [PATCH 02/10] MXS-DMA : change the header Huang Shijie
2012-01-19  6:16 ` [PATCH 03/10] MXS-MMC : change the DMA header file Huang Shijie
2012-01-19  6:16 ` [PATCH 04/10] MTD/GPMI " Huang Shijie
2012-01-19  6:16 ` [PATCH 05/10] ASoc " Huang Shijie
2012-01-19  6:16 ` [PATCH 06/10] MXS-DMA : add more flags for MXS-DMA Huang Shijie
2012-01-19  9:02   ` Russell King - ARM Linux
2012-01-19  9:31     ` Huang Shijie
2012-01-19  6:16 ` [PATCH 07/10] MXS-DMA : change the last parameter of mxs_dma_prep_slave_sg() Huang Shijie
2012-01-19  6:16 ` [PATCH 08/10] MXS-MMC : use the new DMA flags Huang Shijie
2012-01-19  6:16 ` [PATCH 09/10] MTD/GPMI : add a new field `gpmi_version` Huang Shijie
2012-01-19  6:16 ` Huang Shijie [this message]
2012-01-19  9:10 ` [PATCH 00/10] patch set about the MXS-DMA Shawn Guo
2012-01-19  9:45   ` Wolfram Sang
2012-01-20  3:29     ` Huang Shijie

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=1326953767-24155-11-git-send-email-b32955@freescale.com \
    --to=b32955@freescale.com \
    --cc=linux-arm-kernel@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;
as well as URLs for NNTP newsgroup(s).