18c2ecf20Sopenharmony_ciCommon properties 28c2ecf20Sopenharmony_ci================= 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ciEndianness 58c2ecf20Sopenharmony_ci---------- 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciThe Devicetree Specification does not define any properties related to hardware 88c2ecf20Sopenharmony_cibyte swapping, but endianness issues show up frequently in porting drivers to 98c2ecf20Sopenharmony_cidifferent machine types. This document attempts to provide a consistent 108c2ecf20Sopenharmony_ciway of handling byte swapping across drivers. 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciOptional properties: 138c2ecf20Sopenharmony_ci - big-endian: Boolean; force big endian register accesses 148c2ecf20Sopenharmony_ci unconditionally (e.g. ioread32be/iowrite32be). Use this if you 158c2ecf20Sopenharmony_ci know the peripheral always needs to be accessed in big endian (BE) mode. 168c2ecf20Sopenharmony_ci - little-endian: Boolean; force little endian register accesses 178c2ecf20Sopenharmony_ci unconditionally (e.g. readl/writel). Use this if you know the 188c2ecf20Sopenharmony_ci peripheral always needs to be accessed in little endian (LE) mode. 198c2ecf20Sopenharmony_ci - native-endian: Boolean; always use register accesses matched to the 208c2ecf20Sopenharmony_ci endianness of the kernel binary (e.g. LE vmlinux -> readl/writel, 218c2ecf20Sopenharmony_ci BE vmlinux -> ioread32be/iowrite32be). In this case no byte swaps 228c2ecf20Sopenharmony_ci will ever be performed. Use this if the hardware "self-adjusts" 238c2ecf20Sopenharmony_ci register endianness based on the CPU's configured endianness. 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ciIf a binding supports these properties, then the binding should also 268c2ecf20Sopenharmony_cispecify the default behavior if none of these properties are present. 278c2ecf20Sopenharmony_ciIn such cases, little-endian is the preferred default, but it is not 288c2ecf20Sopenharmony_cia requirement. Some implementations assume that little-endian is 298c2ecf20Sopenharmony_cithe default, because most existing (PCI-based) drivers implicitly 308c2ecf20Sopenharmony_cidefault to LE for their MMIO accesses. 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciExamples: 338c2ecf20Sopenharmony_ciScenario 1 : CPU in LE mode & device in LE mode. 348c2ecf20Sopenharmony_cidev: dev@40031000 { 358c2ecf20Sopenharmony_ci compatible = "name"; 368c2ecf20Sopenharmony_ci reg = <0x40031000 0x1000>; 378c2ecf20Sopenharmony_ci ... 388c2ecf20Sopenharmony_ci native-endian; 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciScenario 2 : CPU in LE mode & device in BE mode. 428c2ecf20Sopenharmony_cidev: dev@40031000 { 438c2ecf20Sopenharmony_ci compatible = "name"; 448c2ecf20Sopenharmony_ci reg = <0x40031000 0x1000>; 458c2ecf20Sopenharmony_ci ... 468c2ecf20Sopenharmony_ci big-endian; 478c2ecf20Sopenharmony_ci}; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ciScenario 3 : CPU in BE mode & device in BE mode. 508c2ecf20Sopenharmony_cidev: dev@40031000 { 518c2ecf20Sopenharmony_ci compatible = "name"; 528c2ecf20Sopenharmony_ci reg = <0x40031000 0x1000>; 538c2ecf20Sopenharmony_ci ... 548c2ecf20Sopenharmony_ci native-endian; 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciScenario 4 : CPU in BE mode & device in LE mode. 588c2ecf20Sopenharmony_cidev: dev@40031000 { 598c2ecf20Sopenharmony_ci compatible = "name"; 608c2ecf20Sopenharmony_ci reg = <0x40031000 0x1000>; 618c2ecf20Sopenharmony_ci ... 628c2ecf20Sopenharmony_ci little-endian; 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ciDaisy-chained devices 668c2ecf20Sopenharmony_ci--------------------- 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ciMany serially-attached GPIO and IIO devices are daisy-chainable. To the 698c2ecf20Sopenharmony_cihost controller, a daisy-chain appears as a single device, but the number 708c2ecf20Sopenharmony_ciof inputs and outputs it provides is the sum of inputs and outputs provided 718c2ecf20Sopenharmony_ciby all of its devices. The driver needs to know how many devices the 728c2ecf20Sopenharmony_cidaisy-chain comprises to determine the amount of data exchanged, how many 738c2ecf20Sopenharmony_ciinputs and outputs to register and so on. 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ciOptional properties: 768c2ecf20Sopenharmony_ci - #daisy-chained-devices: Number of devices in the daisy-chain (default is 1). 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ciExample: 798c2ecf20Sopenharmony_cigpio@0 { 808c2ecf20Sopenharmony_ci compatible = "name"; 818c2ecf20Sopenharmony_ci reg = <0>; 828c2ecf20Sopenharmony_ci gpio-controller; 838c2ecf20Sopenharmony_ci #gpio-cells = <2>; 848c2ecf20Sopenharmony_ci #daisy-chained-devices = <3>; 858c2ecf20Sopenharmony_ci}; 86