diff mbox series

[v5,1/2] dt-bindings: mtd: amlogic,meson-nand: support fields for boot ROM code

Message ID 20240416085101.740458-2-avkrasnov@salutedevices.com (mailing list archive)
State Superseded
Headers show
Series Meson: R/W support for pages used by boot ROM | expand

Commit Message

Arseniy Krasnov April 16, 2024, 8:51 a.m. UTC
Boot ROM code on Meson requires that some pages on NAND must be written
in special mode: "short" ECC mode where each block is 384 bytes and
scrambling mode is on. Such pages located with the specified interval
within specified offset. Both interval and offset are located in the
device tree and used by driver if 'nand-is-boot-medium' is set for
NAND chip.

Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
---
 .../bindings/mtd/amlogic,meson-nand.yaml           | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Rob Herring (Arm) April 17, 2024, 6:12 p.m. UTC | #1
On Tue, 16 Apr 2024 11:51:00 +0300, Arseniy Krasnov wrote:
> Boot ROM code on Meson requires that some pages on NAND must be written
> in special mode: "short" ECC mode where each block is 384 bytes and
> scrambling mode is on. Such pages located with the specified interval
> within specified offset. Both interval and offset are located in the
> device tree and used by driver if 'nand-is-boot-medium' is set for
> NAND chip.
> 
> Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
> ---
>  .../bindings/mtd/amlogic,meson-nand.yaml           | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 

Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Miquel Raynal May 6, 2024, 1:48 p.m. UTC | #2
Hi Arseniy,

avkrasnov@salutedevices.com wrote on Tue, 16 Apr 2024 11:51:00 +0300:

> Boot ROM code on Meson requires that some pages on NAND must be written
> in special mode: "short" ECC mode where each block is 384 bytes and
> scrambling mode is on.

Ok

> Such pages located with the specified interval within specified offset.

I'm sorry I don't get that sentence.

> Both interval and offset are located in the
> device tree and used by driver if 'nand-is-boot-medium' is set for
> NAND chip.

This sentence is probably not needed.

> 
> Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
> ---
>  .../bindings/mtd/amlogic,meson-nand.yaml           | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml b/Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml
> index 57b6957c8415..67b2f7c1259c 100644
> --- a/Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml
> +++ b/Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml
> @@ -64,11 +64,25 @@ patternProperties:
>          items:
>            maximum: 0
>  
> +      amlogic,boot-pages:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        description:
> +          Number of pages starting from 0, where special ECC

from *offset* 0 I guess?

> +          algorithm will be used by the driver.

"where a special ECC configuration must be used because it is accessed
by the ROM code"? Maybe you can even detail what are these values if
they are fixed.

You should probably inform that scrambling shall be on as well.
 
> +
> +      amlogic,boot-page-step:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        description:
> +          Interval between pages, read/written by the driver with
> +          special ECC algorithm.

I'm not sure I fully get the description. What is the unit here? can
you draw a small ascii-art diagram?

> +
>      unevaluatedProperties: false
>  
>      dependencies:
>        nand-ecc-strength: [nand-ecc-step-size]
>        nand-ecc-step-size: [nand-ecc-strength]
> +      amlogic,boot-pages: [nand-is-boot-medium, "amlogic,boot-page-step"]
> +      amlogic,boot-page-step: [nand-is-boot-medium, "amlogic,boot-pages"]
>  
>  
>  required:


Thanks,
Miquèl
Arseniy Krasnov May 7, 2024, 6:53 a.m. UTC | #3
On 06.05.2024 16:48, Miquel Raynal wrote:
> Hi Arseniy,
> 
> avkrasnov@salutedevices.com wrote on Tue, 16 Apr 2024 11:51:00 +0300:
> 
>> Boot ROM code on Meson requires that some pages on NAND must be written
>> in special mode: "short" ECC mode where each block is 384 bytes and
>> scrambling mode is on.
> 
> Ok
> 
>> Such pages located with the specified interval within specified offset.
> 
> I'm sorry I don't get that sentence.

Sorry, I mean this (let me draw :) ) :

[ page 0 ][ page 1 ][ page 2 ][ page 3 ][ page 4 ][ page 5 ][ page 6 ][ page 7 ][ page 8 ][ page 9 ]

For example, we have 10 pages starting from the beginning of the chip - this is "within specified offset",
e.g. offset is 10. BootROM on axg needs that (for example) every third page must be written in "special"
mode: scrambling is on and ECC is 384 bytes. Such pages are 0, 2, 4, 6, 8. E.g. "specified interval" will
be 3.

So:

amlogic,boot-pages: 10
amlogic,boot-page-step: 3


> 
>> Both interval and offset are located in the
>> device tree and used by driver if 'nand-is-boot-medium' is set for
>> NAND chip.
> 
> This sentence is probably not needed.

Ok

> 
>>
>> Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
>> ---
>>  .../bindings/mtd/amlogic,meson-nand.yaml           | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml b/Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml
>> index 57b6957c8415..67b2f7c1259c 100644
>> --- a/Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml
>> +++ b/Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml
>> @@ -64,11 +64,25 @@ patternProperties:
>>          items:
>>            maximum: 0
>>  
>> +      amlogic,boot-pages:
>> +        $ref: /schemas/types.yaml#/definitions/uint32
>> +        description:
>> +          Number of pages starting from 0, where special ECC
> 
> from *offset* 0 I guess?

Yes, or may be better "from beginning of the chip" ?

May be i can place here ascii picture from above, with reduced number of pages?
And also place this picture in the commit message ?

> 
>> +          algorithm will be used by the driver.
> 
> "where a special ECC configuration must be used because it is accessed
> by the ROM code"? Maybe you can even detail what are these values if
> they are fixed.
> 
> You should probably inform that scrambling shall be on as well.
>  
>> +
>> +      amlogic,boot-page-step:
>> +        $ref: /schemas/types.yaml#/definitions/uint32
>> +        description:
>> +          Interval between pages, read/written by the driver with
>> +          special ECC algorithm.
> 
> I'm not sure I fully get the description. What is the unit here? can
> you draw a small ascii-art diagram?

May be i can place here "please see diagram above" ? And in 'amlogic,boot-pages' there
will be diagram.


> 
>> +
>>      unevaluatedProperties: false
>>  
>>      dependencies:
>>        nand-ecc-strength: [nand-ecc-step-size]
>>        nand-ecc-step-size: [nand-ecc-strength]
>> +      amlogic,boot-pages: [nand-is-boot-medium, "amlogic,boot-page-step"]
>> +      amlogic,boot-page-step: [nand-is-boot-medium, "amlogic,boot-pages"]
>>  
>>  
>>  required:
> 
> 
> Thanks,
> Miquèl

Thanks, Arseniy
Miquel Raynal May 7, 2024, 7:27 a.m. UTC | #4
Hi Arseniy,

avkrasnov@salutedevices.com wrote on Tue, 7 May 2024 09:53:06 +0300:

> On 06.05.2024 16:48, Miquel Raynal wrote:
> > Hi Arseniy,
> > 
> > avkrasnov@salutedevices.com wrote on Tue, 16 Apr 2024 11:51:00 +0300:
> >   
> >> Boot ROM code on Meson requires that some pages on NAND must be written
> >> in special mode: "short" ECC mode where each block is 384 bytes and
> >> scrambling mode is on.  
> > 
> > Ok
> >   
> >> Such pages located with the specified interval within specified offset.  
> > 
> > I'm sorry I don't get that sentence.  
> 
> Sorry, I mean this (let me draw :) ) :
> 
> [ page 0 ][ page 1 ][ page 2 ][ page 3 ][ page 4 ][ page 5 ][ page 6 ][ page 7 ][ page 8 ][ page 9 ]
> 
> For example, we have 10 pages starting from the beginning of the chip - this is "within specified offset",
> e.g. offset is 10. BootROM on axg needs that (for example) every third page must be written in "special"
> mode: scrambling is on and ECC is 384 bytes. Such pages are 0, 2, 4, 6, 8. E.g. "specified interval" will
> be 3.

Shall be 2, no?

> 
> So:
> 
> amlogic,boot-pages: 10
> amlogic,boot-page-step: 3

Ok I get it. Thanks for the explanation. I don't really understand the
logic behind it though. Do you know why the bootROM would access only
one page over 2 or 3? Is there a default value? Is this configurable?

Thanks,
Miquèl
Arseniy Krasnov May 7, 2024, 7:35 a.m. UTC | #5
On 07.05.2024 10:27, Miquel Raynal wrote:
> Hi Arseniy,
> 
> avkrasnov@salutedevices.com wrote on Tue, 7 May 2024 09:53:06 +0300:
> 
>> On 06.05.2024 16:48, Miquel Raynal wrote:
>>> Hi Arseniy,
>>>
>>> avkrasnov@salutedevices.com wrote on Tue, 16 Apr 2024 11:51:00 +0300:
>>>   
>>>> Boot ROM code on Meson requires that some pages on NAND must be written
>>>> in special mode: "short" ECC mode where each block is 384 bytes and
>>>> scrambling mode is on.  
>>>
>>> Ok
>>>   
>>>> Such pages located with the specified interval within specified offset.  
>>>
>>> I'm sorry I don't get that sentence.  
>>
>> Sorry, I mean this (let me draw :) ) :
>>
>> [ page 0 ][ page 1 ][ page 2 ][ page 3 ][ page 4 ][ page 5 ][ page 6 ][ page 7 ][ page 8 ][ page 9 ]
>>
>> For example, we have 10 pages starting from the beginning of the chip - this is "within specified offset",
>> e.g. offset is 10. BootROM on axg needs that (for example) every third page must be written in "special"
>> mode: scrambling is on and ECC is 384 bytes. Such pages are 0, 2, 4, 6, 8. E.g. "specified interval" will
>> be 3.
> 
> Shall be 2, no?

yes, starting from 0 - then 2. e.g.
if (!(page_num % 2))
    boot ROM need this page

> 
>>
>> So:
>>
>> amlogic,boot-pages: 10
>> amlogic,boot-page-step: 3
> 
> Ok I get it. Thanks for the explanation. I don't really understand the
> logic behind it though. Do you know why the bootROM would access only
> one page over 2 or 3? Is there a default value? Is this configurable?

No, boot rom source is closed, I don't have access to it. I get this logic
from old version of vendor's uboot - in practice they use non 2 or 3, they
use hardcoded 128 step value. And amlogic,boot-pages is 1024

Thanks, Arseniy

> 
> Thanks,
> Miquèl
Miquel Raynal May 7, 2024, 8:05 a.m. UTC | #6
Hi Arseniy,

avkrasnov@salutedevices.com wrote on Tue, 7 May 2024 10:35:51 +0300:

> On 07.05.2024 10:27, Miquel Raynal wrote:
> > Hi Arseniy,
> > 
> > avkrasnov@salutedevices.com wrote on Tue, 7 May 2024 09:53:06 +0300:
> >   
> >> On 06.05.2024 16:48, Miquel Raynal wrote:  
> >>> Hi Arseniy,
> >>>
> >>> avkrasnov@salutedevices.com wrote on Tue, 16 Apr 2024 11:51:00 +0300:
> >>>     
> >>>> Boot ROM code on Meson requires that some pages on NAND must be written
> >>>> in special mode: "short" ECC mode where each block is 384 bytes and
> >>>> scrambling mode is on.    
> >>>
> >>> Ok
> >>>     
> >>>> Such pages located with the specified interval within specified offset.    
> >>>
> >>> I'm sorry I don't get that sentence.    
> >>
> >> Sorry, I mean this (let me draw :) ) :
> >>
> >> [ page 0 ][ page 1 ][ page 2 ][ page 3 ][ page 4 ][ page 5 ][ page 6 ][ page 7 ][ page 8 ][ page 9 ]
> >>
> >> For example, we have 10 pages starting from the beginning of the chip - this is "within specified offset",
> >> e.g. offset is 10. BootROM on axg needs that (for example) every third page must be written in "special"
> >> mode: scrambling is on and ECC is 384 bytes. Such pages are 0, 2, 4, 6, 8. E.g. "specified interval" will
> >> be 3.  
> > 
> > Shall be 2, no?  
> 
> yes, starting from 0 - then 2. e.g.
> if (!(page_num % 2))
>     boot ROM need this page
> 
> >   
> >>
> >> So:
> >>
> >> amlogic,boot-pages: 10
> >> amlogic,boot-page-step: 3  
> > 
> > Ok I get it. Thanks for the explanation. I don't really understand the
> > logic behind it though. Do you know why the bootROM would access only
> > one page over 2 or 3? Is there a default value? Is this configurable?  
> 
> No, boot rom source is closed, I don't have access to it. I get this logic
> from old version of vendor's uboot - in practice they use non 2 or 3, they
> use hardcoded 128 step value. And amlogic,boot-pages is 1024

Feels like they are trying to use only the first page of each block, no?

That's very weird but I understand better.

Thanks,
Miquèl
Arseniy Krasnov May 7, 2024, 8:11 a.m. UTC | #7
On 07.05.2024 11:05, Miquel Raynal wrote:
> Hi Arseniy,
> 
> avkrasnov@salutedevices.com wrote on Tue, 7 May 2024 10:35:51 +0300:
> 
>> On 07.05.2024 10:27, Miquel Raynal wrote:
>>> Hi Arseniy,
>>>
>>> avkrasnov@salutedevices.com wrote on Tue, 7 May 2024 09:53:06 +0300:
>>>   
>>>> On 06.05.2024 16:48, Miquel Raynal wrote:  
>>>>> Hi Arseniy,
>>>>>
>>>>> avkrasnov@salutedevices.com wrote on Tue, 16 Apr 2024 11:51:00 +0300:
>>>>>     
>>>>>> Boot ROM code on Meson requires that some pages on NAND must be written
>>>>>> in special mode: "short" ECC mode where each block is 384 bytes and
>>>>>> scrambling mode is on.    
>>>>>
>>>>> Ok
>>>>>     
>>>>>> Such pages located with the specified interval within specified offset.    
>>>>>
>>>>> I'm sorry I don't get that sentence.    
>>>>
>>>> Sorry, I mean this (let me draw :) ) :
>>>>
>>>> [ page 0 ][ page 1 ][ page 2 ][ page 3 ][ page 4 ][ page 5 ][ page 6 ][ page 7 ][ page 8 ][ page 9 ]
>>>>
>>>> For example, we have 10 pages starting from the beginning of the chip - this is "within specified offset",
>>>> e.g. offset is 10. BootROM on axg needs that (for example) every third page must be written in "special"
>>>> mode: scrambling is on and ECC is 384 bytes. Such pages are 0, 2, 4, 6, 8. E.g. "specified interval" will
>>>> be 3.  
>>>
>>> Shall be 2, no?  
>>
>> yes, starting from 0 - then 2. e.g.
>> if (!(page_num % 2))
>>     boot ROM need this page
>>
>>>   
>>>>
>>>> So:
>>>>
>>>> amlogic,boot-pages: 10
>>>> amlogic,boot-page-step: 3  
>>>
>>> Ok I get it. Thanks for the explanation. I don't really understand the
>>> logic behind it though. Do you know why the bootROM would access only
>>> one page over 2 or 3? Is there a default value? Is this configurable?  
>>
>> No, boot rom source is closed, I don't have access to it. I get this logic
>> from old version of vendor's uboot - in practice they use non 2 or 3, they
>> use hardcoded 128 step value. And amlogic,boot-pages is 1024
> 
> Feels like they are trying to use only the first page of each block, no?
> 
> That's very weird but I understand better.

A little bit no, they use every 128 page in range [0, 1024] pages. E.g. there will
be 8 such pages:
0
128
256
512
640
768
896
1024

They write some metadata about SoC to such pages.

Thanks, Arseniy

> 
> Thanks,
> Miquèl
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml b/Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml
index 57b6957c8415..67b2f7c1259c 100644
--- a/Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml
+++ b/Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml
@@ -64,11 +64,25 @@  patternProperties:
         items:
           maximum: 0
 
+      amlogic,boot-pages:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description:
+          Number of pages starting from 0, where special ECC
+          algorithm will be used by the driver.
+
+      amlogic,boot-page-step:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description:
+          Interval between pages, read/written by the driver with
+          special ECC algorithm.
+
     unevaluatedProperties: false
 
     dependencies:
       nand-ecc-strength: [nand-ecc-step-size]
       nand-ecc-step-size: [nand-ecc-strength]
+      amlogic,boot-pages: [nand-is-boot-medium, "amlogic,boot-page-step"]
+      amlogic,boot-page-step: [nand-is-boot-medium, "amlogic,boot-pages"]
 
 
 required: