pine64-pinephone: Support for eMMC Vccq hardware mod
Describe your issue
TL:DR
You can greatly increase the speed of the PinePhone eMMC with a hardware mod, but this requires some DT change which must be loaded only on modded PinePhones.
More details below:
Introduction
I discovered that the eMMC speed on PinePhones is limited by the timing used: DDR52 (Double Data Rate 52MHz) while the eMMC and A64 SoC on PP support speeds up to HS400 (High Speed 200MHz, DDR), with driver support ready up to HS200 (200MHz SDR).
An eMMC card includes one or more NAND dices and a micro-controller and has two power supplies:
- Vcc powering the NAND dices at 3.3v
- Vccq powering the micro-controller and eMMC bus that can be either 3.3v or 1.8v or 1.2v
A stock PinePhone of any current hw revision cannot go faster than 52MHz because the Vccq is powered at 3.3v,
and HS200 or higher by eMMC specification can be used only with Vccq at 1.8v or 1.2v
On PinePhone Vccq can be changed from 3.3v to 1.8v by moving the 0ohm resistor from R615 to R614.
I have done this hardware mod on my PinePhone and I have not found any counter effects.
Disclaimer
You should do this mod at your own risk, I have tested only one device and do not give any guarantee.
Results
After modifying the Linux and U-Boot DT to match the regulator change and enable HS200, but limiting the maximum frequency to 150MHz, the eMMC read speed has increased from 55MB/s to 128MB/s
200MHz does not work (gives write errors) probably because eMMC delay calibration is not implemented in the driver, it could be used in the future as well as HS400 which is lacking driver support.
What's the expected behaviour?
There should be a way to load a modified device tree on a modded PinePhone.
A correct device tree can make use of High Speed eMMC timings and will reflect actual power regulator configuration.
What's the current behaviour?
Without patching the DT, the eMMC gets configured to DDR52 as before the mod and you get no performance gain.
How to reproduce your issue?
Install a pre-built or manually built pmos image
What device are you using?
pine64-pinephone PinePhone pmos CE (rev 1.2)
On what postmarketOS version did you encounter the issue?
-
edge ( master
branch) -
v21.06
How did you get postmarketOS image?
-
from https://images.postmarketos.org -
I built it using pmbootstrap -
It was preinstalled on my device
What's the build date of the image? (in yyyy-mm-dd format)
2021-10-27
Solution proposal:
Since a regular pmos image can be run fine on a PP with Vccq mod (without a speed increase), the DT change information can be configured after booting the phone with update-u-boot
script, in the same way as one can currently increase the ram frequency.
The update-u-boot script can reapply the change on the following u-boot updates.
Another solution proposed by dsimic and megi on Pine64 chat is to store the uboot env in the eMMC boot partition and read those to load a different Device Tree.
Other proposals are welcome.
Credits
Thanks to dsimic and megi for help and advices on Pine64 dev chat
Additional information
Device Tree patches needed
Patch to linux-postmarketos-allwinner
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
index 4ede9fe66..48e6dfe6e 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
@@ -609,13 +609,15 @@ rtl8723cs: wifi@1 {
&mmc2 {
pinctrl-names = "default";
- pinctrl-0 = <&mmc2_pins>;
+ pinctrl-0 = <&mmc2_pins>, <&mmc2_ds_pin>;
vmmc-supply = <®_dcdc1>;
- vqmmc-supply = <®_dcdc1>;
+ vqmmc-supply = <®_eldo1>;
+ max-frequency = <150000000>;
bus-width = <8>;
non-removable;
cap-mmc-hw-reset;
post-power-on-delay-ms = <1>; /* power is already turned on by the bootloader */
+ mmc-hs200-1_8v;
status = "okay";
};
@@ -629,7 +631,7 @@ &ohci1 {
&pio {
vcc-pb-supply = <®_dcdc1>;
- vcc-pc-supply = <®_dcdc1>;
+ vcc-pc-supply = <®_eldo1>;
vcc-pd-supply = <®_dcdc1>;
vcc-pe-supply = <®_aldo1>;
vcc-pf-supply = <®_dcdc1>;
Patch to u-boot-pinephone
diff --git a/arch/arm/dts/sun50i-a64-pinephone.dtsi b/arch/arm/dts/sun50i-a64-pinephone.dtsi
index 9f69d489..abc935ca 100644
--- a/arch/arm/dts/sun50i-a64-pinephone.dtsi
+++ b/arch/arm/dts/sun50i-a64-pinephone.dtsi
@@ -248,12 +248,14 @@
&mmc2 {
pinctrl-names = "default";
- pinctrl-0 = <&mmc2_pins>;
+ pinctrl-0 = <&mmc2_pins>, <&mmc2_ds_pin>;
vmmc-supply = <®_dcdc1>;
- vqmmc-supply = <®_dcdc1>;
+ vqmmc-supply = <®_eldo1>;
+ max-frequency = <150000000>;
bus-width = <8>;
non-removable;
cap-mmc-hw-reset;
+ mmc-hs200-1.8v;
status = "okay";
};
@@ -267,7 +269,7 @@
&pio {
vcc-pb-supply = <®_dcdc1>;
- vcc-pc-supply = <®_dcdc1>;
+ vcc-pc-supply = <®_eldo1>;
vcc-pd-supply = <®_dcdc1>;
vcc-pe-supply = <®_aldo1>;
vcc-pf-supply = <®_dcdc1>;