sd_overclock does not work for EMMC5.1 cards requesting 52MHz
Describe the bug
I used an EMMC5.1 to Micro SD converter on my raspberry pi 3b+, but sd_overclock doesn't work because EMMC5.1 requested 52MHz instead of 50MHz.EMMC5.1 will request 52MHz to traditional SD hosts.I hope to be able to use sd_overclock normally when using EMMC5.1
Device (s)
Raspberry Pi 3 Mod. B+
Logs
$ sudo cat /sys/kernel/debug/mmc0/ios
clock: 52000000 Hz
actual clock: 50000000 Hz
vdd: 21 (3.3 ~ 3.4 V)
bus mode: 2 (push-pull)
chip select: 0 (don't care)
power mode: 2 (on)
bus width: 2 (4 bits)
timing spec: 1 (mmc high-speed)
signal voltage: 0 (3.30 V)
driver type: 0 (driver type B)
Additional context
No response
The problem lies in this line of code https://github.com/raspberrypi/linux/blob/78fd5c93f1568d0dac7c56ee3d497739a63b058e/drivers/mmc/host/bcm2835-mmc.c#L1071C2-L1072C49
You're reading the wrong driver. bcm2835-sdhost is used to drive the SD slot on 3B+. Even so, in both drivers, overclocking is possible, and it's a requirement that the card clock must be an even divisor of the source clock (see further down in the file).
In this case, that's 400MHz.
/sys/kernel/debug/clk/clk_summary
enable prepare protect duty hardware connection
clock count count count rate accuracy phase cycle enable consumer id
---------------------------------------------------------------------------------------------------------------------------------------------
[...]
osc 7 7 1 19200000 0 0 50000 Y deviceless no_connection_id
[...]
pllc 3 3 1 2400000000 0 0 50000 Y deviceless no_connection_id
pllc_core0 2 2 1 1200000000 0 0 50000 Y deviceless no_connection_id
vpu 2 2 1 400000000 0 0 50000 Y 3f805000.i2c no_connection_id
3f201000.serial apb_pclk
---> 3f202000.mmc no_connection_id
3f215000.aux no_connection_id
Therefore requesting 52MHz will round down to 50MHz. The next step up would be 66.7MHz.
Yes, @P33M, but the problem here is that the trigger doesn't work unless exactly 50MHz is requested. It needs some form of inequality or other method of determining that the full speed is required.
@P33M Yes,but both drivers have this issue.https://github.com/raspberrypi/linux/blob/78fd5c93f1568d0dac7c56ee3d497739a63b058e/drivers/mmc/host/bcm2835-sdhost.c#L1544
I have another question. My EMMC5.1 card can run at 200MHz. What is the maximum frequency that BCM2837's sdhost can support overclocking to? Is it possible to run at 200MHz (400MHz/2) or 134MHz (400MHz/3) after this issue is fixed?If possible, this is faster than the DDR50 speed of Raspberry Pi 4.
Your mileage may vary, but I don't think I've seen it work reliably above 100MHz (that's with a divisor of 4). The next possible clock is 133MHz (a divisor of 3), which is a big jump.
N.B. To maintain that speed you will need to keep the core/peripheral clock at 400MHz, preventing it from dropping down to 250MHz. You can do this with core_freq=400 or, with a recent firmware, core_freq_fixed=1.
https://github.com/raspberrypi/linux/pull/7135 is a pull request with a proposed fix for this issue. Once the auto-builds have completed in about 20 minutes you will be able to install a trial build (assuming you aren't making use of initramfs for booting - check by seeing if your Pi will still boot with auto_initramfs=0 in config.txt), with:
$ sudo rpi-update pulls/7135