diff mbox series

[v1,1/3] mtd: rawnand: nand_base: support for 'NAND_IS_BOOT_MEDIUM' flag

Message ID 20240602200836.3949773-2-avkrasnov@salutedevices.com
State Superseded
Delegated to: Neil Armstrong
Headers show
Series Meson: R/W support for pages used by boot ROM | expand

Commit Message

Arseniy Krasnov June 2, 2024, 8:08 p.m. UTC
Based on Linux kernel:
commit f922bd798bb9 ("mtd: rawnand: add an option to specify NAND chip as a boot device")

Allow to define a NAND chip as a boot device. This can be helpful
for the selection of the ECC algorithm and strength in case the boot
ROM supports only a subset of controller provided options.

Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
---
 drivers/mtd/nand/raw/nand_base.c | 3 +++
 include/linux/mtd/rawnand.h      | 6 ++++++
 2 files changed, 9 insertions(+)

Comments

Arseniy Krasnov June 24, 2024, 5:04 a.m. UTC | #1
Hi, sorry, pls ping :)

Thanks

On 02.06.2024 23:08, Arseniy Krasnov wrote:
> Based on Linux kernel:
> commit f922bd798bb9 ("mtd: rawnand: add an option to specify NAND chip as a boot device")
> 
> Allow to define a NAND chip as a boot device. This can be helpful
> for the selection of the ECC algorithm and strength in case the boot
> ROM supports only a subset of controller provided options.
> 
> Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
> ---
>  drivers/mtd/nand/raw/nand_base.c | 3 +++
>  include/linux/mtd/rawnand.h      | 6 ++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index c40a0f23d7..ed605b4af5 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -4458,6 +4458,9 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod
>  	if (ret == 16)
>  		chip->options |= NAND_BUSWIDTH_16;
>  
> +	if (ofnode_read_bool(node, "nand-is-boot-medium"))
> +		chip->options |= NAND_IS_BOOT_MEDIUM;
> +
>  	if (ofnode_read_bool(node, "nand-on-flash-bbt"))
>  		chip->bbt_options |= NAND_BBT_USE_FLASH;
>  
> diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
> index fb002ae641..4eb880d8fb 100644
> --- a/include/linux/mtd/rawnand.h
> +++ b/include/linux/mtd/rawnand.h
> @@ -218,6 +218,12 @@ enum nand_ecc_algo {
>  /* Device needs 3rd row address cycle */
>  #define NAND_ROW_ADDR_3		0x00004000
>  
> +/*
> + * Whether the NAND chip is a boot medium. Drivers might use this information
> + * to select ECC algorithms supported by the boot ROM or similar restrictions.
> + */
> +#define NAND_IS_BOOT_MEDIUM	0x00400000
> +
>  /* Options valid for Samsung large page devices */
>  #define NAND_SAMSUNG_LP_OPTIONS NAND_CACHEPRG
>
Michael Nazzareno Trimarchi June 24, 2024, 8:37 a.m. UTC | #2
Hi

Yes I have seen and I will review today and cross-check. Did you lunch
the testing on the other patches series? I would like to merge
at all but we were having some build breakage

Michael

On Mon, Jun 24, 2024 at 7:16 AM Arseniy Krasnov
<avkrasnov@salutedevices.com> wrote:
>
> Hi, sorry, pls ping :)
>
> Thanks
>
> On 02.06.2024 23:08, Arseniy Krasnov wrote:
> > Based on Linux kernel:
> > commit f922bd798bb9 ("mtd: rawnand: add an option to specify NAND chip as a boot device")
> >
> > Allow to define a NAND chip as a boot device. This can be helpful
> > for the selection of the ECC algorithm and strength in case the boot
> > ROM supports only a subset of controller provided options.
> >
> > Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
> > ---
> >  drivers/mtd/nand/raw/nand_base.c | 3 +++
> >  include/linux/mtd/rawnand.h      | 6 ++++++
> >  2 files changed, 9 insertions(+)
> >
> > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> > index c40a0f23d7..ed605b4af5 100644
> > --- a/drivers/mtd/nand/raw/nand_base.c
> > +++ b/drivers/mtd/nand/raw/nand_base.c
> > @@ -4458,6 +4458,9 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod
> >       if (ret == 16)
> >               chip->options |= NAND_BUSWIDTH_16;
> >
> > +     if (ofnode_read_bool(node, "nand-is-boot-medium"))
> > +             chip->options |= NAND_IS_BOOT_MEDIUM;
> > +
> >       if (ofnode_read_bool(node, "nand-on-flash-bbt"))
> >               chip->bbt_options |= NAND_BBT_USE_FLASH;
> >
> > diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
> > index fb002ae641..4eb880d8fb 100644
> > --- a/include/linux/mtd/rawnand.h
> > +++ b/include/linux/mtd/rawnand.h
> > @@ -218,6 +218,12 @@ enum nand_ecc_algo {
> >  /* Device needs 3rd row address cycle */
> >  #define NAND_ROW_ADDR_3              0x00004000
> >
> > +/*
> > + * Whether the NAND chip is a boot medium. Drivers might use this information
> > + * to select ECC algorithms supported by the boot ROM or similar restrictions.
> > + */
> > +#define NAND_IS_BOOT_MEDIUM  0x00400000
> > +
> >  /* Options valid for Samsung large page devices */
> >  #define NAND_SAMSUNG_LP_OPTIONS NAND_CACHEPRG
> >
Arseniy Krasnov June 24, 2024, 8:43 a.m. UTC | #3
Hi, thanks, ok! What build problem ? With this [PATCH v1] mtd: rawnand: macronix: OTP access for MX30LFxG18AC ?

Thanks

On 24.06.2024 11:37, Michael Nazzareno Trimarchi wrote:
> Hi
> 
> Yes I have seen and I will review today and cross-check. Did you lunch
> the testing on the other patches series? I would like to merge
> at all but we were having some build breakage
> 
> Michael
> 
> On Mon, Jun 24, 2024 at 7:16 AM Arseniy Krasnov
> <avkrasnov@salutedevices.com> wrote:
>>
>> Hi, sorry, pls ping :)
>>
>> Thanks
>>
>> On 02.06.2024 23:08, Arseniy Krasnov wrote:
>>> Based on Linux kernel:
>>> commit f922bd798bb9 ("mtd: rawnand: add an option to specify NAND chip as a boot device")
>>>
>>> Allow to define a NAND chip as a boot device. This can be helpful
>>> for the selection of the ECC algorithm and strength in case the boot
>>> ROM supports only a subset of controller provided options.
>>>
>>> Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
>>> ---
>>>  drivers/mtd/nand/raw/nand_base.c | 3 +++
>>>  include/linux/mtd/rawnand.h      | 6 ++++++
>>>  2 files changed, 9 insertions(+)
>>>
>>> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
>>> index c40a0f23d7..ed605b4af5 100644
>>> --- a/drivers/mtd/nand/raw/nand_base.c
>>> +++ b/drivers/mtd/nand/raw/nand_base.c
>>> @@ -4458,6 +4458,9 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod
>>>       if (ret == 16)
>>>               chip->options |= NAND_BUSWIDTH_16;
>>>
>>> +     if (ofnode_read_bool(node, "nand-is-boot-medium"))
>>> +             chip->options |= NAND_IS_BOOT_MEDIUM;
>>> +
>>>       if (ofnode_read_bool(node, "nand-on-flash-bbt"))
>>>               chip->bbt_options |= NAND_BBT_USE_FLASH;
>>>
>>> diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
>>> index fb002ae641..4eb880d8fb 100644
>>> --- a/include/linux/mtd/rawnand.h
>>> +++ b/include/linux/mtd/rawnand.h
>>> @@ -218,6 +218,12 @@ enum nand_ecc_algo {
>>>  /* Device needs 3rd row address cycle */
>>>  #define NAND_ROW_ADDR_3              0x00004000
>>>
>>> +/*
>>> + * Whether the NAND chip is a boot medium. Drivers might use this information
>>> + * to select ECC algorithms supported by the boot ROM or similar restrictions.
>>> + */
>>> +#define NAND_IS_BOOT_MEDIUM  0x00400000
>>> +
>>>  /* Options valid for Samsung large page devices */
>>>  #define NAND_SAMSUNG_LP_OPTIONS NAND_CACHEPRG
>>>
> 
> 
>
Alexander Dahl June 24, 2024, 9:14 a.m. UTC | #4
Hello Arseniy,

Am Sun, Jun 02, 2024 at 11:08:34PM +0300 schrieb Arseniy Krasnov:
> Based on Linux kernel:
> commit f922bd798bb9 ("mtd: rawnand: add an option to specify NAND chip as a boot device")
> 
> Allow to define a NAND chip as a boot device. This can be helpful
> for the selection of the ECC algorithm and strength in case the boot
> ROM supports only a subset of controller provided options.
> 
> Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
> ---
>  drivers/mtd/nand/raw/nand_base.c | 3 +++
>  include/linux/mtd/rawnand.h      | 6 ++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index c40a0f23d7..ed605b4af5 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -4458,6 +4458,9 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod
>  	if (ret == 16)
>  		chip->options |= NAND_BUSWIDTH_16;
>  
> +	if (ofnode_read_bool(node, "nand-is-boot-medium"))
> +		chip->options |= NAND_IS_BOOT_MEDIUM;
> +
>  	if (ofnode_read_bool(node, "nand-on-flash-bbt"))
>  		chip->bbt_options |= NAND_BBT_USE_FLASH;
>  
> diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
> index fb002ae641..4eb880d8fb 100644
> --- a/include/linux/mtd/rawnand.h
> +++ b/include/linux/mtd/rawnand.h
> @@ -218,6 +218,12 @@ enum nand_ecc_algo {
>  /* Device needs 3rd row address cycle */
>  #define NAND_ROW_ADDR_3		0x00004000
>  
> +/*
> + * Whether the NAND chip is a boot medium. Drivers might use this information
> + * to select ECC algorithms supported by the boot ROM or similar restrictions.
> + */
> +#define NAND_IS_BOOT_MEDIUM	0x00400000
> +
>  /* Options valid for Samsung large page devices */
>  #define NAND_SAMSUNG_LP_OPTIONS NAND_CACHEPRG

The entries in that file are ordered numerically.  Comparing with the
same file in Linux this should go before NAND_KEEP_TIMINGS, not
anywhere in between.  Makes later diffs and ports from Linux easier.

Greets
Alex

>  
> -- 
> 2.35.0
>
Arseniy Krasnov June 25, 2024, 10:16 a.m. UTC | #5
On 24.06.2024 12:14, Alexander Dahl wrote:
> Hello Arseniy,
> 
> Am Sun, Jun 02, 2024 at 11:08:34PM +0300 schrieb Arseniy Krasnov:
>> Based on Linux kernel:
>> commit f922bd798bb9 ("mtd: rawnand: add an option to specify NAND chip as a boot device")
>>
>> Allow to define a NAND chip as a boot device. This can be helpful
>> for the selection of the ECC algorithm and strength in case the boot
>> ROM supports only a subset of controller provided options.
>>
>> Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
>> ---
>>  drivers/mtd/nand/raw/nand_base.c | 3 +++
>>  include/linux/mtd/rawnand.h      | 6 ++++++
>>  2 files changed, 9 insertions(+)
>>
>> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
>> index c40a0f23d7..ed605b4af5 100644
>> --- a/drivers/mtd/nand/raw/nand_base.c
>> +++ b/drivers/mtd/nand/raw/nand_base.c
>> @@ -4458,6 +4458,9 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod
>>  	if (ret == 16)
>>  		chip->options |= NAND_BUSWIDTH_16;
>>  
>> +	if (ofnode_read_bool(node, "nand-is-boot-medium"))
>> +		chip->options |= NAND_IS_BOOT_MEDIUM;
>> +
>>  	if (ofnode_read_bool(node, "nand-on-flash-bbt"))
>>  		chip->bbt_options |= NAND_BBT_USE_FLASH;
>>  
>> diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
>> index fb002ae641..4eb880d8fb 100644
>> --- a/include/linux/mtd/rawnand.h
>> +++ b/include/linux/mtd/rawnand.h
>> @@ -218,6 +218,12 @@ enum nand_ecc_algo {
>>  /* Device needs 3rd row address cycle */
>>  #define NAND_ROW_ADDR_3		0x00004000
>>  
>> +/*
>> + * Whether the NAND chip is a boot medium. Drivers might use this information
>> + * to select ECC algorithms supported by the boot ROM or similar restrictions.
>> + */
>> +#define NAND_IS_BOOT_MEDIUM	0x00400000
>> +
>>  /* Options valid for Samsung large page devices */
>>  #define NAND_SAMSUNG_LP_OPTIONS NAND_CACHEPRG
> 
> The entries in that file are ordered numerically.  Comparing with the
> same file in Linux this should go before NAND_KEEP_TIMINGS, not
> anywhere in between.  Makes later diffs and ports from Linux easier.

Ok, I'll update this in the next version.

Thanks

> 
> Greets
> Alex
> 
>>  
>> -- 
>> 2.35.0
>>
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index c40a0f23d7..ed605b4af5 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -4458,6 +4458,9 @@  static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod
 	if (ret == 16)
 		chip->options |= NAND_BUSWIDTH_16;
 
+	if (ofnode_read_bool(node, "nand-is-boot-medium"))
+		chip->options |= NAND_IS_BOOT_MEDIUM;
+
 	if (ofnode_read_bool(node, "nand-on-flash-bbt"))
 		chip->bbt_options |= NAND_BBT_USE_FLASH;
 
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index fb002ae641..4eb880d8fb 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -218,6 +218,12 @@  enum nand_ecc_algo {
 /* Device needs 3rd row address cycle */
 #define NAND_ROW_ADDR_3		0x00004000
 
+/*
+ * Whether the NAND chip is a boot medium. Drivers might use this information
+ * to select ECC algorithms supported by the boot ROM or similar restrictions.
+ */
+#define NAND_IS_BOOT_MEDIUM	0x00400000
+
 /* Options valid for Samsung large page devices */
 #define NAND_SAMSUNG_LP_OPTIONS NAND_CACHEPRG