Skip to content

Commit d71dac3

Browse files
committed
Merge tag 'mtd/spi-mem-ecc-for-5.18' into mtd/next
Topic branch bringing-in changes related to the support of ECC engines that can be used by SPI controllers to manage SPI NANDs as well as possibly by parallel NAND controllers. In particular, it brings support for Macronix ECC engine that can be used with Macronix SPI controller. The changes touch the NAND core, the NAND ECC core, the spi-mem layer, a SPI controller driver and add a new NAND ECC driver, as well as a number of binding updates. Binding changes: * Vendor prefixes: Clarify Macronix prefix * SPI NAND: Convert spi-nand description file to yaml * Raw NAND chip: Create a NAND chip description * Raw NAND controller: - Harmonize the property types - Fix a comment in the examples - Fix the reg property description * Describe Macronix NAND ECC engine * Macronix SPI controller: - Document the nand-ecc-engine property - Convert to yaml - The interrupt property is not mandatory NAND core changes: * ECC: - Add infrastructure to support hardware engines - Add a new helper to retrieve the ECC context - Provide a helper to retrieve a pilelined engine device NAND-ECC changes: * Macronix ECC engine: - Add Macronix external ECC engine support - Support SPI pipelined mode SPI-NAND core changes: * Delay a little bit the dirmap creation * Create direct mapping descriptors for ECC operations SPI-NAND driver changes: * macronix: Use random program load SPI changes: * Macronix SPI controller: - Fix the transmit path - Create a helper to configure the controller before an operation - Create a helper to ease the start of an operation - Add support for direct mapping - Add support for pipelined ECC operations * spi-mem: - Introduce a capability structure - Check the controller extra capabilities - cadence-quadspi/mxic: Provide capability structures - Kill the spi_mem_dtr_supports_op() helper - Add an ecc parameter to the spi_mem_op structure
2 parents ad5e35f + 00360eb commit d71dac3

24 files changed

Lines changed: 1730 additions & 201 deletions
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/mtd/mxicy,nand-ecc-engine.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Macronix NAND ECC engine device tree bindings
8+
9+
maintainers:
10+
- Miquel Raynal <miquel.raynal@bootlin.com>
11+
12+
properties:
13+
compatible:
14+
const: mxicy,nand-ecc-engine-rev3
15+
16+
reg:
17+
maxItems: 1
18+
19+
clocks:
20+
maxItems: 1
21+
22+
interrupts:
23+
maxItems: 1
24+
25+
required:
26+
- compatible
27+
- reg
28+
29+
additionalProperties: false
30+
31+
examples:
32+
- |
33+
/* External configuration */
34+
spi_controller0: spi@43c30000 {
35+
compatible = "mxicy,mx25f0a-spi";
36+
reg = <0x43c30000 0x10000>, <0xa0000000 0x4000000>;
37+
reg-names = "regs", "dirmap";
38+
clocks = <&clkwizard 0>, <&clkwizard 1>, <&clkc 15>;
39+
clock-names = "send_clk", "send_dly_clk", "ps_clk";
40+
#address-cells = <1>;
41+
#size-cells = <0>;
42+
43+
flash@0 {
44+
compatible = "spi-nand";
45+
reg = <0>;
46+
nand-ecc-engine = <&ecc_engine0>;
47+
};
48+
};
49+
50+
ecc_engine0: ecc@43c40000 {
51+
compatible = "mxicy,nand-ecc-engine-rev3";
52+
reg = <0x43c40000 0x10000>;
53+
};
54+
55+
- |
56+
/* Pipelined configuration */
57+
spi_controller1: spi@43c30000 {
58+
compatible = "mxicy,mx25f0a-spi";
59+
reg = <0x43c30000 0x10000>, <0xa0000000 0x4000000>;
60+
reg-names = "regs", "dirmap";
61+
clocks = <&clkwizard 0>, <&clkwizard 1>, <&clkc 15>;
62+
clock-names = "send_clk", "send_dly_clk", "ps_clk";
63+
#address-cells = <1>;
64+
#size-cells = <0>;
65+
nand-ecc-engine = <&ecc_engine1>;
66+
67+
flash@0 {
68+
compatible = "spi-nand";
69+
reg = <0>;
70+
nand-ecc-engine = <&spi_controller1>;
71+
};
72+
};
73+
74+
ecc_engine1: ecc@43c40000 {
75+
compatible = "mxicy,nand-ecc-engine-rev3";
76+
reg = <0x43c40000 0x10000>;
77+
};
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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-chip.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: NAND Chip and NAND Controller Generic Binding
8+
9+
maintainers:
10+
- Miquel Raynal <miquel.raynal@bootlin.com>
11+
12+
description: |
13+
This file covers the generic description 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+
reg:
19+
description:
20+
Contains the chip-select IDs.
21+
22+
nand-ecc-engine:
23+
description: |
24+
A phandle on the hardware ECC engine if any. There are
25+
basically three possibilities:
26+
1/ The ECC engine is part of the NAND controller, in this
27+
case the phandle should reference the parent node.
28+
2/ The ECC engine is part of the NAND part (on-die), in this
29+
case the phandle should reference the node itself.
30+
3/ The ECC engine is external, in this case the phandle should
31+
reference the specific ECC engine node.
32+
$ref: /schemas/types.yaml#/definitions/phandle
33+
34+
nand-use-soft-ecc-engine:
35+
description: Use a software ECC engine.
36+
type: boolean
37+
38+
nand-no-ecc-engine:
39+
description: Do not use any ECC correction.
40+
type: boolean
41+
42+
nand-ecc-algo:
43+
description:
44+
Desired ECC algorithm.
45+
$ref: /schemas/types.yaml#/definitions/string
46+
enum: [hamming, bch, rs]
47+
48+
nand-ecc-strength:
49+
description:
50+
Maximum number of bits that can be corrected per ECC step.
51+
$ref: /schemas/types.yaml#/definitions/uint32
52+
minimum: 1
53+
54+
nand-ecc-step-size:
55+
description:
56+
Number of data bytes covered by a single ECC step.
57+
$ref: /schemas/types.yaml#/definitions/uint32
58+
minimum: 1
59+
60+
secure-regions:
61+
description:
62+
Regions in the NAND chip which are protected using a secure element
63+
like Trustzone. This property contains the start address and size of
64+
the secure regions present.
65+
$ref: /schemas/types.yaml#/definitions/uint64-matrix
66+
67+
required:
68+
- reg
69+
70+
additionalProperties: true

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

Lines changed: 11 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -39,60 +39,34 @@ properties:
3939
ranges: true
4040

4141
cs-gpios:
42-
minItems: 1
43-
maxItems: 8
4442
description:
4543
Array of chip-select available to the controller. The first
4644
entries are a 1:1 mapping of the available chip-select on the
4745
NAND controller (even if they are not used). As many additional
4846
chip-select as needed may follow and should be phandles of GPIO
4947
lines. 'reg' entries of the NAND chip subnodes become indexes of
5048
this array when this property is present.
49+
minItems: 1
50+
maxItems: 8
5151

5252
patternProperties:
5353
"^nand@[a-f0-9]$":
5454
type: object
55+
$ref: "nand-chip.yaml#"
56+
5557
properties:
5658
reg:
5759
description:
58-
Contains the native Ready/Busy IDs.
59-
60-
nand-ecc-engine:
61-
allOf:
62-
- $ref: /schemas/types.yaml#/definitions/phandle
63-
description: |
64-
A phandle on the hardware ECC engine if any. There are
65-
basically three possibilities:
66-
1/ The ECC engine is part of the NAND controller, in this
67-
case the phandle should reference the parent node.
68-
2/ The ECC engine is part of the NAND part (on-die), in this
69-
case the phandle should reference the node itself.
70-
3/ The ECC engine is external, in this case the phandle should
71-
reference the specific ECC engine node.
72-
73-
nand-use-soft-ecc-engine:
74-
type: boolean
75-
description: Use a software ECC engine.
76-
77-
nand-no-ecc-engine:
78-
type: boolean
79-
description: Do not use any ECC correction.
60+
Contains the chip-select IDs.
8061

8162
nand-ecc-placement:
82-
allOf:
83-
- $ref: /schemas/types.yaml#/definitions/string
84-
- enum: [ oob, interleaved ]
8563
description:
8664
Location of the ECC bytes. This location is unknown by default
8765
but can be explicitly set to "oob", if all ECC bytes are
8866
known to be stored in the OOB area, or "interleaved" if ECC
8967
bytes will be interleaved with regular data in the main area.
90-
91-
nand-ecc-algo:
92-
description:
93-
Desired ECC algorithm.
9468
$ref: /schemas/types.yaml#/definitions/string
95-
enum: [hamming, bch, rs]
69+
enum: [ oob, interleaved ]
9670

9771
nand-bus-width:
9872
description:
@@ -102,7 +76,6 @@ patternProperties:
10276
default: 8
10377

10478
nand-on-flash-bbt:
105-
$ref: /schemas/types.yaml#/definitions/flag
10679
description:
10780
With this property, the OS will search the device for a Bad
10881
Block Table (BBT). If not found, it will create one, reserve
@@ -111,21 +84,9 @@ patternProperties:
11184
few pages of all the blocks will be scanned at boot time to
11285
find Bad Block Markers (BBM). These markers will help to
11386
build a volatile BBT in RAM.
114-
115-
nand-ecc-strength:
116-
description:
117-
Maximum number of bits that can be corrected per ECC step.
118-
$ref: /schemas/types.yaml#/definitions/uint32
119-
minimum: 1
120-
121-
nand-ecc-step-size:
122-
description:
123-
Number of data bytes covered by a single ECC step.
124-
$ref: /schemas/types.yaml#/definitions/uint32
125-
minimum: 1
87+
$ref: /schemas/types.yaml#/definitions/flag
12688

12789
nand-ecc-maximize:
128-
$ref: /schemas/types.yaml#/definitions/flag
12990
description:
13091
Whether or not the ECC strength should be maximized. The
13192
maximum ECC strength is both controller and chip
@@ -134,18 +95,19 @@ patternProperties:
13495
constraint into account. This is particularly useful when
13596
only the in-band area is used by the upper layers, and you
13697
want to make your NAND as reliable as possible.
98+
$ref: /schemas/types.yaml#/definitions/flag
13799

138100
nand-is-boot-medium:
139-
$ref: /schemas/types.yaml#/definitions/flag
140101
description:
141102
Whether or not the NAND chip is a boot medium. Drivers might
142103
use this information to select ECC algorithms supported by
143104
the boot ROM or similar restrictions.
105+
$ref: /schemas/types.yaml#/definitions/flag
144106

145107
nand-rb:
146-
$ref: /schemas/types.yaml#/definitions/uint32-array
147108
description:
148109
Contains the native Ready/Busy IDs.
110+
$ref: /schemas/types.yaml#/definitions/uint32-array
149111

150112
rb-gpios:
151113
description:
@@ -154,13 +116,6 @@ patternProperties:
154116
Ready/Busy pins. Active state refers to the NAND ready state and
155117
should be set to GPIOD_ACTIVE_HIGH unless the signal is inverted.
156118

157-
secure-regions:
158-
$ref: /schemas/types.yaml#/definitions/uint64-matrix
159-
description:
160-
Regions in the NAND chip which are protected using a secure element
161-
like Trustzone. This property contains the start address and size of
162-
the secure regions present.
163-
164119
required:
165120
- reg
166121

@@ -181,10 +136,7 @@ examples:
181136
182137
nand@0 {
183138
reg = <0>; /* Native CS */
184-
nand-use-soft-ecc-engine;
185-
nand-ecc-algo = "bch";
186-
187-
/* controller specific properties */
139+
/* NAND chip specific properties */
188140
};
189141
190142
nand@1 {

Documentation/devicetree/bindings/mtd/spi-nand.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/mtd/spi-nand.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: SPI-NAND flash device tree bindings
8+
9+
maintainers:
10+
- Miquel Raynal <miquel.raynal@bootlin.com>
11+
12+
allOf:
13+
- $ref: "nand-chip.yaml#"
14+
15+
properties:
16+
compatible:
17+
const: spi-nand
18+
19+
reg:
20+
description: Encode the chip-select line on the SPI bus
21+
maxItems: 1
22+
23+
required:
24+
- compatible
25+
- reg
26+
27+
unevaluatedProperties: false
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/spi/mxicy,mx25f0a-spi.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Macronix SPI controller device tree bindings
8+
9+
maintainers:
10+
- Miquel Raynal <miquel.raynal@bootlin.com>
11+
12+
allOf:
13+
- $ref: "spi-controller.yaml#"
14+
15+
properties:
16+
compatible:
17+
const: mxicy,mx25f0a-spi
18+
19+
reg:
20+
minItems: 2
21+
maxItems: 2
22+
23+
reg-names:
24+
items:
25+
- const: regs
26+
- const: dirmap
27+
28+
interrupts:
29+
maxItems: 1
30+
31+
clocks:
32+
minItems: 3
33+
maxItems: 3
34+
35+
clock-names:
36+
items:
37+
- const: send_clk
38+
- const: send_dly_clk
39+
- const: ps_clk
40+
41+
nand-ecc-engine:
42+
description: NAND ECC engine used by the SPI controller in order to perform
43+
on-the-fly correction when using a SPI-NAND memory.
44+
$ref: /schemas/types.yaml#/definitions/phandle
45+
46+
required:
47+
- compatible
48+
- reg
49+
- reg-names
50+
- clocks
51+
- clock-names
52+
53+
unevaluatedProperties: false
54+
55+
examples:
56+
- |
57+
spi@43c30000 {
58+
compatible = "mxicy,mx25f0a-spi";
59+
reg = <0x43c30000 0x10000>, <0xa0000000 0x20000000>;
60+
reg-names = "regs", "dirmap";
61+
clocks = <&clkwizard 0>, <&clkwizard 1>, <&clkc 18>;
62+
clock-names = "send_clk", "send_dly_clk", "ps_clk";
63+
#address-cells = <1>;
64+
#size-cells = <0>;
65+
};

0 commit comments

Comments
 (0)