From patchwork Wed Jan 25 01:01:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 13114937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ABEE4C38142 for ; Wed, 25 Jan 2023 01:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=db/JvSRRPPrcDGIjmHQoPbSzuJl3ZsZA4BXHUlHb2kw=; b=ILs+XhmJ+hZw5z DU7bW17O15Cew6uCMkvHBUUJqPli8ae3D/lSmKJYXdmVtFJrE6OyRakXpcsZwYI5dUaf7CPIyN60j 0gPWn/9CVsLVXSJBFrULOjs/O2oAjUCrZLJ/ADIcpiMmRvwLVecrPAj5wbSyVzEsE6FnvfGGCXUS4 Ezi3VrgztrIBE2D6h/wtC8M+xVAJtfSiEpFXnbx4TuPEtVN0Xn/iCapkSR1pB0J0QevGN0tNy/Gij leTJmEqW0qkDdp6IXJHx9MOM8gXcTTG33yjljKBs/9+E8tselGvYB8G7x2vXDenEKmx/L7bA570n6 YQX+PX98xHOMcbbodDkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKUBo-005li6-8T; Wed, 25 Jan 2023 01:03:00 +0000 Received: from mx.socionext.com ([202.248.49.38]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKUBT-005lYa-9A for linux-arm-kernel@lists.infradead.org; Wed, 25 Jan 2023 01:02:45 +0000 Received: from unknown (HELO iyokan2-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 25 Jan 2023 10:02:16 +0900 Received: from mail.mfilter.local (m-filter-1 [10.213.24.61]) by iyokan2-ex.css.socionext.com (Postfix) with ESMTP id AFF9D2058B4F; Wed, 25 Jan 2023 10:02:16 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Wed, 25 Jan 2023 10:02:19 +0900 Received: from plum.e01.socionext.com (unknown [10.212.243.119]) by kinkan2.css.socionext.com (Postfix) with ESMTP id 118003D53; Wed, 25 Jan 2023 10:02:16 +0900 (JST) From: Kunihiko Hayashi To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Masami Hiramatsu Cc: linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi Subject: [PATCH 3/5] mmc: uniphier-sd: Add control to switch UHS speed Date: Wed, 25 Jan 2023 10:01:59 +0900 Message-Id: <20230125010201.28246-4-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230125010201.28246-1-hayashi.kunihiko@socionext.com> References: <20230125010201.28246-1-hayashi.kunihiko@socionext.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_170239_459655_8CBB23CF X-CRM114-Status: GOOD ( 14.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org SD interface logic has the register to switch UHS speed. The default is up to SDR25 and to support SDR50 or faster, add uniphier_sd_speed_switch() function to switch the speed mode. Signed-off-by: Kunihiko Hayashi --- drivers/mmc/host/uniphier-sd.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/mmc/host/uniphier-sd.c b/drivers/mmc/host/uniphier-sd.c index c9766d6a690f..61acd69fac0e 100644 --- a/drivers/mmc/host/uniphier-sd.c +++ b/drivers/mmc/host/uniphier-sd.c @@ -54,6 +54,7 @@ #define UNIPHIER_SDCTRL_CHOFFSET 0x200 #define UNIPHIER_SDCTRL_MODE 0x30 #define UNIPHIER_SDCTRL_MODE_UHS1MOD BIT(15) +#define UNIPHIER_SDCTRL_MODE_SDRSEL BIT(14) /* * IP is extended to support various features: built-in DMA engine, @@ -429,6 +430,25 @@ static void uniphier_sd_hw_reset(struct mmc_host *mmc) usleep_range(300, 1000); } +static void uniphier_sd_speed_switch(struct tmio_mmc_host *host) +{ + struct uniphier_sd_priv *priv = uniphier_sd_priv(host); + unsigned int offset; + u32 val = 0; + + if (!(host->mmc->caps & MMC_CAP_UHS)) + return; + + if (host->mmc->ios.timing == MMC_TIMING_UHS_SDR50 || + host->mmc->ios.timing == MMC_TIMING_UHS_SDR104) + val = UNIPHIER_SDCTRL_MODE_SDRSEL; + + offset = UNIPHIER_SDCTRL_CHOFFSET * priv->sdctrl_ch + + UNIPHIER_SDCTRL_MODE; + regmap_write_bits(priv->sdctrl_regmap, offset, + UNIPHIER_SDCTRL_MODE_SDRSEL, val); +} + static void uniphier_sd_uhs_enable(struct tmio_mmc_host *host, bool uhs_en) { struct uniphier_sd_priv *priv = uniphier_sd_priv(host); @@ -459,6 +479,8 @@ static void uniphier_sd_set_clock(struct tmio_mmc_host *host, tmp &= ~CLK_CTL_SCLKEN; writel(tmp, host->ctl + (CTL_SD_CARD_CLK_CTL << 1)); + uniphier_sd_speed_switch(host); + if (clock == 0) return;