Kevin Cernekee | 65a7100 | 2015-04-09 13:05:16 -0700 | [diff] [blame] | 1 | Common properties |
| 2 | |
| 3 | The ePAPR specification does not define any properties related to hardware |
| 4 | byteswapping, but endianness issues show up frequently in porting Linux to |
| 5 | different machine types. This document attempts to provide a consistent |
| 6 | way of handling byteswapping across drivers. |
| 7 | |
| 8 | Optional 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 | |
| 21 | If a binding supports these properties, then the binding should also |
| 22 | specify the default behavior if none of these properties are present. |
| 23 | In such cases, little-endian is the preferred default, but it is not |
| 24 | a requirement. The of_device_is_big_endian() and of_fdt_is_big_endian() |
| 25 | helper functions do assume that little-endian is the default, because |
| 26 | most existing (PCI-based) drivers implicitly default to LE by using |
| 27 | readl/writel for MMIO accesses. |
| 28 | |
| 29 | Examples: |
| 30 | Scenario 1 : CPU in LE mode & device in LE mode. |
| 31 | dev: dev@40031000 { |
| 32 | compatible = "name"; |
| 33 | reg = <0x40031000 0x1000>; |
| 34 | ... |
| 35 | native-endian; |
| 36 | }; |
| 37 | |
| 38 | Scenario 2 : CPU in LE mode & device in BE mode. |
| 39 | dev: dev@40031000 { |
| 40 | compatible = "name"; |
| 41 | reg = <0x40031000 0x1000>; |
| 42 | ... |
| 43 | big-endian; |
| 44 | }; |
| 45 | |
| 46 | Scenario 3 : CPU in BE mode & device in BE mode. |
| 47 | dev: dev@40031000 { |
| 48 | compatible = "name"; |
| 49 | reg = <0x40031000 0x1000>; |
| 50 | ... |
| 51 | native-endian; |
| 52 | }; |
| 53 | |
| 54 | Scenario 4 : CPU in BE mode & device in LE mode. |
| 55 | dev: dev@40031000 { |
| 56 | compatible = "name"; |
| 57 | reg = <0x40031000 0x1000>; |
| 58 | ... |
| 59 | little-endian; |
| 60 | }; |