linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: gpmi: make blockmark swapping optional
@ 2014-03-19 13:23 y
  2014-03-20  8:33 ` Juergen Beisert
                   ` (3 more replies)
  0 siblings, 4 replies; 32+ messages in thread
From: y @ 2014-03-19 13:23 UTC (permalink / raw)
  To: Arnd Bergmann, Artem Bityutskiy, Brian Norris, David Woodhouse,
	Fabio Estevam, Huang Shijie, Ian Campbell, Kumar Gala,
	Lothar Waßmann, Mark Rutland, Pawel Moll, Rob Herring,
	Rob Landley, Russell King, Sascha Hauer, Shawn Guo, devicetree,
	linux-arm-kernel, linux-doc, linux-kernel, linux-mtd

From: Lothar Waßmann <LW@KARO-electronics.de>

With a flash-based BBT there is no reason to move the Factory Bad
Block Marker from the data area buffer (to where it is mapped by the
GPMI NAND controller) to the OOB buffer. Thus, make this feature
configurable via DT. This is required for the Ka-Ro electronics
platforms.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 Documentation/devicetree/bindings/mtd/gpmi-nand.txt |    3 +++
 arch/arm/boot/dts/imx28-tx28.dts                    |    1 +
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c              |   10 +++++++---
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
index 458d596..f28949a 100644
--- a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
@@ -25,6 +25,9 @@ Optional properties:
                        discoverable or this property is not enabled,
                        the software may chooses an implementation-defined
                        ECC scheme.
+  - fsl,no-blockmark-swap: Don't swap the bad block marker from the OOB
+                       area with the byte in the data area but rely on the
+                       BBT for identifying bad blocks.
 
 The device tree may optionally contain sub-nodes describing partitions of the
 address space. See partition.txt for more detail.
diff --git a/arch/arm/boot/dts/imx28-tx28.dts b/arch/arm/boot/dts/imx28-tx28.dts
index e14bd86..7d2bea8 100644
--- a/arch/arm/boot/dts/imx28-tx28.dts
+++ b/arch/arm/boot/dts/imx28-tx28.dts
@@ -247,6 +247,7 @@
 &gpmi {
 	pinctrl-0 = <&gpmi_pins_a &gpmi_status_cfg>;
 	nand-on-flash-bbt;
+	fsl,no-blockmark-swap;
 	status = "okay";
 };
 
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index bb77f75..98562eb 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -1632,9 +1632,6 @@ static int gpmi_init_last(struct gpmi_nand_data *this)
 	struct bch_geometry *bch_geo = &this->bch_geometry;
 	int ret;
 
-	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
-	this->swap_block_mark = !GPMI_IS_MX23(this);
-
 	/* Set up the medium geometry */
 	ret = gpmi_set_geometry(this);
 	if (ret)
@@ -1701,6 +1698,13 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
 	if (of_get_nand_on_flash_bbt(this->dev->of_node))
 		chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
 
+	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
+	if (!of_property_read_bool(this->dev->of_node, "fsl,no-blockmark-swap"))
+		this->swap_block_mark = !GPMI_IS_MX23(this);
+
+	dev_dbg(this->dev, "Blockmark swapping %sabled\n",
+		this->swap_block_mark ? "en" : "dis");
+
 	/*
 	 * Allocate a temporary DMA buffer for reading ID in the
 	 * nand_scan_ident().
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH] mtd: gpmi: make blockmark swapping optional
  2014-03-19 13:23 [PATCH] mtd: gpmi: make blockmark swapping optional y
@ 2014-03-20  8:33 ` Juergen Beisert
  2014-03-20  9:20   ` Lothar Waßmann
  2014-03-20  9:15 ` Huang Shijie
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 32+ messages in thread
From: Juergen Beisert @ 2014-03-20  8:33 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Fabio Estevam, Mark Rutland, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, y, linux-doc,
	linux-kernel, Huang Shijie, devicetree, Rob Herring, linux-mtd,
	Rob Landley, Kumar Gala, Brian Norris, David Woodhouse,
	Sascha Hauer, Shawn Guo, Lothar Waßmann

Hi Lothar,

On Wednesday 19 March 2014 14:23:26 y@karo-electronics.de wrote:
> With a flash-based BBT there is no reason to move the Factory Bad
> Block Marker from the data area buffer (to where it is mapped by the
> GPMI NAND controller) to the OOB buffer. Thus, make this feature
> configurable via DT. This is required for the Ka-Ro electronics
> platforms.
> [...]

How do you create the BBT the very first time with valuable data when the NAND 
already contains factory bad blocks?

jbe

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] mtd: gpmi: make blockmark swapping optional
  2014-03-19 13:23 [PATCH] mtd: gpmi: make blockmark swapping optional y
  2014-03-20  8:33 ` Juergen Beisert
@ 2014-03-20  9:15 ` Huang Shijie
  2014-03-20  9:21   ` Lothar Waßmann
  2014-03-21  5:36 ` Huang Shijie
  2014-03-28 10:35 ` [PATCHv3 0/2] " Lothar Waßmann
  3 siblings, 1 reply; 32+ messages in thread
From: Huang Shijie @ 2014-03-20  9:15 UTC (permalink / raw)
  To: y
  Cc: Fabio Estevam, Mark Rutland, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, linux-doc,
	linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo, Lothar Waßmann

于 2014年03月19日 21:23, y@karo-electronics.de 写道:
> configurable via DT. This is required for the Ka-Ro electronics
> platforms.
>
If you disable the swapping, you will disable the NAND boot in actually.

do you need the nand boot?

could you please tell me more detail background?

thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] mtd: gpmi: make blockmark swapping optional
  2014-03-20  8:33 ` Juergen Beisert
@ 2014-03-20  9:20   ` Lothar Waßmann
  0 siblings, 0 replies; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-20  9:20 UTC (permalink / raw)
  To: Juergen Beisert
  Cc: Fabio Estevam, Mark Rutland, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, y, linux-doc,
	linux-kernel, Huang Shijie, devicetree, Rob Herring, linux-mtd,
	Shawn Guo, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, linux-arm-kernel

Hi,

Juergen Beisert wrote:
> Hi Lothar,
> 
> On Wednesday 19 March 2014 14:23:26 y@karo-electronics.de wrote:
> > With a flash-based BBT there is no reason to move the Factory Bad
> > Block Marker from the data area buffer (to where it is mapped by the
> > GPMI NAND controller) to the OOB buffer. Thus, make this feature
> > configurable via DT. This is required for the Ka-Ro electronics
> > platforms.
> > [...]
> 
> How do you create the BBT the very first time with valuable data when the NAND 
> already contains factory bad blocks?
> 
With the flashtool that does the initial flash programming.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] mtd: gpmi: make blockmark swapping optional
  2014-03-20  9:15 ` Huang Shijie
@ 2014-03-20  9:21   ` Lothar Waßmann
  2014-03-20  9:47     ` Huang Shijie
  0 siblings, 1 reply; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-20  9:21 UTC (permalink / raw)
  To: Huang Shijie
  Cc: Fabio Estevam, Mark Rutland, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, y, linux-doc,
	linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo

Hi,

Huang Shijie wrote:
> 于 2014年03月19日 21:23, y@karo-electronics.de 写道:
> > configurable via DT. This is required for the Ka-Ro electronics
> > platforms.
> >
> If you disable the swapping, you will disable the NAND boot in actually.
> 
No. All our modules do boot from NAND and none of them does the
swapping.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] mtd: gpmi: make blockmark swapping optional
  2014-03-20  9:21   ` Lothar Waßmann
@ 2014-03-20  9:47     ` Huang Shijie
  2014-03-20 10:09       ` Lothar Waßmann
  0 siblings, 1 reply; 32+ messages in thread
From: Huang Shijie @ 2014-03-20  9:47 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Fabio Estevam, Mark Rutland, b47714, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, y, linux-doc,
	linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo

于 2014年03月20日 17:21, Lothar Waßmann 写道:
> Hi,
>
> Huang Shijie wrote:
>> 于 2014年03月19日 21:23, y@karo-electronics.de 写道:
>>> configurable via DT. This is required for the Ka-Ro electronics
>>> platforms.
>>>
>> If you disable the swapping, you will disable the NAND boot in actually.
>>
> No. All our modules do boot from NAND and none of them does the
> swapping.
>
>
It seems the NAND boot runs well by luck.

The ROM will do the swapping when it reads the BBT table written by the 
kobs-ng (or something else?).

If the BBT table is small, not bigger then a page, the NAND boot may 
runs well when you disable the swapping;
But it the BBT table is bigger, the ROM will get a corrupted BBT table.



thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] mtd: gpmi: make blockmark swapping optional
  2014-03-20  9:47     ` Huang Shijie
@ 2014-03-20 10:09       ` Lothar Waßmann
  2014-03-20 10:56         ` Huang Shijie
  0 siblings, 1 reply; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-20 10:09 UTC (permalink / raw)
  To: Huang Shijie
  Cc: Fabio Estevam, Mark Rutland, b47714, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, y, linux-doc,
	linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo

Hi,

Huang Shijie wrote:
> 于 2014年03月20日 17:21, Lothar Waßmann 写道:
> > Hi,
> >
> > Huang Shijie wrote:
> >> 于 2014年03月19日 21:23, y@karo-electronics.de 写道:
> >>> configurable via DT. This is required for the Ka-Ro electronics
> >>> platforms.
> >>>
> >> If you disable the swapping, you will disable the NAND boot in actually.
> >>
> > No. All our modules do boot from NAND and none of them does the
> > swapping.
> >
> >
> It seems the NAND boot runs well by luck.
> 
> The ROM will do the swapping when it reads the BBT table written by the 
> kobs-ng (or something else?).
> 
This can be disabled by parameter in the FCB (at least according to
the i.MX6 reference Manual):
|DISBBM 172 4 If 0 ROM will swap BadBlockMarkerByte with
|             metadata[0] after reading a page using BCH40.
|             If the value set is 1 then ROM will not do
|             swapping


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] mtd: gpmi: make blockmark swapping optional
  2014-03-20 10:09       ` Lothar Waßmann
@ 2014-03-20 10:56         ` Huang Shijie
  0 siblings, 0 replies; 32+ messages in thread
From: Huang Shijie @ 2014-03-20 10:56 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Fabio Estevam, Mark Rutland, b47714, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, y, linux-doc,
	linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo

于 2014年03月20日 18:09, Lothar Waßmann 写道:
> This can be disabled by parameter in the FCB (at least according to
> the i.MX6 reference Manual):
from imx28's reference manual, there is not such bit in the FCB to 
disable the
swapping. But you are disabling the swapping in the imx28's DTS file, 
isn't it?

I think it is dangerous.



> |DISBBM 172 4 If 0 ROM will swap BadBlockMarkerByte with
> |             metadata[0] after reading a page using BCH40.
> |             If the value set is 1 then ROM will not do
> |             swapping
>
>
I will consult with our ROM colleague about this DISBBM bit.

I am not sure if the ROM still do the swapping for the uboot when we set 
DISBBM bit.

thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] mtd: gpmi: make blockmark swapping optional
  2014-03-19 13:23 [PATCH] mtd: gpmi: make blockmark swapping optional y
  2014-03-20  8:33 ` Juergen Beisert
  2014-03-20  9:15 ` Huang Shijie
@ 2014-03-21  5:36 ` Huang Shijie
  2014-03-21 10:50   ` [PATCHv2 1/1] " Lothar Waßmann
  2014-03-28 10:35 ` [PATCHv3 0/2] " Lothar Waßmann
  3 siblings, 1 reply; 32+ messages in thread
From: Huang Shijie @ 2014-03-21  5:36 UTC (permalink / raw)
  To: y
  Cc: Fabio Estevam, Mark Rutland, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, linux-doc,
	linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo, Lothar Waßmann

于 2014年03月19日 21:23, y@karo-electronics.de 写道:
> +	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
> +	if (!of_property_read_bool(this->dev->of_node, "fsl,no-blockmark-swap"))
> +		this->swap_block_mark = !GPMI_IS_MX23(this);


Our ROM guy had confirmed that the Rom will disable the swapping if we 
set the DISBBM bit.
But please do not change any logic for imx23/imx28.

I really do not know what's the benefit we can get from this patch.
Please send the new version about this patch if you want this feature.


thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-21  5:36 ` Huang Shijie
@ 2014-03-21 10:50   ` Lothar Waßmann
  2014-03-24  9:59     ` Huang Shijie
  0 siblings, 1 reply; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-21 10:50 UTC (permalink / raw)
  To: Arnd Bergmann, Artem Bityutskiy, Brian Norris, David Woodhouse,
	Fabio Estevam, Huang Shijie, Ian Campbell, Kumar Gala,
	Lothar Waßmann, Mark Rutland, Pawel Moll, Rob Herring,
	Rob Landley, Russell King, Sascha Hauer, Shawn Guo, devicetree,
	linux-arm-kernel, linux-doc, linux-kernel, linux-mtd, Shawn Guo

With a flash-based BBT there is no reason to move the Factory Bad
Block Marker from the data area buffer (to where it is mapped by the
GPMI NAND controller) to the OOB buffer. Thus, make this feature
configurable via DT. This is required for the Ka-Ro electronics
platforms.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 Documentation/devicetree/bindings/mtd/gpmi-nand.txt |    3 +++
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c              |   10 +++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
index 458d596..f28949a 100644
--- a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
@@ -25,6 +25,9 @@ Optional properties:
                        discoverable or this property is not enabled,
                        the software may chooses an implementation-defined
                        ECC scheme.
+  - fsl,no-blockmark-swap: Don't swap the bad block marker from the OOB
+                       area with the byte in the data area but rely on the
+                       BBT for identifying bad blocks.
 
 The device tree may optionally contain sub-nodes describing partitions of the
 address space. See partition.txt for more detail.
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index bb77f75..98562eb 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -1632,9 +1632,6 @@ static int gpmi_init_last(struct gpmi_nand_data *this)
 	struct bch_geometry *bch_geo = &this->bch_geometry;
 	int ret;
 
-	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
-	this->swap_block_mark = !GPMI_IS_MX23(this);
-
 	/* Set up the medium geometry */
 	ret = gpmi_set_geometry(this);
 	if (ret)
@@ -1701,6 +1698,13 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
 	if (of_get_nand_on_flash_bbt(this->dev->of_node))
 		chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
 
+	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
+	if (!of_property_read_bool(this->dev->of_node, "fsl,no-blockmark-swap"))
+		this->swap_block_mark = !GPMI_IS_MX23(this);
+
+	dev_dbg(this->dev, "Blockmark swapping %sabled\n",
+		this->swap_block_mark ? "en" : "dis");
+
 	/*
 	 * Allocate a temporary DMA buffer for reading ID in the
 	 * nand_scan_ident().
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-21 10:50   ` [PATCHv2 1/1] " Lothar Waßmann
@ 2014-03-24  9:59     ` Huang Shijie
  2014-03-26  8:51       ` Lothar Waßmann
  0 siblings, 1 reply; 32+ messages in thread
From: Huang Shijie @ 2014-03-24  9:59 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Fabio Estevam, Mark Rutland, Shawn Guo, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, linux-doc,
	linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo

On Fri, Mar 21, 2014 at 11:50:17AM +0100, Lothar Waßmann wrote:
> With a flash-based BBT there is no reason to move the Factory Bad
> Block Marker from the data area buffer (to where it is mapped by the
> GPMI NAND controller) to the OOB buffer. Thus, make this feature
> configurable via DT. This is required for the Ka-Ro electronics
> platforms.
> 
> Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
> ---
>  Documentation/devicetree/bindings/mtd/gpmi-nand.txt |    3 +++
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c              |   10 +++++++---
>  2 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
> index 458d596..f28949a 100644
> --- a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
> +++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
> @@ -25,6 +25,9 @@ Optional properties:
>                         discoverable or this property is not enabled,
>                         the software may chooses an implementation-defined
>                         ECC scheme.
> +  - fsl,no-blockmark-swap: Don't swap the bad block marker from the OOB
> +                       area with the byte in the data area but rely on the
> +                       BBT for identifying bad blocks.

Please add the following:
       "NOTE: This property is not supported by the imx23 and imx28"
>  
>  The device tree may optionally contain sub-nodes describing partitions of the
>  address space. See partition.txt for more detail.
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index bb77f75..98562eb 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -1632,9 +1632,6 @@ static int gpmi_init_last(struct gpmi_nand_data *this)
>  	struct bch_geometry *bch_geo = &this->bch_geometry;
>  	int ret;
>  
> -	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
> -	this->swap_block_mark = !GPMI_IS_MX23(this);
> -
>  	/* Set up the medium geometry */
>  	ret = gpmi_set_geometry(this);
>  	if (ret)
> @@ -1701,6 +1698,13 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
>  	if (of_get_nand_on_flash_bbt(this->dev->of_node))
>  		chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
>  
> +	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
> +	if (!of_property_read_bool(this->dev->of_node, "fsl,no-blockmark-swap"))
> +		this->swap_block_mark = !GPMI_IS_MX23(this);

the code should like this:
----------------------------------------------
	this->swap_block_mark = !GPMI_IS_MX23(this);

	if (!GPMI_IS_IMX23(this) && !GPMI_IS_MX28(this) &&
		of_property_read_bool(this->dev->of_node, "fsl,no-blockmark-swap"))
		this->swap_block_mark = false;
----------------------------------------------
          
> +
> +	dev_dbg(this->dev, "Blockmark swapping %sabled\n",
> +		this->swap_block_mark ? "en" : "dis");
> +
>  	/*
>  	 * Allocate a temporary DMA buffer for reading ID in the
>  	 * nand_scan_ident().

There are some bugs in the gpmi driver which is caused by the assumption that
we always enable the swapping except the imx23. 

So, there are some places should be changed with this patch:
   [1] the subpage hook,
        Please also change the gpmi_ecc_read_subpage() too.

   [2] the OOB hook,
   	Please also change the gpmi_ecc_read_oob(). 


   [3] the markbad hook,
   	Please also change the gpmi_block_markbad() . 

thanks
Huang Shijie
        

	

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-24  9:59     ` Huang Shijie
@ 2014-03-26  8:51       ` Lothar Waßmann
  2014-03-26 10:41         ` Huang Shijie
  0 siblings, 1 reply; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-26  8:51 UTC (permalink / raw)
  To: Huang Shijie
  Cc: Fabio Estevam, Mark Rutland, Brian Norris, Russell King,
	Pawel Moll, Arnd Bergmann, Ian Campbell, Artem Bityutskiy,
	linux-doc, linux-kernel, devicetree, Rob Herring, linux-mtd,
	Shawn Guo, Rob Landley, Kumar Gala, Shawn Guo, David Woodhouse,
	Sascha Hauer, linux-arm-kernel

Hi,

Huang Shijie wrote:
> On Fri, Mar 21, 2014 at 11:50:17AM +0100, Lothar Waßmann wrote:
> > With a flash-based BBT there is no reason to move the Factory Bad
> > Block Marker from the data area buffer (to where it is mapped by the
> > GPMI NAND controller) to the OOB buffer. Thus, make this feature
> > configurable via DT. This is required for the Ka-Ro electronics
> > platforms.
> > 
> > Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
> > ---
> >  Documentation/devicetree/bindings/mtd/gpmi-nand.txt |    3 +++
> >  drivers/mtd/nand/gpmi-nand/gpmi-nand.c              |   10 +++++++---
> >  2 files changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
> > index 458d596..f28949a 100644
> > --- a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
> > +++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
> > @@ -25,6 +25,9 @@ Optional properties:
> >                         discoverable or this property is not enabled,
> >                         the software may chooses an implementation-defined
> >                         ECC scheme.
> > +  - fsl,no-blockmark-swap: Don't swap the bad block marker from the OOB
> > +                       area with the byte in the data area but rely on the
> > +                       BBT for identifying bad blocks.
> 
> Please add the following:
>        "NOTE: This property is not supported by the imx23 and imx28"
>
I don't see why this should not be supported on i.MX28 (i.MX23 doesn't
do byteswapping anyway, so this wouldn't change anything for i.MX23).
The partitions used by Linux need not necessarily be accessible for the
Boot ROM code (and vice versa).

> >  The device tree may optionally contain sub-nodes describing partitions of the
> >  address space. See partition.txt for more detail.
> > diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> > index bb77f75..98562eb 100644
> > --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> > +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> > @@ -1632,9 +1632,6 @@ static int gpmi_init_last(struct gpmi_nand_data *this)
> >  	struct bch_geometry *bch_geo = &this->bch_geometry;
> >  	int ret;
> >  
> > -	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
> > -	this->swap_block_mark = !GPMI_IS_MX23(this);
> > -
> >  	/* Set up the medium geometry */
> >  	ret = gpmi_set_geometry(this);
> >  	if (ret)
> > @@ -1701,6 +1698,13 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
> >  	if (of_get_nand_on_flash_bbt(this->dev->of_node))
> >  		chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
> >  
> > +	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
> > +	if (!of_property_read_bool(this->dev->of_node, "fsl,no-blockmark-swap"))
> > +		this->swap_block_mark = !GPMI_IS_MX23(this);
> 
> the code should like this:
> ----------------------------------------------
> 	this->swap_block_mark = !GPMI_IS_MX23(this);
> 
> 	if (!GPMI_IS_IMX23(this) && !GPMI_IS_MX28(this) &&
>
the !GPMI_IS_MX23() is redundant here as i.MX23 will always have
swap_block_mark == false.
I would rather add a dependency on nand-on-flash-bbt as a
prerequisite for not checking the BB marks in each block.

> > +
> > +	dev_dbg(this->dev, "Blockmark swapping %sabled\n",
> > +		this->swap_block_mark ? "en" : "dis");
> > +
> >  	/*
> >  	 * Allocate a temporary DMA buffer for reading ID in the
> >  	 * nand_scan_ident().
> 
> There are some bugs in the gpmi driver which is caused by the assumption that
> we always enable the swapping except the imx23. 
> 
> So, there are some places should be changed with this patch:
>    [1] the subpage hook,
>         Please also change the gpmi_ecc_read_subpage() too.
> 
>    [2] the OOB hook,
>    	Please also change the gpmi_ecc_read_oob(). 
> 
>    [3] the markbad hook,
>    	Please also change the gpmi_block_markbad() . 
> 
OK, I'll check that.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-26  8:51       ` Lothar Waßmann
@ 2014-03-26 10:41         ` Huang Shijie
  2014-03-26 11:55           ` Lothar Waßmann
  0 siblings, 1 reply; 32+ messages in thread
From: Huang Shijie @ 2014-03-26 10:41 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Fabio Estevam, Mark Rutland, Brian Norris, Russell King,
	Pawel Moll, Arnd Bergmann, Ian Campbell, Artem Bityutskiy,
	linux-doc, linux-kernel, devicetree, Rob Herring, linux-mtd,
	Shawn Guo, Rob Landley, Kumar Gala, Shawn Guo, David Woodhouse,
	Sascha Hauer, linux-arm-kernel

于 2014年03月26日 16:51, Lothar Waßmann 写道:
> I don't see why this should not be supported on i.MX28 (i.MX23 doesn't
> do byteswapping anyway, so this wouldn't change anything for i.MX23).
> The partitions used by Linux need not necessarily be accessible for the
> Boot ROM code (and vice versa).
But the first partition used to store the u-boot is accessible for the ROM.

Please see "Figure 12-13" in the 12.12.1.12:
   "In order to preserve the BI (bad block information), flash updater 
or gang programmer
applications need to swap Bad Block Information (BI) data to byte 0 of 
metadata area for
every page before programming NAND Flash. ROM when loading firmware, 
copies back
the value at metadata[0] to BI offset in page data. The following figure 
shows how the
factory bad block marker is preserved."

So please the imx28 should _NOT_ support this feature.

thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-26 10:41         ` Huang Shijie
@ 2014-03-26 11:55           ` Lothar Waßmann
  2014-03-27  9:59             ` Huang Shijie
  0 siblings, 1 reply; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-26 11:55 UTC (permalink / raw)
  To: Huang Shijie
  Cc: Fabio Estevam, Mark Rutland, Brian Norris, Russell King,
	Pawel Moll, Arnd Bergmann, Ian Campbell, Artem Bityutskiy,
	linux-doc, linux-kernel, devicetree, Rob Herring, linux-mtd,
	Shawn Guo, Rob Landley, Kumar Gala, Shawn Guo, David Woodhouse,
	Sascha Hauer, linux-arm-kernel

Hi,

Huang Shijie wrote:
> 于 2014年03月26日 16:51, Lothar Waßmann 写道:
> > I don't see why this should not be supported on i.MX28 (i.MX23 doesn't
> > do byteswapping anyway, so this wouldn't change anything for i.MX23).
> > The partitions used by Linux need not necessarily be accessible for the
> > Boot ROM code (and vice versa).
> But the first partition used to store the u-boot is accessible for the ROM.
> 
Whether this partition is available to Linux depends on the partition table
passed in the DT.

> Please see "Figure 12-13" in the 12.12.1.12:
>    "In order to preserve the BI (bad block information), flash updater 
> or gang programmer
> applications need to swap Bad Block Information (BI) data to byte 0 of 
> metadata area for
> every page before programming NAND Flash. ROM when loading firmware, 
> copies back
> the value at metadata[0] to BI offset in page data. The following figure 
> shows how the
> factory bad block marker is preserved."
> 
The inspection of the BB markers is only a fallback for the case that
there is no DBBT. From the same chapter that you quoted above:
| ROM uses DBBT to skip any bad block that falls within firmware data
| on NAND Flash device.
| If the address of DBBT Search Area in FCB is 0, ROM will rely on
| factory marked bad block markers to find out if a block is good or bad.

Thus, even the boot ROM of i.MX28 can well live without blockmark
swapping.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-26 11:55           ` Lothar Waßmann
@ 2014-03-27  9:59             ` Huang Shijie
  2014-03-27 12:21               ` Lothar Waßmann
  0 siblings, 1 reply; 32+ messages in thread
From: Huang Shijie @ 2014-03-27  9:59 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Fabio Estevam, Mark Rutland, Brian Norris, Russell King,
	Pawel Moll, Arnd Bergmann, Ian Campbell, Artem Bityutskiy,
	linux-doc, linux-kernel, devicetree, Rob Herring, linux-mtd,
	Shawn Guo, Rob Landley, Kumar Gala, Shawn Guo, David Woodhouse,
	Sascha Hauer, linux-arm-kernel

On Wed, Mar 26, 2014 at 12:55:02PM +0100, Lothar Waßmann wrote:
> Hi,
> 
> Huang Shijie wrote:
> > 于 2014年03月26日 16:51, Lothar Waßmann 写道:
> > > I don't see why this should not be supported on i.MX28 (i.MX23 doesn't
> > > do byteswapping anyway, so this wouldn't change anything for i.MX23).
> > > The partitions used by Linux need not necessarily be accessible for the
> > > Boot ROM code (and vice versa).
> > But the first partition used to store the u-boot is accessible for the ROM.
> > 
> Whether this partition is available to Linux depends on the partition table
> passed in the DT.
yes, i agree.

But it is strange if we do not export this partition to Linux.

> 
> > Please see "Figure 12-13" in the 12.12.1.12:
> >    "In order to preserve the BI (bad block information), flash updater 
> > or gang programmer
> > applications need to swap Bad Block Information (BI) data to byte 0 of 
> > metadata area for
> > every page before programming NAND Flash. ROM when loading firmware, 
> > copies back
> > the value at metadata[0] to BI offset in page data. The following figure 
> > shows how the
> > factory bad block marker is preserved."
> > 
> The inspection of the BB markers is only a fallback for the case that
> there is no DBBT. From the same chapter that you quoted above:
> | ROM uses DBBT to skip any bad block that falls within firmware data
> | on NAND Flash device.
> | If the address of DBBT Search Area in FCB is 0, ROM will rely on
> | factory marked bad block markers to find out if a block is good or bad.
> 
> Thus, even the boot ROM of i.MX28 can well live without blockmark
> swapping.

Assume that there is a NAND block "A",  and the A consist of 256 pages.
the uboot is burned to the "A", can occupy 6 pages:

  -----------------------------------------------------------------------------
 | page 0 |  page 1 | page 2 | page 3 | page 4 | page 5 | ... | ... | page 255 |
  -----------------------------------------------------------------------------
 
  \-------------------------------------- ------------------------------------/
                                         V  
                                        "A"					 

The DBBT is used to track if "A" is bad or not.
Assume we know that "A" is a good block, ROM then need to read out the uboot.
When the ROM needs to read out the 6 pages one by one. And each time the ROM read
the page, it should do the swapping for this page.

In this case, the ROM will do the swapping six times.

Please read the sector again, you will see the "every page" in it:
--------------------------------------------------------------------
   "In order to preserve the BI (bad block information), flash updater 
or gang programmer applications need to swap Bad Block Information (BI) data to byte 0 of 
metadata area for every page before programming NAND Flash. ROM when loading firmware, 
copies back
--------------------------------------------------------------------

thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-27  9:59             ` Huang Shijie
@ 2014-03-27 12:21               ` Lothar Waßmann
  2014-03-28  2:09                 ` Huang Shijie
  0 siblings, 1 reply; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-27 12:21 UTC (permalink / raw)
  To: Huang Shijie
  Cc: Fabio Estevam, Mark Rutland, Brian Norris, Russell King,
	Pawel Moll, Arnd Bergmann, Ian Campbell, Artem Bityutskiy,
	linux-doc, linux-kernel, devicetree, Rob Herring, linux-mtd,
	Shawn Guo, Rob Landley, Kumar Gala, Shawn Guo, David Woodhouse,
	Sascha Hauer, linux-arm-kernel

Hi,

Huang Shijie wrote:
> > > Please see "Figure 12-13" in the 12.12.1.12:
> > >    "In order to preserve the BI (bad block information), flash updater 
> > > or gang programmer
> > > applications need to swap Bad Block Information (BI) data to byte 0 of 
> > > metadata area for
> > > every page before programming NAND Flash. ROM when loading firmware, 
> > > copies back
> > > the value at metadata[0] to BI offset in page data. The following figure 
> > > shows how the
> > > factory bad block marker is preserved."
> > > 
> > The inspection of the BB markers is only a fallback for the case that
> > there is no DBBT. From the same chapter that you quoted above:
> > | ROM uses DBBT to skip any bad block that falls within firmware data
> > | on NAND Flash device.
> > | If the address of DBBT Search Area in FCB is 0, ROM will rely on
> > | factory marked bad block markers to find out if a block is good or bad.
> > 
> > Thus, even the boot ROM of i.MX28 can well live without blockmark
> > swapping.
> 
> Assume that there is a NAND block "A",  and the A consist of 256 pages.
> the uboot is burned to the "A", can occupy 6 pages:
> 
>   -----------------------------------------------------------------------------
>  | page 0 |  page 1 | page 2 | page 3 | page 4 | page 5 | ... | ... | page 255 |
>   -----------------------------------------------------------------------------
>  
>   \-------------------------------------- ------------------------------------/
>                                          V  
>                                         "A"					 
> 
> The DBBT is used to track if "A" is bad or not.
> Assume we know that "A" is a good block, ROM then need to read out the uboot.
> When the ROM needs to read out the 6 pages one by one. And each time the ROM read
> the page, it should do the swapping for this page.
> 
> In this case, the ROM will do the swapping six times.
> 
> Please read the sector again, you will see the "every page" in it:
> --------------------------------------------------------------------
>    "In order to preserve the BI (bad block information), flash updater 
> or gang programmer applications need to swap Bad Block Information (BI) data to byte 0 of 
> metadata area for every page before programming NAND Flash. ROM when loading firmware, 
> copies back
> --------------------------------------------------------------------
>
I can assure you that the >100.000 i.MX28 based modules, that we sold
up to now boot from NAND just fine without any block mark swapping in
the U-Boot pages.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-27 12:21               ` Lothar Waßmann
@ 2014-03-28  2:09                 ` Huang Shijie
  2014-03-28  8:16                   ` Lothar Waßmann
  0 siblings, 1 reply; 32+ messages in thread
From: Huang Shijie @ 2014-03-28  2:09 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Fabio Estevam, Mark Rutland, Brian Norris, Russell King,
	Pawel Moll, Arnd Bergmann, Ian Campbell, Artem Bityutskiy,
	linux-doc, linux-kernel, devicetree, Rob Herring, linux-mtd,
	Shawn Guo, Rob Landley, Kumar Gala, Shawn Guo, David Woodhouse,
	Sascha Hauer, linux-arm-kernel

于 2014年03月27日 20:21, Lothar Waßmann 写道:
> I can assure you that the>100.000 i.MX28 based modules, that we sold
> up to now boot from NAND just fine without any block mark swapping in
> the U-Boot pages.
>
Our driver should follow the Reference manual, not the product.

thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-28  2:09                 ` Huang Shijie
@ 2014-03-28  8:16                   ` Lothar Waßmann
  2014-03-28  8:39                     ` Huang Shijie
  0 siblings, 1 reply; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-28  8:16 UTC (permalink / raw)
  To: Huang Shijie
  Cc: Fabio Estevam, Mark Rutland, Shawn Guo, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, linux-doc,
	linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo

Hi,

Huang Shijie wrote:
> 于 2014年03月27日 20:21, Lothar Waßmann 写道:
> > I can assure you that the>100.000 i.MX28 based modules, that we sold
> > up to now boot from NAND just fine without any block mark swapping in
> > the U-Boot pages.
> >
> Our driver should follow the Reference manual, not the product.
> 
Still there is no need for the Linux NAND driver to be able to read or
write partitions in a format that the Boot ROM can understand. Thus it
is perfectly legal to allow disregarding the BB marks and solely rely on
a flash based BBT.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-28  8:16                   ` Lothar Waßmann
@ 2014-03-28  8:39                     ` Huang Shijie
  2014-03-28  9:00                       ` Sascha Hauer
  2014-03-28  9:01                       ` Lothar Waßmann
  0 siblings, 2 replies; 32+ messages in thread
From: Huang Shijie @ 2014-03-28  8:39 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Fabio Estevam, Mark Rutland, Shawn Guo, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, linux-doc,
	linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo

于 2014年03月28日 16:16, Lothar Waßmann 写道:
> Still there is no need for the Linux NAND driver to be able to read or
> write partitions in a format that the Boot ROM can understand. Thus it
If you do not use the NAND boot, there really no need to do so.

Since you need the NAND boot, we should enable the swapping for imx28.
> is perfectly legal to allow disregarding the BB marks and solely rely on
> a flash based BBT.
>
The BB mark is in the page 0 of a NAND block. But the swapping can occur 
in _each_ page of
a NAND block, _NOT_ only the page 0.

I think you are confusing at these two things.

thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-28  8:39                     ` Huang Shijie
@ 2014-03-28  9:00                       ` Sascha Hauer
  2014-03-28  9:26                         ` Huang Shijie
  2014-03-28  9:01                       ` Lothar Waßmann
  1 sibling, 1 reply; 32+ messages in thread
From: Sascha Hauer @ 2014-03-28  9:00 UTC (permalink / raw)
  To: Huang Shijie
  Cc: Fabio Estevam, Mark Rutland, Shawn Guo, Russell King,
	Arnd Bergmann, Pawel Moll, Ian Campbell, Artem Bityutskiy,
	linux-doc, linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo, Lothar Waßmann

On Fri, Mar 28, 2014 at 04:39:00PM +0800, Huang Shijie wrote:
> 于 2014年03月28日 16:16, Lothar Waßmann 写道:
> >Still there is no need for the Linux NAND driver to be able to read or
> >write partitions in a format that the Boot ROM can understand. Thus it
> If you do not use the NAND boot, there really no need to do so.
> 
> Since you need the NAND boot, we should enable the swapping for imx28.
> >is perfectly legal to allow disregarding the BB marks and solely rely on
> >a flash based BBT.
> >
> The BB mark is in the page 0 of a NAND block. But the swapping can
> occur in _each_ page of
> a NAND block, _NOT_ only the page 0.
> 
> I think you are confusing at these two things.

I think you are confusing two things. If Lothar:

- disables swapping of BB marks in the FCB the ROM won't swap bytes.
- writes data without swapping
- Uses a DBBT for telling the ROM code where bad blocks are
- uses a Flash BBT for mtd

Then everything should work just fine.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-28  8:39                     ` Huang Shijie
  2014-03-28  9:00                       ` Sascha Hauer
@ 2014-03-28  9:01                       ` Lothar Waßmann
  2014-03-28  9:33                         ` Huang Shijie
  1 sibling, 1 reply; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-28  9:01 UTC (permalink / raw)
  To: Huang Shijie
  Cc: Fabio Estevam, Mark Rutland, Shawn Guo, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, linux-doc,
	linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo

Hi,

Huang Shijie wrote:
> 于 2014年03月28日 16:16, Lothar Waßmann 写道:
> > Still there is no need for the Linux NAND driver to be able to read or
> > write partitions in a format that the Boot ROM can understand. Thus it
> If you do not use the NAND boot, there really no need to do so.
>
There is no need for the ROM code to access any other partition than
the bootloader itself. Thus Linux can perfectly well be booted from
NAND without any byte swapping.

> Since you need the NAND boot, we should enable the swapping for imx28.
>
Why? There is no need for Linux to do any swapping when not accessing
the bootloader partition.

> > is perfectly legal to allow disregarding the BB marks and solely rely on
> > a flash based BBT.
> >
> The BB mark is in the page 0 of a NAND block. But the swapping can occur 
> in _each_ page of
> a NAND block, _NOT_ only the page 0.
> 
> I think you are confusing at these two things.
> 
No, I'm not confusing anything. The swapping in any other page than
page 0 is completely useless. Thus, when there is no need to recognize
the BB markers, there in no need to do any swapping too.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-28  9:00                       ` Sascha Hauer
@ 2014-03-28  9:26                         ` Huang Shijie
  2014-03-28  9:31                           ` Lothar Waßmann
  0 siblings, 1 reply; 32+ messages in thread
From: Huang Shijie @ 2014-03-28  9:26 UTC (permalink / raw)
  To: Sascha Hauer
  Cc: Fabio Estevam, Mark Rutland, Shawn Guo, Russell King,
	Arnd Bergmann, Pawel Moll, Ian Campbell, Artem Bityutskiy,
	linux-doc, linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo, Lothar Waßmann

于 2014年03月28日 17:00, Sascha Hauer 写道:
> - disables swapping of BB marks in the FCB the ROM won't swap bytes.
We can not disable the swapping in the FCB in the imx28.
The DISBBM bit in the FCB does _NOT_ exit in the imx28's FCB.


thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-28  9:26                         ` Huang Shijie
@ 2014-03-28  9:31                           ` Lothar Waßmann
  2014-03-28 10:09                             ` Huang Shijie
  0 siblings, 1 reply; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-28  9:31 UTC (permalink / raw)
  To: Huang Shijie
  Cc: Fabio Estevam, Mark Rutland, Shawn Guo, Russell King,
	Arnd Bergmann, Pawel Moll, Ian Campbell, Artem Bityutskiy,
	Sascha Hauer, linux-doc, linux-kernel, devicetree, Rob Herring,
	linux-mtd, linux-arm-kernel, Rob Landley, Kumar Gala,
	Brian Norris, David Woodhouse, Sascha Hauer, Shawn Guo

Hi,

Huang Shijie wrote:
> 于 2014年03月28日 17:00, Sascha Hauer 写道:
> > - disables swapping of BB marks in the FCB the ROM won't swap bytes.
> We can not disable the swapping in the FCB in the imx28.
> The DISBBM bit in the FCB does _NOT_ exit in the imx28's FCB.
> 
The Linux kernel does not have any business with the FCB, so it is
completely irrelevant for Linux whether byte swapping can be disabled
in the FCB or not.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-28  9:01                       ` Lothar Waßmann
@ 2014-03-28  9:33                         ` Huang Shijie
  2014-03-28  9:38                           ` Huang Shijie
  0 siblings, 1 reply; 32+ messages in thread
From: Huang Shijie @ 2014-03-28  9:33 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Fabio Estevam, Mark Rutland, Shawn Guo, Russell King, Pawel Moll,
	Arnd Bergmann, Ian Campbell, Artem Bityutskiy, linux-doc,
	linux-kernel, devicetree, Rob Herring, linux-mtd,
	linux-arm-kernel, Rob Landley, Kumar Gala, Brian Norris,
	David Woodhouse, Sascha Hauer, Shawn Guo

于 2014年03月28日 17:01, Lothar Waßmann 写道:
> There is no need for the ROM code to access any other partition than
> the bootloader itself. Thus Linux can perfectly well be booted from
Assume the ROM only access the partition which contains the bootloader, and
the ROM does the swapping for the pages(but we do not do the swapping to 
these pages),

what will happen?



thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-28  9:33                         ` Huang Shijie
@ 2014-03-28  9:38                           ` Huang Shijie
  2014-03-28 10:13                             ` Lothar Waßmann
  0 siblings, 1 reply; 32+ messages in thread
From: Huang Shijie @ 2014-03-28  9:38 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Fabio Estevam, Mark Rutland, Brian Norris, Russell King,
	Pawel Moll, Arnd Bergmann, Ian Campbell, Artem Bityutskiy,
	linux-doc, linux-kernel, devicetree, Rob Herring, linux-mtd,
	Shawn Guo, Rob Landley, Kumar Gala, Shawn Guo, David Woodhouse,
	Sascha Hauer, linux-arm-kernel

于 2014年03月28日 17:33, Huang Shijie 写道:
> 于 2014年03月28日 17:01, Lothar Waßmann 写道:
>> There is no need for the ROM code to access any other partition than
>> the bootloader itself. Thus Linux can perfectly well be booted from
> Assume the ROM only access the partition which contains the 
> bootloader, and
> the ROM does the swapping for the pages(but we do not do the swapping 
> to these pages),
I mean the kernel do not do the swapping when we burn the uboot to the NAND.

thanks
Huang Shijie
>
> what will happen?
>
>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-28  9:31                           ` Lothar Waßmann
@ 2014-03-28 10:09                             ` Huang Shijie
  2014-03-28 10:18                               ` Lothar Waßmann
  0 siblings, 1 reply; 32+ messages in thread
From: Huang Shijie @ 2014-03-28 10:09 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Fabio Estevam, Mark Rutland, Shawn Guo, Russell King,
	Arnd Bergmann, Pawel Moll, Ian Campbell, Artem Bityutskiy,
	Sascha Hauer, linux-doc, linux-kernel, devicetree, Rob Herring,
	linux-mtd, linux-arm-kernel, Rob Landley, Kumar Gala,
	Brian Norris, David Woodhouse, Sascha Hauer, Shawn Guo

于 2014年03月28日 17:31, Lothar Waßmann 写道:
> Hi,
>
> Huang Shijie wrote:
>> 于 2014年03月28日 17:00, Sascha Hauer 写道:
>>> - disables swapping of BB marks in the FCB the ROM won't swap bytes.
>> We can not disable the swapping in the FCB in the imx28.
>> The DISBBM bit in the FCB does _NOT_ exit in the imx28's FCB.
>>
> The Linux kernel does not have any business with the FCB, so it is
> completely irrelevant for Linux whether byte swapping can be disabled
> in the FCB or not.
>
But the gpmi is relevant to the ROM.
the gpmi driver should keep consistency with the ROM.

I do not object you add the swapping optional the gpmi driver(since it's 
ok for imx50/imx6q/imx6sx),
i just object that you enable this feature for imx28.



thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-28  9:38                           ` Huang Shijie
@ 2014-03-28 10:13                             ` Lothar Waßmann
  0 siblings, 0 replies; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-28 10:13 UTC (permalink / raw)
  To: Huang Shijie
  Cc: Fabio Estevam, Mark Rutland, Brian Norris, Russell King,
	Pawel Moll, Arnd Bergmann, Ian Campbell, Artem Bityutskiy,
	linux-doc, linux-kernel, devicetree, Rob Herring, linux-mtd,
	Shawn Guo, Rob Landley, Kumar Gala, Shawn Guo, David Woodhouse,
	Sascha Hauer, linux-arm-kernel

Hi,

Huang Shijie wrote:
> 于 2014年03月28日 17:33, Huang Shijie 写道:
> > 于 2014年03月28日 17:01, Lothar Waßmann 写道:
> >> There is no need for the ROM code to access any other partition than
> >> the bootloader itself. Thus Linux can perfectly well be booted from
> > Assume the ROM only access the partition which contains the 
> > bootloader, and
> > the ROM does the swapping for the pages(but we do not do the swapping 
> > to these pages),
> I mean the kernel do not do the swapping when we burn the uboot to the NAND.
> 
The kernel need not be able to write the bootloader to NAND. 
If you want a kernel that can do it, you just need to boot it with one
line in the DTB removed.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv2 1/1] mtd: gpmi: make blockmark swapping optional
  2014-03-28 10:09                             ` Huang Shijie
@ 2014-03-28 10:18                               ` Lothar Waßmann
  0 siblings, 0 replies; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-28 10:18 UTC (permalink / raw)
  To: Huang Shijie
  Cc: Fabio Estevam, Mark Rutland, Shawn Guo, Russell King,
	Arnd Bergmann, Pawel Moll, Ian Campbell, Artem Bityutskiy,
	Sascha Hauer, linux-doc, linux-kernel, devicetree, Rob Herring,
	linux-mtd, linux-arm-kernel, Rob Landley, Kumar Gala,
	Brian Norris, David Woodhouse, Sascha Hauer, Shawn Guo

Hi,

Huang Shijie wrote:
> 于 2014年03月28日 17:31, Lothar Waßmann 写道:
> > Hi,
> >
> > Huang Shijie wrote:
> >> 于 2014年03月28日 17:00, Sascha Hauer 写道:
> >>> - disables swapping of BB marks in the FCB the ROM won't swap bytes.
> >> We can not disable the swapping in the FCB in the imx28.
> >> The DISBBM bit in the FCB does _NOT_ exit in the imx28's FCB.
> >>
> > The Linux kernel does not have any business with the FCB, so it is
> > completely irrelevant for Linux whether byte swapping can be disabled
> > in the FCB or not.
> >
> But the gpmi is relevant to the ROM.
> the gpmi driver should keep consistency with the ROM.
> 
> I do not object you add the swapping optional the gpmi driver(since it's 
> ok for imx50/imx6q/imx6sx),
> i just object that you enable this feature for imx28.
> 
We are talking about a Linux Kernel Driver here, not about a flashtool
for i.MX28.
It is a valid usecase for Linux not being able to write the bootloader,
so there is no reason to disallow this feature in the driver code.
Since it is a DT option it can be trivially switched on and off without
having to change anything in the kernel.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCHv3 0/2] mtd: gpmi: make blockmark swapping optional
  2014-03-19 13:23 [PATCH] mtd: gpmi: make blockmark swapping optional y
                   ` (2 preceding siblings ...)
  2014-03-21  5:36 ` Huang Shijie
@ 2014-03-28 10:35 ` Lothar Waßmann
  2014-03-28 10:35   ` [PATCHv3 1/2] " Lothar Waßmann
  2014-03-28 10:35   ` [PATCHv3 2/2] of/mtd/nand: add generic binding and helper for NAND_BBT_NO_OOB_BBM Lothar Waßmann
  3 siblings, 2 replies; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-28 10:35 UTC (permalink / raw)
  To: Arnd Bergmann, Artem Bityutskiy, Brian Norris, David Woodhouse,
	Fabio Estevam, Huang Shijie, Ian Campbell, Kumar Gala,
	Lothar Waßmann, Mark Rutland, Pawel Moll, Rob Herring,
	Rob Landley, Russell King, Sascha Hauer, Shawn Guo, devicetree,
	linux-arm-kernel, linux-doc, linux-kernel, linux-mtd, Shawn Guo,
	Boris BREZILLON, Ezequiel Garcia, Grant Likely, Jingoo Han,
	Michael Grzeschik, Michael Opdenacker, Wei Yongjun

patch added:
- add an additional option to turn of BB mark writing

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCHv3 1/2] mtd: gpmi: make blockmark swapping optional
  2014-03-28 10:35 ` [PATCHv3 0/2] " Lothar Waßmann
@ 2014-03-28 10:35   ` Lothar Waßmann
  2014-03-31  2:06     ` Huang Shijie
  2014-03-28 10:35   ` [PATCHv3 2/2] of/mtd/nand: add generic binding and helper for NAND_BBT_NO_OOB_BBM Lothar Waßmann
  1 sibling, 1 reply; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-28 10:35 UTC (permalink / raw)
  To: Arnd Bergmann, Artem Bityutskiy, Brian Norris, David Woodhouse,
	Fabio Estevam, Huang Shijie, Ian Campbell, Kumar Gala,
	Lothar Waßmann, Mark Rutland, Pawel Moll, Rob Herring,
	Rob Landley, Russell King, Sascha Hauer, Shawn Guo, devicetree,
	linux-arm-kernel, linux-doc, linux-kernel, linux-mtd, Shawn Guo,
	Boris BREZILLON, Ezequiel Garcia, Grant Likely, Jingoo Han,
	Michael Grzeschik, Michael Opdenacker, Wei Yongjun

With a flash-based BBT there is no reason to move the Factory Bad
Block Marker from the data area buffer (to where it is mapped by the
GPMI NAND controller) to the OOB buffer. Thus, make this feature
configurable via DT. This is required for the Ka-Ro electronics
platforms.

In the original code 'this->swap_block_mark' was synonymous with
'!GPMI_IS_MX23()', so use the latter at the relevant places.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 .../devicetree/bindings/mtd/gpmi-nand.txt          |   10 ++++
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c             |   51 ++++++++++++--------
 2 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
index 458d596..a011fdf 100644
--- a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
@@ -25,6 +25,16 @@ Optional properties:
                        discoverable or this property is not enabled,
                        the software may chooses an implementation-defined
                        ECC scheme.
+  - fsl,no-blockmark-swap: Don't swap the bad block marker from the OOB
+                       area with the byte in the data area but rely on the
+                       flash based BBT for identifying bad blocks.
+                       NOTE: this is only valid in conjunction with
+                             'nand-on-flash-bbt'.
+                       WARNING: on i.MX28 blockmark swapping cannot be
+                       disabled for the BootROM in the FCB. Thus,
+                       partitions written from Linux with this feature
+                       turned on may not be accessible by the BootROM
+                       code.
 
 The device tree may optionally contain sub-nodes describing partitions of the
 address space. See partition.txt for more detail.
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index bb77f75..2a489b3 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -1065,6 +1065,7 @@ static int gpmi_ecc_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
 	int first, last, marker_pos;
 	int ecc_parity_size;
 	int col = 0;
+	int old_swap_block_mark = this->swap_block_mark;
 
 	/* The size of ECC parity */
 	ecc_parity_size = geo->gf_len * geo->ecc_strength / 8;
@@ -1073,17 +1074,21 @@ static int gpmi_ecc_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
 	first = offs / size;
 	last = (offs + len - 1) / size;
 
-	/*
-	 * Find the chunk which contains the Block Marker. If this chunk is
-	 * in the range of [first, last], we have to read out the whole page.
-	 * Why? since we had swapped the data at the position of Block Marker
-	 * to the metadata which is bound with the chunk 0.
-	 */
-	marker_pos = geo->block_mark_byte_offset / size;
-	if (last >= marker_pos && first <= marker_pos) {
-		dev_dbg(this->dev, "page:%d, first:%d, last:%d, marker at:%d\n",
+	if (this->swap_block_mark) {
+		/*
+		 * Find the chunk which contains the Block Marker.
+		 * If this chunk is in the range of [first, last],
+		 * we have to read out the whole page.
+		 * Why? since we had swapped the data at the position of Block
+		 * Marker to the metadata which is bound with the chunk 0.
+		 */
+		marker_pos = geo->block_mark_byte_offset / size;
+		if (last >= marker_pos && first <= marker_pos) {
+			dev_dbg(this->dev,
+				"page:%d, first:%d, last:%d, marker at:%d\n",
 				page, first, last, marker_pos);
-		return gpmi_ecc_read_page(mtd, chip, buf, 0, page);
+			return gpmi_ecc_read_page(mtd, chip, buf, 0, page);
+		}
 	}
 
 	meta = geo->metadata_size;
@@ -1129,7 +1134,7 @@ static int gpmi_ecc_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
 	writel(r1_old, bch_regs + HW_BCH_FLASH0LAYOUT0);
 	writel(r2_old, bch_regs + HW_BCH_FLASH0LAYOUT1);
 	this->bch_geometry = old_geo;
-	this->swap_block_mark = true;
+	this->swap_block_mark = old_swap_block_mark;
 
 	return max_bitflips;
 }
@@ -1293,10 +1298,10 @@ static int gpmi_ecc_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
 
 	/*
 	 * Now, we want to make sure the block mark is correct. In the
-	 * Swapping/Raw case, we already have it. Otherwise, we need to
-	 * explicitly read it.
+	 * non-transcribing case (!GPMI_IS_MX23()), we already have it.
+	 * Otherwise, we need to explicitly read it.
 	 */
-	if (!this->swap_block_mark) {
+	if (GPMI_IS_MX23(this)) {
 		/* Read the block mark into the first byte of the OOB buffer. */
 		chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
 		chip->oob_poi[0] = chip->read_byte(mtd);
@@ -1337,7 +1342,7 @@ static int gpmi_block_markbad(struct mtd_info *mtd, loff_t ofs)
 	chipnr = (int)(ofs >> chip->chip_shift);
 	chip->select_chip(mtd, chipnr);
 
-	column = this->swap_block_mark ? mtd->writesize : 0;
+	column = !GPMI_IS_MX23(this) ? mtd->writesize : 0;
 
 	/* Write the block mark. */
 	block_mark = this->data_buffer_dma;
@@ -1632,9 +1637,6 @@ static int gpmi_init_last(struct gpmi_nand_data *this)
 	struct bch_geometry *bch_geo = &this->bch_geometry;
 	int ret;
 
-	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
-	this->swap_block_mark = !GPMI_IS_MX23(this);
-
 	/* Set up the medium geometry */
 	ret = gpmi_set_geometry(this);
 	if (ret)
@@ -1698,9 +1700,20 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
 	chip->badblock_pattern	= &gpmi_bbt_descr;
 	chip->block_markbad	= gpmi_block_markbad;
 	chip->options		|= NAND_NO_SUBPAGE_WRITE;
-	if (of_get_nand_on_flash_bbt(this->dev->of_node))
+
+	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
+	this->swap_block_mark = !GPMI_IS_MX23(this);
+
+	if (of_get_nand_on_flash_bbt(this->dev->of_node)) {
 		chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
 
+		if (of_property_read_bool(this->dev->of_node,
+						"fsl,no-blockmark-swap"))
+			this->swap_block_mark = false;
+	}
+	dev_dbg(this->dev, "Blockmark swapping %sabled\n",
+		this->swap_block_mark ? "en" : "dis");
+
 	/*
 	 * Allocate a temporary DMA buffer for reading ID in the
 	 * nand_scan_ident().
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCHv3 2/2] of/mtd/nand: add generic binding and helper for NAND_BBT_NO_OOB_BBM
  2014-03-28 10:35 ` [PATCHv3 0/2] " Lothar Waßmann
  2014-03-28 10:35   ` [PATCHv3 1/2] " Lothar Waßmann
@ 2014-03-28 10:35   ` Lothar Waßmann
  1 sibling, 0 replies; 32+ messages in thread
From: Lothar Waßmann @ 2014-03-28 10:35 UTC (permalink / raw)
  To: Arnd Bergmann, Artem Bityutskiy, Brian Norris, David Woodhouse,
	Fabio Estevam, Huang Shijie, Ian Campbell, Kumar Gala,
	Lothar Waßmann, Mark Rutland, Pawel Moll, Rob Herring,
	Rob Landley, Russell King, Sascha Hauer, Shawn Guo, devicetree,
	linux-arm-kernel, linux-doc, linux-kernel, linux-mtd, Shawn Guo,
	Boris BREZILLON, Ezequiel Garcia, Grant Likely, Jingoo Han,
	Michael Grzeschik, Michael Opdenacker, Wei Yongjun

add a boolean property 'nand-no-oob-bbm' and helper function to be
able to set the NAND_BBT_NO_OOB_BBM flag in DT capable NAND drivers
and use it for i.MX and MXS nand drivers.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 Documentation/devicetree/bindings/mtd/nand.txt |    1 +
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c         |    3 +++
 drivers/mtd/nand/mxc_nand.c                    |    2 ++
 drivers/of/of_mtd.c                            |   12 ++++++++++++
 include/linux/of_mtd.h                         |    6 ++++++
 5 files changed, 24 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/nand.txt b/Documentation/devicetree/bindings/mtd/nand.txt
index b53f92e..e46bfbe 100644
--- a/Documentation/devicetree/bindings/mtd/nand.txt
+++ b/Documentation/devicetree/bindings/mtd/nand.txt
@@ -5,6 +5,7 @@
   "soft_bch".
 - nand-bus-width : 8 or 16 bus width if not present 8
 - nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
+- nand-no-oob-bbm: boolean to disable writing bad block markers to flash
 
 - nand-ecc-strength: integer representing the number of bits to correct
 		     per ECC step.
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 2a489b3..c23f27b 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -1707,6 +1707,9 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
 	if (of_get_nand_on_flash_bbt(this->dev->of_node)) {
 		chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
 
+		if (of_get_nand_no_oob_bbm(this->dev->of_node))
+			chip->bbt_options |= NAND_BBT_NO_OOB_BBM;
+
 		if (of_property_read_bool(this->dev->of_node,
 						"fsl,no-blockmark-swap"))
 			this->swap_block_mark = false;
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index dba262b..bb54a2a 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -1496,6 +1496,8 @@ static int mxcnd_probe(struct platform_device *pdev)
 		this->bbt_md = &bbt_mirror_descr;
 		/* update flash based bbt */
 		this->bbt_options |= NAND_BBT_USE_FLASH;
+		if (of_get_nand_no_oob_bbm(pdev->dev.of_node))
+			this->bbt_options |= NAND_BBT_NO_OOB_BBM;
 	}
 
 	init_completion(&host->op_completion);
diff --git a/drivers/of/of_mtd.c b/drivers/of/of_mtd.c
index b7361ed..d947acc 100644
--- a/drivers/of/of_mtd.c
+++ b/drivers/of/of_mtd.c
@@ -117,3 +117,15 @@ bool of_get_nand_on_flash_bbt(struct device_node *np)
 	return of_property_read_bool(np, "nand-on-flash-bbt");
 }
 EXPORT_SYMBOL_GPL(of_get_nand_on_flash_bbt);
+
+/**
+ * of_get_nand_no_oob_bbm - Get nand no oob bbm for given device_node
+ * @np:	Pointer to the given device_node
+ *
+ * return true if present, false otherwise
+ */
+bool of_get_nand_no_oob_bbm(struct device_node *np)
+{
+	return of_property_read_bool(np, "nand-no-oob-bbm");
+}
+EXPORT_SYMBOL_GPL(of_get_nand_no_oob_bbm);
diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h
index e266caa..6ece1a9 100644
--- a/include/linux/of_mtd.h
+++ b/include/linux/of_mtd.h
@@ -17,6 +17,7 @@ int of_get_nand_ecc_step_size(struct device_node *np);
 int of_get_nand_ecc_strength(struct device_node *np);
 int of_get_nand_bus_width(struct device_node *np);
 bool of_get_nand_on_flash_bbt(struct device_node *np);
+bool of_get_nand_no_oob_bbm(struct device_node *np);
 
 #else /* CONFIG_OF_MTD */
 
@@ -45,6 +46,11 @@ static inline bool of_get_nand_on_flash_bbt(struct device_node *np)
 	return false;
 }
 
+static inline bool of_get_nand_no_oob_bbm(struct device_node *np)
+{
+	return false;
+}
+
 #endif /* CONFIG_OF_MTD */
 
 #endif /* __LINUX_OF_MTD_H */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCHv3 1/2] mtd: gpmi: make blockmark swapping optional
  2014-03-28 10:35   ` [PATCHv3 1/2] " Lothar Waßmann
@ 2014-03-31  2:06     ` Huang Shijie
  0 siblings, 0 replies; 32+ messages in thread
From: Huang Shijie @ 2014-03-31  2:06 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Mark Rutland, Boris BREZILLON, linux-doc, Artem Bityutskiy,
	Wei Yongjun, linux-mtd, Michael Grzeschik, Russell King,
	Arnd Bergmann, Jingoo Han, Shawn Guo, Ezequiel Garcia,
	Michael Opdenacker, Grant Likely, devicetree, Sascha Hauer,
	Pawel Moll, Ian Campbell, Rob Herring, linux-arm-kernel,
	Fabio Estevam, Brian Norris, linux-kernel, Rob Landley,
	Kumar Gala, Shawn Guo, David Woodhouse

On Fri, Mar 28, 2014 at 11:35:06AM +0100, Lothar Waßmann wrote:
> +  - fsl,no-blockmark-swap: Don't swap the bad block marker from the OOB
> +                       area with the byte in the data area but rely on the
> +                       flash based BBT for identifying bad blocks.
> +                       NOTE: this is only valid in conjunction with
> +                             'nand-on-flash-bbt'.
> +                       WARNING: on i.MX28 blockmark swapping cannot be
> +                       disabled for the BootROM in the FCB. Thus,
> +                       partitions written from Linux with this feature
> +                       turned on may not be accessible by the BootROM
> +                       code.

Thanks for adding this warning.

Acked-by: Huang Shijie <b32955@freescale.com>


thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2014-03-31  2:06 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-19 13:23 [PATCH] mtd: gpmi: make blockmark swapping optional y
2014-03-20  8:33 ` Juergen Beisert
2014-03-20  9:20   ` Lothar Waßmann
2014-03-20  9:15 ` Huang Shijie
2014-03-20  9:21   ` Lothar Waßmann
2014-03-20  9:47     ` Huang Shijie
2014-03-20 10:09       ` Lothar Waßmann
2014-03-20 10:56         ` Huang Shijie
2014-03-21  5:36 ` Huang Shijie
2014-03-21 10:50   ` [PATCHv2 1/1] " Lothar Waßmann
2014-03-24  9:59     ` Huang Shijie
2014-03-26  8:51       ` Lothar Waßmann
2014-03-26 10:41         ` Huang Shijie
2014-03-26 11:55           ` Lothar Waßmann
2014-03-27  9:59             ` Huang Shijie
2014-03-27 12:21               ` Lothar Waßmann
2014-03-28  2:09                 ` Huang Shijie
2014-03-28  8:16                   ` Lothar Waßmann
2014-03-28  8:39                     ` Huang Shijie
2014-03-28  9:00                       ` Sascha Hauer
2014-03-28  9:26                         ` Huang Shijie
2014-03-28  9:31                           ` Lothar Waßmann
2014-03-28 10:09                             ` Huang Shijie
2014-03-28 10:18                               ` Lothar Waßmann
2014-03-28  9:01                       ` Lothar Waßmann
2014-03-28  9:33                         ` Huang Shijie
2014-03-28  9:38                           ` Huang Shijie
2014-03-28 10:13                             ` Lothar Waßmann
2014-03-28 10:35 ` [PATCHv3 0/2] " Lothar Waßmann
2014-03-28 10:35   ` [PATCHv3 1/2] " Lothar Waßmann
2014-03-31  2:06     ` Huang Shijie
2014-03-28 10:35   ` [PATCHv3 2/2] of/mtd/nand: add generic binding and helper for NAND_BBT_NO_OOB_BBM Lothar Waßmann

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).