From patchwork Sun Nov 10 15:40:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1192625 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="L2SqLq9l"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 479yrz5bGcz9sP4 for ; Mon, 11 Nov 2019 02:40:49 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 17262C21E1E; Sun, 10 Nov 2019 15:40:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 34C09C21C4A; Sun, 10 Nov 2019 15:40:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7D58FC21C4A; Sun, 10 Nov 2019 15:40:36 +0000 (UTC) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by lists.denx.de (Postfix) with ESMTPS id F3150C21C2C for ; Sun, 10 Nov 2019 15:40:35 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id a15so11959232wrf.9 for ; Sun, 10 Nov 2019 07:40:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MWJ1gxysSvzuEQ66RH32kfZOOScOYsIRZ/1sc95F4CI=; b=L2SqLq9lDcloT9cWLJB49wBTZTGhVbvL082+sXvT9aXd8RCQoTtcir07Yn2+yxsHGX 6zQdWM9ODJAO3pWmsTg0Ybz2OeQmXoze6qgUvd2qIDPZcJswqp74MGXYeseFFYzJJQu0 kJ+L9Eu1HMWBbBUFHRpiNwMr5Hqj6tZOlLkJwuLB0vLbVcSiaGAWnWUH8Y0AsL9yVzgh sbcyLyJ6oIWGWOqZeHJ/Er/m+uNKvKZKOH+KXLnRdTImRqqBDb/VSvGO8Mq05ttFu3yh +ZnGTKWMr6M43giB1Hywpvuj9j+75NOYZsaUVlGKnkJ5owiHYj9xcdQG1LnVYRHFUGSo GhxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MWJ1gxysSvzuEQ66RH32kfZOOScOYsIRZ/1sc95F4CI=; b=VLfve1var5EV6keR4eTQFpLSQxAKEvOvwX7ayoo+XqMsWM6xBRJ3xEUk7g+q3oC0P0 kqSmKalTJeWxiHSwtT5yRzARYMwHSLajKO0jBY75nNsGBaiijVif4LIN5kvv+ciSnV0G W2Z0+OZ3PRB6UxSM4axNvl6DzkoWyEsKun8b9XkdBjr/NRfzU2U3kX/+J13zK5aUIVmK cGqzBzBGL6FXKQWLQqvYnHXYEUmxSs3XY4xqXAJeORSSCc8DTFjRouJy1+0tRXPtYNJT wMqEtg+raTUjNLec7Iy3+WQ7MysNFNQwcJnSwPehpxs7Ihet0kUQSlDY+2ISeOseGapn iV7Q== X-Gm-Message-State: APjAAAVSMz0/mxADCLrzPuXTn1GjhzAWtaLtNBgqnQxRSfHlqfmlGNm+ cBTef2vSh3G61rkdYARLFKpT0HQ5Xns= X-Google-Smtp-Source: APXvYqwZcM77xOFxlwMcaxtEzWNfbI+Xv43MnzS3UhA8BZLX4tbQE+k+woRyIWul7Lt+gZKCB/c4RQ== X-Received: by 2002:adf:f386:: with SMTP id m6mr11090482wro.201.1573400435099; Sun, 10 Nov 2019 07:40:35 -0800 (PST) Received: from chi.lan (p578adb1c.dip0.t-ipconnect.de. [87.138.219.28]) by smtp.gmail.com with ESMTPSA id v10sm24948918wmg.48.2019.11.10.07.40.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2019 07:40:34 -0800 (PST) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Date: Sun, 10 Nov 2019 16:40:04 +0100 Message-Id: <20191110154012.24603-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.24.0.rc1 MIME-Version: 1.0 Cc: Marek Vasut Subject: [U-Boot] [PATCH 1/9] mmc: tmio: sdhi: Track current tap number in private data X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Retain the tap number from last calibration in private data. This will be later used for SCC error checking after each command. Signed-off-by: Marek Vasut Cc: Masahiro Yamada --- drivers/mmc/renesas-sdhi.c | 31 ++++++++++++++++--------------- drivers/mmc/tmio-common.h | 1 + 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c index 0cb65b480d..acc44e5b90 100644 --- a/drivers/mmc/renesas-sdhi.c +++ b/drivers/mmc/renesas-sdhi.c @@ -289,8 +289,7 @@ static unsigned int renesas_sdhi_compare_scc_data(struct tmio_sd_priv *priv) } static int renesas_sdhi_select_tuning(struct tmio_sd_priv *priv, - unsigned int tap_num, unsigned int taps, - unsigned int smpcmp) + unsigned int taps, unsigned int smpcmp) { unsigned long tap_cnt; /* counter of tuning success */ unsigned long tap_start;/* start position of tuning success */ @@ -307,14 +306,14 @@ static int renesas_sdhi_select_tuning(struct tmio_sd_priv *priv, tmio_sd_writel(priv, 0, RENESAS_SDHI_SCC_RVSREQ); /* Merge the results */ - for (i = 0; i < tap_num * 2; i++) { + for (i = 0; i < priv->tap_num * 2; i++) { if (!(taps & BIT(i))) { - taps &= ~BIT(i % tap_num); - taps &= ~BIT((i % tap_num) + tap_num); + taps &= ~BIT(i % priv->tap_num); + taps &= ~BIT((i % priv->tap_num) + priv->tap_num); } if (!(smpcmp & BIT(i))) { - smpcmp &= ~BIT(i % tap_num); - smpcmp &= ~BIT((i % tap_num) + tap_num); + smpcmp &= ~BIT(i % priv->tap_num); + smpcmp &= ~BIT((i % priv->tap_num) + priv->tap_num); } } @@ -327,7 +326,7 @@ static int renesas_sdhi_select_tuning(struct tmio_sd_priv *priv, ntap = 0; tap_start = 0; tap_end = 0; - for (i = 0; i < tap_num * 2; i++) { + for (i = 0; i < priv->tap_num * 2; i++) { if (taps & BIT(i)) ntap++; else { @@ -350,12 +349,12 @@ static int renesas_sdhi_select_tuning(struct tmio_sd_priv *priv, * If all of the TAP is OK, the sampling clock position is selected by * identifying the change point of data. */ - if (tap_cnt == tap_num * 2) { + if (tap_cnt == priv->tap_num * 2) { match_cnt = 0; ntap = 0; tap_start = 0; tap_end = 0; - for (i = 0; i < tap_num * 2; i++) { + for (i = 0; i < priv->tap_num * 2; i++) { if (smpcmp & BIT(i)) ntap++; else { @@ -378,7 +377,7 @@ static int renesas_sdhi_select_tuning(struct tmio_sd_priv *priv, select = true; if (select) - priv->tap_set = ((tap_start + tap_end) / 2) % tap_num; + priv->tap_set = ((tap_start + tap_end) / 2) % priv->tap_num; else return -EIO; @@ -419,15 +418,17 @@ int renesas_sdhi_execute_tuning(struct udevice *dev, uint opcode) /* Tuning is not supported */ goto out; - if (tap_num * 2 >= sizeof(taps) * 8) { + priv->tap_num = tap_num; + + if (priv->tap_num * 2 >= sizeof(taps) * 8) { dev_err(dev, "Too many taps, skipping tuning. Please consider updating size of taps field of tmio_mmc_host\n"); goto out; } /* Issue CMD19 twice for each tap */ - for (i = 0; i < 2 * tap_num; i++) { - renesas_sdhi_prepare_tuning(priv, i % tap_num); + for (i = 0; i < 2 * priv->tap_num; i++) { + renesas_sdhi_prepare_tuning(priv, i % priv->tap_num); /* Force PIO for the tuning */ caps = priv->caps; @@ -447,7 +448,7 @@ int renesas_sdhi_execute_tuning(struct udevice *dev, uint opcode) mdelay(1); } - ret = renesas_sdhi_select_tuning(priv, tap_num, taps, smpcmp); + ret = renesas_sdhi_select_tuning(priv, taps, smpcmp); out: if (ret < 0) { diff --git a/drivers/mmc/tmio-common.h b/drivers/mmc/tmio-common.h index 51607de142..da89cc90c2 100644 --- a/drivers/mmc/tmio-common.h +++ b/drivers/mmc/tmio-common.h @@ -138,6 +138,7 @@ struct tmio_sd_priv { #endif #if CONFIG_IS_ENABLED(RENESAS_SDHI) u8 tap_set; + u8 tap_num; u8 nrtaps; bool needs_adjust_hs400; bool adjust_hs400_enable;