[RFC] dt: add of_platform_bus_snoop() which attaches nodes to devices

Grant Likely grant.likely at secretlab.ca
Tue Feb 1 09:07:49 EST 2011


On Mon, Jan 31, 2011 at 3:01 PM, Grant Likely <grant.likely at secretlab.ca> wrote:
> This patch implements an alternate method for using device tree data
> for populating machine device registration.  Traditionally, board
> support has directly generated and registered devices based on nodes
> in the device tree.  The board support code starts at the root of the
> tree and begins allocating devices for each device node it finds.
> Similarly, bus drivers (i2c, spi, etc.) use their child nodes to
> register child devices.  This model can be seen in almost all the powerpc
> board ports (arch/powerpc/platforms/*).
>
> However, for many of the ARM SoCs, there already exists complete board
> support for many SoCs that have their own code for registering the
> basic set of platform devices with non-trivial dependencies on clock
> structure and machine specific platform code.  While starting at the
> base of the tree and working up is certainly possible, it requires
> modifying a lot of machine support code to get it working.
>
> Instead, this patch provides an alternate approach.  Instead of
> starting at the root of the tree and working up, this patch allows the
> SoC support code to register its standard set of platform devices in
> the normal way.  However, it also registers a platform_bus notifier
> function which compares platform_device registrations with data in the
> device tree.  Whenever it finds a matching node, it increments the
> node reference count and assigns it to the device's of_node pointer so
> that it is available for the device driver to use and bind against.
> For example, an spi master driver would have access to the spi node
> which contains information about all the spi slaves on the bus.

One more note.  It might also be a good idea to do something like this
for the PCI and AMBA buses.  I've not yet looked at how much code
could be made common for implementing that.

g.


More information about the devicetree-discuss mailing list