All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v4 00/10] mmc: fixes for HS200/UHS core support
@ 2017-11-29 14:29 Jean-Jacques Hiblot
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 01/10] mmc: dump card and host capabilities if debug is enabled Jean-Jacques Hiblot
                   ` (8 more replies)
  0 siblings, 9 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-11-29 14:29 UTC (permalink / raw)
  To: u-boot

This series applies on top of "[PATCH v2 00/26] mmc: Add support for HS200
and UHS modes"

It fixes a bug with old SD and MMC cards that support only the legacy mode.
This series also adresses the problem of increased code size that broke some
platform (openrd and omapl138_lcdk) by making more things optional.

It also addresses other comments made on the mailing list:
* dump card and host capabilities in debug mode
* use 1-bit if the DTS property 'bus-width' is not present.
* recognize the "mmc-ddr-1_2v" and "mmc-hs200-1_2v" DTS properties
* convert mmc_of_parse to livetree

  
Tested on DRA72

changes since v3:
* Make UHS support optional. Disabled by default
* Make HS200 support optional. Disabled by default
* Make eMMC Hardware Partitioning optional. Enabled by default
* Display most of the error messages only if MMC_VERBOSE is set (it's set by default)

changes since v2:
* use the device-oriented helpers like dev_read_u32_default() instead of using
  the livetree API
* Dump the host and card capabilities only in when debug is enabled. Also dump
  the capabilities when 'mmc info' is executed if the verbose option is enabled

changes since v1:
* convert mmc_of_parse to livetree
* squashed all changes to mmc_of_parse in a single patch


Jean-Jacques Hiblot (10):
  mmc: dump card and host capabilities if debug is enabled
  dm: mmc: update mmc_of_parse()
  mmc: Fixed a problem with old sd or mmc that do not support High speed
  mmc: all hosts support 1-bit bus width and legacy timings
  mmc: fix for old MMCs (below version 4)
  mmc: don't use malloc_cache_aligned()
  mmc: allow to compile out the error messages
  mmc: make UHS and HS200 optional
  mmc: make optional the support for eMMMC hardware partitioning
  configs: openrd: removed support for eMMC hardware partitioning

 cmd/mmc.c                         |   8 ++
 configs/openrd_base_defconfig     |   1 +
 configs/openrd_client_defconfig   |   1 +
 configs/openrd_ultimate_defconfig |   1 +
 drivers/mmc/Kconfig               |  54 +++++++++++++
 drivers/mmc/mmc-uclass.c          |  40 ++++++----
 drivers/mmc/mmc.c                 | 162 +++++++++++++++++++++++++++++---------
 include/mmc.h                     |  38 +++++++--
 8 files changed, 245 insertions(+), 60 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 01/10] mmc: dump card and host capabilities if debug is enabled
  2017-11-29 14:29 [U-Boot] [PATCH v4 00/10] mmc: fixes for HS200/UHS core support Jean-Jacques Hiblot
@ 2017-11-29 14:29 ` Jean-Jacques Hiblot
  2017-12-02  3:29   ` Simon Glass
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 02/10] dm: mmc: update mmc_of_parse() Jean-Jacques Hiblot
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-11-29 14:29 UTC (permalink / raw)
  To: u-boot

This is a useful information while debugging the initialization process or
performance issues.
Also dump this information with the other mmc info if the verbose option
is selected

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---

no changes since v3

 cmd/mmc.c         | 4 ++++
 drivers/mmc/mmc.c | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/cmd/mmc.c b/cmd/mmc.c
index 6d48ecb..25795e0 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -24,7 +24,11 @@ static void print_mmcinfo(struct mmc *mmc)
 			(mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff);
 
 	printf("Bus Speed: %d\n", mmc->clock);
+#if CONFIG_IS_ENABLED(MMC_VERBOSE)
 	printf("Mode : %s\n", mmc_mode_name(mmc->selected_mode));
+	mmc_dump_capabilities("card capabilities", mmc->card_caps);
+	mmc_dump_capabilities("host capabilities", mmc->host_caps);
+#endif
 	printf("Rd Block Len: %d\n", mmc->read_bl_len);
 
 	printf("%s version %d.%d", IS_SD(mmc) ? "SD" : "MMC",
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index ab2483e..9b5c982 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1582,6 +1582,10 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps)
 	bool uhs_en = (mmc->ocr & OCR_S18R) ? true : false;
 	uint caps;
 
+#ifdef DEBUG
+	mmc_dump_capabilities("sd card", card_caps);
+	mmc_dump_capabilities("host", mmc->host_caps | MMC_MODE_1BIT);
+#endif
 
 	/* Restrict card's capabilities by what the host can do */
 	caps = card_caps & (mmc->host_caps | MMC_MODE_1BIT);
@@ -1764,6 +1768,11 @@ static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps)
 	const struct mode_width_tuning *mwt;
 	const struct ext_csd_bus_width *ecbw;
 
+#ifdef DEBUG
+	mmc_dump_capabilities("mmc", card_caps);
+	mmc_dump_capabilities("host", mmc->host_caps | MMC_MODE_1BIT);
+#endif
+
 	/* Restrict card's capabilities by what the host can do */
 	card_caps &= (mmc->host_caps | MMC_MODE_1BIT);
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 02/10] dm: mmc: update mmc_of_parse()
  2017-11-29 14:29 [U-Boot] [PATCH v4 00/10] mmc: fixes for HS200/UHS core support Jean-Jacques Hiblot
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 01/10] mmc: dump card and host capabilities if debug is enabled Jean-Jacques Hiblot
@ 2017-11-29 14:29 ` Jean-Jacques Hiblot
  2017-12-02  3:29   ` Simon Glass
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 03/10] mmc: Fixed a problem with old sd or mmc that do not support High speed Jean-Jacques Hiblot
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-11-29 14:29 UTC (permalink / raw)
  To: u-boot

* convert to livetree API
* don't fail because of an invalid bus-width, instead default to 1-bit.
* recognize 1.2v DDR and 1.2v HS200 flags

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---

no changes since v3

 drivers/mmc/mmc-uclass.c | 36 ++++++++++++++++++++----------------
 include/mmc.h            | 11 ++++++++++-
 2 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index e30cde7..bfda942 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -10,7 +10,6 @@
 #include <dm.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
-#include <dm/root.h>
 #include "mmc_private.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -120,11 +119,11 @@ int mmc_execute_tuning(struct mmc *mmc, uint opcode)
 	return dm_mmc_execute_tuning(mmc->dev, opcode);
 }
 
-int mmc_of_parse(const void *fdt, int node, struct mmc_config *cfg)
+int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg)
 {
 	int val;
 
-	val = fdtdec_get_int(fdt, node, "bus-width", 1);
+	val = dev_read_u32_default(dev, "bus-width", 1);
 
 	switch (val) {
 	case 0x8:
@@ -137,30 +136,35 @@ int mmc_of_parse(const void *fdt, int node, struct mmc_config *cfg)
 		cfg->host_caps |= MMC_MODE_1BIT;
 		break;
 	default:
-		printf("error: %s invalid bus-width property %d\n",
-		       fdt_get_name(fdt, node, NULL), val);
-		return -ENOENT;
+		debug("warning: %s invalid bus-width property. using 1-bit\n",
+		      dev_read_name(dev));
+		cfg->host_caps |= MMC_MODE_1BIT;
+		break;
 	}
 
-	cfg->f_max = fdtdec_get_int(fdt, node, "max-frequency", 52000000);
+	cfg->f_max = dev_read_u32_default(dev, "max-frequency", 52000000);
 
-	if (fdtdec_get_bool(fdt, node, "cap-sd-highspeed"))
+	if (dev_read_bool(dev, "cap-sd-highspeed"))
 		cfg->host_caps |= MMC_CAP(SD_HS);
-	if (fdtdec_get_bool(fdt, node, "cap-mmc-highspeed"))
+	if (dev_read_bool(dev, "cap-mmc-highspeed"))
 		cfg->host_caps |= MMC_CAP(MMC_HS);
-	if (fdtdec_get_bool(fdt, node, "sd-uhs-sdr12"))
+	if (dev_read_bool(dev, "sd-uhs-sdr12"))
 		cfg->host_caps |= MMC_CAP(UHS_SDR12);
-	if (fdtdec_get_bool(fdt, node, "sd-uhs-sdr25"))
+	if (dev_read_bool(dev, "sd-uhs-sdr25"))
 		cfg->host_caps |= MMC_CAP(UHS_SDR25);
-	if (fdtdec_get_bool(fdt, node, "sd-uhs-sdr50"))
+	if (dev_read_bool(dev, "sd-uhs-sdr50"))
 		cfg->host_caps |= MMC_CAP(UHS_SDR50);
-	if (fdtdec_get_bool(fdt, node, "sd-uhs-sdr104"))
+	if (dev_read_bool(dev, "sd-uhs-sdr104"))
 		cfg->host_caps |= MMC_CAP(UHS_SDR104);
-	if (fdtdec_get_bool(fdt, node, "sd-uhs-ddr50"))
+	if (dev_read_bool(dev, "sd-uhs-ddr50"))
 		cfg->host_caps |= MMC_CAP(UHS_DDR50);
-	if (fdtdec_get_bool(fdt, node, "mmc-ddr-1_8v"))
+	if (dev_read_bool(dev, "mmc-ddr-1_8v"))
 		cfg->host_caps |= MMC_CAP(MMC_DDR_52);
-	if (fdtdec_get_bool(fdt, node, "mmc-hs200-1_8v"))
+	if (dev_read_bool(dev, "mmc-ddr-1_2v"))
+		cfg->host_caps |= MMC_CAP(MMC_DDR_52);
+	if (dev_read_bool(dev, "mmc-hs200-1_8v"))
+		cfg->host_caps |= MMC_CAP(MMC_HS_200);
+	if (dev_read_bool(dev, "mmc-hs200-1_2v"))
 		cfg->host_caps |= MMC_CAP(MMC_HS_200);
 
 	return 0;
diff --git a/include/mmc.h b/include/mmc.h
index 6230a32..e3f777f 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -651,7 +651,16 @@ int mmc_unbind(struct udevice *dev);
 int mmc_initialize(bd_t *bis);
 int mmc_init(struct mmc *mmc);
 int mmc_send_tuning(struct mmc *mmc, u32 opcode, int *cmd_error);
-int mmc_of_parse(const void *fdt, int node, struct mmc_config *cfg);
+
+/**
+ * mmc_of_parse() - Parse the device tree to get the capabilities of the host
+ *
+ * @dev:	MMC device
+ * @cfg:	MMC configuration
+ * @return 0 if OK, -ve on error
+ */
+int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg);
+
 int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size);
 
 /**
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 03/10] mmc: Fixed a problem with old sd or mmc that do not support High speed
  2017-11-29 14:29 [U-Boot] [PATCH v4 00/10] mmc: fixes for HS200/UHS core support Jean-Jacques Hiblot
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 01/10] mmc: dump card and host capabilities if debug is enabled Jean-Jacques Hiblot
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 02/10] dm: mmc: update mmc_of_parse() Jean-Jacques Hiblot
@ 2017-11-29 14:29 ` Jean-Jacques Hiblot
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 04/10] mmc: all hosts support 1-bit bus width and legacy timings Jean-Jacques Hiblot
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-11-29 14:29 UTC (permalink / raw)
  To: u-boot

As the legacy modes were not added to the list of supported modes, old
cards that do not support other modes could not be used.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
no change since v1

 drivers/mmc/mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 9b5c982..c1f8851 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -818,7 +818,7 @@ static int mmc_get_capabilities(struct mmc *mmc)
 	u8 *ext_csd = mmc->ext_csd;
 	char cardtype;
 
-	mmc->card_caps = MMC_MODE_1BIT;
+	mmc->card_caps = MMC_MODE_1BIT | MMC_CAP(MMC_LEGACY);
 
 	if (mmc_host_is_spi(mmc))
 		return 0;
@@ -1171,7 +1171,7 @@ static int sd_get_capabilities(struct mmc *mmc)
 	int timeout;
 	u32 sd3_bus_mode;
 
-	mmc->card_caps = MMC_MODE_1BIT;
+	mmc->card_caps = MMC_MODE_1BIT | MMC_CAP(SD_LEGACY);
 
 	if (mmc_host_is_spi(mmc))
 		return 0;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 04/10] mmc: all hosts support 1-bit bus width and legacy timings
  2017-11-29 14:29 [U-Boot] [PATCH v4 00/10] mmc: fixes for HS200/UHS core support Jean-Jacques Hiblot
                   ` (2 preceding siblings ...)
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 03/10] mmc: Fixed a problem with old sd or mmc that do not support High speed Jean-Jacques Hiblot
@ 2017-11-29 14:29 ` Jean-Jacques Hiblot
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 05/10] mmc: fix for old MMCs (below version 4) Jean-Jacques Hiblot
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-11-29 14:29 UTC (permalink / raw)
  To: u-boot

Make sure that those basic capabilities are advertised by the host.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

no change since v1


 drivers/mmc/mmc.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index c1f8851..0ebcc45 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1584,11 +1584,11 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps)
 
 #ifdef DEBUG
 	mmc_dump_capabilities("sd card", card_caps);
-	mmc_dump_capabilities("host", mmc->host_caps | MMC_MODE_1BIT);
+	mmc_dump_capabilities("host", mmc->host_caps);
 #endif
 
 	/* Restrict card's capabilities by what the host can do */
-	caps = card_caps & (mmc->host_caps | MMC_MODE_1BIT);
+	caps = card_caps & mmc->host_caps;
 
 	if (!uhs_en)
 		caps &= ~UHS_CAPS;
@@ -1770,11 +1770,11 @@ static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps)
 
 #ifdef DEBUG
 	mmc_dump_capabilities("mmc", card_caps);
-	mmc_dump_capabilities("host", mmc->host_caps | MMC_MODE_1BIT);
+	mmc_dump_capabilities("host", mmc->host_caps);
 #endif
 
 	/* Restrict card's capabilities by what the host can do */
-	card_caps &= (mmc->host_caps | MMC_MODE_1BIT);
+	card_caps &= mmc->host_caps;
 
 	/* Only version 4 of MMC supports wider bus widths */
 	if (mmc->version < MMC_VERSION_4)
@@ -2389,7 +2389,12 @@ int mmc_start_init(struct mmc *mmc)
 	bool uhs_en = supports_uhs(mmc->cfg->host_caps);
 	int err;
 
-	mmc->host_caps = mmc->cfg->host_caps;
+	/*
+	 * all hosts are capable of 1 bit bus-width and able to use the legacy
+	 * timings.
+	 */
+	mmc->host_caps = mmc->cfg->host_caps | MMC_CAP(SD_LEGACY) |
+			 MMC_CAP(MMC_LEGACY) | MMC_MODE_1BIT;
 
 	/* we pretend there's no card when init is NULL */
 	no_card = mmc_getcd(mmc) == 0;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 05/10] mmc: fix for old MMCs (below version 4)
  2017-11-29 14:29 [U-Boot] [PATCH v4 00/10] mmc: fixes for HS200/UHS core support Jean-Jacques Hiblot
                   ` (3 preceding siblings ...)
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 04/10] mmc: all hosts support 1-bit bus width and legacy timings Jean-Jacques Hiblot
@ 2017-11-29 14:29 ` Jean-Jacques Hiblot
  2017-12-02  3:29   ` Simon Glass
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 06/10] mmc: don't use malloc_cache_aligned() Jean-Jacques Hiblot
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-11-29 14:29 UTC (permalink / raw)
  To: u-boot

The ext_csd is allocated only for MMC above version 4. The compare will
crash or fail for older MMCs.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 drivers/mmc/mmc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 0ebcc45..2a58031 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1657,6 +1657,9 @@ static int mmc_read_and_compare_ext_csd(struct mmc *mmc)
 	const u8 *ext_csd = mmc->ext_csd;
 	ALLOC_CACHE_ALIGN_BUFFER(u8, test_csd, MMC_MAX_BLOCK_LEN);
 
+	if (mmc->version < MMC_VERSION_4)
+		return 0;
+
 	err = mmc_send_ext_csd(mmc, test_csd);
 	if (err)
 		return err;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 06/10] mmc: don't use malloc_cache_aligned()
  2017-11-29 14:29 [U-Boot] [PATCH v4 00/10] mmc: fixes for HS200/UHS core support Jean-Jacques Hiblot
                   ` (4 preceding siblings ...)
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 05/10] mmc: fix for old MMCs (below version 4) Jean-Jacques Hiblot
@ 2017-11-29 14:29 ` Jean-Jacques Hiblot
  2017-12-02  3:29   ` Simon Glass
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 07/10] mmc: allow to compile out the error messages Jean-Jacques Hiblot
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-11-29 14:29 UTC (permalink / raw)
  To: u-boot

Not using this function reduces the size of the binary. It's replaces by
a standard malloc() and the alignment requirement is handled by an
intermediate buffer on the stack.

Also make sure that the allocated buffer is freed in case of error.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 drivers/mmc/mmc.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 2a58031..13979a5 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1867,21 +1867,23 @@ static int mmc_startup_v4(struct mmc *mmc)
 	u64 capacity;
 	bool has_parts = false;
 	bool part_completed;
-	u8 *ext_csd;
+	ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN);
 
 	if (IS_SD(mmc) || (mmc->version < MMC_VERSION_4))
 		return 0;
 
-	ext_csd = malloc_cache_aligned(MMC_MAX_BLOCK_LEN);
-	if (!ext_csd)
-		return -ENOMEM;
-
-	mmc->ext_csd = ext_csd;
-
 	/* check  ext_csd version and capacity */
 	err = mmc_send_ext_csd(mmc, ext_csd);
 	if (err)
-		return err;
+		goto error;
+
+	/* store the ext csd for future reference */
+	if (!mmc->ext_csd)
+		mmc->ext_csd = malloc(MMC_MAX_BLOCK_LEN);
+	if (!mmc->ext_csd)
+		return -ENOMEM;
+	memcpy(mmc->ext_csd, ext_csd, MMC_MAX_BLOCK_LEN);
+
 	if (ext_csd[EXT_CSD_REV] >= 2) {
 		/*
 		 * According to the JEDEC Standard, the value of
@@ -1990,7 +1992,7 @@ static int mmc_startup_v4(struct mmc *mmc)
 				 EXT_CSD_ERASE_GROUP_DEF, 1);
 
 		if (err)
-			return err;
+			goto error;
 
 		ext_csd[EXT_CSD_ERASE_GROUP_DEF] = 1;
 	}
@@ -2029,6 +2031,12 @@ static int mmc_startup_v4(struct mmc *mmc)
 	mmc->wr_rel_set = ext_csd[EXT_CSD_WR_REL_SET];
 
 	return 0;
+error:
+	if (mmc->ext_csd) {
+		free(mmc->ext_csd);
+		mmc->ext_csd = NULL;
+	}
+	return err;
 }
 
 static int mmc_startup(struct mmc *mmc)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 07/10] mmc: allow to compile out the error messages
  2017-11-29 14:29 [U-Boot] [PATCH v4 00/10] mmc: fixes for HS200/UHS core support Jean-Jacques Hiblot
                   ` (5 preceding siblings ...)
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 06/10] mmc: don't use malloc_cache_aligned() Jean-Jacques Hiblot
@ 2017-11-29 14:29 ` Jean-Jacques Hiblot
  2017-11-29 18:43   ` Tom Rini
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 08/10] mmc: make UHS and HS200 optional Jean-Jacques Hiblot
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 09/10] mmc: make optional the support for eMMMC hardware partitioning Jean-Jacques Hiblot
  8 siblings, 1 reply; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-11-29 14:29 UTC (permalink / raw)
  To: u-boot

Error messages may not be as valued as code space. Allow to compile out
most of them to free space.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 drivers/mmc/Kconfig |  1 +
 drivers/mmc/mmc.c   | 44 ++++++++++++++++++++------------------------
 2 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index dbbef5a..7a45d4b 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -60,6 +60,7 @@ config MMC_VERBOSE
 
 config SPL_MMC_VERBOSE
 	bool "Output more information about the MMC in SPL"
+	depends on SPL_LIBCOMMON_SUPPORT
 	default n
 	help
 	  Enable the output of more information about the card such as the
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 13979a5..af303b3 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -22,6 +22,12 @@
 #include <div64.h>
 #include "mmc_private.h"
 
+#if CONFIG_IS_ENABLED(MMC_VERBOSE)
+#define error printf
+#else
+#define error(...)
+#endif
+
 static const unsigned int sd_au_size[] = {
 	0,		SZ_16K / 512,		SZ_32K / 512,
 	SZ_64K / 512,	SZ_128K / 512,		SZ_256K / 512,
@@ -250,10 +256,8 @@ int mmc_send_status(struct mmc *mmc, int timeout)
 				break;
 
 			if (cmd.response[0] & MMC_STATUS_MASK) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-				printf("Status Error: 0x%08X\n",
-					cmd.response[0]);
-#endif
+				error("Status Error: 0x%08X\n",
+				      cmd.response[0]);
 				return -ECOMM;
 			}
 		} else if (--retries < 0)
@@ -267,9 +271,7 @@ int mmc_send_status(struct mmc *mmc, int timeout)
 
 	mmc_trace_state(mmc, &cmd);
 	if (timeout <= 0) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-		printf("Timeout waiting card ready\n");
-#endif
+		error("Timeout waiting card ready\n");
 		return -ETIMEDOUT;
 	}
 
@@ -407,9 +409,7 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
 		cmd.cmdarg = 0;
 		cmd.resp_type = MMC_RSP_R1b;
 		if (mmc_send_cmd(mmc, &cmd, NULL)) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-			printf("mmc fail to send stop cmd\n");
-#endif
+			error("mmc fail to send stop cmd\n");
 			return 0;
 		}
 	}
@@ -447,10 +447,8 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
 		return 0;
 
 	if ((start + blkcnt) > block_dev->lba) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-		printf("MMC: block number 0x" LBAF " exceeds max(0x" LBAF ")\n",
-			start + blkcnt, block_dev->lba);
-#endif
+		error("MMC: block number 0x" LBAF " exceeds max(0x" LBAF ")\n",
+		      start + blkcnt, block_dev->lba);
 		return 0;
 	}
 
@@ -828,7 +826,7 @@ static int mmc_get_capabilities(struct mmc *mmc)
 		return 0;
 
 	if (!ext_csd) {
-		printf("No ext_csd found!\n"); /* this should enver happen */
+		error("No ext_csd found!\n"); /* this should enver happen */
 		return -ENOTSUPP;
 	}
 
@@ -1433,7 +1431,7 @@ static inline int bus_width(uint cap)
 		return 4;
 	if (cap == MMC_MODE_1BIT)
 		return 1;
-	printf("invalid bus witdh capability 0x%x\n", cap);
+	debug("invalid bus witdh capability 0x%x\n", cap);
 	return 0;
 }
 
@@ -1632,7 +1630,7 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps)
 				if (!err)
 					return 0;
 
-				printf("bad ssr\n");
+				error("bad ssr\n");
 
 error:
 				/* revert to a safer bus speed */
@@ -1642,7 +1640,7 @@ error:
 		}
 	}
 
-	printf("unable to select a mode\n");
+	error("unable to select a mode\n");
 	return -ENOTSUPP;
 }
 
@@ -1856,7 +1854,7 @@ error:
 		}
 	}
 
-	printf("unable to select a mode\n");
+	error("unable to select a mode\n");
 
 	return -ENOTSUPP;
 }
@@ -2188,7 +2186,7 @@ static int mmc_startup(struct mmc *mmc)
 		cmd.cmdarg = (mmc->dsr & 0xffff) << 16;
 		cmd.resp_type = MMC_RSP_NONE;
 		if (mmc_send_cmd(mmc, &cmd, NULL))
-			printf("MMC: SET_DSR failed\n");
+			error("MMC: SET_DSR failed\n");
 	}
 
 	/* Select the card, and put it into Transfer Mode */
@@ -2341,7 +2339,7 @@ static void mmc_set_initial_state(struct mmc *mmc)
 	if (err != 0)
 		err = mmc_set_signal_voltage(mmc, MMC_SIGNAL_VOLTAGE_180);
 	if (err != 0)
-		printf("mmc: failed to set signal voltage\n");
+		debug("mmc: failed to set signal voltage\n");
 
 	mmc_select_mode(mmc, MMC_LEGACY);
 	mmc_set_bus_width(mmc, 1);
@@ -2489,9 +2487,7 @@ retry:
 		err = mmc_send_op_cond(mmc);
 
 		if (err) {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-			printf("Card did not respond to voltage select!\n");
-#endif
+			error("Card did not respond to voltage select!\n");
 			return -EOPNOTSUPP;
 		}
 	}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 08/10] mmc: make UHS and HS200 optional
  2017-11-29 14:29 [U-Boot] [PATCH v4 00/10] mmc: fixes for HS200/UHS core support Jean-Jacques Hiblot
                   ` (6 preceding siblings ...)
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 07/10] mmc: allow to compile out the error messages Jean-Jacques Hiblot
@ 2017-11-29 14:29 ` Jean-Jacques Hiblot
  2017-12-02  3:29   ` Simon Glass
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 09/10] mmc: make optional the support for eMMMC hardware partitioning Jean-Jacques Hiblot
  8 siblings, 1 reply; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-11-29 14:29 UTC (permalink / raw)
  To: u-boot

Supporting USH and HS200 increases the code size as it brings in IO voltage
control, tuning and fatter data structures.
Use Kconfig configuration to select which of those features should be
built in.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 drivers/mmc/Kconfig      | 46 +++++++++++++++++++++++++++++++++++
 drivers/mmc/mmc-uclass.c |  4 +++
 drivers/mmc/mmc.c        | 63 +++++++++++++++++++++++++++++++++++++++++++++++-
 include/mmc.h            | 27 ++++++++++++++++++---
 4 files changed, 135 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 7a45d4b..63d7f08 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -51,6 +51,52 @@ config MMC_QUIRKS
 	  are enabled by default, other may require additionnal flags or are
 	  enabled by the host driver.
 
+config MMC_UHS_SUPPORT
+	bool "enable UHS support"
+	depends on MMC_IO_VOLTAGE
+	help
+	  The Ultra High Speed (UHS) bus is available on some SDHC and SDXC
+	  cards. The IO voltage must be switchable from 3.3v to 1.8v. The bus
+	  frequency can go up to 208MHz (SDR104)
+
+config SPL_MMC_UHS_SUPPORT
+	bool "enable UHS support in SPL"
+	depends on SPL_MMC_IO_VOLTAGE
+	help
+	  The Ultra High Speed (UHS) bus is available on some SDHC and SDXC
+	  cards. The IO voltage must be switchable from 3.3v to 1.8v. The bus
+	  frequency can go up to 208MHz (SDR104)
+
+config MMC_HS200_SUPPORT
+	bool "enable HS200 support"
+	help
+	  The HS200 mode is support by some eMMC. The bus frequency is up to
+	  200MHz. This mode requires tuning the IO.
+
+
+config SPL_MMC_HS200_SUPPORT
+	bool "enable HS200 support in SPL"
+	help
+	  The HS200 mode is support by some eMMC. The bus frequency is up to
+	  200MHz. This mode requires tuning the IO.
+
+config MMC_IO_VOLTAGE
+	bool "Support IO voltage configuration"
+	help
+	  IO voltage configuration allows selecting the voltage level of the IO
+	  lines (not the level of main supply). This is required for UHS
+	  support. For eMMC this not mandatory, but not enabling this option may
+	  prevent the driver of using the faster modes.
+
+config SPL_MMC_IO_VOLTAGE
+	bool "Support IO voltage configuration in SPL"
+	default n
+	help
+	  IO voltage configuration allows selecting the voltage level of the IO
+	  lines (not the level of main supply). This is required for UHS
+	  support. For eMMC this not mandatory, but not enabling this option may
+	  prevent the driver of using the faster modes.
+
 config MMC_VERBOSE
 	bool "Output more information about the MMC"
 	default y
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index bfda942..793196b 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -63,6 +63,7 @@ void mmc_send_init_stream(struct mmc *mmc)
 	dm_mmc_send_init_stream(mmc->dev);
 }
 
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
 int dm_mmc_wait_dat0(struct udevice *dev, int state, int timeout)
 {
 	struct dm_mmc_ops *ops = mmc_get_ops(dev);
@@ -76,6 +77,7 @@ int mmc_wait_dat0(struct mmc *mmc, int state, int timeout)
 {
 	return dm_mmc_wait_dat0(mmc->dev, state, timeout);
 }
+#endif
 
 int dm_mmc_get_wp(struct udevice *dev)
 {
@@ -105,6 +107,7 @@ int mmc_getcd(struct mmc *mmc)
 	return dm_mmc_get_cd(mmc->dev);
 }
 
+#ifdef MMC_SUPPORTS_TUNING
 int dm_mmc_execute_tuning(struct udevice *dev, uint opcode)
 {
 	struct dm_mmc_ops *ops = mmc_get_ops(dev);
@@ -118,6 +121,7 @@ int mmc_execute_tuning(struct mmc *mmc, uint opcode)
 {
 	return dm_mmc_execute_tuning(mmc->dev, opcode);
 }
+#endif
 
 int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg)
 {
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index af303b3..b6d3f96 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -65,10 +65,12 @@ struct blk_desc *mmc_get_blk_desc(struct mmc *mmc)
 
 #if !CONFIG_IS_ENABLED(DM_MMC)
 
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
 static int mmc_wait_dat0(struct mmc *mmc, int state, int timeout)
 {
 	return -ENOSYS;
 }
+#endif
 
 __weak int board_mmc_getwp(struct mmc *mmc)
 {
@@ -196,14 +198,20 @@ static uint mmc_mode2freq(struct mmc *mmc, enum bus_mode mode)
 	      [SD_LEGACY]	= 25000000,
 	      [MMC_HS]		= 26000000,
 	      [SD_HS]		= 50000000,
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
 	      [UHS_SDR12]	= 25000000,
 	      [UHS_SDR25]	= 50000000,
 	      [UHS_SDR50]	= 100000000,
-	      [UHS_SDR104]	= 208000000,
 	      [UHS_DDR50]	= 50000000,
+#ifdef MMC_SUPPORTS_TUNING
+	      [UHS_SDR104]	= 208000000,
+#endif
+#endif
 	      [MMC_HS_52]	= 52000000,
 	      [MMC_DDR_52]	= 52000000,
+#if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
 	      [MMC_HS_200]	= 200000000,
+#endif
 	};
 
 	if (mode == MMC_LEGACY)
@@ -310,6 +318,7 @@ int mmc_set_blocklen(struct mmc *mmc, int len)
 	return err;
 }
 
+#ifdef MMC_SUPPORTS_TUNING
 static const u8 tuning_blk_pattern_4bit[] = {
 	0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc,
 	0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef,
@@ -377,6 +386,7 @@ int mmc_send_tuning(struct mmc *mmc, u32 opcode, int *cmd_error)
 
 	return 0;
 }
+#endif
 
 static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
 			   lbaint_t blkcnt)
@@ -493,6 +503,7 @@ static int mmc_go_idle(struct mmc *mmc)
 	return 0;
 }
 
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
 static int mmc_switch_voltage(struct mmc *mmc, int signal_voltage)
 {
 	struct mmc_cmd cmd;
@@ -552,6 +563,7 @@ static int mmc_switch_voltage(struct mmc *mmc, int signal_voltage)
 
 	return 0;
 }
+#endif
 
 static int sd_send_op_cond(struct mmc *mmc, bool uhs_en)
 {
@@ -618,12 +630,14 @@ static int sd_send_op_cond(struct mmc *mmc, bool uhs_en)
 
 	mmc->ocr = cmd.response[0];
 
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
 	if (uhs_en && !(mmc_host_is_spi(mmc)) && (cmd.response[0] & 0x41000000)
 	    == 0x41000000) {
 		err = mmc_switch_voltage(mmc, MMC_SIGNAL_VOLTAGE_180);
 		if (err)
 			return err;
 	}
+#endif
 
 	mmc->high_capacity = ((mmc->ocr & OCR_HCS) == OCR_HCS);
 	mmc->rca = 0;
@@ -878,6 +892,7 @@ static int mmc_set_capacity(struct mmc *mmc, int part_num)
 	return 0;
 }
 
+#if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
 static int mmc_boot_part_access_chk(struct mmc *mmc, unsigned int part_num)
 {
 	int forbidden = 0;
@@ -901,6 +916,13 @@ static int mmc_boot_part_access_chk(struct mmc *mmc, unsigned int part_num)
 
 	return 0;
 }
+#else
+static inline int mmc_boot_part_access_chk(struct mmc *mmc,
+					   unsigned int part_num)
+{
+	return 0;
+}
+#endif
 
 int mmc_switch_part(struct mmc *mmc, unsigned int part_num)
 {
@@ -1167,7 +1189,9 @@ static int sd_get_capabilities(struct mmc *mmc)
 	ALLOC_CACHE_ALIGN_BUFFER(__be32, switch_status, 16);
 	struct mmc_data data;
 	int timeout;
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
 	u32 sd3_bus_mode;
+#endif
 
 	mmc->card_caps = MMC_MODE_1BIT | MMC_CAP(SD_LEGACY);
 
@@ -1249,6 +1273,7 @@ retry_scr:
 	if (__be32_to_cpu(switch_status[3]) & SD_HIGHSPEED_SUPPORTED)
 		mmc->card_caps |= MMC_CAP(SD_HS);
 
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
 	/* Version before 3.0 don't support UHS modes */
 	if (mmc->version < SD_VERSION_3)
 		return 0;
@@ -1264,6 +1289,7 @@ retry_scr:
 		mmc->card_caps |= MMC_CAP(UHS_SDR12);
 	if (sd3_bus_mode & SD_MODE_UHS_DDR50)
 		mmc->card_caps |= MMC_CAP(UHS_DDR50);
+#endif
 
 	return 0;
 }
@@ -1436,10 +1462,12 @@ static inline int bus_width(uint cap)
 }
 
 #if !CONFIG_IS_ENABLED(DM_MMC)
+#ifdef MMC_SUPPORTS_TUNING
 static int mmc_execute_tuning(struct mmc *mmc, uint opcode)
 {
 	return -ENOTSUPP;
 }
+#endif
 
 static void mmc_send_init_stream(struct mmc *mmc)
 {
@@ -1505,9 +1533,12 @@ void mmc_dump_capabilities(const char *text, uint caps)
 struct mode_width_tuning {
 	enum bus_mode mode;
 	uint widths;
+#ifdef MMC_SUPPORTS_TUNING
 	uint tuning;
+#endif
 };
 
+#if CONFIG_IS_ENABLED(MMC_IO_VOLTAGE)
 int mmc_voltage_to_mv(enum mmc_voltage voltage)
 {
 	switch (voltage) {
@@ -1533,13 +1564,22 @@ static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage)
 
 	return err;
 }
+#else
+static inline int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage)
+{
+	return 0;
+}
+#endif
 
 static const struct mode_width_tuning sd_modes_by_pref[] = {
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
+#ifdef MMC_SUPPORTS_TUNING
 	{
 		.mode = UHS_SDR104,
 		.widths = MMC_MODE_4BIT | MMC_MODE_1BIT,
 		.tuning = MMC_CMD_SEND_TUNING_BLOCK
 	},
+#endif
 	{
 		.mode = UHS_SDR50,
 		.widths = MMC_MODE_4BIT | MMC_MODE_1BIT,
@@ -1552,14 +1592,17 @@ static const struct mode_width_tuning sd_modes_by_pref[] = {
 		.mode = UHS_SDR25,
 		.widths = MMC_MODE_4BIT | MMC_MODE_1BIT,
 	},
+#endif
 	{
 		.mode = SD_HS,
 		.widths = MMC_MODE_4BIT | MMC_MODE_1BIT,
 	},
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
 	{
 		.mode = UHS_SDR12,
 		.widths = MMC_MODE_4BIT | MMC_MODE_1BIT,
 	},
+#endif
 	{
 		.mode = SD_LEGACY,
 		.widths = MMC_MODE_4BIT | MMC_MODE_1BIT,
@@ -1577,7 +1620,11 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps)
 	int err;
 	uint widths[] = {MMC_MODE_4BIT, MMC_MODE_1BIT};
 	const struct mode_width_tuning *mwt;
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
 	bool uhs_en = (mmc->ocr & OCR_S18R) ? true : false;
+#else
+	bool uhs_en = false;
+#endif
 	uint caps;
 
 #ifdef DEBUG
@@ -1616,6 +1663,7 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps)
 				mmc_select_mode(mmc, mwt->mode);
 				mmc_set_clock(mmc, mmc->tran_speed, false);
 
+#ifdef MMC_SUPPORTS_TUNING
 				/* execute tuning if needed */
 				if (mwt->tuning && !mmc_host_is_spi(mmc)) {
 					err = mmc_execute_tuning(mmc,
@@ -1625,6 +1673,7 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps)
 						goto error;
 					}
 				}
+#endif
 
 				err = sd_read_ssr(mmc);
 				if (!err)
@@ -1678,6 +1727,7 @@ static int mmc_read_and_compare_ext_csd(struct mmc *mmc)
 	return -EBADMSG;
 }
 
+#if CONFIG_IS_ENABLED(MMC_IO_VOLTAGE)
 static int mmc_set_lowest_voltage(struct mmc *mmc, enum bus_mode mode,
 				  uint32_t allowed_mask)
 {
@@ -1714,13 +1764,22 @@ static int mmc_set_lowest_voltage(struct mmc *mmc, enum bus_mode mode,
 
 	return -ENOTSUPP;
 }
+#else
+static inline int mmc_set_lowest_voltage(struct mmc *mmc, enum bus_mode mode,
+					 uint32_t allowed_mask)
+{
+	return 0;
+}
+#endif
 
 static const struct mode_width_tuning mmc_modes_by_pref[] = {
+#if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
 	{
 		.mode = MMC_HS_200,
 		.widths = MMC_MODE_8BIT | MMC_MODE_4BIT,
 		.tuning = MMC_CMD_SEND_TUNING_BLOCK_HS200
 	},
+#endif
 	{
 		.mode = MMC_DDR_52,
 		.widths = MMC_MODE_8BIT | MMC_MODE_4BIT,
@@ -1830,6 +1889,7 @@ static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps)
 			/* configure the bus mode (host) */
 			mmc_select_mode(mmc, mwt->mode);
 			mmc_set_clock(mmc, mmc->tran_speed, false);
+#ifdef MMC_SUPPORTS_TUNING
 
 			/* execute tuning if needed */
 			if (mwt->tuning) {
@@ -1839,6 +1899,7 @@ static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps)
 					goto error;
 				}
 			}
+#endif
 
 			/* do a transfer to check the configuration */
 			err = mmc_read_and_compare_ext_csd(mmc);
diff --git a/include/mmc.h b/include/mmc.h
index e3f777f..e89ba95 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -15,6 +15,13 @@
 #include <linux/compiler.h>
 #include <part.h>
 
+#if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
+#define MMC_SUPPORTS_TUNING
+#endif
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
+#define MMC_SUPPORTS_TUNING
+#endif
+
 /* SD/MMC version bits; 8 flags, 8 major, 8 minor, 8 change */
 #define SD_VERSION_SD	(1U << 31)
 #define MMC_VERSION_MMC	(1U << 30)
@@ -425,6 +432,7 @@ struct dm_mmc_ops {
 	 */
 	int (*get_wp)(struct udevice *dev);
 
+#ifdef MMC_SUPPORTS_TUNING
 	/**
 	 * execute_tuning() - Start the tuning process
 	 *
@@ -433,7 +441,9 @@ struct dm_mmc_ops {
 	 * @return 0 if OK, -ve on error
 	 */
 	int (*execute_tuning)(struct udevice *dev, uint opcode);
+#endif
 
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
 	/**
 	 * wait_dat0() - wait until dat0 is in the target state
 	 *		(CLK must be running during the wait)
@@ -444,6 +454,7 @@ struct dm_mmc_ops {
 	 * @return 0 if dat0 is in the target state, -ve on error
 	 */
 	int (*wait_dat0)(struct udevice *dev, int state, int timeout);
+#endif
 };
 
 #define mmc_get_ops(dev)        ((struct dm_mmc_ops *)(dev)->driver->ops)
@@ -500,13 +511,13 @@ enum bus_mode {
 	SD_LEGACY,
 	MMC_HS,
 	SD_HS,
+	MMC_HS_52,
+	MMC_DDR_52,
 	UHS_SDR12,
 	UHS_SDR25,
 	UHS_SDR50,
-	UHS_SDR104,
 	UHS_DDR50,
-	MMC_HS_52,
-	MMC_DDR_52,
+	UHS_SDR104,
 	MMC_HS_200,
 	MMC_MODES_END
 };
@@ -516,8 +527,12 @@ void mmc_dump_capabilities(const char *text, uint caps);
 
 static inline bool mmc_is_mode_ddr(enum bus_mode mode)
 {
-	if ((mode == MMC_DDR_52) || (mode == UHS_DDR50))
+	if (mode == MMC_DDR_52)
+		return true;
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
+	else if (mode == UHS_DDR50)
 		return true;
+#endif
 	else
 		return false;
 }
@@ -528,7 +543,11 @@ static inline bool mmc_is_mode_ddr(enum bus_mode mode)
 
 static inline bool supports_uhs(uint caps)
 {
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
 	return (caps & UHS_CAPS) ? true : false;
+#else
+	return false;
+#endif
 }
 
 /*
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 09/10] mmc: make optional the support for eMMMC hardware partitioning
  2017-11-29 14:29 [U-Boot] [PATCH v4 00/10] mmc: fixes for HS200/UHS core support Jean-Jacques Hiblot
                   ` (7 preceding siblings ...)
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 08/10] mmc: make UHS and HS200 optional Jean-Jacques Hiblot
@ 2017-11-29 14:29 ` Jean-Jacques Hiblot
  2017-11-29 18:44   ` Tom Rini
  8 siblings, 1 reply; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-11-29 14:29 UTC (permalink / raw)
  To: u-boot

Not all boards have an eMMC and not all users have a need for this.
Allow to compile it out. By default it is still included.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 cmd/mmc.c           | 4 ++++
 drivers/mmc/Kconfig | 7 +++++++
 drivers/mmc/mmc.c   | 2 ++
 3 files changed, 13 insertions(+)

diff --git a/cmd/mmc.c b/cmd/mmc.c
index 25795e0..9a95293 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -438,6 +438,7 @@ static int do_mmc_list(cmd_tbl_t *cmdtp, int flag,
 	return CMD_RET_SUCCESS;
 }
 
+#if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
 static int parse_hwpart_user(struct mmc_hwpart_conf *pconf,
 			     int argc, char * const argv[])
 {
@@ -587,6 +588,7 @@ static int do_mmc_hwpartition(cmd_tbl_t *cmdtp, int flag,
 		return CMD_RET_FAILURE;
 	}
 }
+#endif
 
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
 static int do_mmc_bootbus(cmd_tbl_t *cmdtp, int flag,
@@ -796,7 +798,9 @@ static cmd_tbl_t cmd_mmc[] = {
 	U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""),
 	U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),
 	U_BOOT_CMD_MKENT(list, 1, 1, do_mmc_list, "", ""),
+#if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
 	U_BOOT_CMD_MKENT(hwpartition, 28, 0, do_mmc_hwpartition, "", ""),
+#endif
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
 	U_BOOT_CMD_MKENT(bootbus, 5, 0, do_mmc_bootbus, "", ""),
 	U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "", ""),
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 63d7f08..831d6ae 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -51,6 +51,13 @@ config MMC_QUIRKS
 	  are enabled by default, other may require additionnal flags or are
 	  enabled by the host driver.
 
+config MMC_HW_PARTITIONING
+	bool "Support for HW partitioning command(eMMC)"
+	default y
+	help
+	  This adds a command and an API to do hardware partitioning on eMMC
+	  devices.
+
 config MMC_UHS_SUPPORT
 	bool "enable UHS support"
 	depends on MMC_IO_VOLTAGE
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index b6d3f96..bb89542 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -948,6 +948,7 @@ int mmc_switch_part(struct mmc *mmc, unsigned int part_num)
 	return ret;
 }
 
+#if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
 int mmc_hwpart_config(struct mmc *mmc,
 		      const struct mmc_hwpart_conf *conf,
 		      enum mmc_hwpart_conf_mode mode)
@@ -1141,6 +1142,7 @@ int mmc_hwpart_config(struct mmc *mmc,
 
 	return 0;
 }
+#endif
 
 #if !CONFIG_IS_ENABLED(DM_MMC)
 int mmc_getcd(struct mmc *mmc)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 07/10] mmc: allow to compile out the error messages
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 07/10] mmc: allow to compile out the error messages Jean-Jacques Hiblot
@ 2017-11-29 18:43   ` Tom Rini
  0 siblings, 0 replies; 18+ messages in thread
From: Tom Rini @ 2017-11-29 18:43 UTC (permalink / raw)
  To: u-boot

On Wed, Nov 29, 2017 at 03:29:52PM +0100, Jean-Jacques Hiblot wrote:

> Error messages may not be as valued as code space. Allow to compile out
> most of them to free space.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>  drivers/mmc/Kconfig |  1 +
>  drivers/mmc/mmc.c   | 44 ++++++++++++++++++++------------------------
>  2 files changed, 21 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
> index dbbef5a..7a45d4b 100644
> --- a/drivers/mmc/Kconfig
> +++ b/drivers/mmc/Kconfig
> @@ -60,6 +60,7 @@ config MMC_VERBOSE
>  
>  config SPL_MMC_VERBOSE
>  	bool "Output more information about the MMC in SPL"
> +	depends on SPL_LIBCOMMON_SUPPORT
>  	default n
>  	help
>  	  Enable the output of more information about the card such as the
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 13979a5..af303b3 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -22,6 +22,12 @@
>  #include <div64.h>
>  #include "mmc_private.h"
>  
> +#if CONFIG_IS_ENABLED(MMC_VERBOSE)
> +#define error printf
> +#else
> +#define error(...)
> +#endif

Lets switch to pr_XXX so that we can make use of the normal log level
tweaking to keep / drop these, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171129/62f32748/attachment.sig>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 09/10] mmc: make optional the support for eMMMC hardware partitioning
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 09/10] mmc: make optional the support for eMMMC hardware partitioning Jean-Jacques Hiblot
@ 2017-11-29 18:44   ` Tom Rini
  0 siblings, 0 replies; 18+ messages in thread
From: Tom Rini @ 2017-11-29 18:44 UTC (permalink / raw)
  To: u-boot

On Wed, Nov 29, 2017 at 03:29:54PM +0100, Jean-Jacques Hiblot wrote:

> Not all boards have an eMMC and not all users have a need for this.
> Allow to compile it out. By default it is still included.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>

Seems good, subject is "eMMMC" however, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171129/13116ee1/attachment.sig>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 01/10] mmc: dump card and host capabilities if debug is enabled
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 01/10] mmc: dump card and host capabilities if debug is enabled Jean-Jacques Hiblot
@ 2017-12-02  3:29   ` Simon Glass
  0 siblings, 0 replies; 18+ messages in thread
From: Simon Glass @ 2017-12-02  3:29 UTC (permalink / raw)
  To: u-boot

On 29 November 2017 at 07:29, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
> This is a useful information while debugging the initialization process or
> performance issues.
> Also dump this information with the other mmc info if the verbose option
> is selected
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>
> no changes since v3
>
>  cmd/mmc.c         | 4 ++++
>  drivers/mmc/mmc.c | 9 +++++++++
>  2 files changed, 13 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 02/10] dm: mmc: update mmc_of_parse()
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 02/10] dm: mmc: update mmc_of_parse() Jean-Jacques Hiblot
@ 2017-12-02  3:29   ` Simon Glass
  0 siblings, 0 replies; 18+ messages in thread
From: Simon Glass @ 2017-12-02  3:29 UTC (permalink / raw)
  To: u-boot

On 29 November 2017 at 07:29, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
> * convert to livetree API
> * don't fail because of an invalid bus-width, instead default to 1-bit.
> * recognize 1.2v DDR and 1.2v HS200 flags
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>
> no changes since v3
>
>  drivers/mmc/mmc-uclass.c | 36 ++++++++++++++++++++----------------
>  include/mmc.h            | 11 ++++++++++-
>  2 files changed, 30 insertions(+), 17 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

I thought I already reviewed this?

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 05/10] mmc: fix for old MMCs (below version 4)
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 05/10] mmc: fix for old MMCs (below version 4) Jean-Jacques Hiblot
@ 2017-12-02  3:29   ` Simon Glass
  0 siblings, 0 replies; 18+ messages in thread
From: Simon Glass @ 2017-12-02  3:29 UTC (permalink / raw)
  To: u-boot

On 29 November 2017 at 07:29, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
> The ext_csd is allocated only for MMC above version 4. The compare will
> crash or fail for older MMCs.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>  drivers/mmc/mmc.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 06/10] mmc: don't use malloc_cache_aligned()
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 06/10] mmc: don't use malloc_cache_aligned() Jean-Jacques Hiblot
@ 2017-12-02  3:29   ` Simon Glass
  0 siblings, 0 replies; 18+ messages in thread
From: Simon Glass @ 2017-12-02  3:29 UTC (permalink / raw)
  To: u-boot

On 29 November 2017 at 07:29, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
> Not using this function reduces the size of the binary. It's replaces by
> a standard malloc() and the alignment requirement is handled by an
> intermediate buffer on the stack.
>
> Also make sure that the allocated buffer is freed in case of error.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>  drivers/mmc/mmc.c | 26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)

Somewhat unsure of this one but it looks right to me.

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 08/10] mmc: make UHS and HS200 optional
  2017-11-29 14:29 ` [U-Boot] [PATCH v4 08/10] mmc: make UHS and HS200 optional Jean-Jacques Hiblot
@ 2017-12-02  3:29   ` Simon Glass
  2017-12-06  8:29     ` Jean-Jacques Hiblot
  0 siblings, 1 reply; 18+ messages in thread
From: Simon Glass @ 2017-12-02  3:29 UTC (permalink / raw)
  To: u-boot

Hi Jean-Jacques,

On 29 November 2017 at 07:29, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
> Supporting USH and HS200 increases the code size as it brings in IO voltage
> control, tuning and fatter data structures.
> Use Kconfig configuration to select which of those features should be
> built in.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>  drivers/mmc/Kconfig      | 46 +++++++++++++++++++++++++++++++++++
>  drivers/mmc/mmc-uclass.c |  4 +++
>  drivers/mmc/mmc.c        | 63 +++++++++++++++++++++++++++++++++++++++++++++++-
>  include/mmc.h            | 27 ++++++++++++++++++---
>  4 files changed, 135 insertions(+), 5 deletions(-)

A few things:

- Can these default to on? I think going fast is best, and reducing
functionality can be an option
- Can you use if (IS_ENABLED) instead of #if within functions?

Regards,
Simon

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v4 08/10] mmc: make UHS and HS200 optional
  2017-12-02  3:29   ` Simon Glass
@ 2017-12-06  8:29     ` Jean-Jacques Hiblot
  0 siblings, 0 replies; 18+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-06  8:29 UTC (permalink / raw)
  To: u-boot



On 02/12/2017 04:29, Simon Glass wrote:
> Hi Jean-Jacques,
>
> On 29 November 2017 at 07:29, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>> Supporting USH and HS200 increases the code size as it brings in IO voltage
>> control, tuning and fatter data structures.
>> Use Kconfig configuration to select which of those features should be
>> built in.
>>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>> ---
>>   drivers/mmc/Kconfig      | 46 +++++++++++++++++++++++++++++++++++
>>   drivers/mmc/mmc-uclass.c |  4 +++
>>   drivers/mmc/mmc.c        | 63 +++++++++++++++++++++++++++++++++++++++++++++++-
>>   include/mmc.h            | 27 ++++++++++++++++++---
>>   4 files changed, 135 insertions(+), 5 deletions(-)
> A few things:
>
> - Can these default to on? I think going fast is best, and reducing
> functionality can be an option

This is conservative decision. The patches are less likely to break 
untested platforms if this is not enabled if only because of the 
increased footprint.
Most platforms won't benefit from it at first because the host driver 
has to implement a few more callbacks to support those modes.
We can always default to 'y' later when more host support this.
> - Can you use if (IS_ENABLED) instead of #if within functions?
I wasn't sure about the ability of the compiler to always throw away 
unused code this way. I'll give it a try.
>
> Regards,
> Simon
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-12-06  8:29 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-29 14:29 [U-Boot] [PATCH v4 00/10] mmc: fixes for HS200/UHS core support Jean-Jacques Hiblot
2017-11-29 14:29 ` [U-Boot] [PATCH v4 01/10] mmc: dump card and host capabilities if debug is enabled Jean-Jacques Hiblot
2017-12-02  3:29   ` Simon Glass
2017-11-29 14:29 ` [U-Boot] [PATCH v4 02/10] dm: mmc: update mmc_of_parse() Jean-Jacques Hiblot
2017-12-02  3:29   ` Simon Glass
2017-11-29 14:29 ` [U-Boot] [PATCH v4 03/10] mmc: Fixed a problem with old sd or mmc that do not support High speed Jean-Jacques Hiblot
2017-11-29 14:29 ` [U-Boot] [PATCH v4 04/10] mmc: all hosts support 1-bit bus width and legacy timings Jean-Jacques Hiblot
2017-11-29 14:29 ` [U-Boot] [PATCH v4 05/10] mmc: fix for old MMCs (below version 4) Jean-Jacques Hiblot
2017-12-02  3:29   ` Simon Glass
2017-11-29 14:29 ` [U-Boot] [PATCH v4 06/10] mmc: don't use malloc_cache_aligned() Jean-Jacques Hiblot
2017-12-02  3:29   ` Simon Glass
2017-11-29 14:29 ` [U-Boot] [PATCH v4 07/10] mmc: allow to compile out the error messages Jean-Jacques Hiblot
2017-11-29 18:43   ` Tom Rini
2017-11-29 14:29 ` [U-Boot] [PATCH v4 08/10] mmc: make UHS and HS200 optional Jean-Jacques Hiblot
2017-12-02  3:29   ` Simon Glass
2017-12-06  8:29     ` Jean-Jacques Hiblot
2017-11-29 14:29 ` [U-Boot] [PATCH v4 09/10] mmc: make optional the support for eMMMC hardware partitioning Jean-Jacques Hiblot
2017-11-29 18:44   ` Tom Rini

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.