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: 47990 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp24054wrn; Tue, 24 Jan 2023 17:03:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXsrc9W4fVnSVYx4qmw7oFb3H1LdmXUjpzNc9oyFAgjhPJlZPAbK4wwEK6F0ylgfK9odJ57L X-Received: by 2002:a17:906:33cb:b0:86d:7c0e:c816 with SMTP id w11-20020a17090633cb00b0086d7c0ec816mr39098031eja.27.1674608630649; Tue, 24 Jan 2023 17:03:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674608630; cv=none; d=google.com; s=arc-20160816; b=FFkMicuEE+CixnX9lez/+AfOrjda16f/yzkT1w3HlI8tUmz5wlh2yqFM/s7vQwm7SX KrP3+1SWV1h9d9gVnQAoiQNtFEcJm+hz19zEu8WytBsGUzjuIAzWm5s798FNDnKi28KO a/5fuVpEf1lCl6b9xZ4Hqebk3kuEYck9ywaJ3zEfZBd2z0GeS0k740Crq5EJhA9ACc/m wXsRlxc5W1SEeQg3THbI+yuj8p7a8PqiNwZ4Nd48H61JWpYMhIz0/ZMMNhe0hWHwnBZq uGZ0vlIyTSqDi07v7hWGsQgWR38ehPTEw395bncEmicXx/2fPfp2DDXEe/RYcS6/CviG PEQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3zBaZEyihAqxr1i26nZHCjJOLkvwI8vCNLkQ7k0OP80=; b=lgydld1CUvRk3/Dx/ukiTgkJoAb0ZYD9xxCsFX3om5AcX53tg8OyZl4Lo26FvjGWym CFngsY/IpTwxhs3ixMoneD66Ev7SfarrSoiROLaBLd0aHbkGIkI9YepwEf0sTUx4H/wZ tlxIsd1/08ey7z0W86joSLQT/uwFKzo3f3B+xpy5PiksYpFaqHp2tAX3pFceYXCItn5s lk7/1aVvhRb5pEiGlT1BGJxqzoDqPhHuKS+krxzcWDudVNjEKrH06meiC1tjQ15eUpL4 RCJ7Qz0n8npptl4wncP5mpDOe1+fUvpnRMF39xtSxh4U3PwuWPJwPl0mz5oNrhxbFrNw VGdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vl7-20020a17090730c700b0084d4b90896fsi3634867ejb.245.2023.01.24.17.03.22; Tue, 24 Jan 2023 17:03:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234640AbjAYBC2 (ORCPT + 99 others); Tue, 24 Jan 2023 20:02:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234403AbjAYBCY (ORCPT ); Tue, 24 Jan 2023 20:02:24 -0500 Received: from mx.socionext.com (mx.socionext.com [202.248.49.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C7572330B; Tue, 24 Jan 2023 17:02:17 -0800 (PST) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755954419414249706?= X-GMAIL-MSGID: =?utf-8?q?1755954419414249706?= 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;