devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mtd: nand: add support for "nand-ecc-algo" DT property
@ 2016-04-22 11:23 Rafał Miłecki
  2016-04-22 11:23 ` [PATCH 2/3] Documentation: devicetree: deprecate "soft_bch" nand-ecc-mode value Rafał Miłecki
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Rafał Miłecki @ 2016-04-22 11:23 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: linux-mtd, Rafał Miłecki, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Richard Weinberger,
	David Woodhouse, Brian Norris,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	open list

So far it was only possible to specify ECC algorithm using "soft" and
"soft_bch" values of nand-ecc-mode prop. There wasn't a way to specify
it for a hardware ECC mode.

Now that we have independent field in NAND subsystem for storing info
about ECC algorithm we may also add support for this new DT property.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 Documentation/devicetree/bindings/mtd/nand.txt |  2 ++
 drivers/mtd/nand/nand_base.c                   | 20 +++++++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/mtd/nand.txt b/Documentation/devicetree/bindings/mtd/nand.txt
index a17662b..5ac4ab7 100644
--- a/Documentation/devicetree/bindings/mtd/nand.txt
+++ b/Documentation/devicetree/bindings/mtd/nand.txt
@@ -22,6 +22,8 @@ Optional NAND chip properties:
 - nand-ecc-mode : String, operation mode of the NAND ecc mode.
   Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first",
   "soft_bch".
+- nand-ecc-algo: string, algorithm of NAND ECC.
+		 Supported values are: "hamming", "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
 
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 7bc37b4..a5417a0 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -4003,17 +4003,23 @@ static int of_get_nand_ecc_mode(struct device_node *np)
 	return -ENODEV;
 }
 
+static const char * const nand_ecc_algos[] = {
+	[NAND_ECC_HAMMING]	= "hamming",
+	[NAND_ECC_BCH]		= "bch",
+};
+
 static int of_get_nand_ecc_algo(struct device_node *np)
 {
 	const char *pm;
-	int err;
+	int err, i;
 
-	/*
-	 * TODO: Read ECC algo OF property and map it to enum nand_ecc_algo.
-	 * It's not implemented yet as currently NAND subsystem ignores
-	 * algorithm explicitly set this way. Once it's handled we should
-	 * document & support new property.
-	 */
+	err = of_property_read_string(np, "nand-ecc-algo", &pm);
+	if (!err) {
+		for (i = 0; i < ARRAY_SIZE(nand_ecc_algos); i++)
+			if (!strcasecmp(pm, nand_ecc_algos[i]))
+				return i;
+		return -ENODEV;
+	}
 
 	/*
 	 * For backward compatibility we also read "nand-ecc-mode" checking
-- 
1.8.4.5

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

* [PATCH 2/3] Documentation: devicetree: deprecate "soft_bch" nand-ecc-mode value
  2016-04-22 11:23 [PATCH 1/3] mtd: nand: add support for "nand-ecc-algo" DT property Rafał Miłecki
@ 2016-04-22 11:23 ` Rafał Miłecki
       [not found]   ` <1461324197-1333-2-git-send-email-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2016-04-26  7:34   ` Boris Brezillon
  2016-04-25 10:11 ` [PATCH 1/3] mtd: nand: add support for "nand-ecc-algo" DT property Boris Brezillon
       [not found] ` <1461324197-1333-1-git-send-email-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2 siblings, 2 replies; 7+ messages in thread
From: Rafał Miłecki @ 2016-04-22 11:23 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: linux-mtd, Rafał Miłecki, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Brian Norris,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	open list

Now that we support nand-ecc-algo property it should be used together
with "soft" to specify software BCH ECC.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 Documentation/devicetree/bindings/mtd/nand.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/mtd/nand.txt b/Documentation/devicetree/bindings/mtd/nand.txt
index 5ac4ab7..68342ea 100644
--- a/Documentation/devicetree/bindings/mtd/nand.txt
+++ b/Documentation/devicetree/bindings/mtd/nand.txt
@@ -20,8 +20,10 @@ Optional NAND controller properties
 Optional NAND chip properties:
 
 - nand-ecc-mode : String, operation mode of the NAND ecc mode.
-  Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first",
-  "soft_bch".
+		  Supported values are: "none", "soft", "hw", "hw_syndrome",
+		  "hw_oob_first".
+		  Deprecated values:
+		  "soft_bch": use "soft" and nand-ecc-algo instead
 - nand-ecc-algo: string, algorithm of NAND ECC.
 		 Supported values are: "hamming", "bch".
 - nand-bus-width : 8 or 16 bus width if not present 8
-- 
1.8.4.5

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

* Re: [PATCH 1/3] mtd: nand: add support for "nand-ecc-algo" DT property
  2016-04-22 11:23 [PATCH 1/3] mtd: nand: add support for "nand-ecc-algo" DT property Rafał Miłecki
  2016-04-22 11:23 ` [PATCH 2/3] Documentation: devicetree: deprecate "soft_bch" nand-ecc-mode value Rafał Miłecki
@ 2016-04-25 10:11 ` Boris Brezillon
       [not found] ` <1461324197-1333-1-git-send-email-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2 siblings, 0 replies; 7+ messages in thread
From: Boris Brezillon @ 2016-04-25 10:11 UTC (permalink / raw)
  To: Rafał Miłecki, Rob Herring
  Cc: linux-mtd, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Richard Weinberger, David Woodhouse, Brian Norris,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	open list

On Fri, 22 Apr 2016 13:23:13 +0200
Rafał Miłecki <zajec5@gmail.com> wrote:

> So far it was only possible to specify ECC algorithm using "soft" and
> "soft_bch" values of nand-ecc-mode prop. There wasn't a way to specify
> it for a hardware ECC mode.
> 
> Now that we have independent field in NAND subsystem for storing info
> about ECC algorithm we may also add support for this new DT property.
> 
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> ---
>  Documentation/devicetree/bindings/mtd/nand.txt |  2 ++
>  drivers/mtd/nand/nand_base.c                   | 20 +++++++++++++-------
>  2 files changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/nand.txt b/Documentation/devicetree/bindings/mtd/nand.txt
> index a17662b..5ac4ab7 100644
> --- a/Documentation/devicetree/bindings/mtd/nand.txt
> +++ b/Documentation/devicetree/bindings/mtd/nand.txt
> @@ -22,6 +22,8 @@ Optional NAND chip properties:
>  - nand-ecc-mode : String, operation mode of the NAND ecc mode.
>    Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first",
>    "soft_bch".
> +- nand-ecc-algo: string, algorithm of NAND ECC.
> +		 Supported values are: "hamming", "bch".

Rob, any objection to this binding change (and the one in patch 3).
Please note that everything is backward compatible.

Thanks,

Boris

>  - 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
>  
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 7bc37b4..a5417a0 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -4003,17 +4003,23 @@ static int of_get_nand_ecc_mode(struct device_node *np)
>  	return -ENODEV;
>  }
>  
> +static const char * const nand_ecc_algos[] = {
> +	[NAND_ECC_HAMMING]	= "hamming",
> +	[NAND_ECC_BCH]		= "bch",
> +};
> +
>  static int of_get_nand_ecc_algo(struct device_node *np)
>  {
>  	const char *pm;
> -	int err;
> +	int err, i;
>  
> -	/*
> -	 * TODO: Read ECC algo OF property and map it to enum nand_ecc_algo.
> -	 * It's not implemented yet as currently NAND subsystem ignores
> -	 * algorithm explicitly set this way. Once it's handled we should
> -	 * document & support new property.
> -	 */
> +	err = of_property_read_string(np, "nand-ecc-algo", &pm);
> +	if (!err) {
> +		for (i = 0; i < ARRAY_SIZE(nand_ecc_algos); i++)
> +			if (!strcasecmp(pm, nand_ecc_algos[i]))
> +				return i;
> +		return -ENODEV;
> +	}
>  
>  	/*
>  	 * For backward compatibility we also read "nand-ecc-mode" checking



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH 1/3] mtd: nand: add support for "nand-ecc-algo" DT property
       [not found] ` <1461324197-1333-1-git-send-email-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-04-25 12:39   ` Rob Herring
  2016-04-26  7:34   ` Boris Brezillon
  1 sibling, 0 replies; 7+ messages in thread
From: Rob Herring @ 2016-04-25 12:39 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Boris Brezillon, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Richard Weinberger, David Woodhouse, Brian Norris,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	open list

On Fri, Apr 22, 2016 at 01:23:13PM +0200, Rafał Miłecki wrote:
> So far it was only possible to specify ECC algorithm using "soft" and
> "soft_bch" values of nand-ecc-mode prop. There wasn't a way to specify
> it for a hardware ECC mode.
> 
> Now that we have independent field in NAND subsystem for storing info
> about ECC algorithm we may also add support for this new DT property.
> 
> Signed-off-by: Rafał Miłecki <zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/mtd/nand.txt |  2 ++
>  drivers/mtd/nand/nand_base.c                   | 20 +++++++++++++-------
>  2 files changed, 15 insertions(+), 7 deletions(-)

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/3] Documentation: devicetree: deprecate "soft_bch" nand-ecc-mode value
       [not found]   ` <1461324197-1333-2-git-send-email-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-04-25 12:40     ` Rob Herring
  0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2016-04-25 12:40 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Boris Brezillon, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, Brian Norris,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	open list

On Fri, Apr 22, 2016 at 01:23:14PM +0200, Rafał Miłecki wrote:
> Now that we support nand-ecc-algo property it should be used together
> with "soft" to specify software BCH ECC.
> 
> Signed-off-by: Rafał Miłecki <zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/mtd/nand.txt | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/3] mtd: nand: add support for "nand-ecc-algo" DT property
       [not found] ` <1461324197-1333-1-git-send-email-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2016-04-25 12:39   ` Rob Herring
@ 2016-04-26  7:34   ` Boris Brezillon
  1 sibling, 0 replies; 7+ messages in thread
From: Boris Brezillon @ 2016-04-26  7:34 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Richard Weinberger, David Woodhouse, Brian Norris,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	open list

On Fri, 22 Apr 2016 13:23:13 +0200
Rafał Miłecki <zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> So far it was only possible to specify ECC algorithm using "soft" and
> "soft_bch" values of nand-ecc-mode prop. There wasn't a way to specify
> it for a hardware ECC mode.
> 
> Now that we have independent field in NAND subsystem for storing info
> about ECC algorithm we may also add support for this new DT property.
> 
> Signed-off-by: Rafał Miłecki <zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/mtd/nand.txt |  2 ++
>  drivers/mtd/nand/nand_base.c                   | 20 +++++++++++++-------
>  2 files changed, 15 insertions(+), 7 deletions(-)

Applied, thanks.

Boris
-- 
Boris Brezillon, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/3] Documentation: devicetree: deprecate "soft_bch" nand-ecc-mode value
  2016-04-22 11:23 ` [PATCH 2/3] Documentation: devicetree: deprecate "soft_bch" nand-ecc-mode value Rafał Miłecki
       [not found]   ` <1461324197-1333-2-git-send-email-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-04-26  7:34   ` Boris Brezillon
  1 sibling, 0 replies; 7+ messages in thread
From: Boris Brezillon @ 2016-04-26  7:34 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: linux-mtd, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Brian Norris,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	open list

On Fri, 22 Apr 2016 13:23:14 +0200
Rafał Miłecki <zajec5@gmail.com> wrote:

> Now that we support nand-ecc-algo property it should be used together
> with "soft" to specify software BCH ECC.
> 
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> ---
>  Documentation/devicetree/bindings/mtd/nand.txt | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Applied, thanks.

Boris
-- 
Boris Brezillon, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

end of thread, other threads:[~2016-04-26  7:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-22 11:23 [PATCH 1/3] mtd: nand: add support for "nand-ecc-algo" DT property Rafał Miłecki
2016-04-22 11:23 ` [PATCH 2/3] Documentation: devicetree: deprecate "soft_bch" nand-ecc-mode value Rafał Miłecki
     [not found]   ` <1461324197-1333-2-git-send-email-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-04-25 12:40     ` Rob Herring
2016-04-26  7:34   ` Boris Brezillon
2016-04-25 10:11 ` [PATCH 1/3] mtd: nand: add support for "nand-ecc-algo" DT property Boris Brezillon
     [not found] ` <1461324197-1333-1-git-send-email-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-04-25 12:39   ` Rob Herring
2016-04-26  7:34   ` Boris Brezillon

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