18c2ecf20Sopenharmony_ciFlash partitions in device tree 28c2ecf20Sopenharmony_ci=============================== 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ciFlash devices can be partitioned into one or more functional ranges (e.g. "boot 58c2ecf20Sopenharmony_cicode", "nvram", "kernel"). 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciDifferent devices may be partitioned in a different ways. Some may use a fixed 88c2ecf20Sopenharmony_ciflash layout set at production time. Some may use on-flash table that describes 98c2ecf20Sopenharmony_cithe geometry and naming/purpose of each functional region. It is also possible 108c2ecf20Sopenharmony_cito see these methods mixed. 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciTo assist system software in locating partitions, we allow describing which 138c2ecf20Sopenharmony_cimethod is used for a given flash device. To describe the method there should be 148c2ecf20Sopenharmony_cia subnode of the flash device that is named 'partitions'. It must have a 158c2ecf20Sopenharmony_ci'compatible' property, which is used to identify the method to use. 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciWhen a single partition is represented with a DT node (it depends on a used 188c2ecf20Sopenharmony_ciformat) it may also be described using above rules ('compatible' and optionally 198c2ecf20Sopenharmony_cisome extra properties / subnodes). It allows describing more complex, 208c2ecf20Sopenharmony_cihierarchical (multi-level) layouts and should be used if there is some 218c2ecf20Sopenharmony_cisignificant relation between partitions or some partition internally uses 228c2ecf20Sopenharmony_cianother partitioning method. 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciAvailable bindings are listed in the "partitions" subdirectory. 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ciFixed Partitions 288c2ecf20Sopenharmony_ci================ 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ciPartitions can be represented by sub-nodes of a flash device. This can be used 318c2ecf20Sopenharmony_cion platforms which have strong conventions about which portions of a flash are 328c2ecf20Sopenharmony_ciused for what purposes, but which don't use an on-flash partition table such 338c2ecf20Sopenharmony_cias RedBoot. 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciThe partition table should be a subnode of the flash node and should be named 368c2ecf20Sopenharmony_ci'partitions'. This node should have the following property: 378c2ecf20Sopenharmony_ci- compatible : (required) must be "fixed-partitions" 388c2ecf20Sopenharmony_ciPartitions are then defined in subnodes of the partitions node. 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciFor backwards compatibility partitions as direct subnodes of the flash device are 418c2ecf20Sopenharmony_cisupported. This use is discouraged. 428c2ecf20Sopenharmony_ciNOTE: also for backwards compatibility, direct subnodes that have a compatible 438c2ecf20Sopenharmony_cistring are not considered partitions, as they may be used for other bindings. 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#address-cells & #size-cells must both be present in the partitions subnode of the 468c2ecf20Sopenharmony_ciflash device. There are two valid values for both: 478c2ecf20Sopenharmony_ci<1>: for partitions that require a single 32-bit cell to represent their 488c2ecf20Sopenharmony_ci size/address (aka the value is below 4 GiB) 498c2ecf20Sopenharmony_ci<2>: for partitions that require two 32-bit cells to represent their 508c2ecf20Sopenharmony_ci size/address (aka the value is 4 GiB or greater). 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ciRequired properties: 538c2ecf20Sopenharmony_ci- reg : The partition's offset and size within the flash 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ciOptional properties: 568c2ecf20Sopenharmony_ci- label : The label / name for this partition. If omitted, the label is taken 578c2ecf20Sopenharmony_ci from the node name (excluding the unit address). 588c2ecf20Sopenharmony_ci- read-only : This parameter, if present, is a hint to Linux that this 598c2ecf20Sopenharmony_ci partition should only be mounted read-only. This is usually used for flash 608c2ecf20Sopenharmony_ci partitions containing early-boot firmware images or data which should not be 618c2ecf20Sopenharmony_ci clobbered. 628c2ecf20Sopenharmony_ci- lock : Do not unlock the partition at initialization time (not supported on 638c2ecf20Sopenharmony_ci all devices) 648c2ecf20Sopenharmony_ci- slc-mode: This parameter, if present, allows one to emulate SLC mode on a 658c2ecf20Sopenharmony_ci partition attached to an MLC NAND thus making this partition immune to 668c2ecf20Sopenharmony_ci paired-pages corruptions 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ciExamples: 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciflash@0 { 728c2ecf20Sopenharmony_ci partitions { 738c2ecf20Sopenharmony_ci compatible = "fixed-partitions"; 748c2ecf20Sopenharmony_ci #address-cells = <1>; 758c2ecf20Sopenharmony_ci #size-cells = <1>; 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci partition@0 { 788c2ecf20Sopenharmony_ci label = "u-boot"; 798c2ecf20Sopenharmony_ci reg = <0x0000000 0x100000>; 808c2ecf20Sopenharmony_ci read-only; 818c2ecf20Sopenharmony_ci }; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci uimage@100000 { 848c2ecf20Sopenharmony_ci reg = <0x0100000 0x200000>; 858c2ecf20Sopenharmony_ci }; 868c2ecf20Sopenharmony_ci }; 878c2ecf20Sopenharmony_ci}; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ciflash@1 { 908c2ecf20Sopenharmony_ci partitions { 918c2ecf20Sopenharmony_ci compatible = "fixed-partitions"; 928c2ecf20Sopenharmony_ci #address-cells = <1>; 938c2ecf20Sopenharmony_ci #size-cells = <2>; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci /* a 4 GiB partition */ 968c2ecf20Sopenharmony_ci partition@0 { 978c2ecf20Sopenharmony_ci label = "filesystem"; 988c2ecf20Sopenharmony_ci reg = <0x00000000 0x1 0x00000000>; 998c2ecf20Sopenharmony_ci }; 1008c2ecf20Sopenharmony_ci }; 1018c2ecf20Sopenharmony_ci}; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ciflash@2 { 1048c2ecf20Sopenharmony_ci partitions { 1058c2ecf20Sopenharmony_ci compatible = "fixed-partitions"; 1068c2ecf20Sopenharmony_ci #address-cells = <2>; 1078c2ecf20Sopenharmony_ci #size-cells = <2>; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci /* an 8 GiB partition */ 1108c2ecf20Sopenharmony_ci partition@0 { 1118c2ecf20Sopenharmony_ci label = "filesystem #1"; 1128c2ecf20Sopenharmony_ci reg = <0x0 0x00000000 0x2 0x00000000>; 1138c2ecf20Sopenharmony_ci }; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci /* a 4 GiB partition */ 1168c2ecf20Sopenharmony_ci partition@200000000 { 1178c2ecf20Sopenharmony_ci label = "filesystem #2"; 1188c2ecf20Sopenharmony_ci reg = <0x2 0x00000000 0x1 0x00000000>; 1198c2ecf20Sopenharmony_ci }; 1208c2ecf20Sopenharmony_ci }; 1218c2ecf20Sopenharmony_ci}; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ciflash@3 { 1248c2ecf20Sopenharmony_ci partitions { 1258c2ecf20Sopenharmony_ci compatible = "fixed-partitions"; 1268c2ecf20Sopenharmony_ci #address-cells = <1>; 1278c2ecf20Sopenharmony_ci #size-cells = <1>; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci partition@0 { 1308c2ecf20Sopenharmony_ci label = "bootloader"; 1318c2ecf20Sopenharmony_ci reg = <0x000000 0x100000>; 1328c2ecf20Sopenharmony_ci read-only; 1338c2ecf20Sopenharmony_ci }; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci firmware@100000 { 1368c2ecf20Sopenharmony_ci label = "firmware"; 1378c2ecf20Sopenharmony_ci reg = <0x100000 0xe00000>; 1388c2ecf20Sopenharmony_ci compatible = "brcm,trx"; 1398c2ecf20Sopenharmony_ci }; 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci calibration@f00000 { 1428c2ecf20Sopenharmony_ci label = "calibration"; 1438c2ecf20Sopenharmony_ci reg = <0xf00000 0x100000>; 1448c2ecf20Sopenharmony_ci compatible = "fixed-partitions"; 1458c2ecf20Sopenharmony_ci ranges = <0 0xf00000 0x100000>; 1468c2ecf20Sopenharmony_ci #address-cells = <1>; 1478c2ecf20Sopenharmony_ci #size-cells = <1>; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci partition@0 { 1508c2ecf20Sopenharmony_ci label = "wifi0"; 1518c2ecf20Sopenharmony_ci reg = <0x000000 0x080000>; 1528c2ecf20Sopenharmony_ci }; 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci partition@80000 { 1558c2ecf20Sopenharmony_ci label = "wifi1"; 1568c2ecf20Sopenharmony_ci reg = <0x080000 0x080000>; 1578c2ecf20Sopenharmony_ci }; 1588c2ecf20Sopenharmony_ci }; 1598c2ecf20Sopenharmony_ci }; 1608c2ecf20Sopenharmony_ci}; 161