On Mon, Mar 14, 2011 at 03:10:19PM -0600, Grant Likely wrote:
[...]
Several weeks back I posted a patch for of_platform_bus_snoop() which matches platform_device registrations to nodes in the device tree instead of allocating and registering a new device. I've spent some more time on that patch in the last couple of weeks to the point that I'm happy with the model and I'm almost ready to push it out to my devicetree/test branch. John Bonesio is currently refactoring and
I have seen it on devicetree/test branch.
cleaning it up for me so that it can get posted. You can see the current state in my devicetree/preregister branch, with tegra modified to use it.
The model is:
- Platform code calls of_platform_device_preregister() to tell the DT code about the nodes it /intends/ to register as devices.
- Platform code can register as many or as few platform_devices as it likes. If any of these devices match one of the nodes passed by of_platform_device_preregister(), then the DT code will set the of_node pointer before it gets bound to a device.
- Platform code calls of_platform_device_probe() which will register platform_devices for any nodes which *did not* get assigned to a device in step 2.
I implemented this as a way to allow dt and non-dt use-cases to share the same SoC setup code so that anything on-chip would get registered in the same way, but would also get the benefit of being linked to its device tree node. For example, to obtain the list of i2c devices or gpio connections from the tree. It also helps solve the problem of matching nodes to clks which are currently matched by name. I think it would also solve your use case, at least in the short term.
I'm seeing this approach benefits the smooth moving of dt on ARM, but will this be the ultimate shape of dt support on ARM?