u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Zhang Haijun <b42677@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/7 V5] mmc: Get secure erase information from card
Date: Fri, 10 Jan 2014 11:49:26 +0800	[thread overview]
Message-ID: <52CF6DC6.4060102@freescale.com> (raw)
In-Reply-To: <39F67368-4E0F-4F01-88CC-9E7499870257@antoniou-consulting.com>

Ok, Thanks.

Regards,
Haijun.


? 2014/1/9 19:09, Pantelis Antoniou ??:
> Hi Haijun,
>
> Since this is part of the core mmc functionality, I'll
> need to run some test on some board that are affected.
>
> Pending verification and testing from now on.
>
> Regards
>
> -- Pantelis
>
> On Dec 30, 2013, at 10:20 AM, Haijun Zhang wrote:
>
>> Read command class from csd register and secure erase
>> support bit from ext csd register. Also calculate the erase
>> timeout and secure erase timeout.
>>
>> If read ext csd error, error status should be returned instead of
>> giving some incorrect information.
>>
>> Error log:
>> =>
>> => mmcinfo
>> Device: FSL_SDHC
>> Manufacturer ID: 0
>> OEM: 0
>> Name: Tran Speed: 0
>> Rd Block Len: 0
>> MMC version 0.0
>> High Capacity: No
>> Capacity: 0 Bytes
>> Bus Width: 1-bit
>> =>
>>
>> Signed-off-by: Haijun Zhang <haijun.zhang@freescale.com>
>> ---
>> changes for V5:
>> 	- Exclude the judgement of EXT_CSD_REV in case of read EXT_CSD err
>>
>> drivers/mmc/mmc.c | 54 +++++++++++++++++++++++++++++++++++++++---------------
>> 1 file changed, 39 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>> index e1461a9..da06990 100644
>> --- a/drivers/mmc/mmc.c
>> +++ b/drivers/mmc/mmc.c
>> @@ -871,6 +871,8 @@ static int mmc_startup(struct mmc *mmc)
>> 		}
>> 	}
>>
>> +	mmc->cmdclass = (cmd.response[1] >> 20) & 0xfff;
>> +
>> 	/* divide frequency by 10, since the mults are 10x bigger */
>> 	freq = fbase[(cmd.response[0] & 0x7)];
>> 	mult = multipliers[((cmd.response[0] >> 3) & 0xf)];
>> @@ -925,8 +927,10 @@ static int mmc_startup(struct mmc *mmc)
>> 	mmc->part_config = MMCPART_NOAVAILABLE;
>> 	if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {
>> 		/* check  ext_csd version and capacity */
>> -		err = mmc_send_ext_csd(mmc, ext_csd);
>> -		if (!err && (ext_csd[EXT_CSD_REV] >= 2)) {
>> +		if (mmc_send_ext_csd(mmc, ext_csd))
>> +			return COMM_ERR;
>> +
>> +		if (ext_csd[EXT_CSD_REV] >= 2) {
>> 			/*
>> 			 * According to the JEDEC Standard, the value of
>> 			 * ext_csd's capacity is valid if the value is more
>> @@ -960,6 +964,39 @@ static int mmc_startup(struct mmc *mmc)
>> 		}
>>
>> 		/*
>> +		 * The granularity of the erasable units is the Erase Group:The
>> +		 * smallest number of consecutive write blocks which can be
>> +		 * addressed for erase. The size of the Erase Group is card
>> +		 * specific and stored in the CSD when ERASE_GROUP_DEF is
>> +		 * disabled, and in the EXT_CSD when ERASE_GROUP_DEF is
>> +		 * enabled.
>> +		 */
>> +		if (ext_csd[EXT_CSD_ERASE_GROUP_DEF]) {
>> +			mmc->erase_grp_size =
>> +				ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] * 1024;
>> +
>> +			mmc->erase_timeout_mult = 300 *
>> +				ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT];
>> +		} else {
>> +			/* Calculate the group size from the csd value. */
>> +			int erase_gsz, erase_gmul;
>> +			erase_gsz = (mmc->csd[2] & 0x00007c00) >> 10;
>> +			erase_gmul = (mmc->csd[2] & 0x000003e0) >> 5;
>> +			mmc->erase_grp_size = (erase_gsz + 1)
>> +				* (erase_gmul + 1);
>> +		}
>> +
>> +		if (ext_csd[EXT_CSD_REV] >= 4) {
>> +			mmc->sec_feature_support =
>> +				ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT];
>> +			mmc->sec_erase_mult =
>> +				ext_csd[EXT_CSD_SEC_ERASE_MULT];
>> +			mmc->sec_erase_timeout = 300 *
>> +				ext_csd[EXT_CSD_SEC_ERASE_MULT] *
>> +				ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT];
>> +		}
>> +
>> +		/*
>> 		 * Host needs to enable ERASE_GRP_DEF bit if device is
>> 		 * partitioned. This bit will be lost every time after a reset
>> 		 * or power off. This will affect erase size.
>> @@ -971,20 +1008,7 @@ static int mmc_startup(struct mmc *mmc)
>>
>> 			if (err)
>> 				return err;
>> -
>> -			/* Read out group size from ext_csd */
>> -			mmc->erase_grp_size =
>> -				ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] *
>> -					MMC_MAX_BLOCK_LEN * 1024;
>> -		} else {
>> -			/* Calculate the group size from the csd value. */
>> -			int erase_gsz, erase_gmul;
>> -			erase_gsz = (mmc->csd[2] & 0x00007c00) >> 10;
>> -			erase_gmul = (mmc->csd[2] & 0x000003e0) >> 5;
>> -			mmc->erase_grp_size = (erase_gsz + 1)
>> -				* (erase_gmul + 1);
>> 		}
>> -
>> 		/* store the partition info of emmc */
>> 		if ((ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & PART_SUPPORT) ||
>> 		    ext_csd[EXT_CSD_BOOT_MULT])
>> -- 
>> 1.8.4.1
>>
>>
>
>

  reply	other threads:[~2014-01-10  3:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-30  8:20 [U-Boot] [PATCH 1/7 V5] mmc: Add some usefull macro definition Haijun Zhang
2013-12-30  8:20 ` [U-Boot] [PATCH 2/7 V5] mmc: Get secure erase information from card Haijun Zhang
2014-01-09 11:09   ` Pantelis Antoniou
2014-01-10  3:49     ` Zhang Haijun [this message]
2013-12-30  8:20 ` [U-Boot] [PATCH 3/7 V5] mmc: Enhance erase handling procedure Haijun Zhang
2013-12-30  8:20 ` [U-Boot] [PATCH 4/7 V5] mmc: Update the handling of returned erase block Haijun Zhang
2013-12-30  8:20 ` [U-Boot] [PATCH 5/7 V5] mmc: Enhance mmcinfo command Haijun Zhang
2013-12-30  8:20 ` [U-Boot] [PATCH 6/7 V5] Powerpc/esdhc: Add esdhc host version define Haijun Zhang
2013-12-30  8:20 ` [U-Boot] [PATCH 7/7 V5] powerpc/esdhc: Update esdhc command execution process Haijun Zhang
2014-01-09 11:08   ` Pantelis Antoniou
2014-01-10  3:54     ` Zhang Haijun
2014-01-06  3:09 ` [U-Boot] [PATCH 1/7 V5] mmc: Add some usefull macro definition Zhang Haijun
2014-02-24  1:18 ` Zhang Haijun

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=52CF6DC6.4060102@freescale.com \
    --to=b42677@freescale.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).