From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752858AbcEZIVI (ORCPT ); Thu, 26 May 2016 04:21:08 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:35020 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750791AbcEZIVB (ORCPT ); Thu, 26 May 2016 04:21:01 -0400 MIME-Version: 1.0 In-Reply-To: <20160525184421.GB10753@rob-hp-laptop> References: <1464107960-10775-1-git-send-email-christer@weinigel.se> <20160524174140.GE11605@leverpostej> <20160525184421.GB10753@rob-hp-laptop> Date: Thu, 26 May 2016 10:21:00 +0200 X-Google-Sender-Auth: DJQEVG_nNEm9XjSuAavcK6T0Ios Message-ID: Subject: Re: [PATCH] devicetree - document using aliases to set spi bus number. From: Geert Uytterhoeven To: Rob Herring Cc: Mark Rutland , Christer Weinigel , "linux-kernel@vger.kernel.org" , linux-spi , "devicetree@vger.kernel.org" , Mark Brown Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 25, 2016 at 8:44 PM, Rob Herring 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 >> > >> > --- >> > >> > 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/