dm: core: Add a way to skip powering down power domains
authorSimon Glass <sjg@chromium.org>
Sat, 28 Mar 2020 20:03:48 +0000 (14:03 -0600)
committerSimon Glass <sjg@chromium.org>
Thu, 16 Apr 2020 14:07:58 +0000 (08:07 -0600)
When removing a device the power domains it uses are generally powered
off. But when we are trying to unbind all devices (e.g. for running tests)
we don't want to probe a device in the 'remove' path.

Add a new flag to skip this power-down step.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/core/device-remove.c
drivers/core/uclass.c
include/dm/device.h

index 8736fd9821e74515ff7a1ef9255e97c97e18a7ed..efdb0f29058f641837d936389563ceb47543d980 100644 (file)
@@ -198,7 +198,8 @@ int device_remove(struct udevice *dev, uint flags)
                }
        }
 
-       if (!(drv->flags &
+       if (!(flags & DM_REMOVE_NO_PD) &&
+           !(drv->flags &
              (DM_FLAG_DEFAULT_PD_CTRL_OFF | DM_FLAG_REMOVE_WITH_PD_ON)) &&
            dev != gd->cur_serial_dev)
                dev_power_domain_off(dev);
index b24b677c55d69a1fc6457d051ebf7e6b9260e6ec..684930293646c0de297114fac52e4d4acf902047 100644 (file)
@@ -118,7 +118,7 @@ int uclass_destroy(struct uclass *uc)
        while (!list_empty(&uc->dev_head)) {
                dev = list_first_entry(&uc->dev_head, struct udevice,
                                       uclass_node);
-               ret = device_remove(dev, DM_REMOVE_NORMAL);
+               ret = device_remove(dev, DM_REMOVE_NORMAL | DM_REMOVE_NO_PD);
                if (ret)
                        return log_msg_ret("remove", ret);
                ret = device_unbind(dev);
index a56164b19bbca6fb442d127c262e707ed5bde590..17e57bf829c51e04eba1a91c4c6414796068cc27 100644 (file)
@@ -80,18 +80,21 @@ struct driver_info;
  */
 enum {
        /* Normal remove, remove all devices */
-       DM_REMOVE_NORMAL     = 1 << 0,
+       DM_REMOVE_NORMAL        = 1 << 0,
 
        /* 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,
+       DM_REMOVE_OS_PREPARE    = DM_FLAG_OS_PREPARE,
 
        /* Add more use cases here */
 
        /* Remove devices with any active flag */
-       DM_REMOVE_ACTIVE_ALL = DM_REMOVE_ACTIVE_DMA | DM_REMOVE_OS_PREPARE,
+       DM_REMOVE_ACTIVE_ALL    = DM_REMOVE_ACTIVE_DMA | DM_REMOVE_OS_PREPARE,
+
+       /* Don't power down any attached power domains */
+       DM_REMOVE_NO_PD         = 1 << 1,
 };
 
 /**