From patchwork Tue Nov 10 14:20:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11894433 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 66BE8921 for ; Tue, 10 Nov 2020 14:21:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D3BC20809 for ; Tue, 10 Nov 2020 14:21:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="uMVYRaSD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730909AbgKJOVM (ORCPT ); Tue, 10 Nov 2020 09:21:12 -0500 Received: from www.zeus03.de ([194.117.254.33]:57726 "EHLO mail.zeus03.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730059AbgKJOVL (ORCPT ); Tue, 10 Nov 2020 09:21:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=8OLicZQ4BYdeYN CFQUqWfWQAugaY3wMaaYirved77f0=; b=uMVYRaSDHFpxGa94WvjhN/p1auOpdL K4olKpQsXE2zRe+OGuCqJLjaOS1Qo/lUVJLpYQmCBooeeJCeaQvW6u7nMNWMUOr+ Hf/lsMQZFe5qAzWODT8ZEHZU0/a9kO2D+resKtYFINa0D3PtEgsRhiJgUrhwFC+u +s9HneXtJ7OM0= Received: (qmail 2195616 invoked from network); 10 Nov 2020 15:21:09 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Nov 2020 15:21:09 +0100 X-UD-Smtp-Session: l3s3148p1@SzfdY8GzXMogAwDPXxAvAEQD26z+TKuA From: Wolfram Sang To: linux-mmc@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Wolfram Sang Subject: [RFC PATCH 1/4] mmc: renesas_sdhi: only reset SCC when its pointer is populated Date: Tue, 10 Nov 2020 15:20:55 +0100 Message-Id: <20201110142058.36393-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201110142058.36393-1-wsa+renesas@sang-engineering.com> References: <20201110142058.36393-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Only re-initialize SCC and tuning when an SCC was found during probe(). This is currently a noop because all R-Car Gen2+ are considered to have an SCC. But this will change in a later patch, so we need this preparation. Signed-off-by: Wolfram Sang Reviewed-by: Niklas Söderlund --- drivers/mmc/host/renesas_sdhi_core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index acb9c81a4e45..a395f835e836 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -556,16 +556,18 @@ static void renesas_sdhi_reset(struct tmio_mmc_host *host) { struct renesas_sdhi *priv = host_to_priv(host); - renesas_sdhi_reset_scc(host, priv); - renesas_sdhi_reset_hs400_mode(host, priv); - priv->needs_adjust_hs400 = false; + if (priv->scc_ctl) { + renesas_sdhi_reset_scc(host, priv); + renesas_sdhi_reset_hs400_mode(host, priv); + priv->needs_adjust_hs400 = false; - sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN | - sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL)); + sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN | + sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL)); - sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL, - ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN & - sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL)); + sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL, + ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN & + sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL)); + } if (host->pdata->flags & TMIO_MMC_MIN_RCAR2) sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, From patchwork Tue Nov 10 14:20:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11894443 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E98C21668 for ; Tue, 10 Nov 2020 14:21:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C060320867 for ; Tue, 10 Nov 2020 14:21:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="ByzJLg4e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730819AbgKJOVN (ORCPT ); Tue, 10 Nov 2020 09:21:13 -0500 Received: from www.zeus03.de ([194.117.254.33]:57746 "EHLO mail.zeus03.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730465AbgKJOVL (ORCPT ); Tue, 10 Nov 2020 09:21:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=AhBRC8nOnnNfZ3 gEQt+jO9KwYoIZByJQCL9SvzXz1Go=; b=ByzJLg4eJ6bO7dN2fCXprchWJOWB6t AlMe6yO8RhVMlKPUPgUVApweH5CXggNYl9I5oIeJ9u3KsQZPdZJYk4fbj+9D6FXN XoBe7iLlEHMbo9Sk1ktOxeqn81ihf1tySDoZKKa1+UvWfTBUXyTPoVGiHOxSGeFo msyCp+GfIxcmg= Received: (qmail 2195654 invoked from network); 10 Nov 2020 15:21:09 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Nov 2020 15:21:09 +0100 X-UD-Smtp-Session: l3s3148p1@ZiDjY8GzXsogAwDPXxAvAEQD26z+TKuA From: Wolfram Sang To: linux-mmc@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Wolfram Sang Subject: [RFC PATCH 2/4] mmc: renesas_sdhi: probe into TMIO after SCC parameters have been setup Date: Tue, 10 Nov 2020 15:20:56 +0100 Message-Id: <20201110142058.36393-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201110142058.36393-1-wsa+renesas@sang-engineering.com> References: <20201110142058.36393-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Setting up the SCC parameters does not need a probed TMIO device. But in the near future, probing the TMIO device needs the SCC parameters setup. So, fix the ordering. Signed-off-by: Wolfram Sang Reviewed-by: Niklas Söderlund --- drivers/mmc/host/renesas_sdhi_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index a395f835e836..17ebaa324ca1 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -1067,10 +1067,6 @@ int renesas_sdhi_probe(struct platform_device *pdev, quirks->hs400_calib_table + 1); } - ret = tmio_mmc_host_probe(host); - if (ret < 0) - goto edisclk; - /* Enable tuning iff we have an SCC and a supported mode */ if (of_data && of_data->scc_offset && (host->mmc->caps & MMC_CAP_UHS_SDR104 || @@ -1102,6 +1098,10 @@ int renesas_sdhi_probe(struct platform_device *pdev, host->ops.hs400_complete = renesas_sdhi_hs400_complete; } + ret = tmio_mmc_host_probe(host); + if (ret < 0) + goto edisclk; + num_irqs = platform_irq_count(pdev); if (num_irqs < 0) { ret = num_irqs; From patchwork Tue Nov 10 14:20:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11894439 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C4101746 for ; Tue, 10 Nov 2020 14:21:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49D9E20BED for ; Tue, 10 Nov 2020 14:21:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="XXy8V+di" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730703AbgKJOVN (ORCPT ); Tue, 10 Nov 2020 09:21:13 -0500 Received: from www.zeus03.de ([194.117.254.33]:57760 "EHLO mail.zeus03.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730783AbgKJOVM (ORCPT ); Tue, 10 Nov 2020 09:21:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=WPEWoLpcwsLE8K a4vlELROgQsuASC9VPEWSV868h1KY=; b=XXy8V+diaXLOL8RkkT6dpxnrIJVFMZ /Ron9o4e0E5HCzCy/1fTOMIIbK9tNtbJhZdVLtJSSZl7tK8yOyZpm0NsOjXTcJNR JCV7EaPnoTobv6n15C67oAMDpUg0Y9tgbb1lr76kEQeGPnyENKPf9sH94FghaAhW Msx9rxVNeCeck= Received: (qmail 2195699 invoked from network); 10 Nov 2020 15:21:09 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Nov 2020 15:21:09 +0100 X-UD-Smtp-Session: l3s3148p1@BwvpY8GzYMogAwDPXxAvAEQD26z+TKuA From: Wolfram Sang To: linux-mmc@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Wolfram Sang Subject: [RFC PATCH 3/4] mmc: renesas_sdhi: populate SCC pointer at the proper place Date: Tue, 10 Nov 2020 15:20:57 +0100 Message-Id: <20201110142058.36393-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201110142058.36393-1-wsa+renesas@sang-engineering.com> References: <20201110142058.36393-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The SCC pointer is currently filled whenever the SoC is Gen2+. This is wrong because there is a Gen2-variant without SCC (SDHI_VER_GEN2_SDR50). We have been lucky because the writes to unintended registers have not caused problems so far. But further refactoring work exposed the problem. So, move the pointer initialization to the place where we know that the SDHI instance supports tuning. And also populate the 'reset' pointer unconditionally to make sure the interrupt enable register is always properly set for Gen2+. Signed-off-by: Wolfram Sang Reviewed-by: Niklas Söderlund --- drivers/mmc/host/renesas_sdhi_core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index 17ebaa324ca1..4a1ed5bf216c 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -1007,11 +1007,7 @@ int renesas_sdhi_probe(struct platform_device *pdev, host->ops.start_signal_voltage_switch = renesas_sdhi_start_signal_voltage_switch; host->sdcard_irq_setbit_mask = TMIO_STAT_ALWAYS_SET_27; - - if (of_data && of_data->scc_offset) { - priv->scc_ctl = host->ctl + of_data->scc_offset; - host->reset = renesas_sdhi_reset; - } + host->reset = renesas_sdhi_reset; } /* Orginally registers were 16 bit apart, could be 32 or 64 nowadays */ @@ -1091,6 +1087,7 @@ int renesas_sdhi_probe(struct platform_device *pdev, if (!hit) dev_warn(&host->pdev->dev, "Unknown clock rate for tuning\n"); + priv->scc_ctl = host->ctl + of_data->scc_offset; host->check_retune = renesas_sdhi_check_scc_error; host->ops.execute_tuning = renesas_sdhi_execute_tuning; host->ops.prepare_hs400_tuning = renesas_sdhi_prepare_hs400_tuning; From patchwork Tue Nov 10 14:20:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11894435 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7C95138B for ; Tue, 10 Nov 2020 14:21:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D66D20809 for ; Tue, 10 Nov 2020 14:21:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="BA8M3EZE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730784AbgKJOVN (ORCPT ); Tue, 10 Nov 2020 09:21:13 -0500 Received: from www.zeus03.de ([194.117.254.33]:57772 "EHLO mail.zeus03.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730819AbgKJOVM (ORCPT ); Tue, 10 Nov 2020 09:21:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=CW6RZsSqYfdrES rVJQhiX+Wjfbk4vck8CaMzal04ZiY=; b=BA8M3EZEurE409xlsHCM42qfMyOU/Y 6xfvDxMOPIzbjrgJGBSz9b324+Sd6y+uZ5le6vN19A52532tc2PbI9bqC/wn+JIJ bi2Omiz6vhYubG0DzSnyXBBZeZtp6nsnMuxM35R6FyLB9wWQ68oI3ee+iH3VG6Co F4UWW8pvV2IUY= Received: (qmail 2195733 invoked from network); 10 Nov 2020 15:21:10 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Nov 2020 15:21:10 +0100 X-UD-Smtp-Session: l3s3148p1@xofuY8GzYsogAwDPXxAvAEQD26z+TKuA From: Wolfram Sang To: linux-mmc@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Wolfram Sang Subject: [RFC PATCH 4/4] mmc: renesas_sdhi: simplify reset routine a little Date: Tue, 10 Nov 2020 15:20:58 +0100 Message-Id: <20201110142058.36393-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201110142058.36393-1-wsa+renesas@sang-engineering.com> References: <20201110142058.36393-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The 'reset' pointer is only populated for Gen2+. So, we don't need to check for that flag inside the routine. Signed-off-by: Wolfram Sang Reviewed-by: Niklas Söderlund --- drivers/mmc/host/renesas_sdhi_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index 4a1ed5bf216c..1fabf8c5773c 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -552,6 +552,7 @@ static int renesas_sdhi_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_io return 0; } +/* only populated for TMIO_MMC_MIN_RCAR2 */ static void renesas_sdhi_reset(struct tmio_mmc_host *host) { struct renesas_sdhi *priv = host_to_priv(host); @@ -569,9 +570,7 @@ static void renesas_sdhi_reset(struct tmio_mmc_host *host) sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL)); } - if (host->pdata->flags & TMIO_MMC_MIN_RCAR2) - sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, - TMIO_MASK_INIT_RCAR2); + sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, TMIO_MASK_INIT_RCAR2); } #define SH_MOBILE_SDHI_MIN_TAP_ROW 3