fsl_esdhc: Always stop clock before changing frequency
PATCH 1/3 fsl_esdhc: Always stop clock before changing frequency
We need to stop the clocks on 83xx/85xx as well as imx. No need to make this code conditional to just imx.
--- drivers/mmc/fsl_esdhc.c | 11 +++-------- include/fsl_esdhc.h | 3 +-- 2 files changed, 4 insertions(+), 10 deletions(-)
drivers/mmc/fsl_esdhc.c +3 -8
@@ -1,5 +1,5 @@/* -* Copyright 2007, Freescale Semiconductor, Inc +* Copyright 2007,2010 Freescale Semiconductor, Inc * Andy Fleming * * Based vaguely on the pxa mmc code:
@@ -265,18 +265,13 @@ void set_sysctl(struct mmc *mmc, uint clock) clk = (pre_div <<8 ) | (div <<4 ); -/* On imx the clock must be stopped before changing frequency */ -if (cfg->clk_enable) -esdhc_clrbits32 (®s->sysctl,SYSCTL_CKEN ); +esdhc_clrbits32 (®s->sysctl,SYSCTL_CKEN );esdhc_clrsetbits32 (®s->sysctl,SYSCTL_CLOCK_MASK , clk);udelay (10000 ); - clk =SYSCTL_PEREN ; -/* On imx systems the clock must be explicitely enabled */ -if (cfg->clk_enable) - clk |=SYSCTL_CKEN ; + clk =SYSCTL_PEREN |SYSCTL_CKEN ;esdhc_setbits32 (®s->sysctl, clk); }
include/fsl_esdhc.h +1 -2
@@ -2,7 +2,7 @@ * FSL SD/MMC Defines *------------------------------------------------------------------- * - * Copyright 2007-2008, Freescale Semiconductor, Inc + * Copyright 2007-2008,2010 Freescale Semiconductor, Inc * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as
@@ -148,7 +148,6 @@struct fsl_esdhc_cfg {u32 esdhc_base;u32 no_snoop; -u32 clk_enable; };/* Select the correct accessors depending on endianess */
Signature · 1 line
1.6.0.6
PATCH 2/3 fsl_esdhc: Add function to reset the eSDHC controller
From: Jerry Huang <[email protected]>
To support multiple block read command we must set abort or use auto CMD12. If we booted from eSDHC controller neither of these are used and thus we need to reset the controller to allow multiple block read to function.
--- drivers/mmc/fsl_esdhc.c | 17 +++++++++++++++++ include/fsl_esdhc.h | 1 + 2 files changed, 18 insertions(+), 0 deletions(-)
drivers/mmc/fsl_esdhc.c +17 -0
@@ -344,6 +344,20 @@ static int esdhc_init(struct mmc *mmc)return ret; } +static void esdhc_reset (struct fsl_esdhc *regs) +{ +unsigned long timeout =100 ;/* wait max 100 ms */ + +/* reset the controller */ +esdhc_write32 (®s->sysctl,SYSCTL_RSTA ); + +/* hardware clears the bit when it is done */ +while ((esdhc_read32 (®s->sysctl) &SYSCTL_RSTA ) && --timeout) +udelay (1000 ); +if (!timeout) +printf ("MMC/SD: Reset never completed.\n" ); +} +int fsl_esdhc_initialize (bd_t *bis,struct fsl_esdhc_cfg *cfg) {struct fsl_esdhc *regs;
@@ -358,6 +372,9 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)sprintf (mmc->name,"FSL_ESDHC" ); regs = (struct fsl_esdhc *)cfg->esdhc_base; +/* First reset the eSDHC controller */ +esdhc_reset (regs); + mmc->priv = cfg; mmc->send_cmd = esdhc_send_cmd; mmc->set_ios = esdhc_set_ios;
include/fsl_esdhc.h +1 -0
@@ -39,6 +39,7 @@#define SYSCTL_PEREN 0x00000004#define SYSCTL_HCKEN 0x00000002#define SYSCTL_IPGEN 0x00000001 +#define SYSCTL_RSTA 0x01000000#define IRQSTAT 0x0002e030#define IRQSTAT_DMAE (0x10000000)
Signature · 1 line
1.6.0.6
PATCH 3/3 fsl_esdhc: Only modify WML[WR] field
From: Roy Zang <[email protected]>
Maintain the value of the reset of wml register rather than hard coding it
--- drivers/mmc/fsl_esdhc.c | 7 ++++--- include/fsl_esdhc.h | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/mmc/fsl_esdhc.c +4 -3
@@ -110,8 +110,7 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)if (wml_value >0x10 ) wml_value =0x10 ; - wml_value =0x100000 | wml_value; - + wml_value |=in_be32 (®s->wml) & ~WML_RD_WML_MASK ;esdhc_write32 (®s->dsaddr, (u32 )data->dest); }else {if (wml_value >0x80 )
@@ -120,7 +119,9 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)printf ("\nThe SD card is locked. Can not write to a locked card.\n\n" );return TIMEOUT ; } - wml_value = wml_value <<16 |0x10 ; + +esdhc_clrsetbits32 (®s->wml,WML_WR_WML_MASK , wml_value <<16 ); +esdhc_write32 (®s->dsaddr, (u32 )data->src); }
include/fsl_esdhc.h +2 -0
@@ -133,6 +133,8 @@#define WML 0x2e044#define WML_WRITE 0x00010000 +#define WML_RD_WML_MASK 0xff +#define WML_WR_WML_MASK 0xff0000#define BLKATTR 0x2e004#define BLKATTR_CNT (x) ((x & 0xffff) << 16)
Signature · 1 line
1.6.0.6
PATCH 3/3 fsl_esdhc: Only modify WML[WR] field
Quoted 15 lines · Kumar Gala
From: Roy Zang <[email protected]>
Maintain the value of the reset of wml register rather than hard coding it
Signed-off-by Roy Zang <[email protected]>---
drivers/mmc/fsl_esdhc.c | 7 ++++--- include/fsl_esdhc.h | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-)drivers/mmc/fsl_esdhc.c +0
-0
drivers/mmc/fsl_esdhc.c static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data) · line 113
Quoted 6 lines
drivers/mmc/fsl_esdhc.c +1
-2@@ -110,8 +110,7 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)if (wml_value >0x10 ) wml_value =0x10 ; - wml_value =0x100000 | wml_value; - + wml_value |=in_be32 (®s->wml) & ~WML_RD_WML_MASK ;
oops, should be esdhc_read32() instead of in_be32().
Quoted 34 lines
drivers/mmc/fsl_esdhc.c +3
-1esdhc_write32 (®s->dsaddr, (u32 )data->dest); }else {if (wml_value >0x80 )@@ -120,7 +119,9 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)printf ("\nThe SD card is locked. Can not write to a locked card.\n\n" );return TIMEOUT ; } - wml_value = wml_value <<16 |0x10 ; + +esdhc_clrsetbits32 (®s->wml,WML_WR_WML_MASK , wml_value <<16 ); +esdhc_write32 (®s->dsaddr, (u32 )data->src); }include/fsl_esdhc.h +2
-0@@ -133,6 +133,8 @@#define WML 0x2e044#define WML_WRITE 0x00010000 +#define WML_RD_WML_MASK 0xff +#define WML_WR_WML_MASK 0xff0000#define BLKATTR 0x2e004#define BLKATTR_CNT (x) ((x & 0xffff) << 16)Signature · 6 lines
1.6.0.6 _______________________________________________ U-Boot mailing list U-Boot at lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
PATCH 2/3 fsl_esdhc: Add function to reset the eSDHC controller
In reply to Kumar GalaQuoted 9 lines · Kumar Gala
From: Jerry Huang <[email protected]>
To support multiple block read command we must set abort or use auto CMD12. If we booted from eSDHC controller neither of these are used and thus we need to reset the controller to allow multiple block read to function.
Signed-off-by Jerry Huang <[email protected]>Signed-off-by Roy Zang <[email protected]>
Tested successfully on mx51evk.
Regards,
Stefano
Signature · 5 lines
===================================================================== 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 =====================================================================
Kumar Gala
AppliedPATCH 2/3 fsl_esdhc: Add function to reset the eSDHC controller
Quoted 8 lines · Stefano Babic
Quoted 7 lines · Kumar Gala
From: Jerry Huang <[email protected]>
To support multiple block read command we must set abort or use auto CMD12. If we booted from eSDHC controller neither of these are used and thus we need to reset the controller to allow multiple block read to function.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Jerry Huang <[email protected]>Signed-off-by Roy Zang <[email protected]>Tested successfully on mx51evk.
Acked-by Stefano Babic <[email protected]>
applied to 85xx-next.
- k
PATCH 1/3 fsl_esdhc: Always stop clock before changing frequency
In reply to Kumar GalaQuoted 9 lines · Kumar Gala
We need to stop the clocks on 83xx/85xx as well as imx. No need to make this code conditional to just imx.
Signed-off-by Kumar Gala <[email protected]>--- drivers/mmc/fsl_esdhc.c | 11 +++-------- include/fsl_esdhc.h | 3 +-- 2 files changed, 4 insertions(+), 10 deletions(-)
Agree, but please remove clk_enable from the mx51evk.c, too.
Tested successfully on mx51evk.
Regards,
Stefano
Signature · 9 lines
===================================================================== 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 ===================================================================== -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: mx51evk_warnings Url: http://lists.denx.de/pipermail/u-boot/attachments/20100320/4f93d8bf/attachment.txt
Kumar Gala
AppliedPATCH 1/3 fsl_esdhc: Always stop clock before changing frequency
Quoted 11 lines · Stefano Babic
Quoted 9 lines · Kumar Gala
We need to stop the clocks on 83xx/85xx as well as imx. No need to make this code conditional to just imx.
Signed-off-by Kumar Gala <[email protected]>---
drivers/mmc/fsl_esdhc.c| 11 +++--------include/fsl_esdhc.h| 3 +--2 files changed, 4 insertions(+), 10 deletions(-)
Quoted 5 lines
Agree, but please remove
clk_enablefrom themx51evk.c, too.Tested successfully on mx51evk.
Acked-by Stefano Babic <[email protected]>
applied to 85xx-next.
- k