165a71007SKevin CernekeeCommon properties
21f63fab9SLukas Wunner=================
31f63fab9SLukas Wunner
41f63fab9SLukas WunnerEndianness
51f63fab9SLukas Wunner----------
665a71007SKevin Cernekee
7076fb0c4SFrank RowandThe Devicetree Specification does not define any properties related to hardware
8253a41c6SStephen Boydbyte swapping, but endianness issues show up frequently in porting drivers to
965a71007SKevin Cernekeedifferent machine types.  This document attempts to provide a consistent
1065a71007SKevin Cernekeeway of handling byte swapping across drivers.
1165a71007SKevin Cernekee
1265a71007SKevin CernekeeOptional properties:
1365a71007SKevin Cernekee - big-endian: Boolean; force big endian register accesses
1465a71007SKevin Cernekee   unconditionally (e.g. ioread32be/iowrite32be).  Use this if you
15253a41c6SStephen Boyd   know the peripheral always needs to be accessed in big endian (BE) mode.
1665a71007SKevin Cernekee - little-endian: Boolean; force little endian register accesses
1765a71007SKevin Cernekee   unconditionally (e.g. readl/writel).  Use this if you know the
18253a41c6SStephen Boyd   peripheral always needs to be accessed in little endian (LE) mode.
1965a71007SKevin Cernekee - native-endian: Boolean; always use register accesses matched to the
2065a71007SKevin Cernekee   endianness of the kernel binary (e.g. LE vmlinux -> readl/writel,
2165a71007SKevin Cernekee   BE vmlinux -> ioread32be/iowrite32be).  In this case no byte swaps
2265a71007SKevin Cernekee   will ever be performed.  Use this if the hardware "self-adjusts"
2365a71007SKevin Cernekee   register endianness based on the CPU's configured endianness.
2465a71007SKevin Cernekee
2565a71007SKevin CernekeeIf a binding supports these properties, then the binding should also
2665a71007SKevin Cernekeespecify the default behavior if none of these properties are present.
2765a71007SKevin CernekeeIn such cases, little-endian is the preferred default, but it is not
28253a41c6SStephen Boyda requirement.  Some implementations assume that little-endian is
29253a41c6SStephen Boydthe default, because most existing (PCI-based) drivers implicitly
30253a41c6SStephen Boyddefault to LE for their MMIO accesses.
3165a71007SKevin Cernekee
3265a71007SKevin CernekeeExamples:
3365a71007SKevin CernekeeScenario 1 : CPU in LE mode & device in LE mode.
3465a71007SKevin Cernekeedev: dev@40031000 {
3565a71007SKevin Cernekee	      compatible = "name";
3665a71007SKevin Cernekee	      reg = <0x40031000 0x1000>;
3765a71007SKevin Cernekee	      ...
3865a71007SKevin Cernekee	      native-endian;
3965a71007SKevin Cernekee};
4065a71007SKevin Cernekee
4165a71007SKevin CernekeeScenario 2 : CPU in LE mode & device in BE mode.
4265a71007SKevin Cernekeedev: dev@40031000 {
4365a71007SKevin Cernekee	      compatible = "name";
4465a71007SKevin Cernekee	      reg = <0x40031000 0x1000>;
4565a71007SKevin Cernekee	      ...
4665a71007SKevin Cernekee	      big-endian;
4765a71007SKevin Cernekee};
4865a71007SKevin Cernekee
4965a71007SKevin CernekeeScenario 3 : CPU in BE mode & device in BE mode.
5065a71007SKevin Cernekeedev: dev@40031000 {
5165a71007SKevin Cernekee	      compatible = "name";
5265a71007SKevin Cernekee	      reg = <0x40031000 0x1000>;
5365a71007SKevin Cernekee	      ...
5465a71007SKevin Cernekee	      native-endian;
5565a71007SKevin Cernekee};
5665a71007SKevin Cernekee
5765a71007SKevin CernekeeScenario 4 : CPU in BE mode & device in LE mode.
5865a71007SKevin Cernekeedev: dev@40031000 {
5965a71007SKevin Cernekee	      compatible = "name";
6065a71007SKevin Cernekee	      reg = <0x40031000 0x1000>;
6165a71007SKevin Cernekee	      ...
6265a71007SKevin Cernekee	      little-endian;
6365a71007SKevin Cernekee};
641f63fab9SLukas Wunner
651f63fab9SLukas WunnerDaisy-chained devices
661f63fab9SLukas Wunner---------------------
671f63fab9SLukas Wunner
681f63fab9SLukas WunnerMany serially-attached GPIO and IIO devices are daisy-chainable.  To the
691f63fab9SLukas Wunnerhost controller, a daisy-chain appears as a single device, but the number
701f63fab9SLukas Wunnerof inputs and outputs it provides is the sum of inputs and outputs provided
711f63fab9SLukas Wunnerby all of its devices.  The driver needs to know how many devices the
721f63fab9SLukas Wunnerdaisy-chain comprises to determine the amount of data exchanged, how many
731f63fab9SLukas Wunnerinputs and outputs to register and so on.
741f63fab9SLukas Wunner
751f63fab9SLukas WunnerOptional properties:
761f63fab9SLukas Wunner - #daisy-chained-devices: Number of devices in the daisy-chain (default is 1).
771f63fab9SLukas Wunner
781f63fab9SLukas WunnerExample:
791f63fab9SLukas Wunnergpio@0 {
801f63fab9SLukas Wunner	      compatible = "name";
811f63fab9SLukas Wunner	      reg = <0>;
821f63fab9SLukas Wunner	      gpio-controller;
831f63fab9SLukas Wunner	      #gpio-cells = <2>;
841f63fab9SLukas Wunner	      #daisy-chained-devices = <3>;
851f63fab9SLukas Wunner};
86