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 B0B01C433EF for ; Wed, 23 Feb 2022 13:07:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9F72C83C37; Wed, 23 Feb 2022 14:07:35 +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="TE1+xBWd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 56DBD838C9; Wed, 23 Feb 2022 14:07:27 +0100 (CET) Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (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 1CBB183B67 for ; Wed, 23 Feb 2022 14:07:24 +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=jbx6244@gmail.com Received: by mail-ed1-x535.google.com with SMTP id s24so37637376edr.5 for ; Wed, 23 Feb 2022 05:07:24 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=j+G9L+4U+UGXrxAS8bt9OlsGc4q/MsabZZA5RHKCiLY=; b=TE1+xBWdMQzb5wgN1TPoJTQjz2GUWkGC38NqHbaNo7n5F8iFcyVWfsiWeiJkGZjaDC LE5jDGG9dewK7TAQ2IeGa4rrbW46r5cEezldReXvMleC9FWzWntCwTEyyX7grOozRisT +8Hba84RXlbXQodZU2u4uvutfCKUWMybX07lIV6E+k45libxFILH/4pFut58SzCxyI4Y W+/BVKn5jSK1Onnk9XOfiq1SGj01AfuLTJ+mz1vS/lUVJN7KiPOA/y3Y+k/AUlfk33g/ DNUWeP2dcshXETqbcLVVzRrrcy7Z8m3hJULTD+4lERWMAUWXWWIHHnRoJvkcMhnUQ1ln ky+w== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=j+G9L+4U+UGXrxAS8bt9OlsGc4q/MsabZZA5RHKCiLY=; b=HcatGoFVAc8ezVAFqH37jG7jKgNVOiONYhn1KepefFvReZZl6Y8xeNi7Eb2SmQhwYF PmQcEYsk3KyedDP2plrUW+yBhUWDPSpOK3lHp1ahK707IPRomJ+PfiIyelhJ4CKAZkKI LssZcqqDRKXAIpJjCgaZrUU8nc7se9rhd9lJHHFx7X+LXvXtHuF+vcJWrTeJCY0QN0iw rIP4yHOpdWBqsW/i0FuSeOjyOEwC4M1mf3xaQ1EsooD7IudAiefrNtkB+LYI9j6YnBVK P0PhlzN8Ju3WZ8J1TxAD9NaJd36mD4aFiFeIQ0BSX2NuLH3nittNXBue2g13uCIM+epM KFwQ== X-Gm-Message-State: AOAM533vrYqXnQ1OVKsp7hTk7xug4HZvwbuoCNf5KTpLb8PwUtLl+Ixe YDfEnGQXz33DPuaAlttcqVQ= X-Google-Smtp-Source: ABdhPJw1zwej03duF2TT4h13DEcg0yY2jMk8blrA2e3y7w3M6YeQphxtKxeXsg835OMGKwsUa9jEiA== X-Received: by 2002:a05:6402:26d6:b0:413:4ad2:3e1e with SMTP id x22-20020a05640226d600b004134ad23e1emr314433edd.175.1645621643475; Wed, 23 Feb 2022 05:07:23 -0800 (PST) Received: from debian.home (81-204-249-205.fixed.kpn.net. [81.204.249.205]) by smtp.gmail.com with ESMTPSA id q21sm636566ejy.106.2022.02.23.05.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 05:07:23 -0800 (PST) From: Johan Jonker To: kever.yang@rock-chips.com Cc: sjg@chromium.org, philipp.tomsich@vrull.eu, peng.fan@nxp.com, jh80.chung@samsung.com, paweljarosz3691@gmail.com, u-boot@lists.denx.de Subject: [PATCH v2 2/2] mmc: dw_mmc: support transfer mode auto detection Date: Wed, 23 Feb 2022 14:07:14 +0100 Message-Id: <20220223130714.2711-2-jbx6244@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220223130714.2711-1-jbx6244@gmail.com> References: <20220223130714.2711-1-jbx6244@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.5 at phobos.denx.de X-Virus-Status: Clean From: Paweł Jarosz dw_mmc supports two transfer modes in u-boot: IDMA and FIFO. This patch adds auto detection of transfer mode and eliminates the need to set this in host config struct. Allow handling for a u-boot,spl-fifo-mode host property in the logic to not put the MMC controllers into FIFO mode for all time. Signed-off-by: Paweł Jarosz Signed-off-by: Johan Jonker --- Changed V2: use bitfield_extract remove use_dma variable include fifo_mode from host in logic --- drivers/mmc/dw_mmc.c | 6 ++++++ include/dwmmc.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index a949dad5..7e2cd5ed 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -536,6 +536,12 @@ static int dwmci_init(struct mmc *mmc) return -EIO; } + if (!host->fifo_mode && + SDMMC_GET_TRANS_MODE(dwmci_readl(host, DWMCI_HCON)) == DMA_INTERFACE_IDMA) + host->fifo_mode = 0; + else + host->fifo_mode = 1; + /* Enumerate at 400KHz */ dwmci_setup_bus(host, mmc->cfg->f_min); diff --git a/include/dwmmc.h b/include/dwmmc.h index 5fc8ed83..d8d9ebe7 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -119,6 +120,10 @@ #define RX_WMARK_SHIFT 16 #define RX_WMARK_MASK (0xfff << RX_WMARK_SHIFT) +/* HCON Register */ +#define DMA_INTERFACE_IDMA (0x0) +#define SDMMC_GET_TRANS_MODE(x) bitfield_extract(x, 16, 2) + #define DWMCI_IDMAC_OWN (1 << 31) #define DWMCI_IDMAC_CH (1 << 4) #define DWMCI_IDMAC_FS (1 << 3) -- 2.20.1