sunxi: mmc: Fix clk-delay settings
Subsystems (2)
PATCH 1/1 sunxi: mmc: Fix clk-delay settings
In recent allwinner kernel sources the mmc clk-delay settings have been slightly tweaked, and for sun9i they are completely different then what we are using.
This commit brings us in sync with what allwinner does, fixing problems accessing sdcards on some A33 devices (and likely others).
For pre sun9i hardware this makes the following changes:
-At 400Khz change the sample delay from 7 to 0 (first introduced in A31 sdk) -At 50 Mhz change the sample delay from 5 to 4 (first introduced in A23 sdk)
--- drivers/mmc/sunxi_mmc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/mmc/sunxi_mmc.c +13 -3
@@ -120,17 +120,27 @@ static int mmc_set_mod_clk(struct sunxi_mmc_host *mmchost, unsigned int hz)/* determine delays */ if (hz <=400000 ) { oclk_dly =0 ; - sclk_dly =7 ; + sclk_dly =0 ; }else if (hz <=25000000 ) { oclk_dly =0 ; sclk_dly =5 ; +#ifdef CONFIG_MACH_SUN9I }else if (hz <=50000000 ) { - oclk_dly =3 ; - sclk_dly =5 ; + oclk_dly =5 ; + sclk_dly =4 ; }else {/* hz > 50000000 */ oclk_dly =2 ; sclk_dly =4 ; +#else + } else if (hz <= 50000000) { + oclk_dly =3 ; + sclk_dly =4 ; + } else { +/* hz > 50000000 */ + oclk_dly =1 ; + sclk_dly =4 ; +#endif } writel(CCM_MMC_CTRL_ENABLE | pll | CCM_MMC_CTRL_SCLK_DLY(sclk_dly) |
Signature · 1 line
2.5.0
PATCH 1/1 sunxi: mmc: Fix clk-delay settings
Quoted 9 lines · Hans de Goede
In recent allwinner kernel sources the mmc clk-delay settings have been slightly tweaked, and for sun9i they are completely different then what we are using.
This commit brings us in sync with what allwinner does, fixing problems accessing sdcards on some A33 devices (and likely others).
For pre sun9i hardware this makes the following changes:
-At 400Khz change the sample delay from 7 to 0 (first introduced in A31 sdk)
This one applied to sun9i as well as pre I think?
Quoted 1 line
-At 50 Mhz change the sample delay from 5 to 4 (first introduced in A23 sdk)
By my reading it also changes oclk from 2 to 1 on <sun9i @ >50MHz.
I don't really follow the a/w SDK stuff, is it the case that a given Ann SDK is tested and supported by Allwinner and used on real devices for processors Amm < Ann (chronologically, ?
IOW if a change was introduced in the A31 SDK do we then have confidence that it doesn't break A20 due to Allwinners (and their customer's) use of the A31 SDK on A20 or are we relying on our own + community testing?
Quoted 43 lines
Signed-off-by Hans de Goede <[email protected]>--- drivers/mmc/sunxi_mmc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)drivers/mmc/sunxi_mmc.c +13
-3@@ -120,17 +120,27 @@ static int mmc_set_mod_clk(struct sunxi_mmc_host *mmchost, unsigned int hz)/* determine delays */ if (hz <=400000 ) { oclk_dly =0 ; - sclk_dly =7 ; + sclk_dly =0 ; }else if (hz <=25000000 ) { oclk_dly =0 ; sclk_dly =5 ; +#ifdef CONFIG_MACH_SUN9I }else if (hz <=50000000 ) { - oclk_dly =3 ; - sclk_dly =5 ; + oclk_dly =5 ; + sclk_dly =4 ; }else {/* hz > 50000000 */ oclk_dly =2 ; sclk_dly =4 ; +#else + } else if (hz <= 50000000) { + oclk_dly =3 ; + sclk_dly =4 ; + } else { +/* hz > 50000000 */ + oclk_dly =1 ; + sclk_dly =4 ; +#endif }writel(CCM_MMC_CTRL_ENABLE | pll |
CCM_MMC_CTRL_SCLK_DLY(sclk_dly)|
PATCH 1/1 sunxi: mmc: Fix clk-delay settings
Hi,
Quoted 8 lines · Ian Campbell
Quoted 7 lines · Hans de Goede
In recent allwinner kernel sources the mmc clk-delay settings have been slightly tweaked, and for sun9i they are completely different then what we are using.
This commit brings us in sync with what allwinner does, fixing problems accessing sdcards on some A33 devices (and likely others).
Quoted 8 lines
Quoted 2 lines
For pre sun9i hardware this makes the following changes:
-At 400Khz change the sample delay from 7 to 0 (first introduced in A31 sdk)This one applied to sun9i as well as pre I think?
Quoted 1 line
-At 50 Mhz change the sample delay from 5 to 4 (first introduced in A23 sdk)
By my reading it also changes oclk from 2 to 1 on <sun9i @ >50MHz.
Right, I did not list that as we never do > 50MHz, later on in the code we've:
cfg->f_max = 52000000;
And that 52 is somewhat symbolically there, it is meant for 52MHz sdio where as mmc / sdcards run at 50MHz max.
Quoted 3 lines
I don't really follow the a/w SDK stuff, is it the case that a given Ann SDK is tested and supported by Allwinner and used on real devices for processors Amm < Ann (chronologically, ?
Yes and no, Allwinner used to have separate kernel sources for each die, so one for sun4i, sun5i, sun6i and sun7i.
Recently they have changed to one unified kernel tree though, so all of sun6i, sun8i and sun9i build from the same kernel tree. Note that sun7i is missing from the list.
Quoted 3 lines
IOW if a change was introduced in the A31 SDK do we then have confidence that it doesn't break A20 due to Allwinners (and their customer's) use of the A31 SDK on A20 or are we relying on our own + community testing?
It is safe to assume that the A23 changes do not break on the A31 since that is using the same kernel sources. The changes may cause issues on A20 though (A10 / A13 do not use the sample delay bits of the register AFAICT). So I've run several tests on A20 and things seem to work fine with the new settings there.
I believe that the mmc controller and the mmc clock bits really are the same over all of A20 / A23 / A31 / A33, and that these new tweaked values are better to use everywhere.
Regards,
Hans
PATCH 1/1 sunxi: mmc: Fix clk-delay settings
Quoted 18 lines · Hans de Goede
Hi,
Quoted 15 lines · Ian Campbell
Quoted 13 lines · Hans de Goede
In recent allwinner kernel sources the mmc clk-delay settings have been
slightly tweaked, and for sun9i they are completely different then what
we are using.This commit brings us in sync with what allwinner does, fixing problems
accessing sdcards on some A33 devices (and likely others).For pre sun9i hardware this makes the following changes:
-At 400Khz change the sample delay from 7 to 0 (first introduced in A31 sdk)
Quoted 8 lines
Quoted 6 lines
This one applied to sun9i as well as pre I think?
Quoted 2 lines
-At 50 Mhz change the sample delay from 5 to 4 (first introduced in A23 sdk)
By my reading it also changes oclk from 2 to 1 on <sun9i @ >50MHz.
Right, I did not list that as we never do > 50MHz,
But the being changed here does handle that (the else hz > 50000000 case) and that is changing even if we somehow coincidentally arrange that this code is never used today I think it is worth mentioning so that if it does become used we have the history of when/why it was changed.
Quoted 7 lines
later on in the code
we've:cfg->f_max = 52000000;And that 52 is somewhat symbolically there, it is meant for 52MHz sdio where as mmc / sdcards run at 50MHz max.
Are these timings used for sdio as well then? That seems worth noting.
Quoted 19 lines
Quoted 5 lines
I don't really follow the a/w SDK stuff, is it the case that a given Ann
SDK is tested and supported by Allwinner and used on real devices for processors Amm < Ann (chronologically, ?Yes and no, Allwinner used to have separate kernel sources for each die, so one for sun4i, sun5i, sun6i and sun7i.
Recently they have changed to one unified kernel tree though, so all of sun6i, sun8i and sun9i build from the same kernel tree. Note that sun7i is missing from the list.
Quoted 5 lines
IOW if a change was introduced in the A31 SDK do we then have confidence
that it doesn't break A20 due to Allwinners (and their customer's) use of
the A31 SDK on A20 or are we relying on our own + community testing?
Quoted 5 lines
It is safe to assume that the A23 changes do not break on the A31 since that is using the same kernel sources. The changes may cause issues on A20 though (A10 / A13 do not use the sample delay bits of the register AFAICT). So I've run several tests on A20 and things seem to work fine with the new settings there.
Great.
Quoted 8 lines
I believe that the mmc controller and the mmc clock bits really are the same over all of A20 / A23 / A31 / A33, and that these new tweaked values are better to use everywhere.
Regards,
Hans
PATCH 1/1 sunxi: mmc: Fix clk-delay settings
Hi,
Quoted 24 lines · Ian Campbell
Quoted 23 lines · Hans de Goede
Hi,
Quoted 20 lines · Ian Campbell
Quoted 6 lines · Hans de Goede
In recent allwinner kernel sources the mmc clk-delay settings have been
slightly tweaked, and for sun9i they are completely different then what
we are using.Quoted 7 lines
This commit brings us in sync with what allwinner does, fixing problems
accessing sdcards on some A33 devices (and likely others).For pre sun9i hardware this makes the following changes:
-At 400Khz change the sample delay from 7 to 0 (first introduced in A31 sdk)This one applied to sun9i as well as pre I think?
Quoted 2 lines
-At 50 Mhz change the sample delay from 5 to 4 (first introduced in A23 sdk)
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
By my reading it also changes oclk from 2 to 1 on <sun9i @ >50MHz.
Right, I did not list that as we never do > 50MHz,
But the being changed here does handle that (the else hz > 50000000 case) and that is changing even if we somehow coincidentally arrange that this code is never used today I think it is worth mentioning so that if it does become used we have the history of when/why it was changed.
Ok, I'll amend the commit message.
Quoted 9 lines
Quoted 7 lines
later on in the code
we've:cfg->f_max = 52000000;And that 52 is somewhat symbolically there, it is meant for 52MHz sdio where as mmc / sdcards run at 50MHz max.
Are these timings used for sdio as well then? That seems worth noting.
Yes, but we never use sdio in u-boot, more in general mmc/sdio is usually used referred to as just mmc (see e.g. the subsystem name, etc.).
Quoted 18 lines
Quoted 18 lines
Quoted 4 lines
I don't really follow the a/w SDK stuff, is it the case that a given Ann
SDK is tested and supported by Allwinner and used on real devices for processors Amm < Ann (chronologically, ?Yes and no, Allwinner used to have separate kernel sources for each die, so one for sun4i, sun5i, sun6i and sun7i.
Recently they have changed to one unified kernel tree though, so all of sun6i, sun8i and sun9i build from the same kernel tree. Note that sun7i is missing from the list.
Quoted 5 lines
IOW if a change was introduced in the A31 SDK do we then have confidence
that it doesn't break A20 due to Allwinners (and their customer's) use of
the A31 SDK on A20 or are we relying on our own + community testing?
Quoted 16 lines
Quoted 5 lines
It is safe to assume that the A23 changes do not break on the A31 since that is using the same kernel sources. The changes may cause issues on A20 though (A10 / A13 do not use the sample delay bits of the register AFAICT). So I've run several tests on A20 and things seem to work fine with the new settings there.
Great.
Quoted 8 lines
I believe that the mmc controller and the mmc clock bits really are the same over all of A20 / A23 / A31 / A33, and that these new tweaked values are better to use everywhere.
Regards,
Hans
Regards,
Hans
PATCH 1/1 sunxi: mmc: Fix clk-delay settings
Quoted 43 lines · Hans de Goede
Hi,
Quoted 32 lines · Ian Campbell
Quoted 23 lines · Hans de Goede
Hi,
Quoted 20 lines · Ian Campbell
Quoted 8 lines · Hans de Goede
In recent allwinner kernel sources the mmc clk-delay settings have
been
slightly tweaked, and for sun9i they are completely different then
what
we are using.Quoted 8 lines
This commit brings us in sync with what allwinner does, fixing problems
accessing sdcards on some A33 devices (and likely others).For pre sun9i hardware this makes the following changes:
-At 400Khz change the sample delay from 7 to 0 (first introduced in
A31 sdk)This one applied to sun9i as well as pre I think?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
-At 50 Mhz change the sample delay from 5 to 4 (first introduced in
A23 sdk)By my reading it also changes oclk from 2 to 1 on <sun9i @ >50MHz.
Right, I did not list that as we never do > 50MHz,
Quoted 7 lines
But the being changed here does handle that (the else hz > 50000000 case)
and that is changing even if we somehow coincidentally arrange that this
code is never used today I think it is worth mentioning so that if it does
become used we have the history of when/why it was changed.
Quoted 1 line
Ok, I'll amend the commit message.
Thanks.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
later on in the code
we've:cfg->f_max = 52000000;
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
And that 52 is somewhat symbolically there, it is meant for 52MHz sdio
where as mmc / sdcards run at 50MHz max.Are these timings used for sdio as well then? That seems worth noting.
Yes, but we never use sdio in u-boot, more in general mmc/sdio is usually used referred to as just mmc (see e.g. the subsystem name, etc.).
Right, which makes it all the more likely that one day this code might be used for sdio too I think.
Ian.