1Common properties 2 3The ePAPR specification does not define any properties related to hardware 4byteswapping, but endianness issues show up frequently in porting Linux to 5different machine types. This document attempts to provide a consistent 6way of handling byteswapping across drivers. 7 8Optional properties: 9 - big-endian: Boolean; force big endian register accesses 10 unconditionally (e.g. ioread32be/iowrite32be). Use this if you 11 know the peripheral always needs to be accessed in BE mode. 12 - little-endian: Boolean; force little endian register accesses 13 unconditionally (e.g. readl/writel). Use this if you know the 14 peripheral always needs to be accessed in LE mode. 15 - native-endian: Boolean; always use register accesses matched to the 16 endianness of the kernel binary (e.g. LE vmlinux -> readl/writel, 17 BE vmlinux -> ioread32be/iowrite32be). In this case no byteswaps 18 will ever be performed. Use this if the hardware "self-adjusts" 19 register endianness based on the CPU's configured endianness. 20 21If a binding supports these properties, then the binding should also 22specify the default behavior if none of these properties are present. 23In such cases, little-endian is the preferred default, but it is not 24a requirement. The of_device_is_big_endian() and of_fdt_is_big_endian() 25helper functions do assume that little-endian is the default, because 26most existing (PCI-based) drivers implicitly default to LE by using 27readl/writel for MMIO accesses. 28 29Examples: 30Scenario 1 : CPU in LE mode & device in LE mode. 31dev: dev@40031000 { 32 compatible = "name"; 33 reg = <0x40031000 0x1000>; 34 ... 35 native-endian; 36}; 37 38Scenario 2 : CPU in LE mode & device in BE mode. 39dev: dev@40031000 { 40 compatible = "name"; 41 reg = <0x40031000 0x1000>; 42 ... 43 big-endian; 44}; 45 46Scenario 3 : CPU in BE mode & device in BE mode. 47dev: dev@40031000 { 48 compatible = "name"; 49 reg = <0x40031000 0x1000>; 50 ... 51 native-endian; 52}; 53 54Scenario 4 : CPU in BE mode & device in LE mode. 55dev: dev@40031000 { 56 compatible = "name"; 57 reg = <0x40031000 0x1000>; 58 ... 59 little-endian; 60}; 61