6

In the file imx6qdl.dtsi is the following definition of gpio nodes (somewhat shortened):

gpio1: gpio@0209c000 {
    [...]
};

gpio2: gpio@020a0000 {
    [...]
};

[...]

gpio7: gpio@020b4000 {
    [...]
};

But also in this file, the aliases node has the following properties (again shortened):

aliases {
    [...]
    gpio0 = &gpio1;
    gpio1 = &gpio2;
    gpio2 = &gpio3;
    gpio3 = &gpio4;
    gpio4 = &gpio5;
    gpio5 = &gpio6;
    gpio6 = &gpio7;
    [...]
};

What exactly is the reason for doing so? Do the labels get overwritten?

happyMOOyear
  • 161
  • 1
  • 2

2 Answers2

4

Aliases are for use by the Linux kernel, but can't be used within the device tree source (DTS) configuration.

Meanwhile, labels can be used in your DTS files to extend or modify the node later.

e.g. You could have a custom DTS file like:

#include "imx6qdl.dtsi"

&gpio2 {
   [your modifications here]
}

Note, again, this would apply to the gpio2 label, not the alias (see here).

It's also worth noting that labels used within the devicetree source expand either to the full path of the labeled node, or to the (integer) phandle value for the node, depending on context; see here.

AdminBee
  • 21,637
  • 21
  • 47
  • 71
0

@happyMOOyear, not sure if you found an answer but I'll provide how I understand this. I'm working with the same i.MX chip.

The second section uses the already defined node with the label gpio1@0209c000 and creates a new ALIAS for that node. The alias is another way to refer to the same pin. In this case the alias is created with a zero based scheme for easier reference. Thus referring to gpio1@0209c000 is equivalent to gpio0, which is shorter as well.

reference: http://devicetree.org/Device_Tree_Usage#aliases_Node

Daniel
  • 55
  • 11
  • I still have not found a good answer to my question so thanks for your input. In case of the label gpio0 I think it is clear that I refer to gpio1@0209c000. But which gpio am I refereing to when I use the label gpio1? gpio1@0209c000 or gpio2@020a0000? – happyMOOyear Jan 11 '16 at 07:45
  • if you use gpio1, that is the alias. if you wish to access gpio1@0209c000 you must either use the gpio0 alias, or the full gpio1@0209c000 label. – Daniel Jan 11 '16 at 20:32