[PATCH] of: add bus-number specification to spi_mpc8xxx

Grant Likely grant.likely at secretlab.ca
Wed Feb 17 08:23:49 EST 2010


On Tue, Feb 16, 2010 at 11:59 AM, Ernst Schwab <eschwab at online.de> wrote:
> Grant Likely <grant.likely at secretlab.ca> wrote:
>
>> Add a property to the /chosen node to assign short labels to devices.
>
> I'm not familiar with this and will check - does anyone know of an
> existing example for this?

Oops, sorry.  I meant the 'aliases' node.  'chosen' is for something else.

Properties in the aliases node are simply name = "/path/to/node";
pairs.  Do "grep -A 6 arch/powerpc/boot/dts/" to see lots of examples.
dtc expands the <name> = &label; construct into the full path to the
node.

>> Unless you're trying to line up disparate data structure, the actually
>> number assigned to a bus really doesn't matter.  It is better to let
>> Linux dynamically assign than to manually maintain the assigned bus
>> numbers for each machine.  Assuming dynamic assignment also protects
>> against breaking userspace applications when, for whatever reason, the
>> bus numbers get shuffled on a platform.
>
> Hm. What if we have two identical devices, lets say EEPROMs at25,
> connected to two SPI controllers. These are set up as
> /sys/bus/spi/devices/spi32766.0/eeprom and
> /sys/bus/spi/devices/spi32765.0/eeprom.
> How can userspace code determine which one it should
> use if it needs to use the one connected to the first spi controller?
> Can this be solved with the /chosen mechanism?

Use the alias to find the spi bus you care about in /sys/devices/.
Then whichever eeprom has that bus as its parent is the device you
want.  You can read the expanded device tree in /proc/device-tree.
Unfortunately I don't have sample code that shows how to do this; I
haven't had to do so personally yet.

g.


More information about the devicetree-discuss mailing list