mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-04-15 10:51:31 +00:00
dm: core: Add DM_FLAG_OS_PREPARE flag
This new flag can be added to DM device drivers, which need to do some final configuration before U-Boot exits and the OS (e.g. Linux) is started. The remove functions of those drivers will get called at this stage to do these last-stage configuration steps. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
e98856fcff
commit
426f99fa98
2 changed files with 21 additions and 6 deletions
|
@ -152,6 +152,15 @@ void device_free(struct udevice *dev)
|
||||||
devres_release_probe(dev);
|
devres_release_probe(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool flags_remove(uint flags, uint drv_flags)
|
||||||
|
{
|
||||||
|
if ((flags & DM_REMOVE_NORMAL) ||
|
||||||
|
(flags & (drv_flags & (DM_FLAG_ACTIVE_DMA | DM_FLAG_OS_PREPARE))))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int device_remove(struct udevice *dev, uint flags)
|
int device_remove(struct udevice *dev, uint flags)
|
||||||
{
|
{
|
||||||
const struct driver *drv;
|
const struct driver *drv;
|
||||||
|
@ -178,9 +187,7 @@ int device_remove(struct udevice *dev, uint flags)
|
||||||
* Remove the device if called with the "normal" remove flag set,
|
* Remove the device if called with the "normal" remove flag set,
|
||||||
* or if the remove flag matches any of the drivers remove flags
|
* or if the remove flag matches any of the drivers remove flags
|
||||||
*/
|
*/
|
||||||
if (drv->remove &&
|
if (drv->remove && flags_remove(flags, drv->flags)) {
|
||||||
((flags & DM_REMOVE_NORMAL) ||
|
|
||||||
(flags & (drv->flags & DM_FLAG_ACTIVE_DMA)))) {
|
|
||||||
ret = drv->remove(dev);
|
ret = drv->remove(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_remove;
|
goto err_remove;
|
||||||
|
@ -194,8 +201,7 @@ int device_remove(struct udevice *dev, uint flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & DM_REMOVE_NORMAL) ||
|
if (flags_remove(flags, drv->flags)) {
|
||||||
(flags & (drv->flags & DM_FLAG_ACTIVE_DMA))) {
|
|
||||||
device_free(dev);
|
device_free(dev);
|
||||||
|
|
||||||
dev->seq = -1;
|
dev->seq = -1;
|
||||||
|
|
|
@ -54,6 +54,12 @@ struct driver_info;
|
||||||
*/
|
*/
|
||||||
#define DM_FLAG_ACTIVE_DMA (1 << 9)
|
#define DM_FLAG_ACTIVE_DMA (1 << 9)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call driver remove function to do some final configuration, before
|
||||||
|
* U-Boot exits and the OS is started
|
||||||
|
*/
|
||||||
|
#define DM_FLAG_OS_PREPARE (1 << 10)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* One or multiple of these flags are passed to device_remove() so that
|
* One or multiple of these flags are passed to device_remove() so that
|
||||||
* a selective device removal as specified by the remove-stage and the
|
* a selective device removal as specified by the remove-stage and the
|
||||||
|
@ -66,10 +72,13 @@ enum {
|
||||||
/* Remove devices with active DMA */
|
/* Remove devices with active DMA */
|
||||||
DM_REMOVE_ACTIVE_DMA = DM_FLAG_ACTIVE_DMA,
|
DM_REMOVE_ACTIVE_DMA = DM_FLAG_ACTIVE_DMA,
|
||||||
|
|
||||||
|
/* Remove devices which need some final OS preparation steps */
|
||||||
|
DM_REMOVE_OS_PREPARE = DM_FLAG_OS_PREPARE,
|
||||||
|
|
||||||
/* Add more use cases here */
|
/* Add more use cases here */
|
||||||
|
|
||||||
/* Remove devices with any active flag */
|
/* Remove devices with any active flag */
|
||||||
DM_REMOVE_ACTIVE_ALL = DM_REMOVE_ACTIVE_DMA,
|
DM_REMOVE_ACTIVE_ALL = DM_REMOVE_ACTIVE_DMA | DM_REMOVE_OS_PREPARE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue