From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40F66C433F5 for ; Sun, 28 Nov 2021 11:32:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 479E380F9C; Sun, 28 Nov 2021 12:32:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N9v8kPT7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9ABCE80F81; Sun, 28 Nov 2021 12:32:49 +0100 (CET) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4AE5180F67 for ; Sun, 28 Nov 2021 12:32:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=atomar25opensource@gmail.com Received: by mail-wr1-x42e.google.com with SMTP id a9so30006730wrr.8 for ; Sun, 28 Nov 2021 03:32:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E90yxUYtjA4lrDEu/y8RBt0Y/LjvCMsa/Prtwpbkfs0=; b=N9v8kPT77hcuQmCMorTjirlr32fFNGnuzETX4uMuPizmTIriyBnej4jwKLLsgKjXeS cwDE1a7fuKlh6y5zs1Mvol7PWRcF2s5SgRka5vUv2N4o0fmAN7j2WLcl3DMHy60ZTiMe 5hTRLobR/laYdLczkjGyCY1GVj6gUJe2X5xulye6nHi5BvXYNl7p/r+Pf4fa+myVZ6M0 3LfV0y9YXjgnTHyIztZk9RauSiDiASx2GcWcb24Ym1N2e7+fXLoiXrcLGcQb5kMb6vp3 GB0jJIFDmu/0LyHVCiRHsAsnWqFJjdlbYi9L3ccmX7t5cF/O8SwRg3plr9d2qIoBo8i2 OLuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E90yxUYtjA4lrDEu/y8RBt0Y/LjvCMsa/Prtwpbkfs0=; b=bcbFUu3QboRAYdtE1BQQZsO+VZ34dj/5xdtplQVidEI8gud/VoFByieRZQmlXHUtID nOqOyfu308+tpnyGdXwDsdWtNWx2p7ipTrYJ7L1B9kPgr13bztdQCiFirOMaGkjpdg7U zkFkEk3bY2XKgNyl799X0G/iTufTvwb2flwYx2zNamF3w6cyEMv7/45soSctc+RZCK9k R4OL1XYwP1ksUvFsk+dZ6FoLppu0Oz03ciZkgJtb/b6VTrQVFRuZ1Njy8aij9N4w2YqO SFbzow4IERVsfyplLzcndJabTmcW0mlY4dTNvaGdr/9X/Qo0s2vTvWlQZUpMurEvxAH/ rcBw== X-Gm-Message-State: AOAM5330Rw+8uXLMSk0hc7uOyWNAQy1dhQOFmm/eN/r6AyEAweqTVgyp CDhUDYVftr8tf+iWvQD1CKbv/Lm+goxi X-Google-Smtp-Source: ABdhPJwYPcvIGmnQB5G94i3WELJu5YDPGFrXFS7hizCh4Z66a/ChcIMgFRCaBMz6KK/Tywpk1fKaAg== X-Received: by 2002:a5d:64eb:: with SMTP id g11mr26850415wri.438.1638099165608; Sun, 28 Nov 2021 03:32:45 -0800 (PST) Received: from amit-VirtualBox.world.mentorg.com (nat-inn.mentorg.com. [192.94.34.34]) by smtp.gmail.com with ESMTPSA id b6sm17335285wmq.45.2021.11.28.03.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 03:32:45 -0800 (PST) From: Amit Singh Tomar To: u-boot@lists.denx.de Cc: andre.przywara@arm.com, manivannan.sadhasivam@linaro.org, joe.hershberger@ni.com, jh80.chung@samsung.com, Amit Singh Tomar Subject: [PATCH v4 0/6] Add MMC/SD support for S700/S900 Date: Sun, 28 Nov 2021 17:02:19 +0530 Message-Id: <20211128113225.3992-1-atomar25opensource@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi, Sorry, it took me some time to come up with v4. For v3, all the comments are from MMC driver(patch 5/6), and tried to address in this series(v4) with changelog mentioned in the patch (5/6) itself. -------------------------------------------------------- This series(v3) addresses review comments provided by Andre and Jaehoon. Earlier in MMC driver, we were *not* checking the command response errors(for instance, the CRC error) based on STATU register. This is now addressed in patch 5/6. Also, MMC driver(patch 5/6) now has replaced the switch/case with if/else to correlate MMC_RSP_Rx bitmask values with register bits as suggested by Andre. Apart from it, there are changes in patch 2/6 to fix weird assignments to div variable. ---------------------------------------------------------------------------------- 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@e0210000: 0 In: serial@e0126000 Out: serial@e0126000 Err: serial@e0126000 Net: eth0: ethernet@e0220000 Hit any key to stop autoboot: 0 U-Boot => U-Boot => U-Boot => U-Boot => mmc info Device: mmc@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 Starting kernel ... [ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034] [ 0.000000] Linux version 5.7.0-rc6-00022-g99f1c330923b-dirty (amit@amit-ThinkPad-X230) (gcc version 7.3.1 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05), GNU ld (GNU Binutils for Ubuntu) 2.26.1) #474 SMP PREEMPT Thu Aug 13 15:27:10 IST 2020 [ 0.000000] Machine model: CubieBoard7 [ 0.000000] earlycon: owl0 at MMIO 0x00000000e0126000 (options '') [ 0.000000] printk: bootconsole [owl0] enabled [ 0.000000] efi: UEFI not found. [ 0.000000] cma: Reserved 32 MiB at 0x000000003e000000 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/S900 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 | 99 +++++ drivers/mmc/Kconfig | 7 + drivers/mmc/Makefile | 1 + drivers/mmc/owl_mmc.c | 408 ++++++++++++++++++ .../dt-bindings/power/owl-s700-powergate.h | 19 + 8 files changed, 563 insertions(+), 1 deletion(-) create mode 100644 drivers/mmc/owl_mmc.c create mode 100644 include/dt-bindings/power/owl-s700-powergate.h -- 2.27.0