From patchwork Thu Aug 8 03:14:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 817672 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e11:0:b0:367:895a:4699 with SMTP id p17csp674911wrt; Wed, 7 Aug 2024 20:16:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXNLkHeIg4/EA0YiJ6RpY6BkeKa/IrAkKiAdTUQgEBVaDoK3JaFBbB5S/j7HukYBawFuTxZPBd1miYuXltwB7nG X-Google-Smtp-Source: AGHT+IG1nsxGeIncHEq/hGWqPs6Soet0KHGAfti8GZ6i3iczuarb1v2QWFD0m8fvCLA1SRSmEu7T X-Received: by 2002:a05:6402:3484:b0:57a:3046:1cd8 with SMTP id 4fb4d7f45d1cf-5bbb22399e9mr553903a12.7.1723086982831; Wed, 07 Aug 2024 20:16:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723086982; cv=none; d=google.com; s=arc-20160816; b=RZfwe+FCK+bJJMNGp/+DWw64A2MHrneyf7b2gvtm8f70mrYYiY8XiCZsGTmM6sheNO bM/0B+LzAxVyu0Ef24RB7Q6QTWxe+ooGt3Gwo3ATz0OxZ9Us740QA9hEAyGqLaQxCAOo ZzrM6iVwoTS6J9rfLCfRayE6zbyiHIPcex22K3/sWPXRtVGqRNv1w/ualOQqt2RpVudv 2yfUGWsIdyhR0okCHATzWJCJu4MWrFj/hv1w8fDrO4EfsYJPHbaUKF4ZvhbQhCKN/BZc jb++S8I8SkmZn8k4SSc5teUyf1IYXKKPCNJudYHom9HRpCxHF8BZH27yUMzf5Rk0Vf9L Xqsw== 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=lajTQ3JYoTyQySiuDMhbE4W09/EbwBdHGoc2IwlOBbU=; fh=45D9Rh4B1/C1ZXLA6mQRbjtIf8kVezwKbWC9lK1HD1o=; b=ZOCNhLYapfcGt1xc8WDQuxgXJ49XiCdMIzZvRL4nNIchHs2vGshs6lAx3TmIohknIO SufXv/lU1CgwKSCDfb0o/wx73GvdmroB0gGQlmDxPhL2PWY6vkFn629/8UrQ39EBi7VI 6gVnyIpmZlMG3QTe0dzBAkEXe3eY+SZnpVpWvoZRN9DqQ08w6d2Dz8h0/p4XsBmRnYVH lpT1ztixbll42ThkLoHAGg1+iBIEjrelwLESnm42KNrOC6MYB26U9ygteSe5cXdeolb5 HdnwR9wDZbaZCR8Wr1uTo6t+Y/EyIfp2tRW2mciat5bht4TT1q/xu3JurSPk3g1hWI5L goRw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L7RDndfT; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5bbb2e705ffsi244924a12.680.2024.08.07.20.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 20:16:22 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L7RDndfT; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 30D3988AF6; Thu, 8 Aug 2024 05:15:00 +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="L7RDndfT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2CBA98873C; Thu, 8 Aug 2024 05:14:55 +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-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) (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 B78A48871A for ; Thu, 8 Aug 2024 05:14:51 +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-oa1-x2f.google.com with SMTP id 586e51a60fabf-2611da054fbso393890fac.1 for ; Wed, 07 Aug 2024 20:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723086890; x=1723691690; 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=lajTQ3JYoTyQySiuDMhbE4W09/EbwBdHGoc2IwlOBbU=; b=L7RDndfTf2X01URl93pc84NUFEuRt541PiZ4qjnuIgEf8o45P01aQ5l1hAYyxHYMxh KpxODW9kEEb6gRCC3dZ2UfuW4W1MUQcFJwOW5IqfETbngTedEWqeCemIwGhc3Fs2WxB8 9zhI0f7VftGFGJlAgAVMQuvCdEo/IliKAfawwP+TipvT2PNomCSAf75MkvDE3obbZ6jJ JPc7f64NpCdx3BYtbKaqruWQeoduPYXorJDrX24eR3anSyKIlPirelK3VoKlz63kNlmS U2qDRUnFLilL50244gXvkW4np4/ZIBQ2ueFE0RgLsQJqCY5ddqNCH5H6fgn4tptl24yK Q3TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723086890; x=1723691690; 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=lajTQ3JYoTyQySiuDMhbE4W09/EbwBdHGoc2IwlOBbU=; b=MIPYdEH/Yzc4hHxnpi5mxGY53rCAs50OM50xvcI7lwv9rbirY+PuJHVSFdKlB8Rd4s DyWsxPpgSxT2yvxggM1J2QLLb8dvBlQwgJ/slDlYqbFiujDc2llFZA2u+fT1f/jMRBSV 8ZtwTbMhX6tSS23ZA8l+OiJ5J9JIk60OnwhJsfnFeK2rD5aJqgmzNovMSv5DyRpqE9b/ OD3ZjLtMbJ653pqeTHw/LIiTzrwGxjvTdDBqFmgTyPZDpagEz0LhroQb4MGg2ad2dybe 163KWcYw9wu0iqdy5qqIem1EFjZsRAW8YQ3xkdYWaXTnAtrjYMvXwe9vsSkTW4Zvpm+N Ov0Q== X-Forwarded-Encrypted: i=1; AJvYcCU3nZIX+gR9nBOco+/QqEsluTpn3m4kiBv3iu7/lBkJ6dHcM+Wp1kAXjDI22sM9vvVZbT3oXfYOoN2xvpmxjXNID9zgsg== X-Gm-Message-State: AOJu0Yz9dLEGpIlgLlCWKuedhipIeZcCMBP7vmD3s6oe/ibUthwwJf2O st2Q4FI9i0oXsD4GE/a7nZvYr+w/SihR60VHNyxiBKNNOcttIm3GBwLBExdHjqo= X-Received: by 2002:a05:6870:d107:b0:260:fdd5:4147 with SMTP id 586e51a60fabf-2692b63ef02mr709416fac.15.1723086890236; Wed, 07 Aug 2024 20:14:50 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2689a2f1af9sm4379042fac.13.2024.08.07.20.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 20:14:49 -0700 (PDT) From: Sam Protsenko To: Minkyu Kang , Minkyu Kang , Jaehoon Chung Cc: Tom Rini , Henrik Grimler , Peng Fan , Simon Glass , Quentin Schulz , 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 v5 07/38] mmc: dw_mmc: Extract DMA transfer handling code into a separate routine Date: Wed, 7 Aug 2024 22:14:13 -0500 Message-Id: <20240808031444.9619-8-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240808031444.9619-1-semen.protsenko@linaro.org> References: <20240808031444.9619-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 --- Changes in v5: - (none) Changes in v4: - (none) Changes in v3: - (none) Changes in v2: - Added R-b tag from Quentin 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 b99f63a6f8bd..8fc26399034b 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -232,6 +232,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) { @@ -274,7 +301,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); @@ -382,26 +409,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);