summaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2017-03-20 12:51:48 +0100
committerSimon Glass <sjg@chromium.org>2017-04-04 20:15:10 -0600
commit706865afe54eee83c1f3d7e9ea2f51db8e986d7b (patch)
treee5be7f7819dc9218c850d26d0551b6eedb88f198 /include/dm
parent11db152246607868f0e74db958947fbf79f28119 (diff)
dm: core: Add flags parameter to device_remove()
This patch adds the flags parameter to device_remove() and changes all calls to this function to provide the default value of DM_REMOVE_NORMAL for "normal" device removal. This is in preparation for the driver specific pre-OS (e.g. DMA cancelling) remove support. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Simon Glass <sjg@chromium.org> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/device-internal.h5
-rw-r--r--include/dm/device.h26
2 files changed, 29 insertions, 2 deletions
diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index 0bf8707493..2cabc87338 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -96,12 +96,13 @@ int device_probe(struct udevice *dev);
* children are deactivated first.
*
* @dev: Pointer to device to remove
+ * @flags: Flags for selective device removal
* @return 0 if OK, -ve on error (an error here is normally a very bad thing)
*/
#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
-int device_remove(struct udevice *dev);
+int device_remove(struct udevice *dev, uint flags);
#else
-static inline int device_remove(struct udevice *dev) { return 0; }
+static inline int device_remove(struct udevice *dev, uint flags) { return 0; }
#endif
/**
diff --git a/include/dm/device.h b/include/dm/device.h
index 4e95fb7773..079ec57003 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -46,6 +46,32 @@ struct driver_info;
#define DM_FLAG_OF_PLATDATA (1 << 8)
+/*
+ * Call driver remove function to stop currently active DMA transfers or
+ * give DMA buffers back to the HW / controller. This may be needed for
+ * some drivers to do some final stage cleanup before the OS is called
+ * (U-Boot exit)
+ */
+#define DM_FLAG_ACTIVE_DMA (1 << 9)
+
+/*
+ * 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.
+ */
+enum {
+ /* Normal remove, remove all devices */
+ DM_REMOVE_NORMAL = 1 << 0,
+
+ /* Remove devices with active DMA */
+ DM_REMOVE_ACTIVE_DMA = DM_FLAG_ACTIVE_DMA,
+
+ /* Add more use cases here */
+
+ /* Remove devices with any active flag */
+ DM_REMOVE_ACTIVE_ALL = DM_REMOVE_ACTIVE_DMA,
+};
+
/**
* struct udevice - An instance of a driver
*