Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1406282 > unrolled thread

[PATCH] devicetree - document using aliases to set spi bus number.

Started byChrister Weinigel <christer@weinigel.se>
First post2016-05-24 18:50 +0200
Last post2016-05-26 10:30 +0200
Articles 4 on this page of 44 — 6 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] devicetree - document using aliases to set spi bus number. Christer Weinigel <christer@weinigel.se> - 2016-05-24 18:50 +0200
    Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-24 19:30 +0200
      Re: [PATCH] devicetree - document using aliases to set spi bus  number. Christer Weinigel <christer@weinigel.se> - 2016-05-24 20:20 +0200
        Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-24 20:40 +0200
          Re: [PATCH] devicetree - document using aliases to set spi bus  number. Christer Weinigel <christer@weinigel.se> - 2016-05-24 21:00 +0200
            Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Rutland <mark.rutland@arm.com> - 2016-05-25 14:20 +0200
              Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-25 15:00 +0200
            Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-25 14:40 +0200
          Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 01:40 +0200
            Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 02:20 +0200
            Re: [PATCH] devicetree - document using aliases to set spi bus  number. Rob Herring <robh@kernel.org> - 2016-05-25 19:50 +0200
              Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-25 20:10 +0200
              Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 20:10 +0200
                Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-25 20:50 +0200
                  Re: [PATCH] devicetree - document using aliases to set spi bus  number. Christer Weinigel <christer@weinigel.se> - 2016-05-26 03:20 +0200
                    Re: [PATCH] devicetree - document using aliases to set spi bus number. Rob Herring <robh@kernel.org> - 2016-05-26 03:50 +0200
                      Re: [PATCH] devicetree - document using aliases to set spi bus  number. Christer Weinigel <christer@weinigel.se> - 2016-05-26 04:00 +0200
                        Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-26 12:20 +0200
                          Re: [PATCH] devicetree - document using aliases to set spi bus  number. Christer Weinigel <christer@weinigel.se> - 2016-05-26 13:00 +0200
                            Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-26 20:50 +0200
                              Re: [PATCH] devicetree - document using aliases to set spi bus  number. Christer Weinigel <christer@weinigel.se> - 2016-05-26 23:10 +0200
                                Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-27 18:50 +0200
    Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Rutland <mark.rutland@arm.com> - 2016-05-24 19:50 +0200
      Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-24 22:50 +0200
        Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Rutland <mark.rutland@arm.com> - 2016-05-25 11:30 +0200
          Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-25 12:40 +0200
            Re: [PATCH] devicetree - document using aliases to set spi bus  number. Christer Weinigel <christer@weinigel.se> - 2016-05-25 13:30 +0200
              Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Rutland <mark.rutland@arm.com> - 2016-05-25 14:40 +0200
                Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-25 15:10 +0200
          Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 17:40 +0200
            Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Rutland <mark.rutland@arm.com> - 2016-05-25 18:10 +0200
              Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 18:30 +0200
              Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-25 20:10 +0200
            Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-25 20:00 +0200
              Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 20:50 +0200
                Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-27 20:40 +0200
                  Re: [PATCH] devicetree - document using aliases to set spi bus  number. Christer Weinigel <christer@weinigel.se> - 2016-05-28 23:00 +0200
                    Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-30 18:20 +0200
      Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 17:30 +0200
        Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Rutland <mark.rutland@arm.com> - 2016-05-25 18:10 +0200
          Re: [PATCH] devicetree - document using aliases to set spi bus number. Frank Rowand <frowand.list@gmail.com> - 2016-05-25 18:40 +0200
      Re: [PATCH] devicetree - document using aliases to set spi bus  number. Mark Brown <broonie@kernel.org> - 2016-05-25 20:50 +0200
      Re: [PATCH] devicetree - document using aliases to set spi bus  number. Rob Herring <robh@kernel.org> - 2016-05-25 20:50 +0200
        Re: [PATCH] devicetree - document using aliases to set spi bus number. Geert Uytterhoeven <geert@linux-m68k.org> - 2016-05-26 10:30 +0200

Page 3 of 3 — ← Prev page 1 2 [3]


#1407061

FromFrank Rowand <frowand.list@gmail.com>
Date2016-05-25 18:40 +0200
Message-ID<rCK0F-3ct-1@gated-at.bofh.it>
In reply to#1407025
On 5/25/2016 9:06 AM, Mark Rutland wrote:
> On Wed, May 25, 2016 at 08:25:44AM -0700, Frank Rowand wrote:
>> On 5/24/2016 10:41 AM, Mark Rutland wrote:
>>> On Tue, May 24, 2016 at 06:39:20PM +0200, Christer Weinigel wrote:
>>>> +Normally SPI buses are assigned dynamic bus numbers starting at 32766
>>>> +and counting downwards.  It is possible to assign the bus number
>>>> +statically using devicetee aliases.  For example, on the MPC5200 the
>>>> +"spi@f00" device above is connected to the "soc" bus.  To set its
>>>> +bus_num to 1 add an aliases entry like this:
>>>
>>> As Mark Brown pointed out, this is very Linux-specific (at least in the
>>> wording of the above).
>>>
>>> Generally, aliases are there to match _physical_ identifiers (e.g. to
>>> match physical labels for UART0, UART1, and on).
>>
>> Can you point to anything in the specification or any other place that
>> states that aliases are for matching physical identifiers?
>>
>> Can you point to anything in the specification or any other place that
>> states that aliases are not to be used for anything else?
> 
> You have me there; I cannot find any wording to that effect, and I am
> evidently going by my understanding alone.

There seems to be a fair amount of things about devicetree that are tribal
knowledge.  I try to take note of these things as I see them and would
like to convert them from tribal knowledge to knowledge that is
explicitly stated in our documentation.  The documented knowledge may end
up being the same as the tribal lore, or we may find that it needs to be
modified as we document it.


> IEEE 1275 simply states that there may be predefined aliases for a
> machine, or that users can create and use them dynamically. ePAPR (and
> the devicetree specification) only states that aliases exist, and that a
> client program might use them (through some means which is never
> described).
> 
> Thanks,
> Mark.
> .
> 

[toc] | [prev] | [next] | [standalone]


#1407160 — Re: [PATCH] devicetree - document using aliases to set spi bus number.

FromMark Brown <broonie@kernel.org>
Date2016-05-25 20:50 +0200
SubjectRe: [PATCH] devicetree - document using aliases to set spi bus number.
Message-ID<rCM2t-4mV-1@gated-at.bofh.it>
In reply to#1406306

[Multipart message — attachments visible in raw view] — view raw

On Wed, May 25, 2016 at 01:44:21PM -0500, Rob Herring wrote:

> For SPI, I think we should use "label" which reflects a name that is 
> defined by the h/w design and is meaningful to the user. Then perhaps 
> the device becomes "/dev/spi/by-name/<label>/spidev.0" or simply 
> "/dev/spidev-<label>.0".

I agree - this makes a lot more sense.

[toc] | [prev] | [next] | [standalone]


#1407163 — Re: [PATCH] devicetree - document using aliases to set spi bus number.

FromRob Herring <robh@kernel.org>
Date2016-05-25 20:50 +0200
SubjectRe: [PATCH] devicetree - document using aliases to set spi bus number.
Message-ID<rCM2t-4mV-3@gated-at.bofh.it>
In reply to#1406306
On Tue, May 24, 2016 at 06:41:41PM +0100, Mark Rutland wrote:
> On Tue, May 24, 2016 at 06:39:20PM +0200, Christer Weinigel wrote:
> > Document how to use devicetree aliases to assign a stable
> > bus number to a spi bus.
> > 
> > Signed-off-by: Christer Weinigel <christer@weinigel.se>
> > 
> > ---
> > 
> > Trivial documentation change.
> > 
> > Not having used devicetree that much it was surprisingly hard to
> > figure out how to assign a stable bus number to a spi bus.  Add a
> > simple example that shows how to do that.
> > 
> > Mark Cced as the SPI maintainer.  Or should trivial documentation
> > fixes like this be addressed to someone else?
> > 
> >   /Christer
> > 
> >  Documentation/devicetree/bindings/spi/spi-bus.txt | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt
> > index 42d5954..c35c4c2 100644
> > --- a/Documentation/devicetree/bindings/spi/spi-bus.txt
> > +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt
> > @@ -94,3 +94,13 @@ SPI example for an MPC5200 SPI bus:
> >  			reg = <1>;
> >  		};
> >  	};
> > +
> > +Normally SPI buses are assigned dynamic bus numbers starting at 32766
> > +and counting downwards.  It is possible to assign the bus number
> > +statically using devicetee aliases.  For example, on the MPC5200 the
> > +"spi@f00" device above is connected to the "soc" bus.  To set its
> > +bus_num to 1 add an aliases entry like this:
> 
> As Mark Brown pointed out, this is very Linux-specific (at least in the
> wording of the above).
> 
> Generally, aliases are there to match _physical_ identifiers (e.g. to
> match physical labels for UART0, UART1, and on).

While there may be some correlation to physical identifiers, the reality 
is aliases are used for mapping to Linux numbering. Their primary use 
has been to avoid breaking existing userspace and kernel command lines 
when converting to DT. The reality is that matters on very few platforms 
and can be solved in other ways for new platforms. For serial port 
console, that means using stdout-path for example. 

For SPI, I think we should use "label" which reflects a name that is 
defined by the h/w design and is meaningful to the user. Then perhaps 
the device becomes "/dev/spi/by-name/<label>/spidev.0" or simply 
"/dev/spidev-<label>.0".

Rob

[toc] | [prev] | [next] | [standalone]


#1407451

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2016-05-26 10:30 +0200
Message-ID<rCYQ2-42k-21@gated-at.bofh.it>
In reply to#1407163
On Wed, May 25, 2016 at 8:44 PM, Rob Herring <robh@kernel.org> wrote:
> On Tue, May 24, 2016 at 06:41:41PM +0100, Mark Rutland wrote:
>> On Tue, May 24, 2016 at 06:39:20PM +0200, Christer Weinigel wrote:
>> > Document how to use devicetree aliases to assign a stable
>> > bus number to a spi bus.
>> >
>> > Signed-off-by: Christer Weinigel <christer@weinigel.se>
>> >
>> > ---
>> >
>> > Trivial documentation change.
>> >
>> > Not having used devicetree that much it was surprisingly hard to
>> > figure out how to assign a stable bus number to a spi bus.  Add a
>> > simple example that shows how to do that.
>> >
>> > Mark Cced as the SPI maintainer.  Or should trivial documentation
>> > fixes like this be addressed to someone else?
>> >
>> >   /Christer
>> >
>> >  Documentation/devicetree/bindings/spi/spi-bus.txt | 10 ++++++++++
>> >  1 file changed, 10 insertions(+)
>> >
>> > diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt
>> > index 42d5954..c35c4c2 100644
>> > --- a/Documentation/devicetree/bindings/spi/spi-bus.txt
>> > +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt
>> > @@ -94,3 +94,13 @@ SPI example for an MPC5200 SPI bus:
>> >                     reg = <1>;
>> >             };
>> >     };
>> > +
>> > +Normally SPI buses are assigned dynamic bus numbers starting at 32766
>> > +and counting downwards.  It is possible to assign the bus number
>> > +statically using devicetee aliases.  For example, on the MPC5200 the
>> > +"spi@f00" device above is connected to the "soc" bus.  To set its
>> > +bus_num to 1 add an aliases entry like this:
>>
>> As Mark Brown pointed out, this is very Linux-specific (at least in the
>> wording of the above).
>>
>> Generally, aliases are there to match _physical_ identifiers (e.g. to
>> match physical labels for UART0, UART1, and on).

Indeed.

> While there may be some correlation to physical identifiers, the reality
> is aliases are used for mapping to Linux numbering. Their primary use
> has been to avoid breaking existing userspace and kernel command lines
> when converting to DT. The reality is that matters on very few platforms
> and can be solved in other ways for new platforms. For serial port
> console, that means using stdout-path for example.

Fortunately the SPI aliases are optional, while for serial devices they
are mandatory in most (all?) drivers. But this is more a relic of the aging
serial subsystem, which still relies on allocating arrays of NR_MAX_PORTS at
driver registration time, and thus can't support uart_port.line counting down
from 32767 for dynamic numbers like SPI does.
(BTW, I'd really like to see that fixed ;-)

Aliases are also an obstacle for DT overlays:
  1. You can't update the aliases from an overlay (I did post a patch to
     implement that, but it's ugly and buggy, but I still use that as I need to
     load DT overlays for serial port testing),
  2. They're almost a guarantee for conflicts (does your overlay provide spi2,
     or does mine?).

So yes, try to stay away from aliases if you can.
There's nothing a udev rule can't solve, can it?

> For SPI, I think we should use "label" which reflects a name that is
> defined by the h/w design and is meaningful to the user. Then perhaps
> the device becomes "/dev/spi/by-name/<label>/spidev.0" or simply
> "/dev/spidev-<label>.0".

I guess using the node name is not an option (say "use standard node names")?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

[toc] | [prev] | [standalone]


Page 3 of 3 — ← Prev page 1 2 [3]

Back to top | Article view | linux.kernel


csiph-web