Commit 97f3ee34 authored by Simon Glass's avatar Simon Glass
Browse files

dm: Add platform data advice and admonishment



We should guide people more strongly towards device tree to avoid the
proliferation of platform data structures. Add documentation to the driver
model README, and also the platform data header file.
Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
parent e15bb3e6
...@@ -301,6 +301,15 @@ device tree) and probe. ...@@ -301,6 +301,15 @@ device tree) and probe.
Platform Data Platform Data
------------- -------------
*** Note: platform data is the old way of doing things. It is
*** basically a C structure which is passed to drivers to tell them about
*** platform-specific settings like the address of its registers, bus
*** speed, etc. Device tree is now the preferred way of handling this.
*** Unless you have a good reason not to use device tree (the main one
*** being you need serial support in SPL and don't have enough SRAM for
*** the cut-down device tree and libfdt libraries) you should stay away
*** from platform data.
Platform data is like Linux platform data, if you are familiar with that. Platform data is like Linux platform data, if you are familiar with that.
It provides the board-specific information to start up a device. It provides the board-specific information to start up a device.
...@@ -366,8 +375,12 @@ Device Tree ...@@ -366,8 +375,12 @@ Device Tree
----------- -----------
While platdata is useful, a more flexible way of providing device data is While platdata is useful, a more flexible way of providing device data is
by using device tree. With device tree we replace the above code with the by using device tree. In U-Boot you should use this where possible. Avoid
following device tree fragment: sending patches which make use of the U_BOOT_DEVICE() macro unless strictly
necessary.
With device tree we replace the above code with the following device tree
fragment:
red-square { red-square {
compatible = "demo-shape"; compatible = "demo-shape";
......
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
/** /**
* struct driver_info - Information required to instantiate a device * struct driver_info - Information required to instantiate a device
* *
* NOTE: Avoid using this except in extreme circumstances, where device tree
* is not feasible (e.g. serial driver in SPL where <8KB of SRAM is
* available). U-Boot's driver model uses device tree for configuration.
*
* @name: Driver name * @name: Driver name
* @platdata: Driver-specific platform data * @platdata: Driver-specific platform data
*/ */
...@@ -24,6 +28,11 @@ struct driver_info { ...@@ -24,6 +28,11 @@ struct driver_info {
const void *platdata; const void *platdata;
}; };
/**
* NOTE: Avoid using these except in extreme circumstances, where device tree
* is not feasible (e.g. serial driver in SPL where <8KB of SRAM is
* available). U-Boot's driver model uses device tree for configuration.
*/
#define U_BOOT_DEVICE(__name) \ #define U_BOOT_DEVICE(__name) \
ll_entry_declare(struct driver_info, __name, driver_info) ll_entry_declare(struct driver_info, __name, driver_info)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment