Patchwork mtd/gpmi : add gpmi support for mx6q

login
register
mail settings
Submitter Huang Shijie
Date Feb. 6, 2012, 5:20 a.m.
Message ID <1328505606-27981-1-git-send-email-b32955@freescale.com>
Download mbox | patch
Permalink /patch/139679/
State New
Headers show

Comments

Huang Shijie - Feb. 6, 2012, 5:20 a.m.
add gpmi support to mx6q.

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 drivers/mtd/nand/gpmi-nand/bch-regs.h  |   42 ++++++++++++++++++++++++-------
 drivers/mtd/nand/gpmi-nand/gpmi-lib.c  |   14 ++++++----
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    3 ++
 drivers/mtd/nand/gpmi-nand/gpmi-nand.h |    2 +
 4 files changed, 45 insertions(+), 16 deletions(-)
Bityutskiy, Artem - Feb. 13, 2012, 11:58 a.m.
On Mon, 2012-02-06 at 13:20 +0800, Huang Shijie wrote:
> add gpmi support to mx6q.
> 
> Signed-off-by: Huang Shijie <b32955@freescale.com>

Please, let me know how I can compile-test this. This diver depends on
imx23 or imx28 and I cannot find a defconfig for these. When I select
MXS platform the compilation fails. Could you please describe some way
to generate a compilable configuration which would include this driver
as well, or send me the defconfig file.
Wolfram Sang - Feb. 13, 2012, 2:41 p.m.
> Please, let me know how I can compile-test this. This diver depends on
> imx23 or imx28 and I cannot find a defconfig for these. When I select
> MXS platform the compilation fails. Could you please describe some way
> to generate a compilable configuration which would include this driver
> as well, or send me the defconfig file.

I can't tell about MX6, but the defconfig for mx23/28 is called
mxs_defconfig.
Fabio Estevam - Feb. 13, 2012, 2:45 p.m.
On 2/13/12, Wolfram Sang <w.sang@pengutronix.de> wrote:

> I can't tell about MX6, but the defconfig for mx23/28 is called
> mxs_defconfig.

For mx6 the defconfig is imx_v6_v7_defconfig.
Huang Shijie - Feb. 13, 2012, 3:05 p.m.
Hi Artem:

>Please, let me know how I can compile-test this. This diver depends on
>imx23 or imx28 and I cannot find a defconfig for these. When I select
>MXS platform the compilation fails. Could you please describe some way
>to generate a compilable configuration which would include this driver
>as well, or send me the defconfig file.

use make mxs_defconfig to make the .config.
and select the gpmi-nand driver. then you can compile it.

This patch is just part of the patches for mx6q, another two patches are the mxs-dma patches.
So in the mx6q, I do not enable the  gpmi-nand driver. you can compile-test it just on mxs_defconfig.

BR
Huang Shijie
Bityutskiy, Artem - Feb. 13, 2012, 3:34 p.m.
On Mon, 2012-02-13 at 15:05 +0000, Huang Shijie-B32955 wrote:
> Hi Artem:
> 
> >Please, let me know how I can compile-test this. This diver depends on
> >imx23 or imx28 and I cannot find a defconfig for these. When I select
> >MXS platform the compilation fails. Could you please describe some way
> >to generate a compilable configuration which would include this driver
> >as well, or send me the defconfig file.
> 
> use make mxs_defconfig to make the .config.
> and select the gpmi-nand driver. then you can compile it.
> 
> This patch is just part of the patches for mx6q, another two patches are the mxs-dma patches.
> So in the mx6q, I do not enable the  gpmi-nand driver. you can compile-test it just on mxs_defconfig.

Thanks. When I select MTD stuff I get the following Kbuild complaint:

scripts/kconfig/conf --savedefconfig=defconfig Kconfig
warning: (MTD_NAND_GPMI_NAND) selects MTD_CMDLINE_PARTS which has unmet direct dependencies (MTD=y)

Would mxs people send a fix?
Huang Shijie - Feb. 13, 2012, 3:48 p.m.
Hi,

>scripts/kconfig/conf --savedefconfig=defconfig Kconfig
>warning: (MTD_NAND_GPMI_NAND) selects MTD_CMDLINE_PARTS which has unmet direct dependencies (MTD=y)

>Would mxs people send a fix?

Do you mean i have to remove the "select MTD_CMD_LINE_PARTS" for gpmi-nand?

BR
Huang Shijie
Artem Bityutskiy - Feb. 13, 2012, 4:13 p.m.
On Mon, 2012-02-13 at 15:48 +0000, Huang Shijie-B32955 wrote:
> Hi,
> 
> >scripts/kconfig/conf --savedefconfig=defconfig Kconfig
> >warning: (MTD_NAND_GPMI_NAND) selects MTD_CMDLINE_PARTS which has unmet direct dependencies (MTD=y)
> 
> >Would mxs people send a fix?
> 
> Do you mean i have to remove the "select MTD_CMD_LINE_PARTS" for gpmi-nand?

Not sure, think of something :-) I've attached the defconfig I used.
Probably something to do with the fact that I enabled everything as a
module. If you are unable to analyze, let me know and I'll try to look
closer.
Bityutskiy, Artem - Feb. 13, 2012, 4:22 p.m.
On Mon, 2012-02-13 at 15:05 +0000, Huang Shijie-B32955 wrote:
> Hi Artem:
> 
> >Please, let me know how I can compile-test this. This diver depends on
> >imx23 or imx28 and I cannot find a defconfig for these. When I select
> >MXS platform the compilation fails. Could you please describe some way
> >to generate a compilable configuration which would include this driver
> >as well, or send me the defconfig file.
> 
> use make mxs_defconfig to make the .config.
> and select the gpmi-nand driver. then you can compile it.
> 
> This patch is just part of the patches for mx6q, another two patches are the mxs-dma patches.
> So in the mx6q, I do not enable the  gpmi-nand driver. you can compile-test it just on mxs_defconfig.

I cannot apply this to l2-mtd.git tree anyway:

$:~/git/l2-mtd$ git am ~/tmp/gpmi.mbox
Applying: mtd/gpmi : add gpmi support for mx6q
error: patch failed: drivers/mtd/nand/gpmi-nand/gpmi-lib.c:1066
error: drivers/mtd/nand/gpmi-nand/gpmi-lib.c: patch does not apply
Patch failed at 0001 mtd/gpmi : add gpmi support for mx6q
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".
$:~/git/l2-mtd$ patch -p1 < .git/rebase-apply/patch 
patching file drivers/mtd/nand/gpmi-nand/bch-regs.h
patching file drivers/mtd/nand/gpmi-nand/gpmi-lib.c
Hunk #3 FAILED at 1067.
1 out of 3 hunks FAILED -- saving rejects to file drivers/mtd/nand/gpmi-nand/gpmi-lib.c.rej
patching file drivers/mtd/nand/gpmi-nand/gpmi-nand.c
patching file drivers/mtd/nand/gpmi-nand/gpmi-nand.h
Shawn Guo - Feb. 15, 2012, 6:37 p.m.
On Mon, Feb 06, 2012 at 01:20:06PM +0800, Huang Shijie wrote:
> add gpmi support to mx6q.
> 
> Signed-off-by: Huang Shijie <b32955@freescale.com>
> ---
>  drivers/mtd/nand/gpmi-nand/bch-regs.h  |   42 ++++++++++++++++++++++++-------
>  drivers/mtd/nand/gpmi-nand/gpmi-lib.c  |   14 ++++++----
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    3 ++
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.h |    2 +
>  4 files changed, 45 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/mtd/nand/gpmi-nand/bch-regs.h b/drivers/mtd/nand/gpmi-nand/bch-regs.h
> index 4effb8c..a092451 100644
> --- a/drivers/mtd/nand/gpmi-nand/bch-regs.h
> +++ b/drivers/mtd/nand/gpmi-nand/bch-regs.h
> @@ -51,15 +51,26 @@
>  
>  #define BP_BCH_FLASH0LAYOUT0_ECC0		12
>  #define BM_BCH_FLASH0LAYOUT0_ECC0	(0xf << BP_BCH_FLASH0LAYOUT0_ECC0)
> -#define BF_BCH_FLASH0LAYOUT0_ECC0(v)		\
> -	(((v) << BP_BCH_FLASH0LAYOUT0_ECC0) & BM_BCH_FLASH0LAYOUT0_ECC0)
> +#define MX6Q_BP_BCH_FLASH0LAYOUT0_ECC0		11
> +#define MX6Q_BM_BCH_FLASH0LAYOUT0_ECC0	(0x1f << MX6Q_BP_BCH_FLASH0LAYOUT0_ECC0)
> +#define BF_BCH_FLASH0LAYOUT0_ECC0(v, x)				\
> +	(GPMI_IS_MX6Q(x)					\
> +		? (((v) << MX6Q_BP_BCH_FLASH0LAYOUT0_ECC0)	\
> +			& MX6Q_BM_BCH_FLASH0LAYOUT0_ECC0)	\
> +		: (((v) << BP_BCH_FLASH0LAYOUT0_ECC0)		\
> +			& BM_BCH_FLASH0LAYOUT0_ECC0)		\
> +	)
>  
>  #define BP_BCH_FLASH0LAYOUT0_DATA0_SIZE		0
>  #define BM_BCH_FLASH0LAYOUT0_DATA0_SIZE		\
>  			(0xfff << BP_BCH_FLASH0LAYOUT0_DATA0_SIZE)
> -#define BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(v)	\
> -	(((v) << BP_BCH_FLASH0LAYOUT0_DATA0_SIZE)\
> -					 & BM_BCH_FLASH0LAYOUT0_DATA0_SIZE)
> +#define MX6Q_BM_BCH_FLASH0LAYOUT0_DATA0_SIZE	\
> +			(0x3ff << BP_BCH_FLASH0LAYOUT0_DATA0_SIZE)
> +#define BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(v, x)				\
> +	(GPMI_IS_MX6Q(x)						\
> +		? (((v) >> 2) & MX6Q_BM_BCH_FLASH0LAYOUT0_DATA0_SIZE)	\
> +		: ((v) & BM_BCH_FLASH0LAYOUT0_DATA0_SIZE)		\
> +	)
>  
>  #define HW_BCH_FLASH0LAYOUT1			0x00000090
>  
> @@ -72,13 +83,24 @@
>  
>  #define BP_BCH_FLASH0LAYOUT1_ECCN		12
>  #define BM_BCH_FLASH0LAYOUT1_ECCN	(0xf << BP_BCH_FLASH0LAYOUT1_ECCN)
> -#define BF_BCH_FLASH0LAYOUT1_ECCN(v)		\
> -	(((v) << BP_BCH_FLASH0LAYOUT1_ECCN) & BM_BCH_FLASH0LAYOUT1_ECCN)
> +#define MX6Q_BP_BCH_FLASH0LAYOUT1_ECCN		11
> +#define MX6Q_BM_BCH_FLASH0LAYOUT1_ECCN	(0x1f << MX6Q_BP_BCH_FLASH0LAYOUT1_ECCN)
> +#define BF_BCH_FLASH0LAYOUT1_ECCN(v, x)				\
> +	(GPMI_IS_MX6Q(x)					\
> +		? (((v) << MX6Q_BP_BCH_FLASH0LAYOUT1_ECCN)	\
> +			& MX6Q_BM_BCH_FLASH0LAYOUT1_ECCN)	\
> +		: (((v) << BP_BCH_FLASH0LAYOUT1_ECCN)		\
> +			& BM_BCH_FLASH0LAYOUT1_ECCN)		\
> +	)
>  
>  #define BP_BCH_FLASH0LAYOUT1_DATAN_SIZE		0
>  #define BM_BCH_FLASH0LAYOUT1_DATAN_SIZE		\
>  			(0xfff << BP_BCH_FLASH0LAYOUT1_DATAN_SIZE)
> -#define BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(v)	\
> -	(((v) << BP_BCH_FLASH0LAYOUT1_DATAN_SIZE) \
> -					 & BM_BCH_FLASH0LAYOUT1_DATAN_SIZE)
> +#define MX6Q_BM_BCH_FLASH0LAYOUT1_DATAN_SIZE	\
> +			(0x3ff << BP_BCH_FLASH0LAYOUT1_DATAN_SIZE)
> +#define BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(v, x)				\
> +	(GPMI_IS_MX6Q(x)						\
> +		? (((v) >> 2) & MX6Q_BM_BCH_FLASH0LAYOUT1_DATAN_SIZE)	\
> +		: ((v) & BM_BCH_FLASH0LAYOUT1_DATAN_SIZE)		\
> +	)
>  #endif
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
> index 28f8df0..fd39350 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
> @@ -223,13 +223,13 @@ int bch_set_geometry(struct gpmi_nand_data *this)
>  	/* Configure layout 0. */
>  	writel(BF_BCH_FLASH0LAYOUT0_NBLOCKS(block_count)
>  			| BF_BCH_FLASH0LAYOUT0_META_SIZE(metadata_size)
> -			| BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength)
> -			| BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block_size),
> +			| BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this)
> +			| BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block_size, this),
>  			r->bch_regs + HW_BCH_FLASH0LAYOUT0);
>  
>  	writel(BF_BCH_FLASH0LAYOUT1_PAGE_SIZE(page_size)
> -			| BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength)
> -			| BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size),
> +			| BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this)
> +			| BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size, this),
>  			r->bch_regs + HW_BCH_FLASH0LAYOUT1);
>  
>  	/* Set *all* chip selects to use layout 0. */
> @@ -803,7 +803,8 @@ int gpmi_is_ready(struct gpmi_nand_data *this, unsigned chip)
>  	if (GPMI_IS_MX23(this)) {
>  		mask = MX23_BM_GPMI_DEBUG_READY0 << chip;
>  		reg = readl(r->gpmi_regs + HW_GPMI_DEBUG);
> -	} else if (GPMI_IS_MX28(this)) {
> +	} else if (GPMI_IS_MX28(this) || GPMI_IS_MX6Q(this)) {
> +		/* MX28 shares the same R/B register as MX6Q. */
>  		mask = MX28_BF_GPMI_STAT_READY_BUSY(1 << chip);
>  		reg = readl(r->gpmi_regs + HW_GPMI_STAT);
>  	} else
> @@ -1066,8 +1067,9 @@ 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; /* set GPMI_HW_GPMI_ECCCTRL, disable the BCH. */
>  	desc = channel->device->device_prep_slave_sg(channel,
> -				(struct scatterlist *)pio, 2,
> +				(struct scatterlist *)pio, 3,
>  				DMA_TRANS_NONE,
>  				DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
>  	if (!desc) {
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index 493ec2f..90545e2 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -1582,6 +1582,9 @@ static const struct platform_device_id gpmi_ids[] = {
>  	}, {
>  		.name = "imx28-gpmi-nand",
>  		.driver_data = IS_MX28,
> +	}, {
> +		.name = "imx6q-gpmi-nand",
> +		.driver_data = IS_MX6Q,
>  	}, {},
>  };
>  
The imx6q only supports DT boot, but I do not see you are adding DT
probe for the driver, so I'm wondering how you tested the driver on
imx6q.
Huang Shijie - Feb. 16, 2012, 1:56 a.m.
Hi,
> The imx6q only supports DT boot, but I do not see you are adding DT
> probe for the driver, so I'm wondering how you tested the driver on
> imx6q.
>
This patch is just the first patch  for mx6q. My following patches will
add DT to the gpmi nand driver for mx6q. Due to the dependency issue, I 
will send the patches
in the following order:
[1] mtd/gpmi: add gpmi support for mx6q.
[2] [PATCH v5] patch set about the MXS-DMA
[3] add DT support to gpmi for mx6q.

I tested this patch based on our bsp code.

BR
Huang Shijie
Shawn Guo - Feb. 16, 2012, 2:18 a.m.
On Thu, Feb 16, 2012 at 09:56:10AM +0800, Huang Shijie wrote:
> Hi,
> >The imx6q only supports DT boot, but I do not see you are adding DT
> >probe for the driver, so I'm wondering how you tested the driver on
> >imx6q.
> >
> This patch is just the first patch  for mx6q. My following patches will
> add DT to the gpmi nand driver for mx6q. Due to the dependency
> issue, I will send the patches
> in the following order:
> [1] mtd/gpmi: add gpmi support for mx6q.
> [2] [PATCH v5] patch set about the MXS-DMA
> [3] add DT support to gpmi for mx6q.
> 
It should be:

 1. MXS-DMA series
 2. Add imx6q support with DT probe

> I tested this patch based on our bsp code.
> 
This is wrong approach.  You are submitting patches to mainline, so
you should test your patches on mainline tree.
Huang Shijie - Feb. 16, 2012, 2:38 a.m.
Hi,
> On Thu, Feb 16, 2012 at 09:56:10AM +0800, Huang Shijie wrote:
>> Hi,
>>> The imx6q only supports DT boot, but I do not see you are adding DT
>>> probe for the driver, so I'm wondering how you tested the driver on
>>> imx6q.
>>>
>> This patch is just the first patch  for mx6q. My following patches will
>> add DT to the gpmi nand driver for mx6q. Due to the dependency
>> issue, I will send the patches
>> in the following order:
>> [1] mtd/gpmi: add gpmi support for mx6q.
>> [2] [PATCH v5] patch set about the MXS-DMA
>> [3] add DT support to gpmi for mx6q.
>>
> It should be:
>
>   1. MXS-DMA series
>   2. Add imx6q support with DT probe
>
I ever did so in this order. But the mxs-dma series delayed for long 
time( I missed the CCs).
But Artem's tree is faster to merge patch.
>> I tested this patch based on our bsp code.
>>
> This is wrong approach.  You are submitting patches to mainline, so
> you should test your patches on mainline tree.
>
Beside the DT, the gpmi nand driver is the same.

Is the mainline tree ready now? How can i to set the pinmux for gpmi?

BR
Huang Shijie
Shawn Guo - Feb. 16, 2012, 4:51 a.m.
On Thu, Feb 16, 2012 at 10:38:26AM +0800, Huang Shijie wrote:
> Hi,
> >On Thu, Feb 16, 2012 at 09:56:10AM +0800, Huang Shijie wrote:
> >>Hi,
> >>>The imx6q only supports DT boot, but I do not see you are adding DT
> >>>probe for the driver, so I'm wondering how you tested the driver on
> >>>imx6q.
> >>>
> >>This patch is just the first patch  for mx6q. My following patches will
> >>add DT to the gpmi nand driver for mx6q. Due to the dependency
> >>issue, I will send the patches
> >>in the following order:
> >>[1] mtd/gpmi: add gpmi support for mx6q.
> >>[2] [PATCH v5] patch set about the MXS-DMA
> >>[3] add DT support to gpmi for mx6q.
> >>
> >It should be:
> >
> >  1. MXS-DMA series
> >  2. Add imx6q support with DT probe
> >
> I ever did so in this order. But the mxs-dma series delayed for long
> time( I missed the CCs).
> But Artem's tree is faster to merge patch.

You can not change the order because of that.  The fact is imx6q gpmi
support depends on the mxs-dma change.

> >>I tested this patch based on our bsp code.
> >>
> >This is wrong approach.  You are submitting patches to mainline, so
> >you should test your patches on mainline tree.
> >
> Beside the DT, the gpmi nand driver is the same.
> 
> Is the mainline tree ready now? How can i to set the pinmux for gpmi?
> 
People have eventually archived the agreement on pinctrl DT design,
and the patch will come out pretty soon.  Before we have the pinctrl
driver for imx6q, you can rely on boot loader to set pins up properly
for your testing.
Huang Shijie - Feb. 16, 2012, 5:42 a.m.
hi
> You can not change the order because of that.  The fact is imx6q gpmi
> support depends on the mxs-dma change.
>
ok, I will send out the new version about this patch set.

thanks
Huang Shijie

Patch

diff --git a/drivers/mtd/nand/gpmi-nand/bch-regs.h b/drivers/mtd/nand/gpmi-nand/bch-regs.h
index 4effb8c..a092451 100644
--- a/drivers/mtd/nand/gpmi-nand/bch-regs.h
+++ b/drivers/mtd/nand/gpmi-nand/bch-regs.h
@@ -51,15 +51,26 @@ 
 
 #define BP_BCH_FLASH0LAYOUT0_ECC0		12
 #define BM_BCH_FLASH0LAYOUT0_ECC0	(0xf << BP_BCH_FLASH0LAYOUT0_ECC0)
-#define BF_BCH_FLASH0LAYOUT0_ECC0(v)		\
-	(((v) << BP_BCH_FLASH0LAYOUT0_ECC0) & BM_BCH_FLASH0LAYOUT0_ECC0)
+#define MX6Q_BP_BCH_FLASH0LAYOUT0_ECC0		11
+#define MX6Q_BM_BCH_FLASH0LAYOUT0_ECC0	(0x1f << MX6Q_BP_BCH_FLASH0LAYOUT0_ECC0)
+#define BF_BCH_FLASH0LAYOUT0_ECC0(v, x)				\
+	(GPMI_IS_MX6Q(x)					\
+		? (((v) << MX6Q_BP_BCH_FLASH0LAYOUT0_ECC0)	\
+			& MX6Q_BM_BCH_FLASH0LAYOUT0_ECC0)	\
+		: (((v) << BP_BCH_FLASH0LAYOUT0_ECC0)		\
+			& BM_BCH_FLASH0LAYOUT0_ECC0)		\
+	)
 
 #define BP_BCH_FLASH0LAYOUT0_DATA0_SIZE		0
 #define BM_BCH_FLASH0LAYOUT0_DATA0_SIZE		\
 			(0xfff << BP_BCH_FLASH0LAYOUT0_DATA0_SIZE)
-#define BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(v)	\
-	(((v) << BP_BCH_FLASH0LAYOUT0_DATA0_SIZE)\
-					 & BM_BCH_FLASH0LAYOUT0_DATA0_SIZE)
+#define MX6Q_BM_BCH_FLASH0LAYOUT0_DATA0_SIZE	\
+			(0x3ff << BP_BCH_FLASH0LAYOUT0_DATA0_SIZE)
+#define BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(v, x)				\
+	(GPMI_IS_MX6Q(x)						\
+		? (((v) >> 2) & MX6Q_BM_BCH_FLASH0LAYOUT0_DATA0_SIZE)	\
+		: ((v) & BM_BCH_FLASH0LAYOUT0_DATA0_SIZE)		\
+	)
 
 #define HW_BCH_FLASH0LAYOUT1			0x00000090
 
@@ -72,13 +83,24 @@ 
 
 #define BP_BCH_FLASH0LAYOUT1_ECCN		12
 #define BM_BCH_FLASH0LAYOUT1_ECCN	(0xf << BP_BCH_FLASH0LAYOUT1_ECCN)
-#define BF_BCH_FLASH0LAYOUT1_ECCN(v)		\
-	(((v) << BP_BCH_FLASH0LAYOUT1_ECCN) & BM_BCH_FLASH0LAYOUT1_ECCN)
+#define MX6Q_BP_BCH_FLASH0LAYOUT1_ECCN		11
+#define MX6Q_BM_BCH_FLASH0LAYOUT1_ECCN	(0x1f << MX6Q_BP_BCH_FLASH0LAYOUT1_ECCN)
+#define BF_BCH_FLASH0LAYOUT1_ECCN(v, x)				\
+	(GPMI_IS_MX6Q(x)					\
+		? (((v) << MX6Q_BP_BCH_FLASH0LAYOUT1_ECCN)	\
+			& MX6Q_BM_BCH_FLASH0LAYOUT1_ECCN)	\
+		: (((v) << BP_BCH_FLASH0LAYOUT1_ECCN)		\
+			& BM_BCH_FLASH0LAYOUT1_ECCN)		\
+	)
 
 #define BP_BCH_FLASH0LAYOUT1_DATAN_SIZE		0
 #define BM_BCH_FLASH0LAYOUT1_DATAN_SIZE		\
 			(0xfff << BP_BCH_FLASH0LAYOUT1_DATAN_SIZE)
-#define BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(v)	\
-	(((v) << BP_BCH_FLASH0LAYOUT1_DATAN_SIZE) \
-					 & BM_BCH_FLASH0LAYOUT1_DATAN_SIZE)
+#define MX6Q_BM_BCH_FLASH0LAYOUT1_DATAN_SIZE	\
+			(0x3ff << BP_BCH_FLASH0LAYOUT1_DATAN_SIZE)
+#define BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(v, x)				\
+	(GPMI_IS_MX6Q(x)						\
+		? (((v) >> 2) & MX6Q_BM_BCH_FLASH0LAYOUT1_DATAN_SIZE)	\
+		: ((v) & BM_BCH_FLASH0LAYOUT1_DATAN_SIZE)		\
+	)
 #endif
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
index 28f8df0..fd39350 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
@@ -223,13 +223,13 @@  int bch_set_geometry(struct gpmi_nand_data *this)
 	/* Configure layout 0. */
 	writel(BF_BCH_FLASH0LAYOUT0_NBLOCKS(block_count)
 			| BF_BCH_FLASH0LAYOUT0_META_SIZE(metadata_size)
-			| BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength)
-			| BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block_size),
+			| BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this)
+			| BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block_size, this),
 			r->bch_regs + HW_BCH_FLASH0LAYOUT0);
 
 	writel(BF_BCH_FLASH0LAYOUT1_PAGE_SIZE(page_size)
-			| BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength)
-			| BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size),
+			| BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this)
+			| BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size, this),
 			r->bch_regs + HW_BCH_FLASH0LAYOUT1);
 
 	/* Set *all* chip selects to use layout 0. */
@@ -803,7 +803,8 @@  int gpmi_is_ready(struct gpmi_nand_data *this, unsigned chip)
 	if (GPMI_IS_MX23(this)) {
 		mask = MX23_BM_GPMI_DEBUG_READY0 << chip;
 		reg = readl(r->gpmi_regs + HW_GPMI_DEBUG);
-	} else if (GPMI_IS_MX28(this)) {
+	} else if (GPMI_IS_MX28(this) || GPMI_IS_MX6Q(this)) {
+		/* MX28 shares the same R/B register as MX6Q. */
 		mask = MX28_BF_GPMI_STAT_READY_BUSY(1 << chip);
 		reg = readl(r->gpmi_regs + HW_GPMI_STAT);
 	} else
@@ -1066,8 +1067,9 @@  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; /* set GPMI_HW_GPMI_ECCCTRL, disable the BCH. */
 	desc = channel->device->device_prep_slave_sg(channel,
-				(struct scatterlist *)pio, 2,
+				(struct scatterlist *)pio, 3,
 				DMA_TRANS_NONE,
 				DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
 	if (!desc) {
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 493ec2f..90545e2 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -1582,6 +1582,9 @@  static const struct platform_device_id gpmi_ids[] = {
 	}, {
 		.name = "imx28-gpmi-nand",
 		.driver_data = IS_MX28,
+	}, {
+		.name = "imx6q-gpmi-nand",
+		.driver_data = IS_MX6Q,
 	}, {},
 };
 
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.h b/drivers/mtd/nand/gpmi-nand/gpmi-nand.h
index 1c7fdbb..a302dd1 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.h
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.h
@@ -268,6 +268,8 @@  extern int gpmi_read_page(struct gpmi_nand_data *,
 /* Use the platform_id to distinguish different Archs. */
 #define IS_MX23			0x1
 #define IS_MX28			0x2
+#define IS_MX6Q			0x8
 #define GPMI_IS_MX23(x)		((x)->pdev->id_entry->driver_data == IS_MX23)
 #define GPMI_IS_MX28(x)		((x)->pdev->id_entry->driver_data == IS_MX28)
+#define GPMI_IS_MX6Q(x)		((x)->pdev->id_entry->driver_data == IS_MX6Q)
 #endif