All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lokesh Vutla <lokeshvutla@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/2] dm: core: device: switch off power domain after device removal
Date: Tue, 23 Jul 2019 19:35:43 +0530	[thread overview]
Message-ID: <93c52947-48ce-809d-8f6b-c1b1cfc197aa@ti.com> (raw)
In-Reply-To: <20190714195732.31232-1-agust@denx.de>



On 15/07/19 1:27 AM, Anatolij Gustschin wrote:
> The power domain associated with a device is enabled when probing,
> but currently the domain remains enabled when the device is removed.
> Some boards started to disable power domains for selected devices
> via custom board_quiesce_devices(), but it doesn't work in many
> cases, i. e. because devices still can be accessed later in
> .remove() callback on behalf of dm_remove_devices_flags().
> 
> Utilize the DM core to power off the device power domain, but add a
> device flag to be able to selectively let the power domain enabled
> after device removal. This might be required for devices that must
> remain enabled when booting OS, i. e. serial console for debug
> output, etc.
> 
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
> Changes in v2:
>  - use CONFIG_IS_ENABLED(POWER_DOMAIN) to reduce code size
> 
>  drivers/core/device-remove.c | 9 +++++++++
>  include/dm/device.h          | 6 ++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
> index 586fadee0a..abed84a652 100644
> --- a/drivers/core/device-remove.c
> +++ b/drivers/core/device-remove.c
> @@ -16,6 +16,7 @@
>  #include <dm/uclass.h>
>  #include <dm/uclass-internal.h>
>  #include <dm/util.h>
> +#include <power-domain.h>
>  
>  int device_chld_unbind(struct udevice *dev, struct driver *drv)
>  {
> @@ -154,6 +155,7 @@ static bool flags_remove(uint flags, uint drv_flags)
>  
>  int device_remove(struct udevice *dev, uint flags)
>  {
> +	struct power_domain pd;
>  	const struct driver *drv;
>  	int ret;
>  
> @@ -192,6 +194,13 @@ int device_remove(struct udevice *dev, uint flags)
>  		}
>  	}
>  
> +	if (CONFIG_IS_ENABLED(POWER_DOMAIN) && dev->parent &&
> +	    device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN &&
> +	    !(dev->flags & DM_FLAG_REMOVE_WITH_PD_ON)) {

This is going to hit every board and all serial drivers needs to be updated. Can
we add an extra check here for (dev != gd->cur_serial_dev).

Thanks and regards,
Lokesh

> +		if (!power_domain_get(dev, &pd))
> +			power_domain_off(&pd);
> +	}
> +
>  	if (flags_remove(flags, drv->flags)) {
>  		device_free(dev);
>  
> diff --git a/include/dm/device.h b/include/dm/device.h
> index 27a6d7b9fd..9a98a4a39e 100644
> --- a/include/dm/device.h
> +++ b/include/dm/device.h
> @@ -61,6 +61,12 @@ struct driver_info;
>   */
>  #define DM_FLAG_OS_PREPARE		(1 << 10)
>  
> +/*
> + * Device is removed without switching off its power domain. This might
> + * be required, i. e. for serial console (debug) output when booting OS.
> + */
> +#define DM_FLAG_REMOVE_WITH_PD_ON	(1 << 11)
> +
>  /*
>   * 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
> 

  parent reply	other threads:[~2019-07-23 14:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-14 19:57 [U-Boot] [PATCH v2 1/2] dm: core: device: switch off power domain after device removal Anatolij Gustschin
2019-07-14 19:57 ` [U-Boot] [PATCH v2 2/2] serial: lpuart: request dm device removal when booting OS Anatolij Gustschin
2019-07-15  3:02   ` Peng Fan
2019-07-31 13:11     ` Anatolij Gustschin
2019-07-15  2:59 ` [U-Boot] [PATCH v2 1/2] dm: core: device: switch off power domain after device removal Peng Fan
2019-07-18 15:22   ` Simon Glass
2019-07-31 16:01     ` Anatolij Gustschin
2019-07-31 16:29       ` Simon Glass
2019-07-31 17:02         ` Anatolij Gustschin
2019-07-23 14:05 ` Lokesh Vutla [this message]
2019-07-31 13:13   ` Anatolij Gustschin

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=93c52947-48ce-809d-8f6b-c1b1cfc197aa@ti.com \
    --to=lokeshvutla@ti.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.