mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH 5/5] mci: add option to detect non-removable cards during startup
Date: Mon, 2 Jun 2025 15:42:38 +0200	[thread overview]
Message-ID: <7886d152-2f27-4a3a-bd0e-58d4a01c6f77@pengutronix.de> (raw)
In-Reply-To: <20250602-createnv-v1-5-c3239ff875d5@pengutronix.de>

Hi,

On 02.06.25 15:28, Sascha Hauer wrote:
> We can optionally detect all MMC/SD cards during startup which might
> cost some boot time, so this is best disabled. This adds another option
> to detect only cards that are marked non-removable in the device tree
> during startup. The rationale is that we will likely boot from that
> device anyway, so detecting it during startup does not add to the boot
> time.
> 
> We are aiming to find a good place for the barebox environment without
> having to explicitly add it to the device tree. Putting the environment
> into a regular partition is a good start, but the device that has the
> environment needs to be available when we are searching for it. Enabling
> this new option is one way to it.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/mci/Kconfig    | 21 +++++++++++++++++++--
>  drivers/mci/mci-core.c |  6 +++++-
>  include/mci.h          |  1 +
>  3 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
> index 44fd4716aade0882264d389cc08547c3f14986c9..417309cdf502cdf1c2b7e584c886dd94661bb0fb 100644
> --- a/drivers/mci/Kconfig
> +++ b/drivers/mci/Kconfig
> @@ -19,14 +19,31 @@ config MCI_TUNING
>  	  higher clock speeds than 52 MHz SDR. MMC only; SD-Card max
>  	  frequency is 50MHz SDR at present.
>  
> +choice
> +	prompt "MMC startup behaviour"

"MMC detection on startup"?

Does not having a default makes MCI_STARTUP the default now whereas before it was
default n? I think MCI_STARTUP_NONE should be the default instead and
MCI_STARTUP_NONREMOVABLE is what we enable in defconfigs that don't already
have MCI_STARTUP.

> +
>  config MCI_STARTUP
> -	bool "Force probe on system start"
> +	bool "detect cards on system start"

detect all cards on system start

>  	help
> -	  Say 'y' here if the MCI framework should always probe for all attached
> +	  Choose this if the MCI framework should always probe for all attached
>  	  MCI cards on system start up. This may required for some legacy boards.
>  	  When this is 'n', probing happens on demand either with "mci*.probe=1"
>  	  or with driver/board code calling device_detect.
>  
> +config MCI_STARTUP_NONREMOVABLE
> +	bool "detect non removable cards on system start"
> +	help
> +	  Choose this if the MCI framework should detect non removable cards (i.e.
> +	  devices which have the non-removable device tree property).
> +
> +config MCI_STARTUP_NONE
> +	bool "detect not detect cards during system start"

do not detect cards during system start

> +	help
> +	  Choose this if the MCI framework should never detect cards during system
> +	  start

should not detect cards on its own during system start. If this is enabled, cards
will need to be explicitly detected by the user by calling detect or by explicit
reference to the device.

> +
> +endchoice
> +
>  config MCI_INFO
>  	bool "MCI Info"
>  	depends on CMD_DEVINFO
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 23cde58c0c5b1fae4e3692c9ac0989362376d06d..3984852a1d8d21226947aa59bc73a68e79f11d8c 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -3101,7 +3101,9 @@ int mci_register(struct mci_host *host)
>  		devinfo_add(&mci->dev, mci_info);
>  
>  	/* if enabled, probe the attached card immediately */
> -	if (IS_ENABLED(CONFIG_MCI_STARTUP))
> +	if (IS_ENABLED(CONFIG_MCI_STARTUP) ||
> +	   (IS_ENABLED(CONFIG_MCI_STARTUP_NONREMOVABLE) &&
> +	    (host->host_caps & MMC_CAP_NONREMOVABLE)))
>  		mci_card_probe(mci);
>  
>  	if (!(host->caps2 & MMC_CAP2_NO_SD) && dev_of_node(host->hw_dev)) {
> @@ -3195,6 +3197,8 @@ void mci_of_parse_node(struct mci_host *host,
>  		host->caps2 |= MMC_CAP2_NO_SD;
>  	if (of_property_read_bool(np, "no-mmc"))
>  		host->caps2 |= MMC_CAP2_NO_MMC;
> +	if (of_property_read_bool(np, "non-removable"))
> +                host->host_caps |= MMC_CAP_NONREMOVABLE;

We already have struct mci_host::non-removable. I don't mind copying the Linux flag,
but we should then drop the duplication.

>  	if (IS_ENABLED(CONFIG_MCI_TUNING)) {
>  		u32 drv_type;
>  
> diff --git a/include/mci.h b/include/mci.h
> index 207fb9779a14495bdbed782c6d18245d95077055..05114fd72e6cc08025e86fe99021ff041e02101c 100644
> --- a/include/mci.h
> +++ b/include/mci.h
> @@ -58,6 +58,7 @@
>  #define MMC_CAP_1_2V_DDR		(1 << 9)	/* Host supports eMMC DDR 1.2V */
>  #define MMC_CAP_DDR			(MMC_CAP_3_3V_DDR | MMC_CAP_1_8V_DDR | \
>  					 MMC_CAP_1_2V_DDR)
> +#define MMC_CAP_NONREMOVABLE	(1 << 8)	/* Nonremovable e.g. eMMC */
>  #define MMC_CAP_UHS_SDR12	(1 << 16)	/* Host supports UHS SDR12 mode */
>  #define MMC_CAP_UHS_SDR25	(1 << 17)	/* Host supports UHS SDR25 mode */
>  #define MMC_CAP_UHS_SDR50	(1 << 18)	/* Host supports UHS SDR50 mode */
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2025-06-02 13:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-02 13:28 [PATCH 0/5] add createnv command to create environment partition Sascha Hauer
2025-06-02 13:28 ` [PATCH 1/5] partitions: efi: calculate instead of hardcode gpt header fields Sascha Hauer
2025-06-02 13:28 ` [PATCH 2/5] partitions: Start partitions at 8MiB offset Sascha Hauer
2025-06-02 22:16   ` Marco Felsch
2025-06-03  7:46     ` Sascha Hauer
2025-06-02 13:28 ` [PATCH 3/5] cdev: fix cdev_open_by_name() misuse Sascha Hauer
2025-06-02 13:28 ` [PATCH 4/5] commands: create createnv command Sascha Hauer
2025-06-02 13:48   ` Ahmad Fatoum
2025-06-02 14:50     ` Sascha Hauer
2025-06-02 13:28 ` [PATCH 5/5] mci: add option to detect non-removable cards during startup Sascha Hauer
2025-06-02 13:42   ` Ahmad Fatoum [this message]

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=7886d152-2f27-4a3a-bd0e-58d4a01c6f77@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.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