18c2ecf20Sopenharmony_ci 28c2ecf20Sopenharmony_ci* Marvell MBus 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ciRequired properties: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci- compatible: Should be set to one of the following: 78c2ecf20Sopenharmony_ci marvell,armada370-mbus 88c2ecf20Sopenharmony_ci marvell,armadaxp-mbus 98c2ecf20Sopenharmony_ci marvell,armada375-mbus 108c2ecf20Sopenharmony_ci marvell,armada380-mbus 118c2ecf20Sopenharmony_ci marvell,kirkwood-mbus 128c2ecf20Sopenharmony_ci marvell,dove-mbus 138c2ecf20Sopenharmony_ci marvell,orion5x-88f5281-mbus 148c2ecf20Sopenharmony_ci marvell,orion5x-88f5182-mbus 158c2ecf20Sopenharmony_ci marvell,orion5x-88f5181-mbus 168c2ecf20Sopenharmony_ci marvell,orion5x-88f6183-mbus 178c2ecf20Sopenharmony_ci marvell,mv78xx0-mbus 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci- address-cells: Must be '2'. The first cell for the MBus ID encoding, 208c2ecf20Sopenharmony_ci the second cell for the address offset within the window. 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci- size-cells: Must be '1'. 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci- ranges: Must be set up to provide a proper translation for each child. 258c2ecf20Sopenharmony_ci See the examples below. 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci- controller: Contains a single phandle referring to the MBus controller 288c2ecf20Sopenharmony_ci node. This allows to specify the node that contains the 298c2ecf20Sopenharmony_ci registers that control the MBus, which is typically contained 308c2ecf20Sopenharmony_ci within the internal register window (see below). 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciOptional properties: 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci- pcie-mem-aperture: This optional property contains the aperture for 358c2ecf20Sopenharmony_ci the memory region of the PCIe driver. 368c2ecf20Sopenharmony_ci If it's defined, it must encode the base address and 378c2ecf20Sopenharmony_ci size for the address decoding windows allocated for 388c2ecf20Sopenharmony_ci the PCIe memory region. 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci- pcie-io-aperture: Just as explained for the above property, this 418c2ecf20Sopenharmony_ci optional property contains the aperture for the 428c2ecf20Sopenharmony_ci I/O region of the PCIe driver. 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci* Marvell MBus controller 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ciRequired properties: 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci- compatible: Should be set to "marvell,mbus-controller". 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci- reg: Device's register space. 518c2ecf20Sopenharmony_ci Two or three entries are expected (see the examples below): 528c2ecf20Sopenharmony_ci the first one controls the devices decoding window, 538c2ecf20Sopenharmony_ci the second one controls the SDRAM decoding window and 548c2ecf20Sopenharmony_ci the third controls the MBus bridge (only with the 558c2ecf20Sopenharmony_ci marvell,armada370-mbus and marvell,armadaxp-mbus 568c2ecf20Sopenharmony_ci compatible strings) 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ciExample: 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci soc { 618c2ecf20Sopenharmony_ci compatible = "marvell,armada370-mbus", "simple-bus"; 628c2ecf20Sopenharmony_ci #address-cells = <2>; 638c2ecf20Sopenharmony_ci #size-cells = <1>; 648c2ecf20Sopenharmony_ci controller = <&mbusc>; 658c2ecf20Sopenharmony_ci pcie-mem-aperture = <0xe0000000 0x8000000>; 668c2ecf20Sopenharmony_ci pcie-io-aperture = <0xe8000000 0x100000>; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci internal-regs { 698c2ecf20Sopenharmony_ci compatible = "simple-bus"; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci mbusc: mbus-controller@20000 { 728c2ecf20Sopenharmony_ci compatible = "marvell,mbus-controller"; 738c2ecf20Sopenharmony_ci reg = <0x20000 0x100>, <0x20180 0x20>, <0x20250 0x8>; 748c2ecf20Sopenharmony_ci }; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci /* more children ...*/ 778c2ecf20Sopenharmony_ci }; 788c2ecf20Sopenharmony_ci }; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci** MBus address decoding window specification 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ciThe MBus children address space is comprised of two cells: the first one for 838c2ecf20Sopenharmony_cithe window ID and the second one for the offset within the window. 848c2ecf20Sopenharmony_ciIn order to allow to describe valid and non-valid window entries, the 858c2ecf20Sopenharmony_cifollowing encoding is used: 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci 0xSIAA0000 0x00oooooo 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ciWhere: 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci S = 0x0 for a MBus valid window 928c2ecf20Sopenharmony_ci S = 0xf for a non-valid window (see below) 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ciIf S = 0x0, then: 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci I = 4-bit window target ID 978c2ecf20Sopenharmony_ci AA = windpw attribute 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ciIf S = 0xf, then: 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci I = don't care 1028c2ecf20Sopenharmony_ci AA = 1 for internal register 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ciFollowing the above encoding, for each ranges entry for a MBus valid window 1058c2ecf20Sopenharmony_ci(S = 0x0), an address decoding window is allocated. On the other side, 1068c2ecf20Sopenharmony_cientries for translation that do not correspond to valid windows (S = 0xf) 1078c2ecf20Sopenharmony_ciare skipped. 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci soc { 1108c2ecf20Sopenharmony_ci compatible = "marvell,armada370-mbus", "simple-bus"; 1118c2ecf20Sopenharmony_ci #address-cells = <2>; 1128c2ecf20Sopenharmony_ci #size-cells = <1>; 1138c2ecf20Sopenharmony_ci controller = <&mbusc>; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci ranges = <0xf0010000 0 0 0xd0000000 0x100000 1168c2ecf20Sopenharmony_ci 0x01e00000 0 0 0xfff00000 0x100000>; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci bootrom { 1198c2ecf20Sopenharmony_ci compatible = "marvell,bootrom"; 1208c2ecf20Sopenharmony_ci reg = <0x01e00000 0 0x100000>; 1218c2ecf20Sopenharmony_ci }; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci /* other children */ 1248c2ecf20Sopenharmony_ci ... 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci internal-regs { 1278c2ecf20Sopenharmony_ci compatible = "simple-bus"; 1288c2ecf20Sopenharmony_ci ranges = <0 0xf0010000 0 0x100000>; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci mbusc: mbus-controller@20000 { 1318c2ecf20Sopenharmony_ci compatible = "marvell,mbus-controller"; 1328c2ecf20Sopenharmony_ci reg = <0x20000 0x100>, <0x20180 0x20>, <0x20250 0x8>; 1338c2ecf20Sopenharmony_ci }; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci /* more children ...*/ 1368c2ecf20Sopenharmony_ci }; 1378c2ecf20Sopenharmony_ci }; 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ciIn the shown example, the translation entry in the 'ranges' property is what 1408c2ecf20Sopenharmony_cimakes the MBus driver create a static decoding window for the corresponding 1418c2ecf20Sopenharmony_cigiven child device. Note that the binding does not require child nodes to be 1428c2ecf20Sopenharmony_cipresent. Of course, child nodes are needed to probe the devices. 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ciSince each window is identified by its target ID and attribute ID there's 1458c2ecf20Sopenharmony_cia special macro that can be use to simplify the translation entries: 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci#define MBUS_ID(target,attributes) (((target) << 24) | ((attributes) << 16)) 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ciUsing this macro, the above example would be: 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci soc { 1528c2ecf20Sopenharmony_ci compatible = "marvell,armada370-mbus", "simple-bus"; 1538c2ecf20Sopenharmony_ci #address-cells = <2>; 1548c2ecf20Sopenharmony_ci #size-cells = <1>; 1558c2ecf20Sopenharmony_ci controller = <&mbusc>; 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci ranges = < MBUS_ID(0xf0, 0x01) 0 0 0xd0000000 0x100000 1588c2ecf20Sopenharmony_ci MBUS_ID(0x01, 0xe0) 0 0 0xfff00000 0x100000>; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci bootrom { 1618c2ecf20Sopenharmony_ci compatible = "marvell,bootrom"; 1628c2ecf20Sopenharmony_ci reg = <MBUS_ID(0x01, 0xe0) 0 0x100000>; 1638c2ecf20Sopenharmony_ci }; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci /* other children */ 1668c2ecf20Sopenharmony_ci ... 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci internal-regs { 1698c2ecf20Sopenharmony_ci compatible = "simple-bus"; 1708c2ecf20Sopenharmony_ci #address-cells = <1>; 1718c2ecf20Sopenharmony_ci #size-cells = <1>; 1728c2ecf20Sopenharmony_ci ranges = <0 MBUS_ID(0xf0, 0x01) 0 0x100000>; 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci mbusc: mbus-controller@20000 { 1758c2ecf20Sopenharmony_ci compatible = "marvell,mbus-controller"; 1768c2ecf20Sopenharmony_ci reg = <0x20000 0x100>, <0x20180 0x20>, <0x20250 0x8>; 1778c2ecf20Sopenharmony_ci }; 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci /* other children */ 1808c2ecf20Sopenharmony_ci ... 1818c2ecf20Sopenharmony_ci }; 1828c2ecf20Sopenharmony_ci }; 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci** About the window base address 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ciRemember the MBus controller allows a great deal of flexibility for choosing 1888c2ecf20Sopenharmony_cithe decoding window base address. When planning the device tree layout it's 1898c2ecf20Sopenharmony_cipossible to choose any address as the base address, provided of course there's 1908c2ecf20Sopenharmony_cia region large enough available, and with the required alignment. 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ciYet in other words: there's nothing preventing us from setting a base address 1938c2ecf20Sopenharmony_ciof 0xf0000000, or 0xd0000000 for the NOR device shown above, if such region is 1948c2ecf20Sopenharmony_ciunused. 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci** Window allocation policy 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ciThe mbus-node ranges property defines a set of mbus windows that are expected 1998c2ecf20Sopenharmony_cito be set by the operating system and that are guaranteed to be free of overlaps 2008c2ecf20Sopenharmony_ciwith one another or with the system memory ranges. 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ciEach entry in the property refers to exactly one window. If the operating system 2038c2ecf20Sopenharmony_cichooses to use a different set of mbus windows, it must ensure that any address 2048c2ecf20Sopenharmony_citranslations performed from downstream devices are adapted accordingly. 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ciThe operating system may insert additional mbus windows that do not conflict 2078c2ecf20Sopenharmony_ciwith the ones listed in the ranges, e.g. for mapping PCIe devices. 2088c2ecf20Sopenharmony_ciAs a special case, the internal register window must be set up by the boot 2098c2ecf20Sopenharmony_ciloader at the address listed in the ranges property, since access to that region 2108c2ecf20Sopenharmony_ciis needed to set up the other windows. 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci** Example 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ciSee the example below, where a more complete device tree is shown: 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci soc { 2178c2ecf20Sopenharmony_ci compatible = "marvell,armadaxp-mbus", "simple-bus"; 2188c2ecf20Sopenharmony_ci controller = <&mbusc>; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xd0000000 0x100000 /* internal-regs */ 2218c2ecf20Sopenharmony_ci MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000 2228c2ecf20Sopenharmony_ci MBUS_ID(0x01, 0x2f) 0 0 0xf0000000 0x8000000>; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci bootrom { 2258c2ecf20Sopenharmony_ci compatible = "marvell,bootrom"; 2268c2ecf20Sopenharmony_ci reg = <MBUS_ID(0x01, 0x1d) 0 0x100000>; 2278c2ecf20Sopenharmony_ci }; 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci devbus-bootcs { 2308c2ecf20Sopenharmony_ci ranges = <0 MBUS_ID(0x01, 0x2f) 0 0x8000000>; 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci /* NOR */ 2338c2ecf20Sopenharmony_ci nor { 2348c2ecf20Sopenharmony_ci compatible = "cfi-flash"; 2358c2ecf20Sopenharmony_ci reg = <0 0x8000000>; 2368c2ecf20Sopenharmony_ci bank-width = <2>; 2378c2ecf20Sopenharmony_ci }; 2388c2ecf20Sopenharmony_ci }; 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci pcie-controller { 2418c2ecf20Sopenharmony_ci compatible = "marvell,armada-xp-pcie"; 2428c2ecf20Sopenharmony_ci device_type = "pci"; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci #address-cells = <3>; 2458c2ecf20Sopenharmony_ci #size-cells = <2>; 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci ranges = 2488c2ecf20Sopenharmony_ci <0x82000000 0 0x40000 MBUS_ID(0xf0, 0x01) 0x40000 0 0x00002000 /* Port 0.0 registers */ 2498c2ecf20Sopenharmony_ci 0x82000000 0 0x42000 MBUS_ID(0xf0, 0x01) 0x42000 0 0x00002000 /* Port 2.0 registers */ 2508c2ecf20Sopenharmony_ci 0x82000000 0 0x44000 MBUS_ID(0xf0, 0x01) 0x44000 0 0x00002000 /* Port 0.1 registers */ 2518c2ecf20Sopenharmony_ci 0x82000000 0 0x48000 MBUS_ID(0xf0, 0x01) 0x48000 0 0x00002000 /* Port 0.2 registers */ 2528c2ecf20Sopenharmony_ci 0x82000000 0 0x4c000 MBUS_ID(0xf0, 0x01) 0x4c000 0 0x00002000 /* Port 0.3 registers */ 2538c2ecf20Sopenharmony_ci 0x82000800 0 0xe0000000 MBUS_ID(0x04, 0xe8) 0xe0000000 0 0x08000000 /* Port 0.0 MEM */ 2548c2ecf20Sopenharmony_ci 0x81000800 0 0 MBUS_ID(0x04, 0xe0) 0xe8000000 0 0x00100000 /* Port 0.0 IO */>; 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci pcie@1,0 { 2588c2ecf20Sopenharmony_ci /* Port 0, Lane 0 */ 2598c2ecf20Sopenharmony_ci }; 2608c2ecf20Sopenharmony_ci }; 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci internal-regs { 2638c2ecf20Sopenharmony_ci compatible = "simple-bus"; 2648c2ecf20Sopenharmony_ci #address-cells = <1>; 2658c2ecf20Sopenharmony_ci #size-cells = <1>; 2668c2ecf20Sopenharmony_ci ranges = <0 MBUS_ID(0xf0, 0x01) 0 0x100000>; 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci mbusc: mbus-controller@20000 { 2698c2ecf20Sopenharmony_ci reg = <0x20000 0x100>, <0x20180 0x20>, <0x20250 0x8>; 2708c2ecf20Sopenharmony_ci }; 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci interrupt-controller@20000 { 2738c2ecf20Sopenharmony_ci reg = <0x20a00 0x2d0>, <0x21070 0x58>; 2748c2ecf20Sopenharmony_ci }; 2758c2ecf20Sopenharmony_ci }; 2768c2ecf20Sopenharmony_ci }; 277