Skip to content

Commit 0ba8da2

Browse files
nxpfranklimiquelraynal
authored andcommitted
dt-bindings: mtd: refactor NAND bindings and add nand-controller-legacy.yaml
The modern NAND controller binding requires NAND chips to be described as child nodes of the controller, for example: nand-controller { ... nand@0 { /* raw NAND chip properties */ }; }; However, many existing device trees place NAND chip properties directly within the controller node because those controllers support only a single chip. This layout is still widely used by older platforms and by other DT consumers such as U-Boot. Migrating all existing users to the new layout will take time. Several kernel drivers, such as ams-delta.c, davinci_nand.c and fsmc_nand.c, still expect the legacy layout where raw NAND properties are defined in the controller node. To support both layouts during the transition: - Extract NAND chip-related properties into separate schemas (nand-property.yaml and raw-nand-property.yaml) from nand-chip.yaml and raw-nand-chip.yaml. - Introduce nand-controller-legacy.yaml to allow both the legacy and modern layouts. - Add a select condition in nand-controller.yaml to prevent node name pattern matching for fsl,* NAND controllers. Keep compatibility with existing device trees while allowing gradual migration to the modern binding structure. Signed-off-by: Frank Li <Frank.Li@nxp.com> Reviewed-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent 25a915f commit 0ba8da2

6 files changed

Lines changed: 231 additions & 118 deletions

File tree

Documentation/devicetree/bindings/mtd/nand-chip.yaml

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ maintainers:
1111

1212
allOf:
1313
- $ref: mtd.yaml#
14+
- $ref: nand-property.yaml
1415

1516
description: |
1617
This file covers the generic description of a NAND chip. It implies that the
@@ -22,51 +23,6 @@ properties:
2223
description:
2324
Contains the chip-select IDs.
2425

25-
nand-ecc-engine:
26-
description: |
27-
A phandle on the hardware ECC engine if any. There are
28-
basically three possibilities:
29-
1/ The ECC engine is part of the NAND controller, in this
30-
case the phandle should reference the parent node.
31-
2/ The ECC engine is part of the NAND part (on-die), in this
32-
case the phandle should reference the node itself.
33-
3/ The ECC engine is external, in this case the phandle should
34-
reference the specific ECC engine node.
35-
$ref: /schemas/types.yaml#/definitions/phandle
36-
37-
nand-use-soft-ecc-engine:
38-
description: Use a software ECC engine.
39-
type: boolean
40-
41-
nand-no-ecc-engine:
42-
description: Do not use any ECC correction.
43-
type: boolean
44-
45-
nand-ecc-algo:
46-
description:
47-
Desired ECC algorithm.
48-
$ref: /schemas/types.yaml#/definitions/string
49-
enum: [hamming, bch, rs]
50-
51-
nand-ecc-strength:
52-
description:
53-
Maximum number of bits that can be corrected per ECC step.
54-
$ref: /schemas/types.yaml#/definitions/uint32
55-
minimum: 1
56-
57-
nand-ecc-step-size:
58-
description:
59-
Number of data bytes covered by a single ECC step.
60-
$ref: /schemas/types.yaml#/definitions/uint32
61-
minimum: 1
62-
63-
secure-regions:
64-
description:
65-
Regions in the NAND chip which are protected using a secure element
66-
like Trustzone. This property contains the start address and size of
67-
the secure regions present.
68-
$ref: /schemas/types.yaml#/definitions/uint64-matrix
69-
7026
required:
7127
- reg
7228

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/mtd/nand-controller-legacy.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: NAND Controller Common Properties
8+
9+
maintainers:
10+
- Miquel Raynal <miquel.raynal@bootlin.com>
11+
- Richard Weinberger <richard@nod.at>
12+
13+
description: >
14+
The NAND controller should be represented with its own DT node, and
15+
all NAND chips attached to this controller should be defined as
16+
children nodes of the NAND controller. This representation should be
17+
enforced even for simple controllers supporting only one chip.
18+
19+
This is only for legacy nand controller, new controller should use
20+
nand-controller.yaml
21+
22+
properties:
23+
24+
"#address-cells":
25+
const: 1
26+
27+
"#size-cells":
28+
enum: [0, 1]
29+
30+
ranges: true
31+
32+
cs-gpios:
33+
description:
34+
Array of chip-select available to the controller. The first
35+
entries are a 1:1 mapping of the available chip-select on the
36+
NAND controller (even if they are not used). As many additional
37+
chip-select as needed may follow and should be phandles of GPIO
38+
lines. 'reg' entries of the NAND chip subnodes become indexes of
39+
this array when this property is present.
40+
minItems: 1
41+
maxItems: 8
42+
43+
partitions:
44+
type: object
45+
46+
required:
47+
- compatible
48+
49+
patternProperties:
50+
"^nand@[a-f0-9]$":
51+
type: object
52+
$ref: raw-nand-chip.yaml#
53+
54+
"^partition@[0-9a-f]+$":
55+
type: object
56+
$ref: /schemas/mtd/partitions/partition.yaml#/$defs/partition-node
57+
deprecated: true
58+
59+
allOf:
60+
- $ref: raw-nand-property.yaml#
61+
- $ref: nand-property.yaml#
62+
63+
# This is a generic file other binding inherit from and extend
64+
additionalProperties: true
65+

Documentation/devicetree/bindings/mtd/nand-controller.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ description: |
1616
children nodes of the NAND controller. This representation should be
1717
enforced even for simple controllers supporting only one chip.
1818
19+
select: false
20+
1921
properties:
2022
$nodename:
2123
pattern: "^nand-controller(@.*)?"
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/mtd/nand-property.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: NAND Chip Common Properties
8+
9+
maintainers:
10+
- Miquel Raynal <miquel.raynal@bootlin.com>
11+
12+
description: |
13+
This file covers the generic properties of a NAND chip. It implies that the
14+
bus interface should not be taken into account: both raw NAND devices and
15+
SPI-NAND devices are concerned by this description.
16+
17+
properties:
18+
nand-ecc-engine:
19+
description: |
20+
A phandle on the hardware ECC engine if any. There are
21+
basically three possibilities:
22+
1/ The ECC engine is part of the NAND controller, in this
23+
case the phandle should reference the parent node.
24+
2/ The ECC engine is part of the NAND part (on-die), in this
25+
case the phandle should reference the node itself.
26+
3/ The ECC engine is external, in this case the phandle should
27+
reference the specific ECC engine node.
28+
$ref: /schemas/types.yaml#/definitions/phandle
29+
30+
nand-use-soft-ecc-engine:
31+
description: Use a software ECC engine.
32+
type: boolean
33+
34+
nand-no-ecc-engine:
35+
description: Do not use any ECC correction.
36+
type: boolean
37+
38+
nand-ecc-algo:
39+
description:
40+
Desired ECC algorithm.
41+
$ref: /schemas/types.yaml#/definitions/string
42+
enum: [hamming, bch, rs]
43+
44+
nand-ecc-strength:
45+
description:
46+
Maximum number of bits that can be corrected per ECC step.
47+
$ref: /schemas/types.yaml#/definitions/uint32
48+
minimum: 1
49+
50+
nand-ecc-step-size:
51+
description:
52+
Number of data bytes covered by a single ECC step.
53+
$ref: /schemas/types.yaml#/definitions/uint32
54+
minimum: 1
55+
56+
secure-regions:
57+
description:
58+
Regions in the NAND chip which are protected using a secure element
59+
like Trustzone. This property contains the start address and size of
60+
the secure regions present.
61+
$ref: /schemas/types.yaml#/definitions/uint64-matrix
62+
63+
# This file can be referenced by more specific devices (like spi-nands)
64+
additionalProperties: true

Documentation/devicetree/bindings/mtd/raw-nand-chip.yaml

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ maintainers:
1111

1212
allOf:
1313
- $ref: nand-chip.yaml#
14+
- $ref: raw-nand-property.yaml#
1415

1516
description: |
1617
The ECC strength and ECC step size properties define the user
@@ -31,79 +32,6 @@ properties:
3132
description:
3233
Contains the chip-select IDs.
3334

34-
nand-ecc-placement:
35-
description:
36-
Location of the ECC bytes. This location is unknown by default
37-
but can be explicitly set to "oob", if all ECC bytes are
38-
known to be stored in the OOB area, or "interleaved" if ECC
39-
bytes will be interleaved with regular data in the main area.
40-
$ref: /schemas/types.yaml#/definitions/string
41-
enum: [ oob, interleaved ]
42-
deprecated: true
43-
44-
nand-ecc-mode:
45-
description:
46-
Legacy ECC configuration mixing the ECC engine choice and
47-
configuration.
48-
$ref: /schemas/types.yaml#/definitions/string
49-
enum: [none, soft, soft_bch, hw, hw_syndrome, on-die]
50-
deprecated: true
51-
52-
nand-bus-width:
53-
description:
54-
Bus width to the NAND chip
55-
$ref: /schemas/types.yaml#/definitions/uint32
56-
enum: [8, 16]
57-
default: 8
58-
59-
nand-on-flash-bbt:
60-
description:
61-
With this property, the OS will search the device for a Bad
62-
Block Table (BBT). If not found, it will create one, reserve
63-
a few blocks at the end of the device to store it and update
64-
it as the device ages. Otherwise, the out-of-band area of a
65-
few pages of all the blocks will be scanned at boot time to
66-
find Bad Block Markers (BBM). These markers will help to
67-
build a volatile BBT in RAM.
68-
$ref: /schemas/types.yaml#/definitions/flag
69-
70-
nand-ecc-maximize:
71-
description:
72-
Whether or not the ECC strength should be maximized. The
73-
maximum ECC strength is both controller and chip
74-
dependent. The ECC engine has to select the ECC config
75-
providing the best strength and taking the OOB area size
76-
constraint into account. This is particularly useful when
77-
only the in-band area is used by the upper layers, and you
78-
want to make your NAND as reliable as possible.
79-
$ref: /schemas/types.yaml#/definitions/flag
80-
81-
nand-is-boot-medium:
82-
description:
83-
Whether or not the NAND chip is a boot medium. Drivers might
84-
use this information to select ECC algorithms supported by
85-
the boot ROM or similar restrictions.
86-
$ref: /schemas/types.yaml#/definitions/flag
87-
88-
nand-rb:
89-
description:
90-
Contains the native Ready/Busy IDs.
91-
$ref: /schemas/types.yaml#/definitions/uint32-array
92-
93-
rb-gpios:
94-
description:
95-
Contains one or more GPIO descriptor (the numper of descriptor
96-
depends on the number of R/B pins exposed by the flash) for the
97-
Ready/Busy pins. Active state refers to the NAND ready state and
98-
should be set to GPIOD_ACTIVE_HIGH unless the signal is inverted.
99-
100-
wp-gpios:
101-
description:
102-
Contains one GPIO descriptor for the Write Protect pin.
103-
Active state refers to the NAND Write Protect state and should be
104-
set to GPIOD_ACTIVE_LOW unless the signal is inverted.
105-
maxItems: 1
106-
10735
required:
10836
- reg
10937

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/mtd/raw-nand-property.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Raw NAND Chip Common Properties
8+
9+
maintainers:
10+
- Miquel Raynal <miquel.raynal@bootlin.com>
11+
12+
description: |
13+
The ECC strength and ECC step size properties define the user
14+
desires in terms of correction capability of a controller. Together,
15+
they request the ECC engine to correct {strength} bit errors per
16+
{size} bytes for a particular raw NAND chip.
17+
18+
The interpretation of these parameters is implementation-defined, so
19+
not all implementations must support all possible
20+
combinations. However, implementations are encouraged to further
21+
specify the value(s) they support.
22+
23+
properties:
24+
nand-ecc-placement:
25+
description:
26+
Location of the ECC bytes. This location is unknown by default
27+
but can be explicitly set to "oob", if all ECC bytes are
28+
known to be stored in the OOB area, or "interleaved" if ECC
29+
bytes will be interleaved with regular data in the main area.
30+
$ref: /schemas/types.yaml#/definitions/string
31+
enum: [ oob, interleaved ]
32+
deprecated: true
33+
34+
nand-ecc-mode:
35+
description:
36+
Legacy ECC configuration mixing the ECC engine choice and
37+
configuration.
38+
$ref: /schemas/types.yaml#/definitions/string
39+
enum: [none, soft, soft_bch, hw, hw_syndrome, on-die]
40+
deprecated: true
41+
42+
nand-bus-width:
43+
description:
44+
Bus width to the NAND chip
45+
$ref: /schemas/types.yaml#/definitions/uint32
46+
enum: [8, 16]
47+
default: 8
48+
49+
nand-on-flash-bbt:
50+
description:
51+
With this property, the OS will search the device for a Bad
52+
Block Table (BBT). If not found, it will create one, reserve
53+
a few blocks at the end of the device to store it and update
54+
it as the device ages. Otherwise, the out-of-band area of a
55+
few pages of all the blocks will be scanned at boot time to
56+
find Bad Block Markers (BBM). These markers will help to
57+
build a volatile BBT in RAM.
58+
$ref: /schemas/types.yaml#/definitions/flag
59+
60+
nand-ecc-maximize:
61+
description:
62+
Whether or not the ECC strength should be maximized. The
63+
maximum ECC strength is both controller and chip
64+
dependent. The ECC engine has to select the ECC config
65+
providing the best strength and taking the OOB area size
66+
constraint into account. This is particularly useful when
67+
only the in-band area is used by the upper layers, and you
68+
want to make your NAND as reliable as possible.
69+
$ref: /schemas/types.yaml#/definitions/flag
70+
71+
nand-is-boot-medium:
72+
description:
73+
Whether or not the NAND chip is a boot medium. Drivers might
74+
use this information to select ECC algorithms supported by
75+
the boot ROM or similar restrictions.
76+
$ref: /schemas/types.yaml#/definitions/flag
77+
78+
nand-rb:
79+
description:
80+
Contains the native Ready/Busy IDs.
81+
$ref: /schemas/types.yaml#/definitions/uint32-array
82+
83+
rb-gpios:
84+
description:
85+
Contains one or more GPIO descriptor (the numper of descriptor
86+
depends on the number of R/B pins exposed by the flash) for the
87+
Ready/Busy pins. Active state refers to the NAND ready state and
88+
should be set to GPIOD_ACTIVE_HIGH unless the signal is inverted.
89+
90+
wp-gpios:
91+
description:
92+
Contains one GPIO descriptor for the Write Protect pin.
93+
Active state refers to the NAND Write Protect state and should be
94+
set to GPIOD_ACTIVE_LOW unless the signal is inverted.
95+
maxItems: 1
96+
97+
# This is a generic file other binding inherit from and extend
98+
additionalProperties: true

0 commit comments

Comments
 (0)