u-boot-brain/drivers/core
Masahiro Yamada 608f26c51b devres: introduce Devres (Managed Device Resource) framework
In U-Boot's driver model, memory is basically allocated and freed
in the core framework.  So, low level drivers generally only have
to specify the size of needed memory with .priv_auto_alloc_size,
.platdata_auto_alloc_size, etc.  Nevertheless, some drivers still
need to allocate/free memory on their own in case they cannot
statically know the necessary memory size.  So, I believe it is
reasonable enough to port Devres into U-boot.

Devres, which originates in Linux, manages device resources for each
device and automatically releases them on driver detach.  With devres,
device resources are guaranteed to be freed whether initialization
fails half-way or the device gets detached.

The basic idea is totally the same to that of Linux, but I tweaked
it a bit so that it fits in U-Boot's driver model.

In U-Boot, drivers are activated in two steps: binding and probing.
Binding puts a driver and a device together.  It is just data
manipulation on the system memory, so nothing has happened on the
hardware device at this moment.  When the device is really used, it
is probed.  Probing initializes the real hardware device to make it
really ready for use.

So, the resources acquired during the probing process must be freed
when the device is removed.  Likewise, what has been allocated in
binding should be released when the device is unbound.  The struct
devres has a member "probe" to remember when the resource was
allocated.

CONFIG_DEBUG_DEVRES is also supported for easier debugging.
If enabled, debug messages are printed each time a resource is
allocated/freed.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:44:29 -06:00
..
device-remove.c devres: introduce Devres (Managed Device Resource) framework 2015-08-06 07:44:29 -06:00
device.c devres: introduce Devres (Managed Device Resource) framework 2015-08-06 07:44:29 -06:00
devres.c devres: introduce Devres (Managed Device Resource) framework 2015-08-06 07:44:29 -06:00
dump.c dm: Move the tree/uclass dump code into its own file 2015-07-21 17:39:22 -06:00
Kconfig devres: introduce Devres (Managed Device Resource) framework 2015-08-06 07:44:29 -06:00
lists.c dm: core: Use debug() instead of printf() for failures 2015-07-21 17:39:22 -06:00
Makefile devres: introduce Devres (Managed Device Resource) framework 2015-08-06 07:44:29 -06:00
regmap.c dm: Add support for register maps (regmap) 2015-07-21 17:39:23 -06:00
root.c dm: core: Select device tree control correctly for SPL 2015-04-23 09:05:54 -06:00
simple-bus.c dm: Support address translation for simple-bus 2015-08-06 07:44:28 -06:00
syscon-uclass.c dm: core: Add device checking to syscon_get_regmap() 2015-07-21 17:39:33 -06:00
uclass.c dm: core: Support finding a device by phandle 2015-08-05 20:57:51 -06:00
util.c dm: Add base driver model support 2014-03-04 12:15:29 -05:00