reduce the size of the mmc core
Subsystems (2)
cover reduce the size of the mmc core
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(-)
Signature · 1 line
1.9.1
PATCH 1/10 common: do not compile common fastboot code when building the SPL
This is not required as fastboot can't be started from SPL.
---
common/Makefile | 2 ++ 1 file changed, 2 insertions(+)
common/Makefile +2 -0
@@ -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
Signature · 1 line
1.9.1
PATCH 1/10 common: do not compile common fastboot code when building the SPL
Quoted 21 lines · Jean-Jacques Hiblot
This is not required as fastboot can't be started from SPL.
Signed-off-by Jean-Jacques Hiblot <[email protected]>---
common/Makefile | 2 ++ 1 file changed, 2 insertions(+)common/Makefile +1
-0@@ -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
common/Makefile ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV · line 126
Quoted 7 lines
common/Makefile +1
-0@@ -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!
Signature · 8 lines
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>
PATCH 1/10 common: do not compile common fastboot code when building the SPL
Quoted 28 lines · Tom Rini
Quoted 26 lines · Jean-Jacques Hiblot
This is not required as fastboot can't be started from SPL.
Signed-off-by Jean-Jacques Hiblot <[email protected]>---
common/Makefile | 2 ++ 1 file changed, 2 insertions(+)common/Makefile +2
-0@@ -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
Quoted 4 lines
common/Makefile ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV · line 126
Quoted 2 lines
common/Makefile +0
-0ifdef CONFIG_CMD_EEPROM_LAYOUT obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.oWe don't need this as all of the code (and text) is discarded. Checked with
am335x_evm_usbsplas 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
Quoted 1 line
PATCH 1/10 common: do not compile common fastboot code when building the SPL
Quoted 33 lines · Jean-Jacques Hiblot
Quoted 22 lines · Tom Rini
Quoted 20 lines · Jean-Jacques Hiblot
This is not required as fastboot can't be started from SPL.
Signed-off-by Jean-Jacques Hiblot <[email protected]>---
common/Makefile | 2 ++ 1 file changed, 2 insertions(+)common/Makefile +1
-0@@ -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_DEVQuoted 8 lines
common/Makefile ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV · line 126
Quoted 6 lines
common/Makefile +1
-0obj-y += fb_nand.o endif endif +endif ifdef CONFIG_CMD_EEPROM_LAYOUT obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.oWe don't need this as all of the code (and text) is discarded. Checked with
am335x_evm_usbsplas that does set FASTBOOT. Thanks!
Quoted 4 lines
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!
Signature · 8 lines
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>
PATCH 2/10 mmc: atmel: when sending a data command, use the provided block size
In reply to Jean-Jacques Hiblotstruct 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.
---
drivers/mmc/gen_atmel_mci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/gen_atmel_mci.c +1 -2
@@ -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;
Signature · 1 line
1.9.1
PATCH 2/10 mmc: atmel: when sending a data command, use the provided block size
Quoted 16 lines · Jean-Jacques Hiblot
struct
mmc_datacontains the block size to use for the data transfer. Use this information instead of relying onread_bl_lenandwrite_bl_lenstored in the mmc structure.Signed-off-by Jean-Jacques Hiblot <[email protected]>---
drivers/mmc/gen_atmel_mci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/mmc/gen_atmel_mci.c +0
-0@@ -301,13 +301,12 @@ mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
drivers/mmc/gen_atmel_mci.c mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) · line 309
Quoted 10 lines
drivers/mmc/gen_atmel_mci.c +1
-2if (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.?
Quoted 4 lines
drivers/mmc/gen_atmel_mci.c +0
-0status =0 ; for (block_count = 0;
PATCH 3/10 mmc: remove unneeded verification in mmc_set_card_speed()
In reply to Jean-Jacques Hiblotmmc_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.
---
drivers/mmc/mmc.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
drivers/mmc/mmc.c +3 -19
@@ -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;
Signature · 1 line
1.9.1
PATCH 3/10 mmc: remove unneeded verification in mmc_set_card_speed()
Quoted 5 lines · Jean-Jacques Hiblot
mmc_set_card_speed()reads the ext csd to check if switch has been OK. But it does it only forMMC_HSandMMC_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.
Quoted 49 lines
Signed-off-by Jean-Jacques Hiblot <[email protected]>---
drivers/mmc/mmc.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)drivers/mmc/mmc.c +1
-19@@ -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)
drivers/mmc/mmc.c static int mmc_get_capabilities(struct mmc *mmc) · line 841
Quoted 9 lines
drivers/mmc/mmc.c +2
-0@@ -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
Quoted 4 lines
drivers/mmc/mmc.c +0
-0if (cardtype &EXT_CSD_CARD_TYPE_52 ) {if (cardtype &EXT_CSD_CARD_TYPE_DDR_52 ) mmc->card_caps |= MMC_MODE_DDR_52MHz;
PATCH 3/10 mmc: remove unneeded verification in mmc_set_card_speed()
Hi Jaehoon,
Quoted 8 lines · Jaehoon Chung
Quoted 5 lines · Jean-Jacques Hiblot
mmc_set_card_speed()reads the ext csd to check if switch has been OK. But it does it only forMMC_HSandMMC_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
Quoted 52 lines
Quoted 52 lines
Signed-off-by Jean-Jacques Hiblot <[email protected]>---
drivers/mmc/mmc.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)drivers/mmc/mmc.c +1
-19@@ -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;
Quoted 7 lines
drivers/mmc/mmc.c static int mmc_get_capabilities(struct mmc *mmc) · line 841
Quoted 6 lines
drivers/mmc/mmc.c +2
-0+#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
Quoted 10 lines
Best Regards,
Jaehoon ChungQuoted 4 lines
drivers/mmc/mmc.c +0
-0if (cardtype &EXT_CSD_CARD_TYPE_52 ) {if (cardtype &EXT_CSD_CARD_TYPE_DDR_52 ) mmc->card_caps |= MMC_MODE_DDR_52MHz;
PATCH 4/10 mmc: compile out more code if support for UHS and HS200 is not enabled
In reply to Jean-Jacques Hiblot---
drivers/mmc/mmc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/mmc/mmc.c +9 -1
@@ -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 ; }
Signature · 1 line
1.9.1
PATCH 5/10 mmc: reworked version lookup in mmc_startup_v4
In reply to Jean-Jacques HiblotUsing a table versus a switch() structure saves a bit of space
---
drivers/mmc/mmc.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-)
drivers/mmc/mmc.c +17 -25
@@ -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,
Signature · 1 line
1.9.1
PATCH 6/10 mmc: add a Kconfig option to enable the support for MMC write operations
In reply to Jean-Jacques HiblotThis 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
---
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(-)
cmd/mvebu/bubt.c +1 -1
@@ -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;
common/spl/Kconfig +8 -0
@@ -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
drivers/mmc/Kconfig +7 -0
@@ -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
drivers/mmc/Makefile +1 -3
@@ -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
drivers/mmc/mmc-uclass.c +1 -1
@@ -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
drivers/mmc/mmc_private.h +2 -2
@@ -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. */
Signature · 1 line
1.9.1
PATCH 6/10 mmc: add a Kconfig option to enable the support for MMC write operations
Quoted 3 lines · Jean-Jacques Hiblot
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]
common/spl/Kconfig config SPL_MMC_SUPPORT · line 423
Quoted 5 lines
common/spl/Kconfig +5
-0+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!
Signature · 8 lines
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>
PATCH 6/10 mmc: add a Kconfig option to enable the support for MMC write operations
Quoted 8 lines · Tom Rini
Quoted 3 lines · Jean-Jacques Hiblot
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".
Quoted 8 lines
[snip]
common/spl/Kconfig config SPL_MMC_SUPPORT · line 423
Quoted 5 lines
common/spl/Kconfig +5
-0+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 SPLThis should be default n.
Actually, even with that, oops, no code is being dropped out.
Signature · 8 lines
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>
PATCH 6/10 mmc: add a Kconfig option to enable the support for MMC write operations
Quoted 8 lines · Tom Rini
Quoted 7 lines · Tom Rini
Quoted 3 lines · Jean-Jacques Hiblot
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".
Quoted 8 lines
Quoted 7 lines
[snip]
common/spl/Kconfig config SPL_MMC_SUPPORT · line 423
Quoted 5 lines
common/spl/Kconfig +5
-0+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 SPLThis 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
Quoted 1 line
PATCH 6/10 mmc: add a Kconfig option to enable the support for MMC write operations
Quoted 18 lines · Jean-Jacques Hiblot
Quoted 15 lines · Tom Rini
Quoted 14 lines · Tom Rini
Quoted 3 lines · Jean-Jacques Hiblot
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]
common/spl/Kconfig config SPL_MMC_SUPPORT · line 423
Quoted 5 lines
common/spl/Kconfig +5
-0+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 SPLThis should be default n.
Quoted 5 lines
Quoted 1 line
Actually, even with that, oops, no code is being dropped out.
The
SPL_MMC_WRITEoption 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!
Signature · 8 lines
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>
PATCH 7/10 mmc: read ssr only if MMC write support is enabled
In reply to Jean-Jacques HiblotThe content of ssr is useful only for erase operations. on ARM, removing sd_read_ssr() saves around 300 bytes.
---
drivers/mmc/mmc.c | 25 ++++++++++++++----------- include/mmc.h | 2 ++ 2 files changed, 16 insertions(+), 11 deletions(-)
drivers/mmc/mmc.c +14 -11
@@ -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 );
include/mmc.h +2 -0
@@ -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;
Signature · 1 line
1.9.1
PATCH 8/10 mmc: compile out erase and write mmc commands if write operations are not enabled
In reply to Jean-Jacques HiblotAlso 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.
---
cmd/mmc.c | 8 ++++++++ drivers/mmc/mmc.c | 16 ++++++++++++++-- include/mmc.h | 2 ++ 3 files changed, 24 insertions(+), 2 deletions(-)
cmd/mmc.c +8 -0
@@ -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,"" ,"" ), +#endifU_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,"" ,"" ),
drivers/mmc/mmc.c +14 -2
@@ -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 */
include/mmc.h +2 -0
@@ -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 */
Signature · 1 line
1.9.1
PATCH 9/10 mmc: don't read the size of eMMC enhanced user data area in SPL
In reply to Jean-Jacques HiblotThis information is only used by the "mmc info" command.
On ARM removing this information from SPL saves about 140 of code space.
---
drivers/mmc/mmc.c | 2 ++ include/mmc.h | 2 ++ 2 files changed, 4 insertions(+)
drivers/mmc/mmc.c +2 -0
@@ -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
include/mmc.h +2 -0
@@ -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
Signature · 1 line
1.9.1
PATCH 10/10 mmc: remove hc_wp_grp_size from struct mmc if not needed
In reply to Jean-Jacques Hiblothc_wp_grp_size is needed only if hardware partitionning is used. On ARM removing it saves about 30 bytes of code space.
---
cmd/mmc.c | 2 ++ drivers/mmc/mmc.c | 2 ++ include/mmc.h | 2 ++ 3 files changed, 6 insertions(+)
cmd/mmc.c +2 -0
@@ -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" :"" );
drivers/mmc/mmc.c +2 -0
@@ -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 ];
include/mmc.h +2 -0
@@ -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
Signature · 1 line
1.9.1