aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/gpmi-nand
diff options
context:
space:
mode:
authorHuang Shijie <b32955@freescale.com>2012-02-16 01:17:33 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-03-26 19:37:28 -0400
commit921de864b7c6413f15224d8f5e677541e8e1ac6d (patch)
tree325815e4a65a26b961796314fdb0b2cd6e0b9975 /drivers/mtd/nand/gpmi-nand
parent3946860409130038ef6e0e5c50f2203053eae2b7 (diff)
mxs-dma : rewrite the last parameter of mxs_dma_prep_slave_sg()
[1] Background : The GPMI does ECC read page operation with a DMA chain consist of three DMA Command Structures. The middle one of the chain is used to enable the BCH, and read out the NAND page. The WAIT4END(wait for command end) is a comunication signal between the GPMI and MXS-DMA. [2] The current DMA code sets the WAIT4END bit at the last one, such as: +-----+ +-----+ +-----+ | cmd | ------------> | cmd | ------------------> | cmd | +-----+ +-----+ +-----+ ^ | | set WAIT4END here This chain works fine in the mx23/mx28. [3] But in the new GPMI version (used in MX50/MX60), the WAIT4END bit should be set not only at the last DMA Command Structure, but also at the middle one, such as: +-----+ +-----+ +-----+ | cmd | ------------> | cmd | ------------------> | cmd | +-----+ +-----+ +-----+ ^ ^ | | | | set WAIT4END here too set WAIT4END here If we do not set WAIT4END, the BCH maybe stalls in "ECC reading page" state. In the next ECC write page operation, a DMA-timeout occurs. This has been catched in the MX6Q board. [4] In order to fix the bug, rewrite the last parameter of mxs_dma_prep_slave_sg(), and use the dma_ctrl_flags: --------------------------------------------------------- DMA_PREP_INTERRUPT : append a new DMA Command Structrue. DMA_CTRL_ACK : set the WAIT4END bit for this DMA Command Structure. --------------------------------------------------------- [5] changes to the relative drivers: <1> For mxs-mmc driver, just use the new flags, do not change any logic. <2> For gpmi-nand driver, and use the new flags to set the DMA chain, especially for ecc read page. Acked-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Huang Shijie <b32955@freescale.com> Acked-by: Vinod Koul <vinod.koul@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand/gpmi-nand')
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-lib.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
index 7db6555ed3ba..5e3c5051e6a2 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
@@ -849,7 +849,9 @@ int gpmi_send_command(struct gpmi_nand_data *this)
849 sg_init_one(sgl, this->cmd_buffer, this->command_length); 849 sg_init_one(sgl, this->cmd_buffer, this->command_length);
850 dma_map_sg(this->dev, sgl, 1, DMA_TO_DEVICE); 850 dma_map_sg(this->dev, sgl, 1, DMA_TO_DEVICE);
851 desc = channel->device->device_prep_slave_sg(channel, 851 desc = channel->device->device_prep_slave_sg(channel,
852 sgl, 1, DMA_MEM_TO_DEV, 1); 852 sgl, 1, DMA_MEM_TO_DEV,
853 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
854
853 if (!desc) { 855 if (!desc) {
854 pr_err("step 2 error\n"); 856 pr_err("step 2 error\n");
855 return -1; 857 return -1;
@@ -891,7 +893,8 @@ int gpmi_send_data(struct gpmi_nand_data *this)
891 /* [2] send DMA request */ 893 /* [2] send DMA request */
892 prepare_data_dma(this, DMA_TO_DEVICE); 894 prepare_data_dma(this, DMA_TO_DEVICE);
893 desc = channel->device->device_prep_slave_sg(channel, &this->data_sgl, 895 desc = channel->device->device_prep_slave_sg(channel, &this->data_sgl,
894 1, DMA_MEM_TO_DEV, 1); 896 1, DMA_MEM_TO_DEV,
897 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
895 if (!desc) { 898 if (!desc) {
896 pr_err("step 2 error\n"); 899 pr_err("step 2 error\n");
897 return -1; 900 return -1;
@@ -927,7 +930,8 @@ int gpmi_read_data(struct gpmi_nand_data *this)
927 /* [2] : send DMA request */ 930 /* [2] : send DMA request */
928 prepare_data_dma(this, DMA_FROM_DEVICE); 931 prepare_data_dma(this, DMA_FROM_DEVICE);
929 desc = channel->device->device_prep_slave_sg(channel, &this->data_sgl, 932 desc = channel->device->device_prep_slave_sg(channel, &this->data_sgl,
930 1, DMA_DEV_TO_MEM, 1); 933 1, DMA_DEV_TO_MEM,
934 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
931 if (!desc) { 935 if (!desc) {
932 pr_err("step 2 error\n"); 936 pr_err("step 2 error\n");
933 return -1; 937 return -1;
@@ -974,7 +978,8 @@ int gpmi_send_page(struct gpmi_nand_data *this,
974 978
975 desc = channel->device->device_prep_slave_sg(channel, 979 desc = channel->device->device_prep_slave_sg(channel,
976 (struct scatterlist *)pio, 980 (struct scatterlist *)pio,
977 ARRAY_SIZE(pio), DMA_TRANS_NONE, 0); 981 ARRAY_SIZE(pio), DMA_TRANS_NONE,
982 DMA_CTRL_ACK);
978 if (!desc) { 983 if (!desc) {
979 pr_err("step 2 error\n"); 984 pr_err("step 2 error\n");
980 return -1; 985 return -1;
@@ -1038,7 +1043,8 @@ int gpmi_read_page(struct gpmi_nand_data *this,
1038 pio[5] = auxiliary; 1043 pio[5] = auxiliary;
1039 desc = channel->device->device_prep_slave_sg(channel, 1044 desc = channel->device->device_prep_slave_sg(channel,
1040 (struct scatterlist *)pio, 1045 (struct scatterlist *)pio,
1041 ARRAY_SIZE(pio), DMA_TRANS_NONE, 1); 1046 ARRAY_SIZE(pio), DMA_TRANS_NONE,
1047 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
1042 if (!desc) { 1048 if (!desc) {
1043 pr_err("step 2 error\n"); 1049 pr_err("step 2 error\n");
1044 return -1; 1050 return -1;
@@ -1057,7 +1063,8 @@ int gpmi_read_page(struct gpmi_nand_data *this,
1057 pio[1] = 0; 1063 pio[1] = 0;
1058 desc = channel->device->device_prep_slave_sg(channel, 1064 desc = channel->device->device_prep_slave_sg(channel,
1059 (struct scatterlist *)pio, 2, 1065 (struct scatterlist *)pio, 2,
1060 DMA_TRANS_NONE, 1); 1066 DMA_TRANS_NONE,
1067 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
1061 if (!desc) { 1068 if (!desc) {
1062 pr_err("step 3 error\n"); 1069 pr_err("step 3 error\n");
1063 return -1; 1070 return -1;