From: Jaehoon Chung <jh80.chung@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] mmc: add bkops-enable command
Date: Wed, 16 Nov 2016 21:05:56 +0900 [thread overview]
Message-ID: <582C4BA4.6050800@gmail.com> (raw)
In-Reply-To: <1479290351-22162-1-git-send-email-tomas.melin@vaisala.com>
Hi,
On 11/16/2016 06:59 PM, tomas.melin at vaisala.com wrote:
> Add new command for enabling the background operations
> handshake functionality (BKOPS_EN, EXT_CSD byte [163])
> on eMMC devices.
>
> This is an optional feature of eMMCs, the setting is write-once.
Why needs to set bkops on bootloader? Is there special reason?
And Linux kernel has already discussed about this.
I don't want to provide this command on u-boot side.
Don't handle Onetime programmable register on u-boot. So NACK.
Best Regards,
Jaehoon Chung
>
> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
> ---
> cmd/mmc.c | 26 ++++++++++++++++++++++++++
> drivers/mmc/mmc.c | 30 ++++++++++++++++++++++++++++++
> include/mmc.h | 4 ++++
> 3 files changed, 60 insertions(+)
>
> diff --git a/cmd/mmc.c b/cmd/mmc.c
> index b2761e9..3ae9682 100644
> --- a/cmd/mmc.c
> +++ b/cmd/mmc.c
> @@ -729,6 +729,29 @@ static int do_mmc_setdsr(cmd_tbl_t *cmdtp, int flag,
> return ret;
> }
>
> +static int do_mmc_bkops_enable(cmd_tbl_t *cmdtp, int flag,
> + int argc, char * const argv[])
> +{
> + int dev;
> + struct mmc *mmc;
> +
> + if (argc != 2)
> + return CMD_RET_USAGE;
> +
> + dev = simple_strtoul(argv[1], NULL, 10);
> +
> + mmc = init_mmc_device(dev, false);
> + if (!mmc)
> + return CMD_RET_FAILURE;
> +
> + if (IS_SD(mmc)) {
> + puts("BKOPS_EN only exists on eMMC\n");
> + return CMD_RET_FAILURE;
> + }
> +
> + return mmc_set_bkops_enable(mmc);
> +}
> +
> 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, "", ""),
> @@ -749,6 +772,7 @@ static cmd_tbl_t cmd_mmc[] = {
> U_BOOT_CMD_MKENT(rpmb, CONFIG_SYS_MAXARGS, 1, do_mmcrpmb, "", ""),
> #endif
> U_BOOT_CMD_MKENT(setdsr, 2, 0, do_mmc_setdsr, "", ""),
> + U_BOOT_CMD_MKENT(bkops-enable, 2, 0, do_mmc_bkops_enable, "", ""),
> };
>
> static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> @@ -813,6 +837,8 @@ U_BOOT_CMD(
> "mmc rpmb counter - read the value of the write counter\n"
> #endif
> "mmc setdsr <value> - set DSR register value\n"
> + "mmc bkops-enable <dev> - enable background operations handshake on device\n"
> + " WARNING: This is a write-once setting.\n"
> );
>
> /* Old command kept for compatibility. Same as 'mmc info' */
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 0cec02c..d6f40cc 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1810,3 +1810,33 @@ int mmc_initialize(bd_t *bis)
> mmc_do_preinit();
> return 0;
> }
> +
> +int mmc_set_bkops_enable(struct mmc *mmc)
> +{
> + int err;
> + ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN);
> +
> + err = mmc_send_ext_csd(mmc, ext_csd);
> + if (err) {
> + puts("Could not get ext_csd register values\n");
> + return err;
> + }
> +
> + if (!(ext_csd[EXT_CSD_BKOPS_SUPPORT] & 0x1)) {
> + puts("Background operations not supported on device\n");
> + return -EMEDIUMTYPE;
> + }
> +
> + if (ext_csd[EXT_CSD_BKOPS_EN] & 0x1) {
> + puts("Background operations already enabled\n");
> + return 0;
> + }
> +
> + err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BKOPS_EN, 1);
> + if (err) {
> + puts("Failed to enable background operations\n");
> + return err;
> + }
> +
> + return 0;
> +}
> diff --git a/include/mmc.h b/include/mmc.h
> index 5ef37d3..0772d53 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -175,6 +175,7 @@
> #define EXT_CSD_MAX_ENH_SIZE_MULT 157 /* R */
> #define EXT_CSD_PARTITIONING_SUPPORT 160 /* RO */
> #define EXT_CSD_RST_N_FUNCTION 162 /* R/W */
> +#define EXT_CSD_BKOPS_EN 163 /* R/W */
> #define EXT_CSD_WR_REL_PARAM 166 /* R */
> #define EXT_CSD_WR_REL_SET 167 /* R/W */
> #define EXT_CSD_RPMB_MULT 168 /* RO */
> @@ -189,6 +190,7 @@
> #define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */
> #define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */
> #define EXT_CSD_BOOT_MULT 226 /* RO */
> +#define EXT_CSD_BKOPS_SUPPORT 502 /* RO */
>
> /*
> * EXT_CSD field definitions
> @@ -541,6 +543,8 @@ int mmc_rpmb_read(struct mmc *mmc, void *addr, unsigned short blk,
> unsigned short cnt, unsigned char *key);
> int mmc_rpmb_write(struct mmc *mmc, void *addr, unsigned short blk,
> unsigned short cnt, unsigned char *key);
> +int mmc_set_bkops_enable(struct mmc *mmc);
> +
> /**
> * Start device initialization and return immediately; it does not block on
> * polling OCR (operation condition register) status. Then you should call
>
>
next prev parent reply other threads:[~2016-11-16 12:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-16 9:59 [U-Boot] [PATCH] mmc: add bkops-enable command Tomas Melin
2016-11-16 12:05 ` Jaehoon Chung [this message]
2016-11-16 13:12 ` [U-Boot] " Tomas Melin
2016-11-16 13:39 ` Jaehoon Chung
2016-11-17 11:05 ` Tomas Melin
2016-11-18 5:07 ` Jaehoon Chung
2016-11-21 7:52 ` Tomas Melin
2016-11-23 9:53 ` Jaehoon Chung
2016-11-23 12:50 ` Tomas Melin
2016-11-24 2:03 ` Jaehoon Chung
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=582C4BA4.6050800@gmail.com \
--to=jh80.chung@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.