From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/4] dm: core: Add DM_FLAG_PRE_OS_FINALIZE flag
Date: Thu, 6 Apr 2017 15:29:42 +0200 [thread overview]
Message-ID: <20170406132944.476-2-sr@denx.de> (raw)
In-Reply-To: <20170406132944.476-1-sr@denx.de>
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>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
---
drivers/core/device-remove.c | 17 ++++++++++++-----
include/dm/device.h | 11 ++++++++++-
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
index 8b46f3343e..390be5a0d8 100644
--- a/drivers/core/device-remove.c
+++ b/drivers/core/device-remove.c
@@ -148,6 +148,16 @@ void device_free(struct udevice *dev)
devres_release_probe(dev);
}
+static int flags_remove(uint flags, uint drv_flags)
+{
+ if ((flags & DM_REMOVE_NORMAL) ||
+ (flags & (drv_flags &
+ (DM_FLAG_ACTIVE_DMA | DM_FLAG_PRE_OS_FINALIZE))))
+ return 1;
+
+ return 0;
+}
+
int device_remove(struct udevice *dev, uint flags)
{
const struct driver *drv;
@@ -174,9 +184,7 @@ int device_remove(struct udevice *dev, uint flags)
* Remove the device if called with the "normal" remove flag set,
* or if the remove flag matches any of the drivers remove flags
*/
- if (drv->remove &&
- ((flags & DM_REMOVE_NORMAL) ||
- (flags & (drv->flags & DM_FLAG_ACTIVE_DMA)))) {
+ if (drv->remove && flags_remove(flags, drv->flags)) {
ret = drv->remove(dev);
if (ret)
goto err_remove;
@@ -190,8 +198,7 @@ int device_remove(struct udevice *dev, uint flags)
}
}
- if ((flags & DM_REMOVE_NORMAL) ||
- (flags & (drv->flags & DM_FLAG_ACTIVE_DMA))) {
+ if (flags_remove(flags, drv->flags)) {
device_free(dev);
dev->seq = -1;
diff --git a/include/dm/device.h b/include/dm/device.h
index 079ec57003..c49b8e688e 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -55,6 +55,12 @@ struct driver_info;
#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_PRE_OS_FINALIZE (1 << 10)
+
+/*
* 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
* driver flags can be done.
@@ -66,10 +72,13 @@ enum {
/* Remove devices with active DMA */
DM_REMOVE_ACTIVE_DMA = DM_FLAG_ACTIVE_DMA,
+ /* Remove devices which need some pre-OS finalization */
+ DM_REMOVE_PRE_OS_FINALIZE = DM_FLAG_PRE_OS_FINALIZE,
+
/* Add more use cases here */
/* Remove devices with any active flag */
- DM_REMOVE_ACTIVE_ALL = DM_REMOVE_ACTIVE_DMA,
+ DM_REMOVE_ACTIVE_ALL = DM_REMOVE_ACTIVE_DMA | DM_REMOVE_PRE_OS_FINALIZE,
};
/**
--
2.12.2
next prev parent reply other threads:[~2017-04-06 13:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-06 13:29 [U-Boot] [PATCH 1/4] dm: device_remove: Don't return in device_chld_remove() upon error Stefan Roese
2017-04-06 13:29 ` Stefan Roese [this message]
2017-04-09 19:28 ` [U-Boot] [PATCH 2/4] dm: core: Add DM_FLAG_PRE_OS_FINALIZE flag Simon Glass
2017-04-19 9:49 ` Stefan Roese
2017-04-06 13:29 ` [U-Boot] [PATCH 3/4] x86: bootm: Add dm_remove_devices_flags() call to bootm_announce_and_cleanup() Stefan Roese
2017-04-09 19:28 ` Simon Glass
2017-04-06 13:29 ` [U-Boot] [PATCH 4/4] spi: ich: Configure SPI BIOS parameters for Linux upon U-Boot exit Stefan Roese
2017-04-07 6:53 ` Jagan Teki
2017-04-09 19:28 ` Simon Glass
2017-04-09 19:28 ` [U-Boot] [PATCH 1/4] dm: device_remove: Don't return in device_chld_remove() upon error Simon Glass
2017-04-19 9:27 ` Stefan Roese
2017-04-24 3:38 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170406132944.476-2-sr@denx.de \
--to=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox