diff mbox

[U-Boot,06/22] mmc: Add a fonction to dump the mmc capabilities

Message ID 1494613000-8156-7-git-send-email-jjhiblot@ti.com
State Changes Requested
Delegated to: Jaehoon Chung
Headers show

Commit Message

Jean-Jacques Hiblot May 12, 2017, 6:16 p.m. UTC
This adds a simple helper function to display information (bus width and
mode) based on a capability mask. Useful for debug.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 drivers/mmc/mmc.c | 17 +++++++++++++++++
 include/mmc.h     |  1 +
 2 files changed, 18 insertions(+)

Comments

Simon Glass May 15, 2017, 3:28 a.m. UTC | #1
On 12 May 2017 at 12:16, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
> This adds a simple helper function to display information (bus width and
> mode) based on a capability mask. Useful for debug.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>  drivers/mmc/mmc.c | 17 +++++++++++++++++
>  include/mmc.h     |  1 +
>  2 files changed, 18 insertions(+)

subject: fonction typo

>
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 2e1cb0d..5d418c5 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1133,6 +1133,23 @@ static void mmc_set_bus_width(struct mmc *mmc, uint width)
>         mmc_set_ios(mmc);
>  }
>
> +void mmc_dump_capabilities(const char *text, uint caps)
> +{
> +       enum bus_mode mode;
> +
> +       printf("%s: widths [", text);
> +       if (caps & MMC_MODE_8BIT)
> +               printf("8, ");
> +       if (caps & MMC_MODE_4BIT)
> +               printf("4, ");
> +       printf("1] modes [");
> +
> +       for (mode = MMC_LEGACY; mode < MMC_MODES_END; mode++)
> +               if (MMC_CAP(mode) & caps)
> +                       printf("%s, ", mmc_mode_name(mode));
> +       printf("\b\b]\n");
> +}
> +
>  static int sd_select_bus_freq_width(struct mmc *mmc)
>  {
>         int err;
> diff --git a/include/mmc.h b/include/mmc.h
> index 60a43b0..afda02d 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -422,6 +422,7 @@ enum bus_mode {
>  };
>
>  const char *mmc_mode_name(enum bus_mode mode);
> +void mmc_dump_capabilities(const char *text, uint caps);

Add function comment

>  /*
>   * With CONFIG_DM_MMC enabled, struct mmc can be accessed from the MMC device
>   * with mmc_get_mmc_dev().
> --
> 1.9.1
>
diff mbox

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 2e1cb0d..5d418c5 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1133,6 +1133,23 @@  static void mmc_set_bus_width(struct mmc *mmc, uint width)
 	mmc_set_ios(mmc);
 }
 
+void mmc_dump_capabilities(const char *text, uint caps)
+{
+	enum bus_mode mode;
+
+	printf("%s: widths [", text);
+	if (caps & MMC_MODE_8BIT)
+		printf("8, ");
+	if (caps & MMC_MODE_4BIT)
+		printf("4, ");
+	printf("1] modes [");
+
+	for (mode = MMC_LEGACY; mode < MMC_MODES_END; mode++)
+		if (MMC_CAP(mode) & caps)
+			printf("%s, ", mmc_mode_name(mode));
+	printf("\b\b]\n");
+}
+
 static int sd_select_bus_freq_width(struct mmc *mmc)
 {
 	int err;
diff --git a/include/mmc.h b/include/mmc.h
index 60a43b0..afda02d 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -422,6 +422,7 @@  enum bus_mode {
 };
 
 const char *mmc_mode_name(enum bus_mode mode);
+void mmc_dump_capabilities(const char *text, uint caps);
 /*
  * With CONFIG_DM_MMC enabled, struct mmc can be accessed from the MMC device
  * with mmc_get_mmc_dev().