From patchwork Wed May 22 23:31:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 798187 Delivered-To: patch@linaro.org Received: by 2002:ab3:6414:0:b0:267:d849:ee76 with SMTP id j20csp917703lte; Wed, 22 May 2024 16:33:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXcuTDPFlvbUXhLHtpl4ryKbYqq0xOifaM4bbAHJSOsWzre4gPSxQqBfaD9WCgMKPjfovS5EgdxiT/II4M9D0UY X-Google-Smtp-Source: AGHT+IG2+xiozPL2ql32+vfOPsrMdR1IOMWeQlAfB4x7Q/dvSTkf8z9n0Xmsx11kqGXswOpxzijT X-Received: by 2002:a17:906:1c8b:b0:a59:af85:17ed with SMTP id a640c23a62f3a-a623e956670mr48134566b.28.1716420794487; Wed, 22 May 2024 16:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716420794; cv=none; d=google.com; s=arc-20160816; b=kuIH+QU6fHlcOZ6QZlJskL1MzDqg+45M6Ye9hh83KP9H8UimA9/hIPYKrkfSrEh/y7 wYLg6lp7qe3adPkwb9uu/KhI5cwEst4t/NISIWkVcfLwKMXfK2DoEhDPT8f1GHwcYmIb 0uCs4cH+TG6s4C2ixrgl+r2Na3BqMGcYE/PlOFtCpf0F0/HoPs6866pnPuOwml7yId8h X0Odphld65nfLiVes3ChbdokfgjJy3xOPTHJ7gR6bTAqkOsdvPvKuJnTtIpTZmKL2OzY i2Af6NHr1ps83P8M+oT+Q7AVdkJiatVYE/NTb13GBPPoIcF6abOuPrj/+Rek4g+YUKzk JYyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HcY0epwhpfO0hsI44S2jc8vf2UMELxebOpqmzAF7DOw=; fh=IkWu3/Tjfg6hvE/JbIZ0JIbP67IPTpuMCe57dO98iSY=; b=l1WhopFBvQzIQ4L8jKazp/ox+2DXUoPy6zfBjuz+686rpL7+u9/f9bCUrKuwVc+S23 aVQOmtO6nyqg/42lbaQ2V8sh4ZxNGV+jxCqPxMB5D+T0c7DZvyUqrdYB1BwR1S8Bu7nk frDAB9XEdNcLsIGco5TMuwpsxicNB5s644VpeiJRmkGtDbxgws9e7nVJilPrtVMK24Ps jaH47ba17l387FiZhgQjNe69DdQbLeKdzxJ2Hq+Kae2Mfe75nMCa98ikAhgl2YZN2jpZ NJpM90IYatra+60sGprdtb9HWU02fL+opwK1jw7HMNKq1p2n51cYjxGisjQHREE7UPet WYnA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="T+jhb3/P"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17baff25si1553648566b.490.2024.05.22.16.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 16:33:14 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="T+jhb3/P"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5C3CD88546; Thu, 23 May 2024 01:31:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="T+jhb3/P"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 21C3F88505; Thu, 23 May 2024 01:31:46 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) (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 EC321884DB for ; Thu, 23 May 2024 01:31:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=semen.protsenko@linaro.org Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6f0e4212d5aso3043594a34.3 for ; Wed, 22 May 2024 16:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716420702; x=1717025502; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HcY0epwhpfO0hsI44S2jc8vf2UMELxebOpqmzAF7DOw=; b=T+jhb3/PAzEKERsb1kjjZqx12MZEyNj/GFr1T51RLX7tAyEj8HTuAfSRhinLjlCm2Y w2XUtqKnP1SO8iXdE92iYwAVsqhv4A6rvMGYG+F3IrftyA9XyoxdRrvjf5eYJDJhyMcu 8eTQIU6Wu7o/CoYNZsdPgmxb91mwLRohjS1GmrD982r9GBaVL+8LU4pU0OIc9NgRN/uu dMo9O8BqyUNzrVLkUdhD90yNNJWScRGGKWMpVh0FEZBPQzwUO9uCT2Qac95Q8gnYO9tg EtwXk25/c1KHazP8rhxmCgj+4acJNBi8RuSyGKHeH/2eNQz22WsNWbll6F0Y6eqPGMqK LtXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716420702; x=1717025502; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HcY0epwhpfO0hsI44S2jc8vf2UMELxebOpqmzAF7DOw=; b=KL6NVPtRqleXhKuw6fDisaJb1FHsjwGQatbmZJVlDpFLXMUMwFmmHqteESTcM7GO+m vNo7OeXp93HSXGvYrQbn+5Jj3OgwO2ugr9IaCpc4HomnpX1xNoOQ3SRM7hia1kXCpWkA 0Cc3YPiKQgYvhbyYmxRFR70MXh0z1XP0HAc34mV4ty+r0goJbYYXckirAyuLsPJg1n0g FIAFfsASsxSBv4AsShVpj8VJip0ZqOpiVHeB/pA7hYwsF0nmr+nIxOWk01dEWHlb15Fp /hTl3PCC1bLDiQyWzeBlzYVrqfadarEZt8AepwX8jwHMt52K0uJQpGiLjDAJ6lDJJin5 5Glg== X-Forwarded-Encrypted: i=1; AJvYcCWcSURCMiZzUFM8moCDScwgeAWlK9KHoUw/n3xG+IpdXadFUL56yGctQrrJHETaQmBpY3P7F0tIjztJ27YR70YjiPqS8w== X-Gm-Message-State: AOJu0Yx8Ryro3d2JJ4127X0KzfJg5VHJpNVGLTLe/iLaNlIb2aHhC7Po 98Vjvtiuooz54W/rbLOfSOsWpL7EEyysWbCWRwEbNfZglznzduu/j4VmrYFcfxI= X-Received: by 2002:a05:6871:550:b0:24c:6024:9d61 with SMTP id 586e51a60fabf-24c68a4e95dmr3844418fac.12.1716420702586; Wed, 22 May 2024 16:31:42 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2412a3c82edsm6675098fac.12.2024.05.22.16.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 16:31:42 -0700 (PDT) From: Sam Protsenko To: Tom Rini , Minkyu Kang , Peng Fan , Jaehoon Chung , Simon Glass Cc: Philipp Tomsich , Kever Yang , Eugeniy Paltsev , Peter Robinson , Jonas Karlman , Yang Xiwen , Ferass El Hafidi , Sean Anderson , u-boot@lists.denx.de, uboot-snps-arc@synopsys.com Subject: [PATCH 08/42] mmc: dw_mmc: Extract DMA transfer handling code into a separate routine Date: Wed, 22 May 2024 18:31:01 -0500 Message-Id: <20240522233135.26835-9-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240522233135.26835-1-semen.protsenko@linaro.org> References: <20240522233135.26835-1-semen.protsenko@linaro.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Make dwmci_send_cmd() easier to read by moving the DMA transfer handling code into a dedicated function. No functional change. Signed-off-by: Sam Protsenko Reviewed-by: Quentin Schulz --- drivers/mmc/dw_mmc.c | 51 ++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 144f29f09240..439f8eb3fb4c 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -233,6 +233,33 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data) return ret; } +static int dwmci_dma_transfer(struct dwmci_host *host, uint flags, + struct bounce_buffer *bbstate) +{ + int ret; + u32 mask, ctrl; + + if (flags == MMC_DATA_READ) + mask = DWMCI_IDINTEN_RI; + else + mask = DWMCI_IDINTEN_TI; + + ret = wait_for_bit_le32(host->ioaddr + DWMCI_IDSTS, + mask, true, 1000, false); + if (ret) + debug("%s: DWMCI_IDINTEN mask 0x%x timeout\n", __func__, mask); + + /* Clear interrupts */ + dwmci_writel(host, DWMCI_IDSTS, DWMCI_IDINTEN_MASK); + + ctrl = dwmci_readl(host, DWMCI_CTRL); + ctrl &= ~DWMCI_DMA_EN; + dwmci_writel(host, DWMCI_CTRL, ctrl); + + bounce_buffer_stop(bbstate); + return ret; +} + static int dwmci_set_transfer_mode(struct dwmci_host *host, struct mmc_data *data) { @@ -275,7 +302,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, data ? DIV_ROUND_UP(data->blocks, 8) : 0); int ret = 0, flags = 0, i; u32 retry = 100000; - u32 mask, ctrl; + u32 mask; struct bounce_buffer bbstate; dwmci_wait_while_busy(host, cmd); @@ -384,26 +411,8 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, if (data) { ret = dwmci_data_transfer(host, data); - - /* only dma mode need it */ - if (!host->fifo_mode) { - if (data->flags == MMC_DATA_READ) - mask = DWMCI_IDINTEN_RI; - else - mask = DWMCI_IDINTEN_TI; - ret = wait_for_bit_le32(host->ioaddr + DWMCI_IDSTS, - mask, true, 1000, false); - if (ret) - debug("%s: DWMCI_IDINTEN mask 0x%x timeout.\n", - __func__, mask); - /* clear interrupts */ - dwmci_writel(host, DWMCI_IDSTS, DWMCI_IDINTEN_MASK); - - ctrl = dwmci_readl(host, DWMCI_CTRL); - ctrl &= ~(DWMCI_DMA_EN); - dwmci_writel(host, DWMCI_CTRL, ctrl); - bounce_buffer_stop(&bbstate); - } + if (!host->fifo_mode) + ret = dwmci_dma_transfer(host, data->flags, &bbstate); } udelay(100);