* [U-Boot] [PATCH v1 00/10] reduce the size of the mmc core
@ 2017-12-21 11:53 Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 01/10] common: do not compile common fastboot code when building the SPL Jean-Jacques Hiblot
` (9 more replies)
0 siblings, 10 replies; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 11:53 UTC (permalink / raw)
To: u-boot
This series applies on u-boot/next
It aims at reducing the size taken by the mmc core in the SPL.
Recent changes (for which I'm to blame) have bloated the mmc core and have
broken platforms that were already tight on code space. This is achieved mostly
by compiling out parts of the initialization process that are not required when
the SD/MMC write operations are not used.
Using am335x_hs_evm_config and Linaro GCC 6.2-2016.11 toolchain, this series
saves 704 bytes of sram (592 bytes of code and 112 bytes of rodata).
This doesn't looks like much but it allows building the platform without
removing features from its config file (tested with commit d2ac491
("am335x_hs_evm: Trim options in SPL to reduce binary size") reverted)
Jean-Jacques Hiblot (10):
common: do not compile common fastboot code when building the SPL
mmc: atmel: when sending a data command, use the provided block size
mmc: remove unneeded verification in mmc_set_card_speed()
mmc: compile out more code if support for UHS and HS200 is not enabled
mmc: reworked version lookup in mmc_startup_v4
mmc: add a Kconfig option to enable the support for MMC write
operations
mmc: read ssr only if MMC write support is enabled
mmc: compile out erase and write mmc commands if write operations are
not enabled
mmc: don't read the size of eMMC enhanced user data area in SPL
mmc: remove hc_wp_grp_size from struct mmc if not needed
cmd/mmc.c | 10 ++++
cmd/mvebu/bubt.c | 2 +-
common/Makefile | 2 +
common/spl/Kconfig | 8 +++
drivers/mmc/Kconfig | 7 +++
drivers/mmc/Makefile | 4 +-
drivers/mmc/gen_atmel_mci.c | 3 +-
drivers/mmc/mmc-uclass.c | 2 +-
drivers/mmc/mmc.c | 119 +++++++++++++++++++++++---------------------
drivers/mmc/mmc_private.h | 4 +-
include/mmc.h | 8 +++
11 files changed, 102 insertions(+), 67 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 01/10] common: do not compile common fastboot code when building the SPL
2017-12-21 11:53 [U-Boot] [PATCH v1 00/10] reduce the size of the mmc core Jean-Jacques Hiblot
@ 2017-12-21 11:53 ` Jean-Jacques Hiblot
2017-12-21 14:46 ` Tom Rini
2017-12-21 11:53 ` [U-Boot] [PATCH v1 02/10] mmc: atmel: when sending a data command, use the provided block size Jean-Jacques Hiblot
` (8 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 11:53 UTC (permalink / raw)
To: u-boot
This is not required as fastboot can't be started from SPL.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
common/Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/common/Makefile b/common/Makefile
index 1416620..c7bde23 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -109,6 +109,7 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o
obj-y += memsize.o
obj-y += stdio.o
+ifndef CONFIG_SPL_BUILD
# This option is not just y/n - it can have a numeric value
ifdef CONFIG_FASTBOOT_FLASH
obj-y += image-sparse.o
@@ -119,6 +120,7 @@ ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
obj-y += fb_nand.o
endif
endif
+endif
ifdef CONFIG_CMD_EEPROM_LAYOUT
obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 02/10] mmc: atmel: when sending a data command, use the provided block size
2017-12-21 11:53 [U-Boot] [PATCH v1 00/10] reduce the size of the mmc core Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 01/10] common: do not compile common fastboot code when building the SPL Jean-Jacques Hiblot
@ 2017-12-21 11:53 ` Jean-Jacques Hiblot
2017-12-26 10:14 ` Jaehoon Chung
2017-12-21 11:53 ` [U-Boot] [PATCH v1 03/10] mmc: remove unneeded verification in mmc_set_card_speed() Jean-Jacques Hiblot
` (7 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 11:53 UTC (permalink / raw)
To: u-boot
struct mmc_data contains the block size to use for the data transfer.
Use this information instead of relying on read_bl_len and write_bl_len
stored in the mmc structure.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
drivers/mmc/gen_atmel_mci.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c
index 22154d1..54646e4 100644
--- a/drivers/mmc/gen_atmel_mci.c
+++ b/drivers/mmc/gen_atmel_mci.c
@@ -301,13 +301,12 @@ mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
if (data->flags & MMC_DATA_READ) {
mci_data_op = mci_data_read;
- sys_blocksize = mmc->read_bl_len;
ioptr = (u32*)data->dest;
} else {
mci_data_op = mci_data_write;
- sys_blocksize = mmc->write_bl_len;
ioptr = (u32*)data->src;
}
+ sys_blocksize = data->blocksize;
status = 0;
for (block_count = 0;
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 03/10] mmc: remove unneeded verification in mmc_set_card_speed()
2017-12-21 11:53 [U-Boot] [PATCH v1 00/10] reduce the size of the mmc core Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 01/10] common: do not compile common fastboot code when building the SPL Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 02/10] mmc: atmel: when sending a data command, use the provided block size Jean-Jacques Hiblot
@ 2017-12-21 11:53 ` Jean-Jacques Hiblot
2017-12-26 10:36 ` Jaehoon Chung
2017-12-21 11:53 ` [U-Boot] [PATCH v1 04/10] mmc: compile out more code if support for UHS and HS200 is not enabled Jean-Jacques Hiblot
` (6 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 11:53 UTC (permalink / raw)
To: u-boot
mmc_set_card_speed() reads the ext csd to check if switch has been OK.
But it does it only for MMC_HS and MMC_HS_52. Moreover this check is not
really required as there will be a ext csd reading later in the
initialization process to make sure that it succeeded.
So remove this partial verification and save space.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
drivers/mmc/mmc.c | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 67d05c5..7a92718 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -788,11 +788,8 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode)
{
- int err;
int speed_bits;
- ALLOC_CACHE_ALIGN_BUFFER(u8, test_csd, MMC_MAX_BLOCK_LEN);
-
switch (mode) {
case MMC_HS:
case MMC_HS_52:
@@ -808,23 +805,8 @@ static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode)
default:
return -EINVAL;
}
- err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
+ return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
speed_bits);
- if (err)
- return err;
-
- if ((mode == MMC_HS) || (mode == MMC_HS_52)) {
- /* Now check to see that it worked */
- err = mmc_send_ext_csd(mmc, test_csd);
- if (err)
- return err;
-
- /* No high-speed support */
- if (!test_csd[EXT_CSD_HS_TIMING])
- return -ENOTSUPP;
- }
-
- return 0;
}
static int mmc_get_capabilities(struct mmc *mmc)
@@ -851,10 +833,12 @@ static int mmc_get_capabilities(struct mmc *mmc)
cardtype = ext_csd[EXT_CSD_CARD_TYPE] & 0x3f;
mmc->cardtype = cardtype;
+#if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
if (cardtype & (EXT_CSD_CARD_TYPE_HS200_1_2V |
EXT_CSD_CARD_TYPE_HS200_1_8V)) {
mmc->card_caps |= MMC_MODE_HS200;
}
+#endif
if (cardtype & EXT_CSD_CARD_TYPE_52) {
if (cardtype & EXT_CSD_CARD_TYPE_DDR_52)
mmc->card_caps |= MMC_MODE_DDR_52MHz;
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 04/10] mmc: compile out more code if support for UHS and HS200 is not enabled
2017-12-21 11:53 [U-Boot] [PATCH v1 00/10] reduce the size of the mmc core Jean-Jacques Hiblot
` (2 preceding siblings ...)
2017-12-21 11:53 ` [U-Boot] [PATCH v1 03/10] mmc: remove unneeded verification in mmc_set_card_speed() Jean-Jacques Hiblot
@ 2017-12-21 11:53 ` Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 05/10] mmc: reworked version lookup in mmc_startup_v4 Jean-Jacques Hiblot
` (5 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 11:53 UTC (permalink / raw)
To: u-boot
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
drivers/mmc/mmc.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 7a92718..d006893 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -796,9 +796,11 @@ static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode)
case MMC_DDR_52:
speed_bits = EXT_CSD_TIMING_HS;
break;
+#if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
case MMC_HS_200:
speed_bits = EXT_CSD_TIMING_HS200;
break;
+#endif
case MMC_LEGACY:
speed_bits = EXT_CSD_TIMING_LEGACY;
break;
@@ -1291,10 +1293,15 @@ static int sd_set_card_speed(struct mmc *mmc, enum bus_mode mode)
switch (mode) {
case SD_LEGACY:
- case UHS_SDR12:
speed = UHS_SDR12_BUS_SPEED;
break;
case SD_HS:
+ speed = HIGH_SPEED_BUS_SPEED;
+ break;
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
+ case UHS_SDR12:
+ speed = UHS_SDR12_BUS_SPEED;
+ break;
case UHS_SDR25:
speed = UHS_SDR25_BUS_SPEED;
break;
@@ -1307,6 +1314,7 @@ static int sd_set_card_speed(struct mmc *mmc, enum bus_mode mode)
case UHS_SDR104:
speed = UHS_SDR104_BUS_SPEED;
break;
+#endif
default:
return -EINVAL;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 05/10] mmc: reworked version lookup in mmc_startup_v4
2017-12-21 11:53 [U-Boot] [PATCH v1 00/10] reduce the size of the mmc core Jean-Jacques Hiblot
` (3 preceding siblings ...)
2017-12-21 11:53 ` [U-Boot] [PATCH v1 04/10] mmc: compile out more code if support for UHS and HS200 is not enabled Jean-Jacques Hiblot
@ 2017-12-21 11:53 ` Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 06/10] mmc: add a Kconfig option to enable the support for MMC write operations Jean-Jacques Hiblot
` (4 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 11:53 UTC (permalink / raw)
To: u-boot
Using a table versus a switch() structure saves a bit of space
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
drivers/mmc/mmc.c | 42 +++++++++++++++++-------------------------
1 file changed, 17 insertions(+), 25 deletions(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index d006893..7d6754f 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1922,6 +1922,17 @@ static int mmc_startup_v4(struct mmc *mmc)
u64 capacity;
bool has_parts = false;
bool part_completed;
+ static const u32 mmc_versions[] = {
+ MMC_VERSION_4,
+ MMC_VERSION_4_1,
+ MMC_VERSION_4_2,
+ MMC_VERSION_4_3,
+ MMC_VERSION_4_41,
+ MMC_VERSION_4_5,
+ MMC_VERSION_5_0,
+ MMC_VERSION_5_1
+ };
+
ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN);
if (IS_SD(mmc) || (mmc->version < MMC_VERSION_4))
@@ -1939,7 +1950,12 @@ static int mmc_startup_v4(struct mmc *mmc)
return -ENOMEM;
memcpy(mmc->ext_csd, ext_csd, MMC_MAX_BLOCK_LEN);
- if (ext_csd[EXT_CSD_REV] >= 2) {
+ if (ext_csd[EXT_CSD_REV] > ARRAY_SIZE(mmc_versions))
+ return -EINVAL;
+
+ mmc->version = mmc_versions[ext_csd[EXT_CSD_REV]];
+
+ if (mmc->version >= MMC_VERSION_4_2) {
/*
* According to the JEDEC Standard, the value of
* ext_csd's capacity is valid if the value is more
@@ -1954,30 +1970,6 @@ static int mmc_startup_v4(struct mmc *mmc)
mmc->capacity_user = capacity;
}
- switch (ext_csd[EXT_CSD_REV]) {
- case 1:
- mmc->version = MMC_VERSION_4_1;
- break;
- case 2:
- mmc->version = MMC_VERSION_4_2;
- break;
- case 3:
- mmc->version = MMC_VERSION_4_3;
- break;
- case 5:
- mmc->version = MMC_VERSION_4_41;
- break;
- case 6:
- mmc->version = MMC_VERSION_4_5;
- break;
- case 7:
- mmc->version = MMC_VERSION_5_0;
- break;
- case 8:
- mmc->version = MMC_VERSION_5_1;
- break;
- }
-
/* The partition data may be non-zero but it is only
* effective if PARTITION_SETTING_COMPLETED is set in
* EXT_CSD, so ignore any data if this bit is not set,
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 06/10] mmc: add a Kconfig option to enable the support for MMC write operations
2017-12-21 11:53 [U-Boot] [PATCH v1 00/10] reduce the size of the mmc core Jean-Jacques Hiblot
` (4 preceding siblings ...)
2017-12-21 11:53 ` [U-Boot] [PATCH v1 05/10] mmc: reworked version lookup in mmc_startup_v4 Jean-Jacques Hiblot
@ 2017-12-21 11:53 ` Jean-Jacques Hiblot
2017-12-21 14:46 ` Tom Rini
2017-12-21 11:53 ` [U-Boot] [PATCH v1 07/10] mmc: read ssr only if MMC write support is enabled Jean-Jacques Hiblot
` (3 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 11:53 UTC (permalink / raw)
To: u-boot
This allows using CONFIG_IS_ENABLED(MMC_WRITE) to compile out code
needed only if write support is required.
The option is added for u-boot and for the SPL
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
cmd/mvebu/bubt.c | 2 +-
common/spl/Kconfig | 8 ++++++++
drivers/mmc/Kconfig | 7 +++++++
drivers/mmc/Makefile | 4 +---
drivers/mmc/mmc-uclass.c | 2 +-
drivers/mmc/mmc_private.h | 4 ++--
6 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
index a1997ac..23fb8cd 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -110,7 +110,7 @@ static ulong get_load_addr(void)
/********************************************************************
* eMMC services
********************************************************************/
-#ifdef CONFIG_DM_MMC
+#if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(MMC_WRITE)
static int mmc_burn_image(size_t image_size)
{
struct mmc *mmc;
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index aef0034..f414e3b 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -301,6 +301,7 @@ config SPL_ENV_SUPPORT
config SPL_SAVEENV
bool "Support save environment"
depends on SPL_ENV_SUPPORT
+ select SPL_MMC_WRITE if ENV_IS_IN_MMC
help
Enable save environment support in SPL after setenv. By default
the saveenv option is not provided in SPL, but some boards need
@@ -415,6 +416,13 @@ config SPL_MMC_SUPPORT
this option to build the drivers in drivers/mmc as part of an SPL
build.
+config SPL_MMC_WRITE
+ bool "MMC/SD/SDIO card support for write operations in SPL"
+ depends on SPL_MMC_SUPPORT
+ help
+ Enable write access to MMC and SD Cards in SPL
+
+
config SPL_MPC8XXX_INIT_DDR_SUPPORT
bool "Support MPC8XXX DDR init"
help
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index d196eed..ab0627a 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -10,6 +10,13 @@ config MMC
If you want MMC/SD/SDIO support, you should say Y here and
also to your specific host controller driver.
+config MMC_WRITE
+ bool "support for MMC/SD write operations"
+ depends on MMC
+ default y
+ help
+ Enable write access to MMC and SD Cards
+
config DM_MMC
bool "Enable MMC controllers using Driver Model"
depends on DM
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 9af375b..64b6f21 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -7,6 +7,7 @@
obj-y += mmc.o
obj-$(CONFIG_$(SPL_)DM_MMC) += mmc-uclass.o
+obj-$(CONFIG_$(SPL_)MMC_WRITE) += mmc_write.o
ifndef CONFIG_$(SPL_)BLK
obj-y += mmc_legacy.o
@@ -16,9 +17,6 @@ obj-$(CONFIG_SUPPORT_EMMC_BOOT) += mmc_boot.o
ifdef CONFIG_SPL_BUILD
obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
-obj-$(CONFIG_SPL_SAVEENV) += mmc_write.o
-else
-obj-y += mmc_write.o
endif
obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 793196b..7a59dae 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -370,7 +370,7 @@ static int mmc_blk_probe(struct udevice *dev)
static const struct blk_ops mmc_blk_ops = {
.read = mmc_bread,
-#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_IS_ENABLED(MMC_WRITE)
.write = mmc_bwrite,
.erase = mmc_berase,
#endif
diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h
index 1290eed..a9be4b0 100644
--- a/drivers/mmc/mmc_private.h
+++ b/drivers/mmc/mmc_private.h
@@ -28,7 +28,7 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
void *dst);
#endif
-#if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV))
+#if CONFIG_IS_ENABLED(MMC_WRITE)
#if CONFIG_IS_ENABLED(BLK)
ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
@@ -40,7 +40,7 @@ ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt);
#endif
-#else /* CONFIG_SPL_BUILD and CONFIG_SPL_SAVEENV is not defined */
+#else /* CONFIG_SPL_MMC_WRITE is not defined */
/* declare dummies to reduce code size. */
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 07/10] mmc: read ssr only if MMC write support is enabled
2017-12-21 11:53 [U-Boot] [PATCH v1 00/10] reduce the size of the mmc core Jean-Jacques Hiblot
` (5 preceding siblings ...)
2017-12-21 11:53 ` [U-Boot] [PATCH v1 06/10] mmc: add a Kconfig option to enable the support for MMC write operations Jean-Jacques Hiblot
@ 2017-12-21 11:53 ` Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 08/10] mmc: compile out erase and write mmc commands if write operations are not enabled Jean-Jacques Hiblot
` (2 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 11:53 UTC (permalink / raw)
To: u-boot
The content of ssr is useful only for erase operations.
on ARM, removing sd_read_ssr() saves around 300 bytes.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
drivers/mmc/mmc.c | 25 ++++++++++++++-----------
include/mmc.h | 2 ++
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 7d6754f..f400e43 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -22,14 +22,6 @@
#include <div64.h>
#include "mmc_private.h"
-static const unsigned int sd_au_size[] = {
- 0, SZ_16K / 512, SZ_32K / 512,
- SZ_64K / 512, SZ_128K / 512, SZ_256K / 512,
- SZ_512K / 512, SZ_1M / 512, SZ_2M / 512,
- SZ_4M / 512, SZ_8M / 512, (SZ_8M + SZ_4M) / 512,
- SZ_16M / 512, (SZ_16M + SZ_8M) / 512, SZ_32M / 512, SZ_64M / 512,
-};
-
static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage);
static int mmc_power_cycle(struct mmc *mmc);
static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps);
@@ -1358,8 +1350,17 @@ int sd_select_bus_width(struct mmc *mmc, int w)
return 0;
}
+#if CONFIG_IS_ENABLED(MMC_WRITE)
static int sd_read_ssr(struct mmc *mmc)
{
+ static const unsigned int sd_au_size[] = {
+ 0, SZ_16K / 512, SZ_32K / 512,
+ SZ_64K / 512, SZ_128K / 512, SZ_256K / 512,
+ SZ_512K / 512, SZ_1M / 512, SZ_2M / 512,
+ SZ_4M / 512, SZ_8M / 512, (SZ_8M + SZ_4M) / 512,
+ SZ_16M / 512, (SZ_16M + SZ_8M) / 512, SZ_32M / 512,
+ SZ_64M / 512,
+ };
int err, i;
struct mmc_cmd cmd;
ALLOC_CACHE_ALIGN_BUFFER(uint, ssr, 16);
@@ -1413,7 +1414,7 @@ retry_ssr:
return 0;
}
-
+#endif
/* frequency bases */
/* divided by 10 to be nice to platforms without floating point */
static const int fbase[] = {
@@ -1671,12 +1672,14 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps)
}
#endif
+#if CONFIG_IS_ENABLED(MMC_WRITE)
err = sd_read_ssr(mmc);
if (!err)
+ pr_warn("unable to read ssr\n");
+#endif
+ if (!err)
return 0;
- pr_warn("bad ssr\n");
-
error:
/* revert to a safer bus speed */
mmc_select_mode(mmc, SD_LEGACY);
diff --git a/include/mmc.h b/include/mmc.h
index e89ba95..f50c714 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -588,7 +588,9 @@ struct mmc {
uint write_bl_len;
uint erase_grp_size; /* in 512-byte sectors */
uint hc_wp_grp_size; /* in 512-byte sectors */
+#if CONFIG_IS_ENABLED(MMC_WRITE)
struct sd_ssr ssr; /* SD status register */
+#endif
u64 capacity;
u64 capacity_user;
u64 capacity_boot;
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 08/10] mmc: compile out erase and write mmc commands if write operations are not enabled
2017-12-21 11:53 [U-Boot] [PATCH v1 00/10] reduce the size of the mmc core Jean-Jacques Hiblot
` (6 preceding siblings ...)
2017-12-21 11:53 ` [U-Boot] [PATCH v1 07/10] mmc: read ssr only if MMC write support is enabled Jean-Jacques Hiblot
@ 2017-12-21 11:53 ` Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 09/10] mmc: don't read the size of eMMC enhanced user data area in SPL Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 10/10] mmc: remove hc_wp_grp_size from struct mmc if not needed Jean-Jacques Hiblot
9 siblings, 0 replies; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 11:53 UTC (permalink / raw)
To: u-boot
Also remove erase_grp_size and write_bl_len from struct mmc as they are
not used anymore. On ARM, removing them saves about 100 bytes of code
space in SPL.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
cmd/mmc.c | 8 ++++++++
drivers/mmc/mmc.c | 16 ++++++++++++++--
include/mmc.h | 2 ++
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/cmd/mmc.c b/cmd/mmc.c
index 9a95293..65601d8 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -45,8 +45,10 @@ static void print_mmcinfo(struct mmc *mmc)
printf("Bus Width: %d-bit%s\n", mmc->bus_width,
mmc->ddr_mode ? " DDR" : "");
+#if CONFIG_IS_ENABLED(MMC_WRITE)
puts("Erase Group Size: ");
print_size(((u64)mmc->erase_grp_size) << 9, "\n");
+#endif
if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) {
bool has_enh = (mmc->part_support & ENHNCD_SUPPORT) != 0;
@@ -302,6 +304,8 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
}
+
+#if CONFIG_IS_ENABLED(MMC_WRITE)
static int do_mmc_write(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
{
@@ -360,6 +364,8 @@ static int do_mmc_erase(cmd_tbl_t *cmdtp, int flag,
return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
}
+#endif
+
static int do_mmc_rescan(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
{
@@ -792,8 +798,10 @@ static int do_mmc_bkops_enable(cmd_tbl_t *cmdtp, int flag,
static cmd_tbl_t cmd_mmc[] = {
U_BOOT_CMD_MKENT(info, 1, 0, do_mmcinfo, "", ""),
U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""),
+#if CONFIG_IS_ENABLED(MMC_WRITE)
U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""),
U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""),
+#endif
U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""),
U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""),
U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index f400e43..531c098 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2048,9 +2048,11 @@ static int mmc_startup_v4(struct mmc *mmc)
}
if (ext_csd[EXT_CSD_ERASE_GROUP_DEF] & 0x01) {
+#if CONFIG_IS_ENABLED(MMC_WRITE)
/* Read out group size from ext_csd */
mmc->erase_grp_size =
ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] * 1024;
+#endif
/*
* if high capacity and partition setting completed
* SEC_COUNT is valid even if it is smaller than 2 GiB
@@ -2064,7 +2066,9 @@ static int mmc_startup_v4(struct mmc *mmc)
capacity *= MMC_MAX_BLOCK_LEN;
mmc->capacity_user = capacity;
}
- } else {
+ }
+#if CONFIG_IS_ENABLED(MMC_WRITE)
+ else {
/* Calculate the group size from the csd value. */
int erase_gsz, erase_gmul;
@@ -2073,7 +2077,7 @@ static int mmc_startup_v4(struct mmc *mmc)
mmc->erase_grp_size = (erase_gsz + 1)
* (erase_gmul + 1);
}
-
+#endif
mmc->hc_wp_grp_size = 1024
* ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]
* ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
@@ -2204,11 +2208,13 @@ static int mmc_startup(struct mmc *mmc)
mmc->dsr_imp = ((cmd.response[1] >> 12) & 0x1);
mmc->read_bl_len = 1 << ((cmd.response[1] >> 16) & 0xf);
+#if CONFIG_IS_ENABLED(MMC_WRITE)
if (IS_SD(mmc))
mmc->write_bl_len = mmc->read_bl_len;
else
mmc->write_bl_len = 1 << ((cmd.response[3] >> 22) & 0xf);
+#endif
if (mmc->high_capacity) {
csize = (mmc->csd[1] & 0x3f) << 16
@@ -2230,8 +2236,10 @@ static int mmc_startup(struct mmc *mmc)
if (mmc->read_bl_len > MMC_MAX_BLOCK_LEN)
mmc->read_bl_len = MMC_MAX_BLOCK_LEN;
+#if CONFIG_IS_ENABLED(MMC_WRITE)
if (mmc->write_bl_len > MMC_MAX_BLOCK_LEN)
mmc->write_bl_len = MMC_MAX_BLOCK_LEN;
+#endif
if ((mmc->dsr_imp) && (0xffffffff != mmc->dsr)) {
cmd.cmdidx = MMC_CMD_SET_DSR;
@@ -2255,7 +2263,9 @@ static int mmc_startup(struct mmc *mmc)
/*
* For SD, its erase group is always one sector
*/
+#if CONFIG_IS_ENABLED(MMC_WRITE)
mmc->erase_grp_size = 1;
+#endif
mmc->part_config = MMCPART_NOAVAILABLE;
err = mmc_startup_v4(mmc);
@@ -2286,7 +2296,9 @@ static int mmc_startup(struct mmc *mmc)
/* Fix the block length for DDR mode */
if (mmc->ddr_mode) {
mmc->read_bl_len = MMC_MAX_BLOCK_LEN;
+#if CONFIG_IS_ENABLED(MMC_WRITE)
mmc->write_bl_len = MMC_MAX_BLOCK_LEN;
+#endif
}
/* fill in device description */
diff --git a/include/mmc.h b/include/mmc.h
index f50c714..3abeb58 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -585,8 +585,10 @@ struct mmc {
uint tran_speed;
uint legacy_speed; /* speed for the legacy mode provided by the card */
uint read_bl_len;
+#if CONFIG_IS_ENABLED(MMC_WRITE)
uint write_bl_len;
uint erase_grp_size; /* in 512-byte sectors */
+#endif
uint hc_wp_grp_size; /* in 512-byte sectors */
#if CONFIG_IS_ENABLED(MMC_WRITE)
struct sd_ssr ssr; /* SD status register */
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 09/10] mmc: don't read the size of eMMC enhanced user data area in SPL
2017-12-21 11:53 [U-Boot] [PATCH v1 00/10] reduce the size of the mmc core Jean-Jacques Hiblot
` (7 preceding siblings ...)
2017-12-21 11:53 ` [U-Boot] [PATCH v1 08/10] mmc: compile out erase and write mmc commands if write operations are not enabled Jean-Jacques Hiblot
@ 2017-12-21 11:53 ` Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 10/10] mmc: remove hc_wp_grp_size from struct mmc if not needed Jean-Jacques Hiblot
9 siblings, 0 replies; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 11:53 UTC (permalink / raw)
To: u-boot
This information is only used by the "mmc info" command.
On ARM removing this information from SPL saves about 140 of code space.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
drivers/mmc/mmc.c | 2 ++
include/mmc.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 531c098..64c7479 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2010,6 +2010,7 @@ static int mmc_startup_v4(struct mmc *mmc)
mmc->capacity_gp[i] <<= 19;
}
+#ifndef CONFIG_SPL_BUILD
if (part_completed) {
mmc->enh_user_size =
(ext_csd[EXT_CSD_ENH_SIZE_MULT + 2] << 16) +
@@ -2026,6 +2027,7 @@ static int mmc_startup_v4(struct mmc *mmc)
if (mmc->high_capacity)
mmc->enh_user_start <<= 9;
}
+#endif
/*
* Host needs to enable ERASE_GRP_DEF bit if device is
diff --git a/include/mmc.h b/include/mmc.h
index 3abeb58..cd068b9 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -598,8 +598,10 @@ struct mmc {
u64 capacity_boot;
u64 capacity_rpmb;
u64 capacity_gp[4];
+#ifndef CONFIG_SPL_BUILD
u64 enh_user_start;
u64 enh_user_size;
+#endif
#if !CONFIG_IS_ENABLED(BLK)
struct blk_desc block_dev;
#endif
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 10/10] mmc: remove hc_wp_grp_size from struct mmc if not needed
2017-12-21 11:53 [U-Boot] [PATCH v1 00/10] reduce the size of the mmc core Jean-Jacques Hiblot
` (8 preceding siblings ...)
2017-12-21 11:53 ` [U-Boot] [PATCH v1 09/10] mmc: don't read the size of eMMC enhanced user data area in SPL Jean-Jacques Hiblot
@ 2017-12-21 11:53 ` Jean-Jacques Hiblot
9 siblings, 0 replies; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 11:53 UTC (permalink / raw)
To: u-boot
hc_wp_grp_size is needed only if hardware partitionning is used.
On ARM removing it saves about 30 bytes of code space.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
cmd/mmc.c | 2 ++
drivers/mmc/mmc.c | 2 ++
include/mmc.h | 2 ++
3 files changed, 6 insertions(+)
diff --git a/cmd/mmc.c b/cmd/mmc.c
index 65601d8..58fdc36 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -54,8 +54,10 @@ static void print_mmcinfo(struct mmc *mmc)
bool has_enh = (mmc->part_support & ENHNCD_SUPPORT) != 0;
bool usr_enh = has_enh && (mmc->part_attr & EXT_CSD_ENH_USR);
+#if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
puts("HC WP Group Size: ");
print_size(((u64)mmc->hc_wp_grp_size) << 9, "\n");
+#endif
puts("User Capacity: ");
print_size(mmc->capacity_user, usr_enh ? " ENH" : "");
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 64c7479..c36228f 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2080,9 +2080,11 @@ static int mmc_startup_v4(struct mmc *mmc)
* (erase_gmul + 1);
}
#endif
+#if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
mmc->hc_wp_grp_size = 1024
* ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]
* ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
+#endif
mmc->wr_rel_set = ext_csd[EXT_CSD_WR_REL_SET];
diff --git a/include/mmc.h b/include/mmc.h
index cd068b9..a46eaed 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -589,7 +589,9 @@ struct mmc {
uint write_bl_len;
uint erase_grp_size; /* in 512-byte sectors */
#endif
+#if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
uint hc_wp_grp_size; /* in 512-byte sectors */
+#endif
#if CONFIG_IS_ENABLED(MMC_WRITE)
struct sd_ssr ssr; /* SD status register */
#endif
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 01/10] common: do not compile common fastboot code when building the SPL
2017-12-21 11:53 ` [U-Boot] [PATCH v1 01/10] common: do not compile common fastboot code when building the SPL Jean-Jacques Hiblot
@ 2017-12-21 14:46 ` Tom Rini
2017-12-21 15:28 ` Jean-Jacques Hiblot
0 siblings, 1 reply; 21+ messages in thread
From: Tom Rini @ 2017-12-21 14:46 UTC (permalink / raw)
To: u-boot
On Thu, Dec 21, 2017 at 12:53:47PM +0100, Jean-Jacques Hiblot wrote:
> This is not required as fastboot can't be started from SPL.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>
> common/Makefile | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/common/Makefile b/common/Makefile
> index 1416620..c7bde23 100644
> --- a/common/Makefile
> +++ b/common/Makefile
> @@ -109,6 +109,7 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o
> obj-y += memsize.o
> obj-y += stdio.o
>
> +ifndef CONFIG_SPL_BUILD
> # This option is not just y/n - it can have a numeric value
> ifdef CONFIG_FASTBOOT_FLASH
> obj-y += image-sparse.o
> @@ -119,6 +120,7 @@ ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
> obj-y += fb_nand.o
> endif
> endif
> +endif
>
> ifdef CONFIG_CMD_EEPROM_LAYOUT
> obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o
We don't need this as all of the code (and text) is discarded. Checked
with am335x_evm_usbspl as that does set FASTBOOT. 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/20171221/a7f9db5b/attachment.sig>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 06/10] mmc: add a Kconfig option to enable the support for MMC write operations
2017-12-21 11:53 ` [U-Boot] [PATCH v1 06/10] mmc: add a Kconfig option to enable the support for MMC write operations Jean-Jacques Hiblot
@ 2017-12-21 14:46 ` Tom Rini
2017-12-21 14:52 ` Tom Rini
0 siblings, 1 reply; 21+ messages in thread
From: Tom Rini @ 2017-12-21 14:46 UTC (permalink / raw)
To: u-boot
On Thu, Dec 21, 2017 at 12:53:52PM +0100, Jean-Jacques Hiblot wrote:
> This allows using CONFIG_IS_ENABLED(MMC_WRITE) to compile out code
> needed only if write support is required.
> The option is added for u-boot and for the SPL
"for SPL".
[snip]
> +config SPL_MMC_WRITE
> + bool "MMC/SD/SDIO card support for write operations in SPL"
> + depends on SPL_MMC_SUPPORT
> + help
> + Enable write access to MMC and SD Cards in SPL
This should be default n.
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/20171221/999bfa16/attachment.sig>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 06/10] mmc: add a Kconfig option to enable the support for MMC write operations
2017-12-21 14:46 ` Tom Rini
@ 2017-12-21 14:52 ` Tom Rini
2017-12-21 15:33 ` Jean-Jacques Hiblot
0 siblings, 1 reply; 21+ messages in thread
From: Tom Rini @ 2017-12-21 14:52 UTC (permalink / raw)
To: u-boot
On Thu, Dec 21, 2017 at 09:46:36AM -0500, Tom Rini wrote:
> On Thu, Dec 21, 2017 at 12:53:52PM +0100, Jean-Jacques Hiblot wrote:
>
> > This allows using CONFIG_IS_ENABLED(MMC_WRITE) to compile out code
> > needed only if write support is required.
> > The option is added for u-boot and for the SPL
>
> "for SPL".
>
> [snip]
> > +config SPL_MMC_WRITE
> > + bool "MMC/SD/SDIO card support for write operations in SPL"
> > + depends on SPL_MMC_SUPPORT
> > + help
> > + Enable write access to MMC and SD Cards in SPL
>
> This should be default n.
Actually, even with that, oops, no code is being dropped out.
--
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/20171221/5496aaa6/attachment.sig>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 01/10] common: do not compile common fastboot code when building the SPL
2017-12-21 14:46 ` Tom Rini
@ 2017-12-21 15:28 ` Jean-Jacques Hiblot
2017-12-21 15:53 ` Tom Rini
0 siblings, 1 reply; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 15:28 UTC (permalink / raw)
To: u-boot
On 21/12/2017 15:46, Tom Rini wrote:
> On Thu, Dec 21, 2017 at 12:53:47PM +0100, Jean-Jacques Hiblot wrote:
>
>> This is not required as fastboot can't be started from SPL.
>>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>> ---
>>
>> common/Makefile | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/common/Makefile b/common/Makefile
>> index 1416620..c7bde23 100644
>> --- a/common/Makefile
>> +++ b/common/Makefile
>> @@ -109,6 +109,7 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o
>> obj-y += memsize.o
>> obj-y += stdio.o
>>
>> +ifndef CONFIG_SPL_BUILD
>> # This option is not just y/n - it can have a numeric value
>> ifdef CONFIG_FASTBOOT_FLASH
>> obj-y += image-sparse.o
>> @@ -119,6 +120,7 @@ ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
>> obj-y += fb_nand.o
>> endif
>> endif
>> +endif
>>
>> ifdef CONFIG_CMD_EEPROM_LAYOUT
>> obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o
> We don't need this as all of the code (and text) is discarded. Checked
> with am335x_evm_usbspl as that does set FASTBOOT. Thanks!
Yes but even if it is dropped out, it gets compiled. At this point in
the series it is okay, but a later patch will conditionally remove some
members from "struct mmc" and the compilation will break. Instead of
adding #ifdef, I opted for not compiling it.
JJ
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 06/10] mmc: add a Kconfig option to enable the support for MMC write operations
2017-12-21 14:52 ` Tom Rini
@ 2017-12-21 15:33 ` Jean-Jacques Hiblot
2017-12-21 15:54 ` Tom Rini
0 siblings, 1 reply; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2017-12-21 15:33 UTC (permalink / raw)
To: u-boot
On 21/12/2017 15:52, Tom Rini wrote:
> On Thu, Dec 21, 2017 at 09:46:36AM -0500, Tom Rini wrote:
>> On Thu, Dec 21, 2017 at 12:53:52PM +0100, Jean-Jacques Hiblot wrote:
>>
>>> This allows using CONFIG_IS_ENABLED(MMC_WRITE) to compile out code
>>> needed only if write support is required.
>>> The option is added for u-boot and for the SPL
>> "for SPL".
>>
>> [snip]
>>> +config SPL_MMC_WRITE
>>> + bool "MMC/SD/SDIO card support for write operations in SPL"
>>> + depends on SPL_MMC_SUPPORT
>>> + help
>>> + Enable write access to MMC and SD Cards in SPL
>> This should be default n.
> Actually, even with that, oops, no code is being dropped out.
The SPL_MMC_WRITE option will be used in the next patches to compile out
part of the code.
I deliberately choose to split the series in a lot of small patches to
ease the reviews but the big part of the reduction come in the next patches
JJ
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 01/10] common: do not compile common fastboot code when building the SPL
2017-12-21 15:28 ` Jean-Jacques Hiblot
@ 2017-12-21 15:53 ` Tom Rini
0 siblings, 0 replies; 21+ messages in thread
From: Tom Rini @ 2017-12-21 15:53 UTC (permalink / raw)
To: u-boot
On Thu, Dec 21, 2017 at 04:28:40PM +0100, Jean-Jacques Hiblot wrote:
>
>
> On 21/12/2017 15:46, Tom Rini wrote:
> >On Thu, Dec 21, 2017 at 12:53:47PM +0100, Jean-Jacques Hiblot wrote:
> >
> >>This is not required as fastboot can't be started from SPL.
> >>
> >>Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> >>---
> >>
> >> common/Makefile | 2 ++
> >> 1 file changed, 2 insertions(+)
> >>
> >>diff --git a/common/Makefile b/common/Makefile
> >>index 1416620..c7bde23 100644
> >>--- a/common/Makefile
> >>+++ b/common/Makefile
> >>@@ -109,6 +109,7 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o
> >> obj-y += memsize.o
> >> obj-y += stdio.o
> >>+ifndef CONFIG_SPL_BUILD
> >> # This option is not just y/n - it can have a numeric value
> >> ifdef CONFIG_FASTBOOT_FLASH
> >> obj-y += image-sparse.o
> >>@@ -119,6 +120,7 @@ ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
> >> obj-y += fb_nand.o
> >> endif
> >> endif
> >>+endif
> >> ifdef CONFIG_CMD_EEPROM_LAYOUT
> >> obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o
> >We don't need this as all of the code (and text) is discarded. Checked
> >with am335x_evm_usbspl as that does set FASTBOOT. Thanks!
> Yes but even if it is dropped out, it gets compiled. At this point in the
> series it is okay, but a later patch will conditionally remove some members
> from "struct mmc" and the compilation will break. Instead of adding #ifdef,
> I opted for not compiling it.
I dropped this in some quick testing, but didn't build everything, so
OK, if you're sure we need it like this for world-building. 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/20171221/cbfb98e3/attachment.sig>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 06/10] mmc: add a Kconfig option to enable the support for MMC write operations
2017-12-21 15:33 ` Jean-Jacques Hiblot
@ 2017-12-21 15:54 ` Tom Rini
0 siblings, 0 replies; 21+ messages in thread
From: Tom Rini @ 2017-12-21 15:54 UTC (permalink / raw)
To: u-boot
On Thu, Dec 21, 2017 at 04:33:10PM +0100, Jean-Jacques Hiblot wrote:
>
>
> On 21/12/2017 15:52, Tom Rini wrote:
> >On Thu, Dec 21, 2017 at 09:46:36AM -0500, Tom Rini wrote:
> >>On Thu, Dec 21, 2017 at 12:53:52PM +0100, Jean-Jacques Hiblot wrote:
> >>
> >>>This allows using CONFIG_IS_ENABLED(MMC_WRITE) to compile out code
> >>>needed only if write support is required.
> >>>The option is added for u-boot and for the SPL
> >>"for SPL".
> >>
> >>[snip]
> >>>+config SPL_MMC_WRITE
> >>>+ bool "MMC/SD/SDIO card support for write operations in SPL"
> >>>+ depends on SPL_MMC_SUPPORT
> >>>+ help
> >>>+ Enable write access to MMC and SD Cards in SPL
> >>This should be default n.
> >Actually, even with that, oops, no code is being dropped out.
> The SPL_MMC_WRITE option will be used in the next patches to compile out
> part of the code.
> I deliberately choose to split the series in a lot of small patches to ease
> the reviews but the big part of the reduction come in the next patches
OK. Please keep this one with the series that follows up, 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/20171221/6ec07b8a/attachment.sig>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 02/10] mmc: atmel: when sending a data command, use the provided block size
2017-12-21 11:53 ` [U-Boot] [PATCH v1 02/10] mmc: atmel: when sending a data command, use the provided block size Jean-Jacques Hiblot
@ 2017-12-26 10:14 ` Jaehoon Chung
0 siblings, 0 replies; 21+ messages in thread
From: Jaehoon Chung @ 2017-12-26 10:14 UTC (permalink / raw)
To: u-boot
On 12/21/2017 08:53 PM, Jean-Jacques Hiblot wrote:
> struct mmc_data contains the block size to use for the data transfer.
> Use this information instead of relying on read_bl_len and write_bl_len
> stored in the mmc structure.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>
> drivers/mmc/gen_atmel_mci.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c
> index 22154d1..54646e4 100644
> --- a/drivers/mmc/gen_atmel_mci.c
> +++ b/drivers/mmc/gen_atmel_mci.c
> @@ -301,13 +301,12 @@ mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
>
> if (data->flags & MMC_DATA_READ) {
> mci_data_op = mci_data_read;
> - sys_blocksize = mmc->read_bl_len;
> ioptr = (u32*)data->dest;
> } else {
> mci_data_op = mci_data_write;
> - sys_blocksize = mmc->write_bl_len;
> ioptr = (u32*)data->src;
> }
> + sys_blocksize = data->blocksize;
Then can use data->blocksize instead of sys_blocksize.?
>
> status = 0;
> for (block_count = 0;
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 03/10] mmc: remove unneeded verification in mmc_set_card_speed()
2017-12-21 11:53 ` [U-Boot] [PATCH v1 03/10] mmc: remove unneeded verification in mmc_set_card_speed() Jean-Jacques Hiblot
@ 2017-12-26 10:36 ` Jaehoon Chung
2018-01-03 14:28 ` Jean-Jacques Hiblot
0 siblings, 1 reply; 21+ messages in thread
From: Jaehoon Chung @ 2017-12-26 10:36 UTC (permalink / raw)
To: u-boot
On 12/21/2017 08:53 PM, Jean-Jacques Hiblot wrote:
> mmc_set_card_speed() reads the ext csd to check if switch has been OK.
> But it does it only for MMC_HS and MMC_HS_52. Moreover this check is not
> really required as there will be a ext csd reading later in the
> initialization process to make sure that it succeeded.
> So remove this partial verification and save space.
Yes, it's saved the space, but it may be affected with the driver strength value.
It needs to consider more whether we can remove it.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>
> drivers/mmc/mmc.c | 22 +++-------------------
> 1 file changed, 3 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 67d05c5..7a92718 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -788,11 +788,8 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
>
> static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode)
> {
> - int err;
> int speed_bits;
>
> - ALLOC_CACHE_ALIGN_BUFFER(u8, test_csd, MMC_MAX_BLOCK_LEN);
> -
> switch (mode) {
> case MMC_HS:
> case MMC_HS_52:
> @@ -808,23 +805,8 @@ static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode)
> default:
> return -EINVAL;
> }
> - err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
> + return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
> speed_bits);
> - if (err)
> - return err;
> -
> - if ((mode == MMC_HS) || (mode == MMC_HS_52)) {
> - /* Now check to see that it worked */
> - err = mmc_send_ext_csd(mmc, test_csd);
> - if (err)
> - return err;
> -
> - /* No high-speed support */
> - if (!test_csd[EXT_CSD_HS_TIMING])
> - return -ENOTSUPP;
> - }
> -
> - return 0;
> }
>
> static int mmc_get_capabilities(struct mmc *mmc)
> @@ -851,10 +833,12 @@ static int mmc_get_capabilities(struct mmc *mmc)
> cardtype = ext_csd[EXT_CSD_CARD_TYPE] & 0x3f;
> mmc->cardtype = cardtype;
>
> +#if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
> if (cardtype & (EXT_CSD_CARD_TYPE_HS200_1_2V |
> EXT_CSD_CARD_TYPE_HS200_1_8V)) {
> mmc->card_caps |= MMC_MODE_HS200;
> }
> +#endif
It's not related with your subject.?
Best Regards,
Jaehoon Chung
> if (cardtype & EXT_CSD_CARD_TYPE_52) {
> if (cardtype & EXT_CSD_CARD_TYPE_DDR_52)
> mmc->card_caps |= MMC_MODE_DDR_52MHz;
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [U-Boot] [PATCH v1 03/10] mmc: remove unneeded verification in mmc_set_card_speed()
2017-12-26 10:36 ` Jaehoon Chung
@ 2018-01-03 14:28 ` Jean-Jacques Hiblot
0 siblings, 0 replies; 21+ messages in thread
From: Jean-Jacques Hiblot @ 2018-01-03 14:28 UTC (permalink / raw)
To: u-boot
Hi Jaehoon,
On 26/12/2017 11:36, Jaehoon Chung wrote:
> On 12/21/2017 08:53 PM, Jean-Jacques Hiblot wrote:
>> mmc_set_card_speed() reads the ext csd to check if switch has been OK.
>> But it does it only for MMC_HS and MMC_HS_52. Moreover this check is not
>> really required as there will be a ext csd reading later in the
>> initialization process to make sure that it succeeded.
>> So remove this partial verification and save space.
> Yes, it's saved the space, but it may be affected with the driver strength value.
> It needs to consider more whether we can remove it.
I'll drop the patch from the series
>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>> ---
>>
>> drivers/mmc/mmc.c | 22 +++-------------------
>> 1 file changed, 3 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>> index 67d05c5..7a92718 100644
>> --- a/drivers/mmc/mmc.c
>> +++ b/drivers/mmc/mmc.c
>> @@ -788,11 +788,8 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
>>
>> static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode)
>> {
>> - int err;
>> int speed_bits;
>>
>> - ALLOC_CACHE_ALIGN_BUFFER(u8, test_csd, MMC_MAX_BLOCK_LEN);
>> -
>> switch (mode) {
>> case MMC_HS:
>> case MMC_HS_52:
>> @@ -808,23 +805,8 @@ static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode)
>> default:
>> return -EINVAL;
>> }
>> - err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
>> + return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
>> speed_bits);
>> - if (err)
>> - return err;
>> -
>> - if ((mode == MMC_HS) || (mode == MMC_HS_52)) {
>> - /* Now check to see that it worked */
>> - err = mmc_send_ext_csd(mmc, test_csd);
>> - if (err)
>> - return err;
>> -
>> - /* No high-speed support */
>> - if (!test_csd[EXT_CSD_HS_TIMING])
>> - return -ENOTSUPP;
>> - }
>> -
>> - return 0;
>> }
>>
>> static int mmc_get_capabilities(struct mmc *mmc)
>> @@ -851,10 +833,12 @@ static int mmc_get_capabilities(struct mmc *mmc)
>> cardtype = ext_csd[EXT_CSD_CARD_TYPE] & 0x3f;
>> mmc->cardtype = cardtype;
>>
>> +#if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
>> if (cardtype & (EXT_CSD_CARD_TYPE_HS200_1_2V |
>> EXT_CSD_CARD_TYPE_HS200_1_8V)) {
>> mmc->card_caps |= MMC_MODE_HS200;
>> }
>> +#endif
> It's not related with your subject.?
You are right. I'll put this in the right patch: 'mmc: compile out more
code if support for UHS and HS200 is not enabled'.
Thanks,
Jean-Jacques
>
>
> Best Regards,
> Jaehoon Chung
>
>> if (cardtype & EXT_CSD_CARD_TYPE_52) {
>> if (cardtype & EXT_CSD_CARD_TYPE_DDR_52)
>> mmc->card_caps |= MMC_MODE_DDR_52MHz;
>>
>
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2018-01-03 14:28 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-21 11:53 [U-Boot] [PATCH v1 00/10] reduce the size of the mmc core Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 01/10] common: do not compile common fastboot code when building the SPL Jean-Jacques Hiblot
2017-12-21 14:46 ` Tom Rini
2017-12-21 15:28 ` Jean-Jacques Hiblot
2017-12-21 15:53 ` Tom Rini
2017-12-21 11:53 ` [U-Boot] [PATCH v1 02/10] mmc: atmel: when sending a data command, use the provided block size Jean-Jacques Hiblot
2017-12-26 10:14 ` Jaehoon Chung
2017-12-21 11:53 ` [U-Boot] [PATCH v1 03/10] mmc: remove unneeded verification in mmc_set_card_speed() Jean-Jacques Hiblot
2017-12-26 10:36 ` Jaehoon Chung
2018-01-03 14:28 ` Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 04/10] mmc: compile out more code if support for UHS and HS200 is not enabled Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 05/10] mmc: reworked version lookup in mmc_startup_v4 Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 06/10] mmc: add a Kconfig option to enable the support for MMC write operations Jean-Jacques Hiblot
2017-12-21 14:46 ` Tom Rini
2017-12-21 14:52 ` Tom Rini
2017-12-21 15:33 ` Jean-Jacques Hiblot
2017-12-21 15:54 ` Tom Rini
2017-12-21 11:53 ` [U-Boot] [PATCH v1 07/10] mmc: read ssr only if MMC write support is enabled Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 08/10] mmc: compile out erase and write mmc commands if write operations are not enabled Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 09/10] mmc: don't read the size of eMMC enhanced user data area in SPL Jean-Jacques Hiblot
2017-12-21 11:53 ` [U-Boot] [PATCH v1 10/10] mmc: remove hc_wp_grp_size from struct mmc if not needed Jean-Jacques Hiblot
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.