18c2ecf20Sopenharmony_ci* Broadcom STB NAND Controller 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ciThe Broadcom Set-Top Box NAND controller supports low-level access to raw NAND 48c2ecf20Sopenharmony_ciflash chips. It has a memory-mapped register interface for both control 58c2ecf20Sopenharmony_ciregisters and for its data input/output buffer. On some SoCs, this controller is 68c2ecf20Sopenharmony_cipaired with a custom DMA engine (inventively named "Flash DMA") which supports 78c2ecf20Sopenharmony_cibasic PROGRAM and READ functions, among other features. 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ciThis controller was originally designed for STB SoCs (BCM7xxx) but is now 108c2ecf20Sopenharmony_ciavailable on a variety of Broadcom SoCs, including some BCM3xxx, BCM63xx, and 118c2ecf20Sopenharmony_ciiProc/Cygnus. Its history includes several similar (but not fully register 128c2ecf20Sopenharmony_cicompatible) versions. 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ciRequired properties: 158c2ecf20Sopenharmony_ci- compatible : May contain an SoC-specific compatibility string (see below) 168c2ecf20Sopenharmony_ci to account for any SoC-specific hardware bits that may be 178c2ecf20Sopenharmony_ci added on top of the base core controller. 188c2ecf20Sopenharmony_ci In addition, must contain compatibility information about 198c2ecf20Sopenharmony_ci the core NAND controller, of the following form: 208c2ecf20Sopenharmony_ci "brcm,brcmnand" and an appropriate version compatibility 218c2ecf20Sopenharmony_ci string, like "brcm,brcmnand-v7.0" 228c2ecf20Sopenharmony_ci Possible values: 238c2ecf20Sopenharmony_ci brcm,brcmnand-v2.1 248c2ecf20Sopenharmony_ci brcm,brcmnand-v2.2 258c2ecf20Sopenharmony_ci brcm,brcmnand-v4.0 268c2ecf20Sopenharmony_ci brcm,brcmnand-v5.0 278c2ecf20Sopenharmony_ci brcm,brcmnand-v6.0 288c2ecf20Sopenharmony_ci brcm,brcmnand-v6.1 298c2ecf20Sopenharmony_ci brcm,brcmnand-v6.2 308c2ecf20Sopenharmony_ci brcm,brcmnand-v7.0 318c2ecf20Sopenharmony_ci brcm,brcmnand-v7.1 328c2ecf20Sopenharmony_ci brcm,brcmnand-v7.2 338c2ecf20Sopenharmony_ci brcm,brcmnand-v7.3 348c2ecf20Sopenharmony_ci brcm,brcmnand 358c2ecf20Sopenharmony_ci- reg : the register start and length for NAND register region. 368c2ecf20Sopenharmony_ci (optional) Flash DMA register range (if present) 378c2ecf20Sopenharmony_ci (optional) NAND flash cache range (if at non-standard offset) 388c2ecf20Sopenharmony_ci- reg-names : a list of the names corresponding to the previous register 398c2ecf20Sopenharmony_ci ranges. Should contain "nand" and (optionally) 408c2ecf20Sopenharmony_ci "flash-dma" or "flash-edu" and/or "nand-cache". 418c2ecf20Sopenharmony_ci- interrupts : The NAND CTLRDY interrupt, (if Flash DMA is available) 428c2ecf20Sopenharmony_ci FLASH_DMA_DONE and if EDU is avaialble and used FLASH_EDU_DONE 438c2ecf20Sopenharmony_ci- interrupt-names : May be "nand_ctlrdy" or "flash_dma_done" or "flash_edu_done", 448c2ecf20Sopenharmony_ci if broken out as individual interrupts. 458c2ecf20Sopenharmony_ci May be "nand", if the SoC has the individual NAND 468c2ecf20Sopenharmony_ci interrupts multiplexed behind another custom piece of 478c2ecf20Sopenharmony_ci hardware 488c2ecf20Sopenharmony_ci- #address-cells : <1> - subnodes give the chip-select number 498c2ecf20Sopenharmony_ci- #size-cells : <0> 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciOptional properties: 528c2ecf20Sopenharmony_ci- clock : reference to the clock for the NAND controller 538c2ecf20Sopenharmony_ci- clock-names : "nand" (required for the above clock) 548c2ecf20Sopenharmony_ci- brcm,nand-has-wp : Some versions of this IP include a write-protect 558c2ecf20Sopenharmony_ci (WP) control bit. It is always available on >= 568c2ecf20Sopenharmony_ci v7.0. Use this property to describe the rare 578c2ecf20Sopenharmony_ci earlier versions of this core that include WP 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci -- Additional SoC-specific NAND controller properties -- 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ciThe NAND controller is integrated differently on the variety of SoCs on which it 628c2ecf20Sopenharmony_ciis found. Part of this integration involves providing status and enable bits 638c2ecf20Sopenharmony_ciwith which to control the 8 exposed NAND interrupts, as well as hardware for 648c2ecf20Sopenharmony_ciconfiguring the endianness of the data bus. On some SoCs, these features are 658c2ecf20Sopenharmony_cihandled via standard, modular components (e.g., their interrupts look like a 668c2ecf20Sopenharmony_cinormal IRQ chip), but on others, they are controlled in unique and interesting 678c2ecf20Sopenharmony_ciways, sometimes with registers that lump multiple NAND-related functions 688c2ecf20Sopenharmony_citogether. The former case can be described simply by the standard interrupts 698c2ecf20Sopenharmony_ciproperties in the main controller node. But for the latter exceptional cases, 708c2ecf20Sopenharmony_ciwe define additional 'compatible' properties and associated register resources within the NAND controller node above. 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci - compatible: Can be one of several SoC-specific strings. Each SoC may have 738c2ecf20Sopenharmony_ci different requirements for its additional properties, as described below each 748c2ecf20Sopenharmony_ci bullet point below. 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci * "brcm,nand-bcm63138" 778c2ecf20Sopenharmony_ci - reg: (required) the 'NAND_INT_BASE' register range, with separate status 788c2ecf20Sopenharmony_ci and enable registers 798c2ecf20Sopenharmony_ci - reg-names: (required) "nand-int-base" 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci * "brcm,nand-bcm6368" 828c2ecf20Sopenharmony_ci - compatible: should contain "brcm,nand-bcm<soc>", "brcm,nand-bcm6368" 838c2ecf20Sopenharmony_ci - reg: (required) the 'NAND_INTR_BASE' register range, with combined status 848c2ecf20Sopenharmony_ci and enable registers, and boot address registers 858c2ecf20Sopenharmony_ci - reg-names: (required) "nand-int-base" 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci * "brcm,nand-iproc" 888c2ecf20Sopenharmony_ci - reg: (required) the "IDM" register range, for interrupt enable and APB 898c2ecf20Sopenharmony_ci bus access endianness configuration, and the "EXT" register range, 908c2ecf20Sopenharmony_ci for interrupt status/ack. 918c2ecf20Sopenharmony_ci - reg-names: (required) a list of the names corresponding to the previous 928c2ecf20Sopenharmony_ci register ranges. Should contain "iproc-idm" and "iproc-ext". 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci* NAND chip-select 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ciEach controller (compatible: "brcm,brcmnand") may contain one or more subnodes 988c2ecf20Sopenharmony_cito represent enabled chip-selects which (may) contain NAND flash chips. Their 998c2ecf20Sopenharmony_ciproperties are as follows. 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ciRequired properties: 1028c2ecf20Sopenharmony_ci- compatible : should contain "brcm,nandcs" 1038c2ecf20Sopenharmony_ci- reg : a single integer representing the chip-select 1048c2ecf20Sopenharmony_ci number (e.g., 0, 1, 2, etc.) 1058c2ecf20Sopenharmony_ci- #address-cells : see partition.txt 1068c2ecf20Sopenharmony_ci- #size-cells : see partition.txt 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ciOptional properties: 1098c2ecf20Sopenharmony_ci- nand-ecc-strength : see nand-controller.yaml 1108c2ecf20Sopenharmony_ci- nand-ecc-step-size : must be 512 or 1024. See nand-controller.yaml 1118c2ecf20Sopenharmony_ci- nand-on-flash-bbt : boolean, to enable the on-flash BBT for this 1128c2ecf20Sopenharmony_ci chip-select. See nand-controller.yaml 1138c2ecf20Sopenharmony_ci- brcm,nand-oob-sector-size : integer, to denote the spare area sector size 1148c2ecf20Sopenharmony_ci expected for the ECC layout in use. This size, in 1158c2ecf20Sopenharmony_ci addition to the strength and step-size, 1168c2ecf20Sopenharmony_ci determines how the hardware BCH engine will lay 1178c2ecf20Sopenharmony_ci out the parity bytes it stores on the flash. 1188c2ecf20Sopenharmony_ci This property can be automatically determined by 1198c2ecf20Sopenharmony_ci the flash geometry (particularly the NAND page 1208c2ecf20Sopenharmony_ci and OOB size) in many cases, but when booting 1218c2ecf20Sopenharmony_ci from NAND, the boot controller has only a limited 1228c2ecf20Sopenharmony_ci number of available options for its default ECC 1238c2ecf20Sopenharmony_ci layout. 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ciEach nandcs device node may optionally contain sub-nodes describing the flash 1268c2ecf20Sopenharmony_cipartition mapping. See partition.txt for more detail. 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ciExample: 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_cinand@f0442800 { 1328c2ecf20Sopenharmony_ci compatible = "brcm,brcmnand-v7.0", "brcm,brcmnand"; 1338c2ecf20Sopenharmony_ci reg = <0xF0442800 0x600>, 1348c2ecf20Sopenharmony_ci <0xF0443000 0x100>; 1358c2ecf20Sopenharmony_ci reg-names = "nand", "flash-dma"; 1368c2ecf20Sopenharmony_ci interrupt-parent = <&hif_intr2_intc>; 1378c2ecf20Sopenharmony_ci interrupts = <24>, <4>; 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci #address-cells = <1>; 1408c2ecf20Sopenharmony_ci #size-cells = <0>; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci nandcs@1 { 1438c2ecf20Sopenharmony_ci compatible = "brcm,nandcs"; 1448c2ecf20Sopenharmony_ci reg = <1>; // Chip select 1 1458c2ecf20Sopenharmony_ci nand-on-flash-bbt; 1468c2ecf20Sopenharmony_ci nand-ecc-strength = <12>; 1478c2ecf20Sopenharmony_ci nand-ecc-step-size = <512>; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci // Partitions 1508c2ecf20Sopenharmony_ci #address-cells = <1>; // <2>, for 64-bit offset 1518c2ecf20Sopenharmony_ci #size-cells = <1>; // <2>, for 64-bit length 1528c2ecf20Sopenharmony_ci flash0.rootfs@0 { 1538c2ecf20Sopenharmony_ci reg = <0 0x10000000>; 1548c2ecf20Sopenharmony_ci }; 1558c2ecf20Sopenharmony_ci flash0@0 { 1568c2ecf20Sopenharmony_ci reg = <0 0>; // MTDPART_SIZ_FULL 1578c2ecf20Sopenharmony_ci }; 1588c2ecf20Sopenharmony_ci flash0.kernel@10000000 { 1598c2ecf20Sopenharmony_ci reg = <0x10000000 0x400000>; 1608c2ecf20Sopenharmony_ci }; 1618c2ecf20Sopenharmony_ci }; 1628c2ecf20Sopenharmony_ci}; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_cinand@10000200 { 1658c2ecf20Sopenharmony_ci compatible = "brcm,nand-bcm63168", "brcm,nand-bcm6368", 1668c2ecf20Sopenharmony_ci "brcm,brcmnand-v4.0", "brcm,brcmnand"; 1678c2ecf20Sopenharmony_ci reg = <0x10000200 0x180>, 1688c2ecf20Sopenharmony_ci <0x10000600 0x200>, 1698c2ecf20Sopenharmony_ci <0x100000b0 0x10>; 1708c2ecf20Sopenharmony_ci reg-names = "nand", "nand-cache", "nand-int-base"; 1718c2ecf20Sopenharmony_ci interrupt-parent = <&periph_intc>; 1728c2ecf20Sopenharmony_ci interrupts = <50>; 1738c2ecf20Sopenharmony_ci clocks = <&periph_clk 20>; 1748c2ecf20Sopenharmony_ci clock-names = "nand"; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci #address-cells = <1>; 1778c2ecf20Sopenharmony_ci #size-cells = <0>; 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci nand0: nandcs@0 { 1808c2ecf20Sopenharmony_ci compatible = "brcm,nandcs"; 1818c2ecf20Sopenharmony_ci reg = <0>; 1828c2ecf20Sopenharmony_ci nand-on-flash-bbt; 1838c2ecf20Sopenharmony_ci nand-ecc-strength = <1>; 1848c2ecf20Sopenharmony_ci nand-ecc-step-size = <512>; 1858c2ecf20Sopenharmony_ci }; 1868c2ecf20Sopenharmony_ci}; 187