From patchwork Mon Jul 22 17:57:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 813750 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1985397wro; Mon, 22 Jul 2024 10:59:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW958H6hjGHotZC5d7jyid3zQrhufizEjE3mAaxPIL341K+gJj/4kNb2OegwQDTCt1PUXCblqFJ94Yh3E2KRK+l X-Google-Smtp-Source: AGHT+IHum83AuqqGk/XUSyfnBmwJMvazvn095V8t9q7e3zZKgVYlg6vQjXrcIH+lMBjxuNZhldJl X-Received: by 2002:a05:6402:5246:b0:5a0:ec55:86dc with SMTP id 4fb4d7f45d1cf-5a478f6d638mr4666003a12.14.1721671150607; Mon, 22 Jul 2024 10:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721671150; cv=none; d=google.com; s=arc-20160816; b=x9XM448G3CsBb4O6Vk1XRfEbZkPtLyiKOJlONQ3Bk7ipfPFVeECu2g7pETHFyy/wNd ZifBNVTrBopoFhddhHLDvV7QVWxw4Tq5cA8uCTZP7FKDGZ4fysx49XClAtzxXMiQSYB9 9MsdKw+yICB8yDWiRvHNMIVzhb7tQM6VNnJwYjDRJAu8hy7jwnLyzyLJuGieuRqf3tAi atJUHnf1OIQ91MYnA9LMkIwgrIowjVfVktHPcWkLZRFRgpv43sKTw6VorbczpEPmtx8T 7BxnjHshpl40hSx0txDKcFmWekLgNMQ5aRpPIZwSCpnSwGds+uXLsgctn0zSgiLJ1eUn o7Fw== 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=ayKudOXUaJapN/875CebWt66dclSkxeyV6btsdEkOpE=; fh=8CA5dHUCMCgewYCtoyWhivE05QEr0dtiwUP6GXCWyFQ=; b=qb9D8x3Xa+qF2K0SklAga/OWXgQ9jPmvb+9IPHqg3RLfY6LtasuxXFK6psK81k/FtF HUCVB6Z7PyNprKhcG0N1dGHYAByLeXpyEqCwUTm25ouA5Z7pwA+euPuqrBYfvwWI7yjP Zb+HldOjQDc7DBeSBwsOP9P1JDHUGIkblpXvgsWSDfb8gjIVBvVLK2Q1UxD6+Y05+6d4 T/pMhuFizeVRuZAZHOyJQTJcv8ujWh+PDZK0tcJHdf07F0Vaou1Nrg9LHIT+oUzmq11H ytNLELmKN2EhJ7g3vayHrAjliorh6esV9eKpoviWSYPwCRT8wb2yasl1YagcFhwP0wxh nYXA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mPjuEyvS; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5a30c2f62besi4708018a12.463.2024.07.22.10.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 10:59:10 -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=mPjuEyvS; 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; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 76002885E4; Mon, 22 Jul 2024 19:57:53 +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="mPjuEyvS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D3A70885C5; Mon, 22 Jul 2024 19:57:50 +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-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) (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 ACE0188005 for ; Mon, 22 Jul 2024 19:57:48 +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-x2b.google.com with SMTP id 586e51a60fabf-25e397c51b2so2408968fac.3 for ; Mon, 22 Jul 2024 10:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721671067; x=1722275867; 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=ayKudOXUaJapN/875CebWt66dclSkxeyV6btsdEkOpE=; b=mPjuEyvSY2TthWyBlqanQKeZQ9v7umZMxOCfGGXeGnqQ74c0qQrQTQ22qowf2HVnTM EAF6soQHgyXtVHp0Y0huXbAydlnfL0IsMja1S2qAKfXDCDnFtIx12XfL2pDuQtTGKN6o WgW2UrgrpwSiMJucdYmB+6rZ6s2cJ33PbqWYrGkNR8HpAFWkUCBsysVv0bjTsuwnVfum ATjoNPHtvETnzMNTNYqG7oWT3Y91f7cuw8/KjLqbFYPIPLjQAiCvE8xWw3MwPlaXQVY4 SEs8+utUQXYpqwHc917mtlezMrySznScm5/g70b96J1+czS44B/g3vPJ/RAvGO6M3yWM XCoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721671067; x=1722275867; 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=ayKudOXUaJapN/875CebWt66dclSkxeyV6btsdEkOpE=; b=NhR41uBqeeHOgv74cDSe693vXDHoGZ/fSv2ARecJH6Qdb0iSpsrIwhqs2BGY8hgjRX AM2rsENvnVNJ6qHAy903MlzPuZustnYP2vmD4W33GZGvN2Vc6zOafS1YOUIgMLp3wYpb eTodCSLnShuzJHjY+cNiR7rhwZkqAKQhb4xtEA3tH56NJ2j2gCdvacHRvgnlP0YdoSY2 HZGY+sN1rl4m8hCqgRXoOwewGjPeY2GBnK/s9VC+V9Fbdn6IqA2CF9YiP4QLtARbLifj SXk5oOOYuFbfMrIWe9ggNFuEQTMLdUOUeTabBdQdPDW7U3u00j4bw92dDC+lXEeX47g2 SMBA== X-Forwarded-Encrypted: i=1; AJvYcCXVVYyVrp9amUb1oOlLproPFN4KbnNYh8RAV806tnM1I/oxCRfuALlX6dNE+YXl+Nb/dMZEvXgamzXBjn3xCwAtpz5vbQ== X-Gm-Message-State: AOJu0YwWEbP9dhMMPNc7odMwp5zhH+9knAGOh8AVlV0s/9ui3EOMq+dG sVqvP3fuDMu9Mfhdy0TLkPZocuL5kpkQeJN1jbNW/OzdICyARmXHATpuSrqkoZJ/JoKMl2IOVV1 o X-Received: by 2002:a05:6870:b61e:b0:25e:d90:fe78 with SMTP id 586e51a60fabf-26468fedc06mr413861fac.8.1721671067353; Mon, 22 Jul 2024 10:57:47 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2610c716fddsm1783083fac.8.2024.07.22.10.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 10:57:46 -0700 (PDT) From: Sam Protsenko To: Minkyu Kang , Minkyu Kang Cc: Tom Rini , Peng Fan , Jaehoon Chung , 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 v3 08/38] mmc: dw_mmc: Extract setting the DMA descriptor into a separate routine Date: Mon, 22 Jul 2024 12:57:10 -0500 Message-Id: <20240722175740.6985-9-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240722175740.6985-1-semen.protsenko@linaro.org> References: <20240722175740.6985-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_prepare_data() function easier to read by extracting the preparation of IDMAC descriptor into a dedicated function. No functional change. Signed-off-by: Sam Protsenko Reviewed-by: Quentin Schulz --- Changes in v3: - (none) Changes in v2: - Added R-b tag from Quentin drivers/mmc/dw_mmc.c | 52 ++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 7b20f4936b62..8bec43f0bd16 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -53,47 +53,57 @@ static void dwmci_set_idma_desc(struct dwmci_idmac *idmac, desc->next_addr = (ulong)desc + sizeof(struct dwmci_idmac); } -static void dwmci_prepare_data(struct dwmci_host *host, - struct mmc_data *data, +static void dwmci_prepare_desc(struct mmc_data *data, struct dwmci_idmac *cur_idmac, void *bounce_buffer) { - unsigned long ctrl; - unsigned int i = 0, flags, cnt, blk_cnt; + struct dwmci_idmac *desc = cur_idmac; ulong data_start, data_end; + unsigned int blk_cnt, i; - + data_start = (ulong)cur_idmac; blk_cnt = data->blocks; - dwmci_wait_reset(host, DWMCI_CTRL_FIFO_RESET); + for (i = 0;; i++) { + unsigned int flags, cnt; - /* Clear IDMAC interrupt */ - dwmci_writel(host, DWMCI_IDSTS, 0xFFFFFFFF); - - data_start = (ulong)cur_idmac; - dwmci_writel(host, DWMCI_DBADDR, (ulong)cur_idmac); - - do { - flags = DWMCI_IDMAC_OWN | DWMCI_IDMAC_CH ; - flags |= (i == 0) ? DWMCI_IDMAC_FS : 0; + flags = DWMCI_IDMAC_OWN | DWMCI_IDMAC_CH; + if (i == 0) + flags |= DWMCI_IDMAC_FS; if (blk_cnt <= 8) { flags |= DWMCI_IDMAC_LD; cnt = data->blocksize * blk_cnt; } else cnt = data->blocksize * 8; - dwmci_set_idma_desc(cur_idmac, flags, cnt, - (ulong)bounce_buffer + (i * PAGE_SIZE)); + dwmci_set_idma_desc(desc, flags, cnt, + (ulong)bounce_buffer + i * PAGE_SIZE); + desc++; - cur_idmac++; if (blk_cnt <= 8) break; blk_cnt -= 8; - i++; - } while(1); + } - data_end = (ulong)cur_idmac; + data_end = (ulong)desc; flush_dcache_range(data_start, roundup(data_end, ARCH_DMA_MINALIGN)); +} + +static void dwmci_prepare_data(struct dwmci_host *host, + struct mmc_data *data, + struct dwmci_idmac *cur_idmac, + void *bounce_buffer) +{ + unsigned long ctrl; + + dwmci_wait_reset(host, DWMCI_CTRL_FIFO_RESET); + + /* Clear IDMAC interrupt */ + dwmci_writel(host, DWMCI_IDSTS, 0xFFFFFFFF); + + dwmci_writel(host, DWMCI_DBADDR, (ulong)cur_idmac); + + dwmci_prepare_desc(data, cur_idmac, bounce_buffer); ctrl = dwmci_readl(host, DWMCI_CTRL); ctrl |= DWMCI_IDMAC_EN | DWMCI_DMA_EN;