All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength
@ 2018-03-04 20:06 Stefan Agner
  2018-03-04 20:06 ` [PATCH v2 2/2] dt-bindings: mtd: rawnand: gpmi: document " Stefan Agner
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Stefan Agner @ 2018-03-04 20:06 UTC (permalink / raw)
  To: han.xu, boris.brezillon
  Cc: marek.vasut, richard, dwmw2, cyrille.pitchen, max.oss.09,
	linux-mtd, linux-kernel, Stefan Agner

Add support for specified ECC strength/size using device tree
properties nand-ecc-strength/nand-ecc-step-size.

Signed-off-by: Stefan Agner <stefan@agner.ch>
---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 61fdd733492f..d04754289c03 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -198,17 +198,16 @@ static inline bool gpmi_check_ecc(struct gpmi_nand_data *this)
  *
  * We may have available oob space in this case.
  */
-static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
+static int set_geometry_by_ecc_info(struct gpmi_nand_data *this,
+				    unsigned int ecc_strength,
+				    unsigned int ecc_step)
 {
 	struct bch_geometry *geo = &this->bch_geometry;
 	struct nand_chip *chip = &this->nand;
 	struct mtd_info *mtd = nand_to_mtd(chip);
 	unsigned int block_mark_bit_offset;
 
-	if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
-		return -EINVAL;
-
-	switch (chip->ecc_step_ds) {
+	switch (ecc_step) {
 	case SZ_512:
 		geo->gf_len = 13;
 		break;
@@ -221,8 +220,8 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
 			chip->ecc_strength_ds, chip->ecc_step_ds);
 		return -EINVAL;
 	}
-	geo->ecc_chunk_size = chip->ecc_step_ds;
-	geo->ecc_strength = round_up(chip->ecc_strength_ds, 2);
+	geo->ecc_chunk_size = ecc_step;
+	geo->ecc_strength = round_up(ecc_strength, 2);
 	if (!gpmi_check_ecc(this))
 		return -EINVAL;
 
@@ -230,7 +229,7 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
 	if (geo->ecc_chunk_size < mtd->oobsize) {
 		dev_err(this->dev,
 			"unsupported nand chip. ecc size: %d, oob size : %d\n",
-			chip->ecc_step_ds, mtd->oobsize);
+			ecc_step, mtd->oobsize);
 		return -EINVAL;
 	}
 
@@ -423,9 +422,20 @@ static int legacy_set_geometry(struct gpmi_nand_data *this)
 
 int common_nfc_set_geometry(struct gpmi_nand_data *this)
 {
+	struct nand_chip *chip = &this->nand;
+
+	if (chip->ecc.strength > 0 && chip->ecc.size > 0)
+		return set_geometry_by_ecc_info(this, chip->ecc.strength,
+						chip->ecc.size);
+
 	if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc"))
-				|| legacy_set_geometry(this))
-		return set_geometry_by_ecc_info(this);
+				|| legacy_set_geometry(this)) {
+		if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
+			return -EINVAL;
+
+		return set_geometry_by_ecc_info(this, chip->ecc_strength_ds,
+						chip->ecc_step_ds);
+	}
 
 	return 0;
 }
-- 
2.16.2

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

* [PATCH v2 2/2] dt-bindings: mtd: rawnand: gpmi: document specific ECC strength
  2018-03-04 20:06 [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength Stefan Agner
@ 2018-03-04 20:06 ` Stefan Agner
  2018-04-13 21:57   ` Han Xu
  2018-03-15 15:36 ` [PATCH v2 1/2] mtd: rawnand: gpmi: add support for " Boris Brezillon
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Stefan Agner @ 2018-03-04 20:06 UTC (permalink / raw)
  To: han.xu, boris.brezillon
  Cc: marek.vasut, richard, dwmw2, cyrille.pitchen, max.oss.09,
	linux-mtd, linux-kernel, Stefan Agner

Document newly supported device tree properties nand-ecc-strength/
nand-ecc-step-size to specify ECC strength/size.

Signed-off-by: Stefan Agner <stefan@agner.ch>
---
 Documentation/devicetree/bindings/mtd/gpmi-nand.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
index b289ef3c1b7e..393588385c6e 100644
--- a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
@@ -47,6 +47,11 @@ Optional properties:
                        partitions written from Linux with this feature
                        turned on may not be accessible by the BootROM
                        code.
+  - nand-ecc-strength: integer representing the number of bits to correct
+                       per ECC step. Needs to be a multiple of 2.
+  - nand-ecc-step-size: integer representing the number of data bytes
+                       that are covered by a single ECC step. The driver
+                       supports 512 and 1024.
 
 The device tree may optionally contain sub-nodes describing partitions of the
 address space. See partition.txt for more detail.
-- 
2.16.2

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

* Re: [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength
  2018-03-04 20:06 [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength Stefan Agner
  2018-03-04 20:06 ` [PATCH v2 2/2] dt-bindings: mtd: rawnand: gpmi: document " Stefan Agner
@ 2018-03-15 15:36 ` Boris Brezillon
  2018-03-15 15:39     ` Stefan Agner
  2018-04-13 21:57 ` Han Xu
  2018-04-22 17:24 ` Boris Brezillon
  3 siblings, 1 reply; 9+ messages in thread
From: Boris Brezillon @ 2018-03-15 15:36 UTC (permalink / raw)
  To: Stefan Agner, han.xu
  Cc: boris.brezillon, max.oss.09, richard, linux-kernel, marek.vasut,
	linux-mtd, cyrille.pitchen, dwmw2

Hi,

On Sun,  4 Mar 2018 21:06:01 +0100
Stefan Agner <stefan@agner.ch> wrote:

> Add support for specified ECC strength/size using device tree
> properties nand-ecc-strength/nand-ecc-step-size.

Han, we didn't hear back from you on that. Are you okay with adding
these new properties? IIRC, you feared there would be a delta between
u-boot and linux support.

Stephan, there's no changelog. Has anything changed in this version or
is this just a RESEND?

Regards,

Boris

> 
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> ---
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 30 ++++++++++++++++++++----------
>  1 file changed, 20 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index 61fdd733492f..d04754289c03 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -198,17 +198,16 @@ static inline bool gpmi_check_ecc(struct gpmi_nand_data *this)
>   *
>   * We may have available oob space in this case.
>   */
> -static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
> +static int set_geometry_by_ecc_info(struct gpmi_nand_data *this,
> +				    unsigned int ecc_strength,
> +				    unsigned int ecc_step)
>  {
>  	struct bch_geometry *geo = &this->bch_geometry;
>  	struct nand_chip *chip = &this->nand;
>  	struct mtd_info *mtd = nand_to_mtd(chip);
>  	unsigned int block_mark_bit_offset;
>  
> -	if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
> -		return -EINVAL;
> -
> -	switch (chip->ecc_step_ds) {
> +	switch (ecc_step) {
>  	case SZ_512:
>  		geo->gf_len = 13;
>  		break;
> @@ -221,8 +220,8 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
>  			chip->ecc_strength_ds, chip->ecc_step_ds);
>  		return -EINVAL;
>  	}
> -	geo->ecc_chunk_size = chip->ecc_step_ds;
> -	geo->ecc_strength = round_up(chip->ecc_strength_ds, 2);
> +	geo->ecc_chunk_size = ecc_step;
> +	geo->ecc_strength = round_up(ecc_strength, 2);
>  	if (!gpmi_check_ecc(this))
>  		return -EINVAL;
>  
> @@ -230,7 +229,7 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
>  	if (geo->ecc_chunk_size < mtd->oobsize) {
>  		dev_err(this->dev,
>  			"unsupported nand chip. ecc size: %d, oob size : %d\n",
> -			chip->ecc_step_ds, mtd->oobsize);
> +			ecc_step, mtd->oobsize);
>  		return -EINVAL;
>  	}
>  
> @@ -423,9 +422,20 @@ static int legacy_set_geometry(struct gpmi_nand_data *this)
>  
>  int common_nfc_set_geometry(struct gpmi_nand_data *this)
>  {
> +	struct nand_chip *chip = &this->nand;
> +
> +	if (chip->ecc.strength > 0 && chip->ecc.size > 0)
> +		return set_geometry_by_ecc_info(this, chip->ecc.strength,
> +						chip->ecc.size);
> +
>  	if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc"))
> -				|| legacy_set_geometry(this))
> -		return set_geometry_by_ecc_info(this);
> +				|| legacy_set_geometry(this)) {
> +		if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
> +			return -EINVAL;
> +
> +		return set_geometry_by_ecc_info(this, chip->ecc_strength_ds,
> +						chip->ecc_step_ds);
> +	}
>  
>  	return 0;
>  }



-- 
Boris Brezillon, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength
  2018-03-15 15:36 ` [PATCH v2 1/2] mtd: rawnand: gpmi: add support for " Boris Brezillon
@ 2018-03-15 15:39     ` Stefan Agner
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Agner @ 2018-03-15 15:39 UTC (permalink / raw)
  To: Boris Brezillon, han.xu
  Cc: boris.brezillon, max.oss.09, richard, linux-kernel, marek.vasut,
	linux-mtd, cyrille.pitchen, dwmw2



On March 15, 2018 4:36:20 PM GMT+01:00, Boris Brezillon <boris.brezillon@bootlin.com> wrote:
>Hi,
>
>On Sun,  4 Mar 2018 21:06:01 +0100
>Stefan Agner <stefan@agner.ch> wrote:
>
>> Add support for specified ECC strength/size using device tree
>> properties nand-ecc-strength/nand-ecc-step-size.
>
>Han, we didn't hear back from you on that. Are you okay with adding
>these new properties? IIRC, you feared there would be a delta between
>u-boot and linux support.
>
>Stephan, there's no changelog. Has anything changed in this version or
>is this just a RESEND?

Sorry forgot that. I just split documentation and driver changes.

--
Stefan

>
>Regards,
>
>Boris
>
>> 
>> Signed-off-by: Stefan Agner <stefan@agner.ch>
>> ---
>>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 30
>++++++++++++++++++++----------
>>  1 file changed, 20 insertions(+), 10 deletions(-)
>> 
>> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
>b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
>> index 61fdd733492f..d04754289c03 100644
>> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
>> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
>> @@ -198,17 +198,16 @@ static inline bool gpmi_check_ecc(struct
>gpmi_nand_data *this)
>>   *
>>   * We may have available oob space in this case.
>>   */
>> -static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
>> +static int set_geometry_by_ecc_info(struct gpmi_nand_data *this,
>> +				    unsigned int ecc_strength,
>> +				    unsigned int ecc_step)
>>  {
>>  	struct bch_geometry *geo = &this->bch_geometry;
>>  	struct nand_chip *chip = &this->nand;
>>  	struct mtd_info *mtd = nand_to_mtd(chip);
>>  	unsigned int block_mark_bit_offset;
>>  
>> -	if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
>> -		return -EINVAL;
>> -
>> -	switch (chip->ecc_step_ds) {
>> +	switch (ecc_step) {
>>  	case SZ_512:
>>  		geo->gf_len = 13;
>>  		break;
>> @@ -221,8 +220,8 @@ static int set_geometry_by_ecc_info(struct
>gpmi_nand_data *this)
>>  			chip->ecc_strength_ds, chip->ecc_step_ds);
>>  		return -EINVAL;
>>  	}
>> -	geo->ecc_chunk_size = chip->ecc_step_ds;
>> -	geo->ecc_strength = round_up(chip->ecc_strength_ds, 2);
>> +	geo->ecc_chunk_size = ecc_step;
>> +	geo->ecc_strength = round_up(ecc_strength, 2);
>>  	if (!gpmi_check_ecc(this))
>>  		return -EINVAL;
>>  
>> @@ -230,7 +229,7 @@ static int set_geometry_by_ecc_info(struct
>gpmi_nand_data *this)
>>  	if (geo->ecc_chunk_size < mtd->oobsize) {
>>  		dev_err(this->dev,
>>  			"unsupported nand chip. ecc size: %d, oob size : %d\n",
>> -			chip->ecc_step_ds, mtd->oobsize);
>> +			ecc_step, mtd->oobsize);
>>  		return -EINVAL;
>>  	}
>>  
>> @@ -423,9 +422,20 @@ static int legacy_set_geometry(struct
>gpmi_nand_data *this)
>>  
>>  int common_nfc_set_geometry(struct gpmi_nand_data *this)
>>  {
>> +	struct nand_chip *chip = &this->nand;
>> +
>> +	if (chip->ecc.strength > 0 && chip->ecc.size > 0)
>> +		return set_geometry_by_ecc_info(this, chip->ecc.strength,
>> +						chip->ecc.size);
>> +
>>  	if ((of_property_read_bool(this->dev->of_node,
>"fsl,use-minimum-ecc"))
>> -				|| legacy_set_geometry(this))
>> -		return set_geometry_by_ecc_info(this);
>> +				|| legacy_set_geometry(this)) {
>> +		if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
>> +			return -EINVAL;
>> +
>> +		return set_geometry_by_ecc_info(this, chip->ecc_strength_ds,
>> +						chip->ecc_step_ds);
>> +	}
>>  
>>  	return 0;
>>  }

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

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

* Re: [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength
@ 2018-03-15 15:39     ` Stefan Agner
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Agner @ 2018-03-15 15:39 UTC (permalink / raw)
  To: Boris Brezillon, han.xu
  Cc: boris.brezillon, max.oss.09, richard, linux-kernel, marek.vasut,
	linux-mtd, cyrille.pitchen, dwmw2



On March 15, 2018 4:36:20 PM GMT+01:00, Boris Brezillon <boris.brezillon@bootlin.com> wrote:
>Hi,
>
>On Sun,  4 Mar 2018 21:06:01 +0100
>Stefan Agner <stefan@agner.ch> wrote:
>
>> Add support for specified ECC strength/size using device tree
>> properties nand-ecc-strength/nand-ecc-step-size.
>
>Han, we didn't hear back from you on that. Are you okay with adding
>these new properties? IIRC, you feared there would be a delta between
>u-boot and linux support.
>
>Stephan, there's no changelog. Has anything changed in this version or
>is this just a RESEND?

Sorry forgot that. I just split documentation and driver changes.

--
Stefan

>
>Regards,
>
>Boris
>
>> 
>> Signed-off-by: Stefan Agner <stefan@agner.ch>
>> ---
>>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 30
>++++++++++++++++++++----------
>>  1 file changed, 20 insertions(+), 10 deletions(-)
>> 
>> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
>b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
>> index 61fdd733492f..d04754289c03 100644
>> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
>> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
>> @@ -198,17 +198,16 @@ static inline bool gpmi_check_ecc(struct
>gpmi_nand_data *this)
>>   *
>>   * We may have available oob space in this case.
>>   */
>> -static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
>> +static int set_geometry_by_ecc_info(struct gpmi_nand_data *this,
>> +				    unsigned int ecc_strength,
>> +				    unsigned int ecc_step)
>>  {
>>  	struct bch_geometry *geo = &this->bch_geometry;
>>  	struct nand_chip *chip = &this->nand;
>>  	struct mtd_info *mtd = nand_to_mtd(chip);
>>  	unsigned int block_mark_bit_offset;
>>  
>> -	if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
>> -		return -EINVAL;
>> -
>> -	switch (chip->ecc_step_ds) {
>> +	switch (ecc_step) {
>>  	case SZ_512:
>>  		geo->gf_len = 13;
>>  		break;
>> @@ -221,8 +220,8 @@ static int set_geometry_by_ecc_info(struct
>gpmi_nand_data *this)
>>  			chip->ecc_strength_ds, chip->ecc_step_ds);
>>  		return -EINVAL;
>>  	}
>> -	geo->ecc_chunk_size = chip->ecc_step_ds;
>> -	geo->ecc_strength = round_up(chip->ecc_strength_ds, 2);
>> +	geo->ecc_chunk_size = ecc_step;
>> +	geo->ecc_strength = round_up(ecc_strength, 2);
>>  	if (!gpmi_check_ecc(this))
>>  		return -EINVAL;
>>  
>> @@ -230,7 +229,7 @@ static int set_geometry_by_ecc_info(struct
>gpmi_nand_data *this)
>>  	if (geo->ecc_chunk_size < mtd->oobsize) {
>>  		dev_err(this->dev,
>>  			"unsupported nand chip. ecc size: %d, oob size : %d\n",
>> -			chip->ecc_step_ds, mtd->oobsize);
>> +			ecc_step, mtd->oobsize);
>>  		return -EINVAL;
>>  	}
>>  
>> @@ -423,9 +422,20 @@ static int legacy_set_geometry(struct
>gpmi_nand_data *this)
>>  
>>  int common_nfc_set_geometry(struct gpmi_nand_data *this)
>>  {
>> +	struct nand_chip *chip = &this->nand;
>> +
>> +	if (chip->ecc.strength > 0 && chip->ecc.size > 0)
>> +		return set_geometry_by_ecc_info(this, chip->ecc.strength,
>> +						chip->ecc.size);
>> +
>>  	if ((of_property_read_bool(this->dev->of_node,
>"fsl,use-minimum-ecc"))
>> -				|| legacy_set_geometry(this))
>> -		return set_geometry_by_ecc_info(this);
>> +				|| legacy_set_geometry(this)) {
>> +		if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
>> +			return -EINVAL;
>> +
>> +		return set_geometry_by_ecc_info(this, chip->ecc_strength_ds,
>> +						chip->ecc_step_ds);
>> +	}
>>  
>>  	return 0;
>>  }

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

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

* Re: [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength
  2018-03-15 15:39     ` Stefan Agner
  (?)
@ 2018-04-12  6:56     ` Stefan Agner
  -1 siblings, 0 replies; 9+ messages in thread
From: Stefan Agner @ 2018-04-12  6:56 UTC (permalink / raw)
  To: Boris Brezillon, han.xu
  Cc: boris.brezillon, max.oss.09, richard, linux-kernel, marek.vasut,
	linux-mtd, cyrille.pitchen, dwmw2

Han,

On 15.03.2018 16:39, Stefan Agner wrote:
> On March 15, 2018 4:36:20 PM GMT+01:00, Boris Brezillon
> <boris.brezillon@bootlin.com> wrote:
>>Hi,
>>
>>On Sun,  4 Mar 2018 21:06:01 +0100
>>Stefan Agner <stefan@agner.ch> wrote:
>>
>>> Add support for specified ECC strength/size using device tree
>>> properties nand-ecc-strength/nand-ecc-step-size.
>>
>>Han, we didn't hear back from you on that. Are you okay with adding
>>these new properties? IIRC, you feared there would be a delta between
>>u-boot and linux support.

Any comment on this?

U-Boot support for device tree support and the same properties is
underway.

--
Stefan


>>
>>Stephan, there's no changelog. Has anything changed in this version or
>>is this just a RESEND?
> 
> Sorry forgot that. I just split documentation and driver changes.
> 
> --
> Stefan
> 
>>
>>Regards,
>>
>>Boris
>>
>>>
>>> Signed-off-by: Stefan Agner <stefan@agner.ch>
>>> ---
>>>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 30
>>++++++++++++++++++++----------
>>>  1 file changed, 20 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
>>b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
>>> index 61fdd733492f..d04754289c03 100644
>>> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
>>> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
>>> @@ -198,17 +198,16 @@ static inline bool gpmi_check_ecc(struct
>>gpmi_nand_data *this)
>>>   *
>>>   * We may have available oob space in this case.
>>>   */
>>> -static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
>>> +static int set_geometry_by_ecc_info(struct gpmi_nand_data *this,
>>> +				    unsigned int ecc_strength,
>>> +				    unsigned int ecc_step)
>>>  {
>>>  	struct bch_geometry *geo = &this->bch_geometry;
>>>  	struct nand_chip *chip = &this->nand;
>>>  	struct mtd_info *mtd = nand_to_mtd(chip);
>>>  	unsigned int block_mark_bit_offset;
>>>
>>> -	if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
>>> -		return -EINVAL;
>>> -
>>> -	switch (chip->ecc_step_ds) {
>>> +	switch (ecc_step) {
>>>  	case SZ_512:
>>>  		geo->gf_len = 13;
>>>  		break;
>>> @@ -221,8 +220,8 @@ static int set_geometry_by_ecc_info(struct
>>gpmi_nand_data *this)
>>>  			chip->ecc_strength_ds, chip->ecc_step_ds);
>>>  		return -EINVAL;
>>>  	}
>>> -	geo->ecc_chunk_size = chip->ecc_step_ds;
>>> -	geo->ecc_strength = round_up(chip->ecc_strength_ds, 2);
>>> +	geo->ecc_chunk_size = ecc_step;
>>> +	geo->ecc_strength = round_up(ecc_strength, 2);
>>>  	if (!gpmi_check_ecc(this))
>>>  		return -EINVAL;
>>>
>>> @@ -230,7 +229,7 @@ static int set_geometry_by_ecc_info(struct
>>gpmi_nand_data *this)
>>>  	if (geo->ecc_chunk_size < mtd->oobsize) {
>>>  		dev_err(this->dev,
>>>  			"unsupported nand chip. ecc size: %d, oob size : %d\n",
>>> -			chip->ecc_step_ds, mtd->oobsize);
>>> +			ecc_step, mtd->oobsize);
>>>  		return -EINVAL;
>>>  	}
>>>
>>> @@ -423,9 +422,20 @@ static int legacy_set_geometry(struct
>>gpmi_nand_data *this)
>>>
>>>  int common_nfc_set_geometry(struct gpmi_nand_data *this)
>>>  {
>>> +	struct nand_chip *chip = &this->nand;
>>> +
>>> +	if (chip->ecc.strength > 0 && chip->ecc.size > 0)
>>> +		return set_geometry_by_ecc_info(this, chip->ecc.strength,
>>> +						chip->ecc.size);
>>> +
>>>  	if ((of_property_read_bool(this->dev->of_node,
>>"fsl,use-minimum-ecc"))
>>> -				|| legacy_set_geometry(this))
>>> -		return set_geometry_by_ecc_info(this);
>>> +				|| legacy_set_geometry(this)) {
>>> +		if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
>>> +			return -EINVAL;
>>> +
>>> +		return set_geometry_by_ecc_info(this, chip->ecc_strength_ds,
>>> +						chip->ecc_step_ds);
>>> +	}
>>>
>>>  	return 0;
>>>  }

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

* Re: [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength
  2018-03-04 20:06 [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength Stefan Agner
  2018-03-04 20:06 ` [PATCH v2 2/2] dt-bindings: mtd: rawnand: gpmi: document " Stefan Agner
  2018-03-15 15:36 ` [PATCH v2 1/2] mtd: rawnand: gpmi: add support for " Boris Brezillon
@ 2018-04-13 21:57 ` Han Xu
  2018-04-22 17:24 ` Boris Brezillon
  3 siblings, 0 replies; 9+ messages in thread
From: Han Xu @ 2018-04-13 21:57 UTC (permalink / raw)
  To: Stefan Agner, boris.brezillon
  Cc: marek.vasut, richard, dwmw2, cyrille.pitchen, max.oss.09,
	linux-mtd, linux-kernel



On 03/04/2018 02:06 PM, Stefan Agner wrote:
> Add support for specified ECC strength/size using device tree
> properties nand-ecc-strength/nand-ecc-step-size.
> 
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> ---
>   drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 30 ++++++++++++++++++++----------
>   1 file changed, 20 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index 61fdd733492f..d04754289c03 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -198,17 +198,16 @@ static inline bool gpmi_check_ecc(struct gpmi_nand_data *this)
>    *
>    * We may have available oob space in this case.
>    */
> -static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
> +static int set_geometry_by_ecc_info(struct gpmi_nand_data *this,
> +				    unsigned int ecc_strength,
> +				    unsigned int ecc_step)
>   {
>   	struct bch_geometry *geo = &this->bch_geometry;
>   	struct nand_chip *chip = &this->nand;
>   	struct mtd_info *mtd = nand_to_mtd(chip);
>   	unsigned int block_mark_bit_offset;
>   
> -	if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
> -		return -EINVAL;
> -
> -	switch (chip->ecc_step_ds) {
> +	switch (ecc_step) {
>   	case SZ_512:
>   		geo->gf_len = 13;
>   		break;
> @@ -221,8 +220,8 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
>   			chip->ecc_strength_ds, chip->ecc_step_ds);
>   		return -EINVAL;
>   	}
> -	geo->ecc_chunk_size = chip->ecc_step_ds;
> -	geo->ecc_strength = round_up(chip->ecc_strength_ds, 2);
> +	geo->ecc_chunk_size = ecc_step;
> +	geo->ecc_strength = round_up(ecc_strength, 2);
>   	if (!gpmi_check_ecc(this))
>   		return -EINVAL;
>   
> @@ -230,7 +229,7 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
>   	if (geo->ecc_chunk_size < mtd->oobsize) {
>   		dev_err(this->dev,
>   			"unsupported nand chip. ecc size: %d, oob size : %d\n",
> -			chip->ecc_step_ds, mtd->oobsize);
> +			ecc_step, mtd->oobsize);
>   		return -EINVAL;
>   	}
>   
> @@ -423,9 +422,20 @@ static int legacy_set_geometry(struct gpmi_nand_data *this)
>   
>   int common_nfc_set_geometry(struct gpmi_nand_data *this)
>   {
> +	struct nand_chip *chip = &this->nand;
> +
> +	if (chip->ecc.strength > 0 && chip->ecc.size > 0)
> +		return set_geometry_by_ecc_info(this, chip->ecc.strength,
> +						chip->ecc.size);
> +
>   	if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc"))
> -				|| legacy_set_geometry(this))
> -		return set_geometry_by_ecc_info(this);
> +				|| legacy_set_geometry(this)) {
> +		if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
> +			return -EINVAL;
> +
> +		return set_geometry_by_ecc_info(this, chip->ecc_strength_ds,
> +						chip->ecc_step_ds);
> +	}
>   
>   	return 0;
>   }
> 

Acked-by: Han Xu <han.xu@nxp.com>

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

* Re: [PATCH v2 2/2] dt-bindings: mtd: rawnand: gpmi: document specific ECC strength
  2018-03-04 20:06 ` [PATCH v2 2/2] dt-bindings: mtd: rawnand: gpmi: document " Stefan Agner
@ 2018-04-13 21:57   ` Han Xu
  0 siblings, 0 replies; 9+ messages in thread
From: Han Xu @ 2018-04-13 21:57 UTC (permalink / raw)
  To: Stefan Agner, boris.brezillon
  Cc: marek.vasut, richard, dwmw2, cyrille.pitchen, max.oss.09,
	linux-mtd, linux-kernel



On 03/04/2018 02:06 PM, Stefan Agner wrote:
> Document newly supported device tree properties nand-ecc-strength/
> nand-ecc-step-size to specify ECC strength/size.
> 
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> ---
>   Documentation/devicetree/bindings/mtd/gpmi-nand.txt | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
> index b289ef3c1b7e..393588385c6e 100644
> --- a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
> +++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
> @@ -47,6 +47,11 @@ Optional properties:
>                          partitions written from Linux with this feature
>                          turned on may not be accessible by the BootROM
>                          code.
> +  - nand-ecc-strength: integer representing the number of bits to correct
> +                       per ECC step. Needs to be a multiple of 2.
> +  - nand-ecc-step-size: integer representing the number of data bytes
> +                       that are covered by a single ECC step. The driver
> +                       supports 512 and 1024.
>   
>   The device tree may optionally contain sub-nodes describing partitions of the
>   address space. See partition.txt for more detail.
> 

Acked-by: Han Xu <han.xu@nxp.com>

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

* Re: [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength
  2018-03-04 20:06 [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength Stefan Agner
                   ` (2 preceding siblings ...)
  2018-04-13 21:57 ` Han Xu
@ 2018-04-22 17:24 ` Boris Brezillon
  3 siblings, 0 replies; 9+ messages in thread
From: Boris Brezillon @ 2018-04-22 17:24 UTC (permalink / raw)
  To: Stefan Agner
  Cc: han.xu, boris.brezillon, marek.vasut, richard, dwmw2,
	cyrille.pitchen, max.oss.09, linux-mtd, linux-kernel

On Sun,  4 Mar 2018 21:06:01 +0100
Stefan Agner <stefan@agner.ch> wrote:

> Add support for specified ECC strength/size using device tree
> properties nand-ecc-strength/nand-ecc-step-size.
> 
> Signed-off-by: Stefan Agner <stefan@agner.ch>

Applied to nand/next.

Thanks,

Boris

> ---
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 30 ++++++++++++++++++++----------
>  1 file changed, 20 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index 61fdd733492f..d04754289c03 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -198,17 +198,16 @@ static inline bool gpmi_check_ecc(struct gpmi_nand_data *this)
>   *
>   * We may have available oob space in this case.
>   */
> -static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
> +static int set_geometry_by_ecc_info(struct gpmi_nand_data *this,
> +				    unsigned int ecc_strength,
> +				    unsigned int ecc_step)
>  {
>  	struct bch_geometry *geo = &this->bch_geometry;
>  	struct nand_chip *chip = &this->nand;
>  	struct mtd_info *mtd = nand_to_mtd(chip);
>  	unsigned int block_mark_bit_offset;
>  
> -	if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
> -		return -EINVAL;
> -
> -	switch (chip->ecc_step_ds) {
> +	switch (ecc_step) {
>  	case SZ_512:
>  		geo->gf_len = 13;
>  		break;
> @@ -221,8 +220,8 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
>  			chip->ecc_strength_ds, chip->ecc_step_ds);
>  		return -EINVAL;
>  	}
> -	geo->ecc_chunk_size = chip->ecc_step_ds;
> -	geo->ecc_strength = round_up(chip->ecc_strength_ds, 2);
> +	geo->ecc_chunk_size = ecc_step;
> +	geo->ecc_strength = round_up(ecc_strength, 2);
>  	if (!gpmi_check_ecc(this))
>  		return -EINVAL;
>  
> @@ -230,7 +229,7 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
>  	if (geo->ecc_chunk_size < mtd->oobsize) {
>  		dev_err(this->dev,
>  			"unsupported nand chip. ecc size: %d, oob size : %d\n",
> -			chip->ecc_step_ds, mtd->oobsize);
> +			ecc_step, mtd->oobsize);
>  		return -EINVAL;
>  	}
>  
> @@ -423,9 +422,20 @@ static int legacy_set_geometry(struct gpmi_nand_data *this)
>  
>  int common_nfc_set_geometry(struct gpmi_nand_data *this)
>  {
> +	struct nand_chip *chip = &this->nand;
> +
> +	if (chip->ecc.strength > 0 && chip->ecc.size > 0)
> +		return set_geometry_by_ecc_info(this, chip->ecc.strength,
> +						chip->ecc.size);
> +
>  	if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc"))
> -				|| legacy_set_geometry(this))
> -		return set_geometry_by_ecc_info(this);
> +				|| legacy_set_geometry(this)) {
> +		if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
> +			return -EINVAL;
> +
> +		return set_geometry_by_ecc_info(this, chip->ecc_strength_ds,
> +						chip->ecc_step_ds);
> +	}
>  
>  	return 0;
>  }

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

end of thread, other threads:[~2018-04-22 17:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-04 20:06 [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength Stefan Agner
2018-03-04 20:06 ` [PATCH v2 2/2] dt-bindings: mtd: rawnand: gpmi: document " Stefan Agner
2018-04-13 21:57   ` Han Xu
2018-03-15 15:36 ` [PATCH v2 1/2] mtd: rawnand: gpmi: add support for " Boris Brezillon
2018-03-15 15:39   ` Stefan Agner
2018-03-15 15:39     ` Stefan Agner
2018-04-12  6:56     ` Stefan Agner
2018-04-13 21:57 ` Han Xu
2018-04-22 17:24 ` Boris Brezillon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.