[PATCH v2 0/6] Add MMC/SD support for S700

Amit Singh Tomar
2020-12-19T14:51:04Z

From: Amit Singh Tomar <amittomer25@gmail.com>

This series(v2) has few important updates, while loading large files we found
that MMC framework puts "0x1fffe00" into DMA Frame Length(DMA_FRAME_LEN 0x000C)
but register itself is limited to 24 bits and hence it was failing.
It is due to the wrong Block count(cfg->b_max) used in driver, that should be
just 512. This is now fixed in patch 5/6.

Apart from it, as Andre pointed that we might be just overclocking the MMC/SD
clock, and to confirm this we run following test:

$ md5sum clang
349eac46cbbe28f8e44da2dce07fa7b7 clang

U-Boot => ext4load mmc 0:2 0x0 clang
503316480 bytes read in 19516 ms (24.6 MiB/s)
U-Boot => md5sum 0x0 0x1e000000
md5 for 00000000 ... 1dffffff ==> d793bb51c4a1cf83c96d1980927461ff

Even though file gets loaded but md5sum doesn't match. This is now fixed in
patch 2/6

U-Boot => ext4load mmc 0:2 0x0 clang
503316480 bytes read in 41524 ms (11.6 MiB/s)
U-Boot => md5sum 0x0 0x1e000000
md5 for 00000000 ... 1dffffff ==> 349eac46cbbe28f8e44da2dce07fa7b7

-----------------------------------------------------------------------------
At the moment on S700 based platforms, only way to load/boot the Kernel
is from Ethernet, and with these patches one can now load/boot the
Kernel from uSD card.

Patches(1/6 and 2/6) adds changes needed for MMC/SD clock. It introduces
set/get callback routine and get/set MMC/SD clock rate based on device id.

Patch 4/6 adds MMC/SD node in U-boot specific dtsi file, which is used by MMC/SD
driver to read controller base address later on.

Patch 5/6 adds driver for MMC/SD controller present on S700 SoC, and its based
on Mainline Linux driver and DMA related bits is picked and simpilified from
vendor source.

Final patch 6/6 enables the driver support along with MMC commands in
Cubieboard7 config file.

Also, while at it just took the opportunity to synchronize the S700 SoC DT with
Linux in patch 3/6.

This patch-set is tested on Cubieboard7-lite board with following results:

U-Boot 2021.01-rc1-04434-g6589149-dirty (Dec 13 2020 - 13:51:07 +0530)
cubieboard7

DRAM: 1 GiB
PSCI: v0.2
MMC: mmc at e0210000: 0
In: serial at e0126000
Out: serial at e0126000
Err: serial at e0126000
Net: eth0: ethernet at e0220000
Hit any key to stop autoboot: 0
U-Boot =>
U-Boot =>
U-Boot =>
U-Boot => mmc info
Device: mmc at e0210000
Manufacturer ID: 3
OEM: 5344
Name: SC16G
Bus Speed: 50000000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
U-Boot => setenv bootargs console=ttyOWL3,115200n8 earlycon=owl,0xe0126000 init=/sbin/init root=/dev/mmcblk0p2 rw rootwait
U-Boot => setenv kernel_addr_r 0x80000;setenv fdt_addr_r 0x10000000;
U-Boot => fatload mmc 0:1 ${kernel_addr_r} image ;fatload mmc 0:1 ${fdt_addr_r} s700-cubieboard7.dtb
27480576 bytes read in 1041 ms (25.2 MiB/s)
7056 bytes read in 2 ms (3.4 MiB/s)
U-Boot => booti $kernel_addr_r - $fdt_addr_r
## Flattened Device Tree blob at 10000000
Booting using the fdt blob at 0x10000000
Loading Device Tree to 000000003df56000, end 000000003df5ab8f ... OK

Amit Singh Tomar (6):
clk: actions: Introduce dummy get/set_rate callbacks
clk: actions: Add SD/MMC clocks
ARM: dts: sync Actions Semi S700 DT from Linux 5.10-rc7
ARM: dts: s700: add MMC/SD controller node
mmc: actions: add MMC driver for Actions OWL S700
configs: Enable mmc support

arch/arm/dts/s700-u-boot.dtsi | 10 +
arch/arm/dts/s700.dtsi | 17 +-
configs/cubieboard7_defconfig | 3 +
drivers/clk/owl/clk_owl.c | 98 ++++++
drivers/clk/owl/clk_owl.h | 2 +
drivers/mmc/Kconfig | 7 +
drivers/mmc/Makefile | 1 +
drivers/mmc/owl_mmc.c | 399 +++++++++++++++++++++++++
include/dt-bindings/power/owl-s700-powergate.h | 19 ++
9 files changed, 555 insertions(+), 1 deletion(-)
create mode 100644 drivers/mmc/owl_mmc.c
create mode 100644 include/dt-bindings/power/owl-s700-powergate.h

--
2.7.4