[maemo-developers] [maemo-developers] speeding up MMC (with success)

From: Frantisek Dufka dufkaf at seznam.cz
Date: Sat Sep 30 23:28:50 EEST 2006

recently I bought 2GB Kingston MMCmobile card and was a bit frustrated 
by N770 mmc slot speed. Basically any card inserted into N770 has speed 
~1.3MB/s. I digged a bit in kernel sources and googled for MMC specs and 
discovered this:

- maximum legacy MMC bus clock speed is 20Mhz
- MMC v4 specification adds faster bus speed - 26 and 52Mhz, 13 pin 
interface and 4 and 8 bit data bus width (legacy = 1 bit)
- TI OMAP mmc controller inside N770 uses 48Mhz reference clock and uses 
integer divider for reducing the speed to 24,16,12,...
- connector inside N770 has only 7 pins (maybe 6) so only 1 bit data 
transfers are possible

There is code in mmc driver which tries to determine proper speed that 
card reports it can handle. Then the omap mmc driver computes the 
divider. Fastest divider for 20Mhz bus speed should be 3 (as described 
in spru765a.pdf) which means 16Mhz (24 is too much). But there is 
strange line in omap mmc driver which then increases divider by one.

So in reality it looks like in the name of maximum compatibility the 
divider is finally set to 4 so the clock is set to 12Mhz (= up to 
1.5MB/s speed).

When commenting out line 'dsor++;' in drivers/mmc/omap.c the bus speed 
is set to 16Mhz and speed jumps to ~1.7MB/s. Unfortunately the 64MB MMC 
card included with N770 stops working. I'm not sure this is kernel bug 
or the card reports wrong speed but it certainly explains why the speed 
is reduced in official kernel. Luckily my Sandisk 1GB RS-MMC has no 
problems with 16Mhz (as should any modern MMC card rated for 20Mhz bus).

Then I found this patch

Unfortunately 4bit data transfers are not possible unless one wants to 
add those 2 or 3 pins for SD card (and also MMCplus) compatibility to 
the slot, but switching to higher speed works. 26Mhz exactly is not 
possible due to 48Mhz clock but 24Mhz runs just fine with my Kingston 
2GB (as it should, specs say 0-26Mhz) and speed jumps to ~2.6MB/s (i.e. 
twice the original speed)

With this speed system boots noticeably faster from MMC than from 
internal flash - boot progress bar finishes at 3/4 and application 
startup feels a bit faster. Even the old speed was comparable to flash 
speed (since jffs2 uses compression which slows I/O down and hogs CPU) 
but now MMC card is clear winner :-)

Also newer cards should handle 52Mhz too. They report it in EXT_CSD 
register. So far there is no proper code in kernel to check this but 
when hardcoding 52000000 to 
http://intr.overt.org/diff.cgi/diffs/mmcv4.diff and bumping up max omap 
mmc driver speed from 24Mhz to 48Mhz it looks like my Kingston 2gb 
MMCplus runs just fine with divider set to 1 = 48Mhz bus clock speed and 
data transfer speed goes to ~5MB/s. With this speed boot progress bar 
stops slightly after 1/2.

So far the stability looks fine (same as with old speed). I have set 
system to boot from MMC, have swap on partition 1 and so far it is OK.

I'm not sure TI supports 48Mhz for its MMC controller but I didn't found 
any limit mentioned in the docs and divider 1 seems to work fine. Also I 
hope the Kingston card really supports 52Mhz (or it should stop 
responding completely as defined by specs) so I hope I am not 
'overclocking' anything.

Hardcoding to 52000000 is of course wrong and will fail with other 
cards, but 26000000 is OK. Every MMCplus card must support 26Mhz bus 
clock speed.

If anyone wants to test kernel with those changes it is here
http:// fanoush.webpark.cz/maemo/zimage-su-18-200625-2gb-mmcplus26mhz.zip
Make sure you first load and boot it without flashing (flasher -l -b). I 
did not try this specific kernel as for easy hacking I'm using different 
kernel with mmc drivers as modules (needs adding to initfs and linuxrc 
script). Also make sure you don't mind killing your device or MMC card 
or losing some data. It works for me for few days but of course YMMV. 
For 52Mhz speed please hack and compile kernel yourself :-)

you can test card speed like this
Nokia770-26:~# time dd if=/dev/mmcblk0 of=/dev/null bs=8192 count=10240
10240+0 records in
10240+0 records out
real    0m 15.90s
user    0m 0.02s
sys     0m 2.33s

80MB in 16 seconds, not bad :-)


More information about the maemo-developers mailing list