public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Peng Fan <van.freenix@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V3 1/2] mmc: sd: extracting erase timeout information from sd status
Date: Thu, 1 Sep 2016 10:20:16 +0800	[thread overview]
Message-ID: <20160901022014.GA25279@linux-7smt.suse> (raw)
In-Reply-To: <1f1ae47d-b3cd-8169-3ddd-c8e82bf37889@samsung.com>

Hi Jaehoon,
On Wed, Aug 31, 2016 at 09:50:24PM +0900, Jaehoon Chung wrote:
>Hi Peng,
>
>On 08/30/2016 06:34 PM, Jaehoon Chung wrote:
>> Hi Peng,
>>
>> On 08/23/2016 05:12 PM, Peng Fan wrote:
>>> Add function to read SD_STATUS information.
>>> According to the information, get erase_timeout/erase_size/erase_offset.
>>> Add a structure sd_ssr to include the erase related information.
>>>
>>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>>> Cc: Jaehoon Chung <jh80.chung@samsung.com>
>>> Cc: Simon Glass <sjg@chromium.org>
>>> Cc: Bin Meng <bmeng.cn@gmail.com>
>>> Cc: Stefan Wahren <stefan.wahren@i2se.com>
>>> Cc: Clemens Gruber <clemens.gruber@pqgruber.com>
>>> Cc: Kever Yang <kever.yang@rock-chips.com>
>>> Cc: Eric Nelson <eric@nelint.com>
>>> Cc: Stephen Warren <swarren@nvidia.com>
>>
>> Applied on u-boot-mmc.
>> Thanks!
>
>Sorry..I have dropped your patchset from u-boot-mmc.
>
>Stephen was pointing out about the below things.
>
>Building current source for 3 boards (3 threads, 4 jobs per thread)
>   sandbox:  +   sandbox_noblk
>+drivers/mmc/mmc.c:25:6: error: ?SZ_16K? undeclared here (not in a function)
>+  0,  SZ_16K / 512,  SZ_32K / 512,
>+      ^
>+drivers/mmc/mmc.c:25:21: error: ?SZ_32K? undeclared here (not in a function)


This is because sanbox.h does not include linux/sizes.h.
Since mmc also use SZ_xx now, I think better include linux/sizes.h in mmc.h

Will use V4 to fix this. 

Thanks,
Peng.

>+                     ^
>
>When i have checked, it's not error for only sandbox_noblk.
>
>       arm:  +   dserve_dsrv9703c
>+../drivers/mmc/mmc.c:25:6: error: ?SZ_16K? undeclared here (not in a function)
>+  0,  SZ_16K / 512,  SZ_32K / 512,
>+      ^
>+../drivers/mmc/mmc.c:25:21: error: ?SZ_32K? undeclared here (not in a function)
>+                     ^
>+../drivers/mmc/mmc.c:26:2: error: ?SZ_64K? undeclared here (not in a function)
>+  SZ_64K / 512, SZ_128K / 512,  SZ_256K / 512,
>+  ^
>+../drivers/mmc/mmc.c:26:16: error: ?SZ_128K? undeclared here (not in a function)
>+                ^
>+../drivers/mmc/mmc.c:26:32: error: ?SZ_256K? undeclared here (not in a function)
>+                                ^
>+../drivers/mmc/mmc.c:27:2: error: ?SZ_512K? undeclared here (not in a function)
>+  SZ_512K / 512, SZ_1M / 512,  SZ_2M / 512,
>+../drivers/mmc/mmc.c:27:17: error: ?SZ_1M? undeclared here (not in a function)
>+                 ^
>+../drivers/mmc/mmc.c:27:31: error: ?SZ_2M? undeclared here (not in a function)
>+                               ^
>+../drivers/mmc/mmc.c:28:2: error: ?SZ_4M? undeclared here (not in a function)
>+  SZ_4M / 512, SZ_8M / 512,  (SZ_8M + SZ_4M) / 512,
>+../drivers/mmc/mmc.c:28:15: error: ?SZ_8M? undeclared here (not in a function)
>+               ^
>+../drivers/mmc/mmc.c:29:2: error: ?SZ_16M? undeclared here (not in a function)
>+  SZ_16M / 512, (SZ_16M + SZ_8M) / 512, SZ_32M / 512, SZ_64M / 512,
>+../drivers/mmc/mmc.c:29:40: error: ?SZ_32M? undeclared here (not in a function)
>+                                        ^
>+../drivers/mmc/mmc.c:29:54: error: ?SZ_64M? undeclared here (not in a function)
>
>02: mmc: sd: extracting erase timeout information from sd status
>       arm:  +   firefly-rk3288
>+../drivers/mmc/mmc.c:25:6: error: ?SZ_16K? undeclared here (not in a function)
>+  0,  SZ_16K / 512,  SZ_32K / 512,
>+      ^
>+../drivers/mmc/mmc.c:25:21: error: ?SZ_32K? undeclared here (not in a function)
>+                     ^
>+../drivers/mmc/mmc.c:26:2: error: ?SZ_64K? undeclared here (not in a function)
>+  SZ_64K / 512, SZ_128K / 512,  SZ_256K / 512,
>+  ^
>+../drivers/mmc/mmc.c:26:16: error: ?SZ_128K? undeclared here (not in a function)
>+                ^
>+../drivers/mmc/mmc.c:26:32: error: ?SZ_256K? undeclared here (not in a function)
>+                                ^
>+../drivers/mmc/mmc.c:27:2: error: ?SZ_512K? undeclared here (not in a function)
>+  SZ_512K / 512, SZ_1M / 512,  SZ_2M / 512,
>+../drivers/mmc/mmc.c:27:17: error: ?SZ_1M? undeclared here (not in a function)
>+                 ^
>+../drivers/mmc/mmc.c:27:31: error: ?SZ_2M? undeclared here (not in a function)
>+                               ^
>+../drivers/mmc/mmc.c:28:2: error: ?SZ_4M? undeclared here (not in a function)
>+  SZ_4M / 512, SZ_8M / 512,  (SZ_8M + SZ_4M) / 512,
>+../drivers/mmc/mmc.c:28:15: error: ?SZ_8M? undeclared here (not in a function)
>+               ^
>+../drivers/mmc/mmc.c:29:2: error: ?SZ_16M? undeclared here (not in a function)
>+  SZ_16M / 512, (SZ_16M + SZ_8M) / 512, SZ_32M / 512, SZ_64M / 512,
>+../drivers/mmc/mmc.c:29:40: error: ?SZ_32M? undeclared here (not in a function)
>+                                        ^
>+../drivers/mmc/mmc.c:29:54: error: ?SZ_64M? undeclared here (not in a function)
>+                                                      ^
>
>Could you check this?
>
>Best Regards,
>Jaehoon Chung
>
>>
>> Best Regards,
>> Jaehoon Chung
>>
>>> ---
>>>
>>> I dropped patch [2,3,4]/5 in V2, which is not a must in this optimization case.
>>>
>>> V3:
>>>  No change.
>>>
>>> V2:
>>>  Address Jaehoon's comments for V1
>>>
>>>  drivers/mmc/mmc.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>  include/mmc.h     |  8 +++++++
>>>  2 files changed, 76 insertions(+)
>>>
>>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>>> index 43ea0bb..0312da9 100644
>>> --- a/drivers/mmc/mmc.c
>>> +++ b/drivers/mmc/mmc.c
>>> @@ -21,6 +21,14 @@
>>>  #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,
>>> +};
>>> +
>>>  #ifndef CONFIG_DM_MMC_OPS
>>>  __weak int board_mmc_getwp(struct mmc *mmc)
>>>  {
>>> @@ -945,6 +953,62 @@ retry_scr:
>>>  	return 0;
>>>  }
>>>
>>> +static int sd_read_ssr(struct mmc *mmc)
>>> +{
>>> +	int err, i;
>>> +	struct mmc_cmd cmd;
>>> +	ALLOC_CACHE_ALIGN_BUFFER(uint, ssr, 16);
>>> +	struct mmc_data data;
>>> +	int timeout = 3;
>>> +	unsigned int au, eo, et, es;
>>> +
>>> +	cmd.cmdidx = MMC_CMD_APP_CMD;
>>> +	cmd.resp_type = MMC_RSP_R1;
>>> +	cmd.cmdarg = mmc->rca << 16;
>>> +
>>> +	err = mmc_send_cmd(mmc, &cmd, NULL);
>>> +	if (err)
>>> +		return err;
>>> +
>>> +	cmd.cmdidx = SD_CMD_APP_SD_STATUS;
>>> +	cmd.resp_type = MMC_RSP_R1;
>>> +	cmd.cmdarg = 0;
>>> +
>>> +retry_ssr:
>>> +	data.dest = (char *)ssr;
>>> +	data.blocksize = 64;
>>> +	data.blocks = 1;
>>> +	data.flags = MMC_DATA_READ;
>>> +
>>> +	err = mmc_send_cmd(mmc, &cmd, &data);
>>> +	if (err) {
>>> +		if (timeout--)
>>> +			goto retry_ssr;
>>> +
>>> +		return err;
>>> +	}
>>> +
>>> +	for (i = 0; i < 16; i++)
>>> +		ssr[i] = be32_to_cpu(ssr[i]);
>>> +
>>> +	au = (ssr[2] >> 12) & 0xF;
>>> +	if ((au <= 9) || (mmc->version == SD_VERSION_3)) {
>>> +		mmc->ssr.au = sd_au_size[au];
>>> +		es = (ssr[3] >> 24) & 0xFF;
>>> +		es |= (ssr[2] & 0xFF) << 8;
>>> +		et = (ssr[3] >> 18) & 0x3F;
>>> +		if (es && et) {
>>> +			eo = (ssr[3] >> 16) & 0x3;
>>> +			mmc->ssr.erase_timeout = (et * 1000) / es;
>>> +			mmc->ssr.erase_offset = eo * 1000;
>>> +		}
>>> +	} else {
>>> +		debug("Invalid Allocation Unit Size.\n");
>>> +	}
>>> +
>>> +	return 0;
>>> +}
>>> +
>>>  /* frequency bases */
>>>  /* divided by 10 to be nice to platforms without floating point */
>>>  static const int fbase[] = {
>>> @@ -1350,6 +1414,10 @@ static int mmc_startup(struct mmc *mmc)
>>>  			mmc_set_bus_width(mmc, 4);
>>>  		}
>>>
>>> +		err = sd_read_ssr(mmc);
>>> +		if (err)
>>> +			return err;
>>> +
>>>  		if (mmc->card_caps & MMC_MODE_HS)
>>>  			mmc->tran_speed = 50000000;
>>>  		else
>>> diff --git a/include/mmc.h b/include/mmc.h
>>> index aa6d5d1..af2595c 100644
>>> --- a/include/mmc.h
>>> +++ b/include/mmc.h
>>> @@ -102,6 +102,7 @@
>>>  #define SD_CMD_SWITCH_UHS18V		11
>>>
>>>  #define SD_CMD_APP_SET_BUS_WIDTH	6
>>> +#define SD_CMD_APP_SD_STATUS		13
>>>  #define SD_CMD_ERASE_WR_BLK_START	32
>>>  #define SD_CMD_ERASE_WR_BLK_END		33
>>>  #define SD_CMD_APP_SEND_OP_COND		41
>>> @@ -392,6 +393,12 @@ struct mmc_config {
>>>  	unsigned char part_type;
>>>  };
>>>
>>> +struct sd_ssr {
>>> +	unsigned int au;		/* In sectors */
>>> +	unsigned int erase_timeout;	/* In milliseconds */
>>> +	unsigned int erase_offset;	/* In milliseconds */
>>> +};
>>> +
>>>  /*
>>>   * With CONFIG_DM_MMC enabled, struct mmc can be accessed from the MMC device
>>>   * with mmc_get_mmc_dev().
>>> @@ -426,6 +433,7 @@ struct mmc {
>>>  	uint write_bl_len;
>>>  	uint erase_grp_size;	/* in 512-byte sectors */
>>>  	uint hc_wp_grp_size;	/* in 512-byte sectors */
>>> +	struct sd_ssr	ssr;	/* SD status register */
>>>  	u64 capacity;
>>>  	u64 capacity_user;
>>>  	u64 capacity_boot;
>>>
>>
>> _______________________________________________
>> U-Boot mailing list
>> U-Boot at lists.denx.de
>> http://lists.denx.de/mailman/listinfo/u-boot
>>
>>
>>
>

      reply	other threads:[~2016-09-01  2:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20160823081303epcas1p321f50f050922fa219a0a8c1c0ffd06e6@epcas1p3.samsung.com>
2016-08-23  8:12 ` [U-Boot] [PATCH V3 1/2] mmc: sd: extracting erase timeout information from sd status Peng Fan
2016-08-23  8:12   ` [U-Boot] [PATCH V3 2/2] mmc: sd: optimize erase Peng Fan
2016-08-30  9:34     ` Jaehoon Chung
2016-08-30  6:57   ` [U-Boot] [PATCH V3 1/2] mmc: sd: extracting erase timeout information from sd status Peng Fan
2016-08-30  9:34   ` Jaehoon Chung
2016-08-31 12:50     ` Jaehoon Chung
2016-09-01  2:20       ` Peng Fan [this message]

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=20160901022014.GA25279@linux-7smt.suse \
    --to=van.freenix@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox