* [U-Boot] [PATCH][v3] fsl_esdhc: Correcting esdhc timeout counter calculation
@ 2011-03-02 4:29 Priyanka Jain
0 siblings, 0 replies; 5+ messages in thread
From: Priyanka Jain @ 2011-03-02 4:29 UTC (permalink / raw)
To: u-boot
- Timeout counter value is set as DTOCV bits in SYSCTL register
For counter value set as timeout,
Timeout period = (2^(timeout + 13)) SD Clock cycles
- As per 4.6.2.2 section of SD Card specification v2.00, host should
cofigure timeout period value to minimum 0.25 sec.
- Number of SD Clock cycles for 0.25sec should be minimum
(SD Clock/sec * 0.25 sec) SD Clock cycles
= (mmc->tran_speed * 1/4) SD Clock cycles
- Calculating timeout based on
(2^(timeout + 13)) >= mmc->tran_speed * 1/4
Taking log2 both the sides and rounding up to next power of 2
=> timeout + 13 = log2(mmc->tran_speed/4) + 1
Signed-off-by: Priyanka Jain <Priyanka.Jain@freescale.com>
Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Mingkai Hu <Mingkai.Hu@freescale.com>
---
Changes for v3:
Including code changes of v1 as suggested by Stefano Babic
Changes for v2:
Added proper description as suggested by Wolfgang Denk
drivers/mmc/fsl_esdhc.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index a368fe6..359d939 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -207,7 +207,21 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
esdhc_write32(®s->blkattr, data->blocks << 16 | data->blocksize);
/* Calculate the timeout period for data transactions */
- timeout = fls(mmc->tran_speed/10) - 1;
+ /*
+ * 1)Timeout period = (2^(timeout+13)) SD Clock cycles
+ * 2)Timeout period should be minimum 0.250sec as per SD Card spec
+ * So, Number of SD Clock cycles for 0.25sec should be minimum
+ * (SD Clock/sec * 0.25 sec) SD Clock cycles
+ * = (mmc->tran_speed * 1/4) SD Clock cycles
+ * As 1) >= 2)
+ * => (2^(timeout+13)) >= mmc->tran_speed * 1/4
+ * Taking log2 both the sides
+ * => timeout + 13 >= log2(mmc->tran_speed/4)
+ * Rounding up to next power of 2
+ * => timeout + 13 = log2(mmc->tran_speed/4) + 1
+ * => timeout + 13 = fls(mmc->tran_speed/4)
+ */
+ timeout = fls(mmc->tran_speed/4);
timeout -= 13;
if (timeout > 14)
--
1.6.5.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH][v3] fsl_esdhc: Correcting esdhc timeout counter calculation
@ 2011-03-03 3:48 Priyanka Jain
2011-03-04 12:26 ` Kumar Gala
2011-03-07 9:41 ` Stefano Babic
0 siblings, 2 replies; 5+ messages in thread
From: Priyanka Jain @ 2011-03-03 3:48 UTC (permalink / raw)
To: u-boot
- Timeout counter value is set as DTOCV bits in SYSCTL register
For counter value set as timeout,
Timeout period = (2^(timeout + 13)) SD Clock cycles
- As per 4.6.2.2 section of SD Card specification v2.00, host should
cofigure timeout period value to minimum 0.25 sec.
- Number of SD Clock cycles for 0.25sec should be minimum
(SD Clock/sec * 0.25 sec) SD Clock cycles
= (mmc->tran_speed * 1/4) SD Clock cycles
- Calculating timeout based on
(2^(timeout + 13)) >= mmc->tran_speed * 1/4
Taking log2 both the sides and rounding up to next power of 2
=> timeout + 13 = log2(mmc->tran_speed/4) + 1
Signed-off-by: Priyanka Jain <Priyanka.Jain@freescale.com>
Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Mingkai Hu <Mingkai.Hu@freescale.com>
---
Changes for v3:
Including code changes of v1 as suggested by Stefano Babic
Changes for v2:
Added proper description as suggested by Wolfgang Denk
drivers/mmc/fsl_esdhc.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index a368fe6..359d939 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -207,7 +207,21 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
esdhc_write32(®s->blkattr, data->blocks << 16 | data->blocksize);
/* Calculate the timeout period for data transactions */
- timeout = fls(mmc->tran_speed/10) - 1;
+ /*
+ * 1)Timeout period = (2^(timeout+13)) SD Clock cycles
+ * 2)Timeout period should be minimum 0.250sec as per SD Card spec
+ * So, Number of SD Clock cycles for 0.25sec should be minimum
+ * (SD Clock/sec * 0.25 sec) SD Clock cycles
+ * = (mmc->tran_speed * 1/4) SD Clock cycles
+ * As 1) >= 2)
+ * => (2^(timeout+13)) >= mmc->tran_speed * 1/4
+ * Taking log2 both the sides
+ * => timeout + 13 >= log2(mmc->tran_speed/4)
+ * Rounding up to next power of 2
+ * => timeout + 13 = log2(mmc->tran_speed/4) + 1
+ * => timeout + 13 = fls(mmc->tran_speed/4)
+ */
+ timeout = fls(mmc->tran_speed/4);
timeout -= 13;
if (timeout > 14)
--
1.6.5.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH][v3] fsl_esdhc: Correcting esdhc timeout counter calculation
2011-03-03 3:48 [U-Boot] [PATCH][v3] fsl_esdhc: Correcting esdhc timeout counter calculation Priyanka Jain
@ 2011-03-04 12:26 ` Kumar Gala
2011-03-07 9:41 ` Stefano Babic
1 sibling, 0 replies; 5+ messages in thread
From: Kumar Gala @ 2011-03-04 12:26 UTC (permalink / raw)
To: u-boot
On Mar 2, 2011, at 9:48 PM, Priyanka Jain wrote:
> - Timeout counter value is set as DTOCV bits in SYSCTL register
> For counter value set as timeout,
> Timeout period = (2^(timeout + 13)) SD Clock cycles
>
> - As per 4.6.2.2 section of SD Card specification v2.00, host should
> cofigure timeout period value to minimum 0.25 sec.
>
> - Number of SD Clock cycles for 0.25sec should be minimum
> (SD Clock/sec * 0.25 sec) SD Clock cycles
> = (mmc->tran_speed * 1/4) SD Clock cycles
>
> - Calculating timeout based on
> (2^(timeout + 13)) >= mmc->tran_speed * 1/4
> Taking log2 both the sides and rounding up to next power of 2
> => timeout + 13 = log2(mmc->tran_speed/4) + 1
>
> Signed-off-by: Priyanka Jain <Priyanka.Jain@freescale.com>
> Signed-off-by: Andy Fleming <afleming@freescale.com>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> Acked-by: Mingkai Hu <Mingkai.Hu@freescale.com>
> ---
> Changes for v3:
> Including code changes of v1 as suggested by Stefano Babic
>
> Changes for v2:
> Added proper description as suggested by Wolfgang Denk
>
> drivers/mmc/fsl_esdhc.c | 16 +++++++++++++++-
> 1 files changed, 15 insertions(+), 1 deletions(-)
Stefano,
Got a chance to test on imx? Would like this fix in v2011.03
- k
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH][v3] fsl_esdhc: Correcting esdhc timeout counter calculation
2011-03-03 3:48 [U-Boot] [PATCH][v3] fsl_esdhc: Correcting esdhc timeout counter calculation Priyanka Jain
2011-03-04 12:26 ` Kumar Gala
@ 2011-03-07 9:41 ` Stefano Babic
2011-03-07 15:04 ` Kumar Gala
1 sibling, 1 reply; 5+ messages in thread
From: Stefano Babic @ 2011-03-07 9:41 UTC (permalink / raw)
To: u-boot
On 03/03/2011 04:48 AM, Priyanka Jain wrote:
> - Timeout counter value is set as DTOCV bits in SYSCTL register
> For counter value set as timeout,
> Timeout period = (2^(timeout + 13)) SD Clock cycles
>
> - As per 4.6.2.2 section of SD Card specification v2.00, host should
> cofigure timeout period value to minimum 0.25 sec.
>
> - Number of SD Clock cycles for 0.25sec should be minimum
> (SD Clock/sec * 0.25 sec) SD Clock cycles
> = (mmc->tran_speed * 1/4) SD Clock cycles
>
> - Calculating timeout based on
> (2^(timeout + 13)) >= mmc->tran_speed * 1/4
> Taking log2 both the sides and rounding up to next power of 2
> => timeout + 13 = log2(mmc->tran_speed/4) + 1
>
> Signed-off-by: Priyanka Jain <Priyanka.Jain@freescale.com>
> Signed-off-by: Andy Fleming <afleming@freescale.com>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> Acked-by: Mingkai Hu <Mingkai.Hu@freescale.com>
> ---
Tested on a i.MX51 board.
Tested-by: Stefano Babic <sbabic@denx.de>
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH][v3] fsl_esdhc: Correcting esdhc timeout counter calculation
2011-03-07 9:41 ` Stefano Babic
@ 2011-03-07 15:04 ` Kumar Gala
0 siblings, 0 replies; 5+ messages in thread
From: Kumar Gala @ 2011-03-07 15:04 UTC (permalink / raw)
To: u-boot
On Mar 7, 2011, at 3:41 AM, Stefano Babic wrote:
> On 03/03/2011 04:48 AM, Priyanka Jain wrote:
>> - Timeout counter value is set as DTOCV bits in SYSCTL register
>> For counter value set as timeout,
>> Timeout period = (2^(timeout + 13)) SD Clock cycles
>>
>> - As per 4.6.2.2 section of SD Card specification v2.00, host should
>> cofigure timeout period value to minimum 0.25 sec.
>>
>> - Number of SD Clock cycles for 0.25sec should be minimum
>> (SD Clock/sec * 0.25 sec) SD Clock cycles
>> = (mmc->tran_speed * 1/4) SD Clock cycles
>>
>> - Calculating timeout based on
>> (2^(timeout + 13)) >= mmc->tran_speed * 1/4
>> Taking log2 both the sides and rounding up to next power of 2
>> => timeout + 13 = log2(mmc->tran_speed/4) + 1
>>
>> Signed-off-by: Priyanka Jain <Priyanka.Jain@freescale.com>
>> Signed-off-by: Andy Fleming <afleming@freescale.com>
>> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>> Acked-by: Mingkai Hu <Mingkai.Hu@freescale.com>
>> ---
>
> Tested on a i.MX51 board.
>
> Tested-by: Stefano Babic <sbabic@denx.de>
>
> Best regards,
> Stefano Babic
thanks
applied.
- k
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-03-07 15:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-03 3:48 [U-Boot] [PATCH][v3] fsl_esdhc: Correcting esdhc timeout counter calculation Priyanka Jain
2011-03-04 12:26 ` Kumar Gala
2011-03-07 9:41 ` Stefano Babic
2011-03-07 15:04 ` Kumar Gala
-- strict thread matches above, loose matches on Subject: below --
2011-03-02 4:29 Priyanka Jain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox