clock divisor in mmc_omap_set_ios in drivers/mmc/omap.c wrong
Hello,
anyone knows real reason why the divisor is intentionally lowered in mmc_omap_set_ios so the result frequency is _not_ near the one requested?
First there is a code which tries hard to select the divisor that produces highest possible frequency which is lower or equal to the requested one
fclk_rate = clk_get_rate(host->fclk);
dsor = fclk_rate / freq;
if (dsor < 1)
dsor = 1;
if (fclk_rate / dsor > freq)
dsor++;
if (dsor > 250)
dsor = 250;and then there is additional
dsor++;
which intentionally makes resulting frequency lower by unknown factor.
If this is some workaround for specific cards maybe it should be solved in different place like blacklisting offending cards and actually requesting lower frequency for them. Or is there some real reason?
For requested 20Mhz MMC bus speed and 48Mhz omap clock current code results in 12Mhz instead of 16Mhz.
Frantisek
Quoted 23 lines · Frantisek Dufka
Hello,
anyone knows real reason why the divisor is intentionally lowered in
mmc_omap_set_iosso the result frequency is _not_ near the one requested?First there is a code which tries hard to select the divisor that produces highest possible frequency which is lower or equal to the requested one
fclk_rate = clk_get_rate(host->fclk); dsor = fclk_rate / freq; if (dsor < 1) dsor = 1; if (fclk_rate / dsor > freq) dsor++; if (dsor > 250) dsor = 250;and then there is additional
dsor++;
Quoted 8 lines
which intentionally makes resulting frequency lower by unknown factor.
If this is some workaround for specific cards maybe it should be solved in different place like blacklisting offending cards and actually requesting lower frequency for them. Or is there some real reason?
For requested 20Mhz MMC bus speed and 48Mhz omap clock current code results in 12Mhz instead of 16Mhz.
This seems like a bug to me (or else the TRMs have a typo). Let's patch it out and see if it still works.
Regards,
Tony
Quoted 4 lines · Tony Lindgren
This seems like a bug to me (or else the TRMs have a typo). Let's patch it out and see if it still works.
Yes, that's what I did on Nokia 770 and have mixed results. Most MMC cards around me work with this line removed (at 16Mhz) and there is some speedup (~1.8MB/s@16Mhz vs ~1.4MB/s@12Mhz) but the 64 MB one shipped with Nokia (plain MMC, 7 pins) give me I/O error when inserted. Even partition table is not read. Other cards that work are 128MB noname RS-MMC, 1GB Sandisk RS-MMC, 2GB Kingston MMCmobile (13 pins).
Also interesting is that after I posted my question to this list few days later Nokia released newer kernel source for newer N770 firmware and this dsor++ line is removed there, but there is board specific code that limits MMC speed on Nokia N770 to 12Mhz. So there seems to be something fishy with MMC speeds over 12Mhz (on N770). Either there are known cards on market which fail or Nokia shipped buggy cards with devices and limited MMC interface speed due to this. Or can this limit be matter of wiring/shielding of specific device? Their newer kernel have also support for newer device with miniSD slot with speed limited to 24Mhz in same omap driver.
I'm digging into in this because the MMC speed on N770 is pathetic and newer MMCmobile cards can operate up to 52Mhz. And it looks like with high speed MMC v4.1 patches MMC interface in OMAP1710 inside N770 can run at 48Mhz (divisor=1) giving me ~6MB/s@48Mhz when reading. Every MMCmobile/plus card can do at least 26Mhz so even 24Mhz is good speedup (over original 12Mhz).
See also http://fanoush.webpark.cz/maemo/#mmcplus
Some people tried it on their N770 and I got few successful reports and no unsuccesful ones. Such speed is quite useful when booting from MMC and having swap on MMC too. I'm running my N770 in this setup for more than month with Kingston 2GB card @ 48Mhz and had no problems so far (i/o error, data corruption).
So my next related question is whether OMAP 1710 MMC interface is designed to run with divisor set to 1 with 48Mhz clock. It seems to work fine and give nice speed boost with newer MMCmobile cards on market. There is no limit mentioned in spru765a.pdf so I don't know whether I'm in fact overclocking something or not.
Regards,
Frantisek