From 7a96ec74592847cd7bf5664cb72996500ebde92b Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 21 Sep 2017 16:29:56 +0200 Subject: cmd: mmc: display the mode name and current bus speed in the mmc info Display the mode name when the user execute 'mmc info'. Also instead of displaying tran_speed, display the actual bus speed. Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Simon Glass --- cmd/mmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/mmc.c b/cmd/mmc.c index 5def4ea1a2..6d48ecbe0b 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -23,7 +23,8 @@ static void print_mmcinfo(struct mmc *mmc) (mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff, (mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff); - printf("Tran Speed: %d\n", mmc->tran_speed); + printf("Bus Speed: %d\n", mmc->clock); + printf("Mode : %s\n", mmc_mode_name(mmc->selected_mode)); printf("Rd Block Len: %d\n", mmc->read_bl_len); printf("%s version %d.%d", IS_SD(mmc) ? "SD" : "MMC", -- cgit v1.2.3 From 52d241dfba7c3903a3a7d97fe6cb815c9ed379d6 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 30 Nov 2017 17:43:54 +0100 Subject: mmc: dump card and host capabilities if debug is enabled 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 --- cmd/mmc.c | 4 ++++ drivers/mmc/mmc.c | 9 +++++++++ 2 files changed, 13 insertions(+) (limited to 'cmd') diff --git a/cmd/mmc.c b/cmd/mmc.c index 6d48ecbe0b..25795e0325 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 ab2483e9db..9b5c982578 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); -- cgit v1.2.3 From cf17789e078fd23b95ee86ffc441e98709c2d063 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 30 Nov 2017 17:44:02 +0100 Subject: mmc: make optional the support for eMMC hardware partitioning 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 --- cmd/mmc.c | 4 ++++ drivers/mmc/Kconfig | 7 +++++++ drivers/mmc/mmc.c | 2 ++ 3 files changed, 13 insertions(+) (limited to 'cmd') diff --git a/cmd/mmc.c b/cmd/mmc.c index 25795e0325..9a95293753 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 2fcdaddf22..d196eed540 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_IO_VOLTAGE bool "Support IO voltage configuration" help diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 400e163340..67d05c5413 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -950,6 +950,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) @@ -1143,6 +1144,7 @@ int mmc_hwpart_config(struct mmc *mmc, return 0; } +#endif #if !CONFIG_IS_ENABLED(DM_MMC) int mmc_getcd(struct mmc *mmc) -- cgit v1.2.3 From d6400c3f8520bb9a203fe397039279c80f093c27 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 4 Jan 2018 15:23:32 +0100 Subject: mmc: add a Kconfig option to enable the support for MMC write operations 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 SPL Signed-off-by: Jean-Jacques Hiblot --- cmd/mvebu/bubt.c | 2 +- common/spl/Kconfig | 9 +++++++++ drivers/mmc/Kconfig | 7 +++++++ drivers/mmc/Makefile | 4 +--- drivers/mmc/mmc-uclass.c | 2 +- drivers/mmc/mmc_private.h | 4 ++-- 6 files changed, 21 insertions(+), 7 deletions(-) (limited to 'cmd') diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index a1997ac0d3..23fb8cd807 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 9d35f41233..d686b1ecbd 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,14 @@ 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 + default n + 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 d196eed540..ab0627a8af 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 9af375b044..64b6f21c61 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 793196bfec..26c6ab7ad1 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 +#if 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 1290eed590..a9be4b0102 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. */ -- cgit v1.2.3 From e6fa5a546154a42c4f6662cd8890c238207ce21a Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 4 Jan 2018 15:23:34 +0100 Subject: mmc: compile out erase and write mmc commands if write operations are not enabled 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 --- cmd/mmc.c | 8 ++++++++ drivers/mmc/mmc.c | 16 ++++++++++++++-- include/mmc.h | 2 ++ 3 files changed, 24 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/mmc.c b/cmd/mmc.c index 9a95293753..65601d82c3 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 fd9498708c..3930aad13b 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -2066,9 +2066,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 @@ -2082,7 +2084,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; @@ -2091,7 +2095,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]; @@ -2222,11 +2226,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 @@ -2248,8 +2254,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; @@ -2273,7 +2281,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); @@ -2304,7 +2314,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 f50c714428..3abeb581ae 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 */ -- cgit v1.2.3 From b7a6e2c9c396c35596f467f5187da937306ddeb8 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 4 Jan 2018 15:23:36 +0100 Subject: mmc: remove hc_wp_grp_size from struct mmc if not needed 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 --- cmd/mmc.c | 2 ++ drivers/mmc/mmc.c | 2 ++ include/mmc.h | 2 ++ 3 files changed, 6 insertions(+) (limited to 'cmd') diff --git a/cmd/mmc.c b/cmd/mmc.c index 65601d82c3..58fdc36f08 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 c1ba57f86d..53c819187e 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -2098,9 +2098,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 cd068b9429..a46eaed746 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 -- cgit v1.2.3