18c2ecf20Sopenharmony_ciDevice tree bindings for GPMC connected NANDs 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ciGPMC connected NAND (found on OMAP boards) are represented as child nodes of 48c2ecf20Sopenharmony_cithe GPMC controller with a name of "nand". 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ciAll timing relevant properties as well as generic gpmc child properties are 78c2ecf20Sopenharmony_ciexplained in a separate documents - please refer to 88c2ecf20Sopenharmony_ciDocumentation/devicetree/bindings/memory-controllers/omap-gpmc.txt 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciFor NAND specific properties such as ECC modes or bus width, please refer to 118c2ecf20Sopenharmony_ciDocumentation/devicetree/bindings/mtd/nand-controller.yaml 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ciRequired properties: 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci - compatible: "ti,omap2-nand" 178c2ecf20Sopenharmony_ci - reg: range id (CS number), base offset and length of the 188c2ecf20Sopenharmony_ci NAND I/O space 198c2ecf20Sopenharmony_ci - interrupts: Two interrupt specifiers, one for fifoevent, one for termcount. 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ciOptional properties: 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci - nand-bus-width: Set this numeric value to 16 if the hardware 248c2ecf20Sopenharmony_ci is wired that way. If not specified, a bus 258c2ecf20Sopenharmony_ci width of 8 is assumed. 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci - ti,nand-ecc-opt: A string setting the ECC layout to use. One of: 288c2ecf20Sopenharmony_ci "sw" 1-bit Hamming ecc code via software 298c2ecf20Sopenharmony_ci "hw" <deprecated> use "ham1" instead 308c2ecf20Sopenharmony_ci "hw-romcode" <deprecated> use "ham1" instead 318c2ecf20Sopenharmony_ci "ham1" 1-bit Hamming ecc code 328c2ecf20Sopenharmony_ci "bch4" 4-bit BCH ecc code 338c2ecf20Sopenharmony_ci "bch8" 8-bit BCH ecc code 348c2ecf20Sopenharmony_ci "bch16" 16-bit BCH ECC code 358c2ecf20Sopenharmony_ci Refer below "How to select correct ECC scheme for your device ?" 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci - ti,nand-xfer-type: A string setting the data transfer type. One of: 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci "prefetch-polled" Prefetch polled mode (default) 408c2ecf20Sopenharmony_ci "polled" Polled mode, without prefetch 418c2ecf20Sopenharmony_ci "prefetch-dma" Prefetch enabled DMA mode 428c2ecf20Sopenharmony_ci "prefetch-irq" Prefetch enabled irq mode 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci - elm_id: <deprecated> use "ti,elm-id" instead 458c2ecf20Sopenharmony_ci - ti,elm-id: Specifies phandle of the ELM devicetree node. 468c2ecf20Sopenharmony_ci ELM is an on-chip hardware engine on TI SoC which is used for 478c2ecf20Sopenharmony_ci locating ECC errors for BCHx algorithms. SoC devices which have 488c2ecf20Sopenharmony_ci ELM hardware engines should specify this device node in .dtsi 498c2ecf20Sopenharmony_ci Using ELM for ECC error correction frees some CPU cycles. 508c2ecf20Sopenharmony_ci - rb-gpios: GPIO specifier for the ready/busy# pin. 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ciFor inline partition table parsing (optional): 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci - #address-cells: should be set to 1 558c2ecf20Sopenharmony_ci - #size-cells: should be set to 1 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciExample for an AM33xx board: 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci gpmc: gpmc@50000000 { 608c2ecf20Sopenharmony_ci compatible = "ti,am3352-gpmc"; 618c2ecf20Sopenharmony_ci ti,hwmods = "gpmc"; 628c2ecf20Sopenharmony_ci reg = <0x50000000 0x36c>; 638c2ecf20Sopenharmony_ci interrupts = <100>; 648c2ecf20Sopenharmony_ci gpmc,num-cs = <8>; 658c2ecf20Sopenharmony_ci gpmc,num-waitpins = <2>; 668c2ecf20Sopenharmony_ci #address-cells = <2>; 678c2ecf20Sopenharmony_ci #size-cells = <1>; 688c2ecf20Sopenharmony_ci ranges = <0 0 0x08000000 0x1000000>; /* CS0 space, 16MB */ 698c2ecf20Sopenharmony_ci elm_id = <&elm>; 708c2ecf20Sopenharmony_ci interrupt-controller; 718c2ecf20Sopenharmony_ci #interrupt-cells = <2>; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci nand@0,0 { 748c2ecf20Sopenharmony_ci compatible = "ti,omap2-nand"; 758c2ecf20Sopenharmony_ci reg = <0 0 4>; /* CS0, offset 0, NAND I/O window 4 */ 768c2ecf20Sopenharmony_ci interrupt-parent = <&gpmc>; 778c2ecf20Sopenharmony_ci interrupts = <0 IRQ_TYPE_NONE>, <1 IRQ_TYPE NONE>; 788c2ecf20Sopenharmony_ci nand-bus-width = <16>; 798c2ecf20Sopenharmony_ci ti,nand-ecc-opt = "bch8"; 808c2ecf20Sopenharmony_ci ti,nand-xfer-type = "polled"; 818c2ecf20Sopenharmony_ci rb-gpios = <&gpmc 0 GPIO_ACTIVE_HIGH>; /* gpmc_wait0 */ 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci gpmc,sync-clk-ps = <0>; 848c2ecf20Sopenharmony_ci gpmc,cs-on-ns = <0>; 858c2ecf20Sopenharmony_ci gpmc,cs-rd-off-ns = <44>; 868c2ecf20Sopenharmony_ci gpmc,cs-wr-off-ns = <44>; 878c2ecf20Sopenharmony_ci gpmc,adv-on-ns = <6>; 888c2ecf20Sopenharmony_ci gpmc,adv-rd-off-ns = <34>; 898c2ecf20Sopenharmony_ci gpmc,adv-wr-off-ns = <44>; 908c2ecf20Sopenharmony_ci gpmc,we-off-ns = <40>; 918c2ecf20Sopenharmony_ci gpmc,oe-off-ns = <54>; 928c2ecf20Sopenharmony_ci gpmc,access-ns = <64>; 938c2ecf20Sopenharmony_ci gpmc,rd-cycle-ns = <82>; 948c2ecf20Sopenharmony_ci gpmc,wr-cycle-ns = <82>; 958c2ecf20Sopenharmony_ci gpmc,wr-access-ns = <40>; 968c2ecf20Sopenharmony_ci gpmc,wr-data-mux-bus-ns = <0>; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci #address-cells = <1>; 998c2ecf20Sopenharmony_ci #size-cells = <1>; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci /* partitions go here */ 1028c2ecf20Sopenharmony_ci }; 1038c2ecf20Sopenharmony_ci }; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ciHow to select correct ECC scheme for your device ? 1068c2ecf20Sopenharmony_ci-------------------------------------------------- 1078c2ecf20Sopenharmony_ciHigher ECC scheme usually means better protection against bit-flips and 1088c2ecf20Sopenharmony_ciincreased system lifetime. However, selection of ECC scheme is dependent 1098c2ecf20Sopenharmony_cion various other factors also like; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci(1) support of built in hardware engines. 1128c2ecf20Sopenharmony_ci Some legacy OMAP SoC do not have ELM harware engine, so those SoC cannot 1138c2ecf20Sopenharmony_ci support ecc-schemes with hardware error-correction (BCHx_HW). However 1148c2ecf20Sopenharmony_ci such SoC can use ecc-schemes with software library for error-correction 1158c2ecf20Sopenharmony_ci (BCHx_HW_DETECTION_SW). The error correction capability with software 1168c2ecf20Sopenharmony_ci library remains equivalent to their hardware counter-part, but there is 1178c2ecf20Sopenharmony_ci slight CPU penalty when too many bit-flips are detected during reads. 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci(2) Device parameters like OOBSIZE. 1208c2ecf20Sopenharmony_ci Other factor which governs the selection of ecc-scheme is oob-size. 1218c2ecf20Sopenharmony_ci Higher ECC schemes require more OOB/Spare area to store ECC syndrome, 1228c2ecf20Sopenharmony_ci so the device should have enough free bytes available its OOB/Spare 1238c2ecf20Sopenharmony_ci area to accommodate ECC for entire page. In general following expression 1248c2ecf20Sopenharmony_ci helps in determining if given device can accommodate ECC syndrome: 1258c2ecf20Sopenharmony_ci "2 + (PAGESIZE / 512) * ECC_BYTES" <= OOBSIZE" 1268c2ecf20Sopenharmony_ci where 1278c2ecf20Sopenharmony_ci OOBSIZE number of bytes in OOB/spare area 1288c2ecf20Sopenharmony_ci PAGESIZE number of bytes in main-area of device page 1298c2ecf20Sopenharmony_ci ECC_BYTES number of ECC bytes generated to protect 1308c2ecf20Sopenharmony_ci 512 bytes of data, which is: 1318c2ecf20Sopenharmony_ci '3' for HAM1_xx ecc schemes 1328c2ecf20Sopenharmony_ci '7' for BCH4_xx ecc schemes 1338c2ecf20Sopenharmony_ci '14' for BCH8_xx ecc schemes 1348c2ecf20Sopenharmony_ci '26' for BCH16_xx ecc schemes 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci Example(a): For a device with PAGESIZE = 2048 and OOBSIZE = 64 and 1378c2ecf20Sopenharmony_ci trying to use BCH16 (ECC_BYTES=26) ecc-scheme. 1388c2ecf20Sopenharmony_ci Number of ECC bytes per page = (2 + (2048 / 512) * 26) = 106 B 1398c2ecf20Sopenharmony_ci which is greater than capacity of NAND device (OOBSIZE=64) 1408c2ecf20Sopenharmony_ci Hence, BCH16 cannot be supported on given device. But it can 1418c2ecf20Sopenharmony_ci probably use lower ecc-schemes like BCH8. 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci Example(b): For a device with PAGESIZE = 2048 and OOBSIZE = 128 and 1448c2ecf20Sopenharmony_ci trying to use BCH16 (ECC_BYTES=26) ecc-scheme. 1458c2ecf20Sopenharmony_ci Number of ECC bytes per page = (2 + (2048 / 512) * 26) = 106 B 1468c2ecf20Sopenharmony_ci which can be accommodated in the OOB/Spare area of this device 1478c2ecf20Sopenharmony_ci (OOBSIZE=128). So this device can use BCH16 ecc-scheme. 148