18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci%YAML 1.2
38c2ecf20Sopenharmony_ci---
48c2ecf20Sopenharmony_ci$id: http://devicetree.org/schemas/mtd/nand-controller.yaml#
58c2ecf20Sopenharmony_ci$schema: http://devicetree.org/meta-schemas/core.yaml#
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_cititle: NAND Chip and NAND Controller Generic Binding
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_cimaintainers:
108c2ecf20Sopenharmony_ci  - Miquel Raynal <miquel.raynal@bootlin.com>
118c2ecf20Sopenharmony_ci  - Richard Weinberger <richard@nod.at>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_cidescription: |
148c2ecf20Sopenharmony_ci  The NAND controller should be represented with its own DT node, and
158c2ecf20Sopenharmony_ci  all NAND chips attached to this controller should be defined as
168c2ecf20Sopenharmony_ci  children nodes of the NAND controller. This representation should be
178c2ecf20Sopenharmony_ci  enforced even for simple controllers supporting only one chip.
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci  The ECC strength and ECC step size properties define the user
208c2ecf20Sopenharmony_ci  desires in terms of correction capability of a controller. Together,
218c2ecf20Sopenharmony_ci  they request the ECC engine to correct {strength} bit errors per
228c2ecf20Sopenharmony_ci  {size} bytes.
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci  The interpretation of these parameters is implementation-defined, so
258c2ecf20Sopenharmony_ci  not all implementations must support all possible
268c2ecf20Sopenharmony_ci  combinations. However, implementations are encouraged to further
278c2ecf20Sopenharmony_ci  specify the value(s) they support.
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ciproperties:
308c2ecf20Sopenharmony_ci  $nodename:
318c2ecf20Sopenharmony_ci    pattern: "^nand-controller(@.*)?"
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci  "#address-cells":
348c2ecf20Sopenharmony_ci    const: 1
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci  "#size-cells":
378c2ecf20Sopenharmony_ci    const: 0
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci  ranges: true
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cipatternProperties:
428c2ecf20Sopenharmony_ci  "^nand@[a-f0-9]$":
438c2ecf20Sopenharmony_ci    type: object
448c2ecf20Sopenharmony_ci    properties:
458c2ecf20Sopenharmony_ci      reg:
468c2ecf20Sopenharmony_ci        description:
478c2ecf20Sopenharmony_ci          Contains the chip-select IDs.
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci      nand-ecc-mode:
508c2ecf20Sopenharmony_ci        description:
518c2ecf20Sopenharmony_ci          Desired ECC engine, either hardware (most of the time
528c2ecf20Sopenharmony_ci          embedded in the NAND controller) or software correction
538c2ecf20Sopenharmony_ci          (Linux will handle the calculations). soft_bch is deprecated
548c2ecf20Sopenharmony_ci          and should be replaced by soft and nand-ecc-algo.
558c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/string
568c2ecf20Sopenharmony_ci        enum: [none, soft, hw, hw_syndrome, hw_oob_first, on-die]
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci      nand-ecc-engine:
598c2ecf20Sopenharmony_ci        allOf:
608c2ecf20Sopenharmony_ci          - $ref: /schemas/types.yaml#/definitions/phandle
618c2ecf20Sopenharmony_ci        description: |
628c2ecf20Sopenharmony_ci          A phandle on the hardware ECC engine if any. There are
638c2ecf20Sopenharmony_ci          basically three possibilities:
648c2ecf20Sopenharmony_ci          1/ The ECC engine is part of the NAND controller, in this
658c2ecf20Sopenharmony_ci          case the phandle should reference the parent node.
668c2ecf20Sopenharmony_ci          2/ The ECC engine is part of the NAND part (on-die), in this
678c2ecf20Sopenharmony_ci          case the phandle should reference the node itself.
688c2ecf20Sopenharmony_ci          3/ The ECC engine is external, in this case the phandle should
698c2ecf20Sopenharmony_ci          reference the specific ECC engine node.
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci      nand-use-soft-ecc-engine:
728c2ecf20Sopenharmony_ci        type: boolean
738c2ecf20Sopenharmony_ci        description: Use a software ECC engine.
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci      nand-no-ecc-engine:
768c2ecf20Sopenharmony_ci        type: boolean
778c2ecf20Sopenharmony_ci        description: Do not use any ECC correction.
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci      nand-ecc-placement:
808c2ecf20Sopenharmony_ci        allOf:
818c2ecf20Sopenharmony_ci          - $ref: /schemas/types.yaml#/definitions/string
828c2ecf20Sopenharmony_ci          - enum: [ oob, interleaved ]
838c2ecf20Sopenharmony_ci        description:
848c2ecf20Sopenharmony_ci          Location of the ECC bytes. This location is unknown by default
858c2ecf20Sopenharmony_ci          but can be explicitly set to "oob", if all ECC bytes are
868c2ecf20Sopenharmony_ci          known to be stored in the OOB area, or "interleaved" if ECC
878c2ecf20Sopenharmony_ci          bytes will be interleaved with regular data in the main area.
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci      nand-ecc-algo:
908c2ecf20Sopenharmony_ci        description:
918c2ecf20Sopenharmony_ci          Desired ECC algorithm.
928c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/string
938c2ecf20Sopenharmony_ci        enum: [hamming, bch, rs]
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci      nand-bus-width:
968c2ecf20Sopenharmony_ci        description:
978c2ecf20Sopenharmony_ci          Bus width to the NAND chip
988c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/uint32
998c2ecf20Sopenharmony_ci        enum: [8, 16]
1008c2ecf20Sopenharmony_ci        default: 8
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci      nand-on-flash-bbt:
1038c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/flag
1048c2ecf20Sopenharmony_ci        description:
1058c2ecf20Sopenharmony_ci          With this property, the OS will search the device for a Bad
1068c2ecf20Sopenharmony_ci          Block Table (BBT). If not found, it will create one, reserve
1078c2ecf20Sopenharmony_ci          a few blocks at the end of the device to store it and update
1088c2ecf20Sopenharmony_ci          it as the device ages. Otherwise, the out-of-band area of a
1098c2ecf20Sopenharmony_ci          few pages of all the blocks will be scanned at boot time to
1108c2ecf20Sopenharmony_ci          find Bad Block Markers (BBM). These markers will help to
1118c2ecf20Sopenharmony_ci          build a volatile BBT in RAM.
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci      nand-ecc-strength:
1148c2ecf20Sopenharmony_ci        description:
1158c2ecf20Sopenharmony_ci          Maximum number of bits that can be corrected per ECC step.
1168c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/uint32
1178c2ecf20Sopenharmony_ci        minimum: 1
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci      nand-ecc-step-size:
1208c2ecf20Sopenharmony_ci        description:
1218c2ecf20Sopenharmony_ci          Number of data bytes covered by a single ECC step.
1228c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/uint32
1238c2ecf20Sopenharmony_ci        minimum: 1
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci      nand-ecc-maximize:
1268c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/flag
1278c2ecf20Sopenharmony_ci        description:
1288c2ecf20Sopenharmony_ci          Whether or not the ECC strength should be maximized. The
1298c2ecf20Sopenharmony_ci          maximum ECC strength is both controller and chip
1308c2ecf20Sopenharmony_ci          dependent. The ECC engine has to select the ECC config
1318c2ecf20Sopenharmony_ci          providing the best strength and taking the OOB area size
1328c2ecf20Sopenharmony_ci          constraint into account. This is particularly useful when
1338c2ecf20Sopenharmony_ci          only the in-band area is used by the upper layers, and you
1348c2ecf20Sopenharmony_ci          want to make your NAND as reliable as possible.
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci      nand-is-boot-medium:
1378c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/flag
1388c2ecf20Sopenharmony_ci        description:
1398c2ecf20Sopenharmony_ci          Whether or not the NAND chip is a boot medium. Drivers might
1408c2ecf20Sopenharmony_ci          use this information to select ECC algorithms supported by
1418c2ecf20Sopenharmony_ci          the boot ROM or similar restrictions.
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci      nand-rb:
1448c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/uint32-array
1458c2ecf20Sopenharmony_ci        description:
1468c2ecf20Sopenharmony_ci          Contains the native Ready/Busy IDs.
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci      rb-gpios:
1498c2ecf20Sopenharmony_ci        description:
1508c2ecf20Sopenharmony_ci          Contains one or more GPIO descriptor (the numper of descriptor
1518c2ecf20Sopenharmony_ci          depends on the number of R/B pins exposed by the flash) for the
1528c2ecf20Sopenharmony_ci          Ready/Busy pins. Active state refers to the NAND ready state and
1538c2ecf20Sopenharmony_ci          should be set to GPIOD_ACTIVE_HIGH unless the signal is inverted.
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci    required:
1568c2ecf20Sopenharmony_ci      - reg
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_cirequired:
1598c2ecf20Sopenharmony_ci  - "#address-cells"
1608c2ecf20Sopenharmony_ci  - "#size-cells"
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ciadditionalProperties: true
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ciexamples:
1658c2ecf20Sopenharmony_ci  - |
1668c2ecf20Sopenharmony_ci    nand-controller {
1678c2ecf20Sopenharmony_ci      #address-cells = <1>;
1688c2ecf20Sopenharmony_ci      #size-cells = <0>;
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci      /* controller specific properties */
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci      nand@0 {
1738c2ecf20Sopenharmony_ci        reg = <0>;
1748c2ecf20Sopenharmony_ci        nand-ecc-mode = "soft";
1758c2ecf20Sopenharmony_ci        nand-ecc-algo = "bch";
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci        /* NAND chip specific properties */
1788c2ecf20Sopenharmony_ci      };
1798c2ecf20Sopenharmony_ci    };
180