From patchwork Wed Jun 21 10:01:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Shih X-Patchwork-Id: 110949 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4253208vqr; Wed, 21 Jun 2023 03:15:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4rnGdWjFMoKCWmXWKID+OIiCqpAPrlp/W6jlB68VA0EtGK9TNjF0/tAtMbNz7/qx8FHdi8 X-Received: by 2002:a05:6a21:788a:b0:121:e787:f5c3 with SMTP id bf10-20020a056a21788a00b00121e787f5c3mr6243244pzc.54.1687342517708; Wed, 21 Jun 2023 03:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687342517; cv=none; d=google.com; s=arc-20160816; b=E3Wg/RG94v21fm67uv1DnqEysGc7KvBW4ys2Xxulv3ra8hYGJT5Lf1mHhpoSNsqF0g tYeDuTPzy5Pw9FNgKz9rptQXnHMZZax0jN5A6AxvVCLwhRqChDGWLvBCHyWNIz8ndNH+ Jwov/uY2IXWPgsuZd1/eMAvZWcEgS2+the3hhJcrwEEqUOy9dJcPSyXY366wgpF3/cUY 15chQW2qSWI/4MCNCAPe5GpJF8l42Mb+uvx/7gZQ4Vn0T/3Bh+M5IPboFtoMii+aNoo9 SKGxBJgHPoXfeEi+j4fG8YEl0yXSSgf1mdB+kq5cnc3254RbV+Vsk22HH2UUqjrneUPq j2ow== 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 :dkim-signature; bh=MQhkkbl220OOjmhEpbjmN1GSLiQ0H1N57oOo51T5Ous=; b=Fddyx1XRdhnIv0O9ea5QUrlUTyb8B4CTcLxB/3xGemubspp0S/CWOO0ZLoY9wnb63I snrlROAxwsEFsPbqeDTtW8q1ocqmmppw2GwoOeOA8Ff/pBtwq78miExesC4CBcTRSsck SToFjfnIlRoE4m974Y9HEOCcfcmBPC+ibCeLtKu7kDv04jfXrIyR13BjqevxZvQQBsEr CtjEycf5kEbQ7rw4xgrSxBR2+GcCa0pXg59IJ3RYDseNv2m04FGionty5gQNoM8k3/bn /fqogfezLF8MA5qZBpqB1+EJ3Ol6EeynfgMh7Mg9uLv3BPMOPIdzvs+CdyEGN5byGhrQ 5rwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=QVTWyJCb; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a63b941000000b0054fe6828cf4si3612625pgo.725.2023.06.21.03.15.04; Wed, 21 Jun 2023 03:15:17 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20221208 header.b=QVTWyJCb; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232225AbjFUKEO (ORCPT + 99 others); Wed, 21 Jun 2023 06:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232192AbjFUKCx (ORCPT ); Wed, 21 Jun 2023 06:02:53 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBAC5E9; Wed, 21 Jun 2023 03:02:29 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-666683eb028so3316146b3a.0; Wed, 21 Jun 2023 03:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687341749; x=1689933749; 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=MQhkkbl220OOjmhEpbjmN1GSLiQ0H1N57oOo51T5Ous=; b=QVTWyJCbzzhjmuaK6eykFkwHGjyw6KN4VVDYmMR1GShhh28cG0mNUIS/GD4kcOn67c 7AQk3qZMoRAO3ewrQ4TUZK19NXLLutPYqsXzmafon9WkZ4gGjoVHRCF2QHmN9kvvnmwK OtXVtIgrRREQygVgKc443VhZ7X1UT/xoHftOLoucZYNbMxay0F0BfZyRgmFd4XSOaaz0 fCqx68niLJaZs/b0/ZNEmM4kO9QuaRYC6Qo3xUO5QRnUfGtyARDzNs+ksgTUOutGrwwX JqLILGn0rh8bejxJtWET91LQuL+gCO4mdUu6WODqoG43YYSHVg/Exk81EeOKTG3rWZ5h La9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687341749; x=1689933749; 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=MQhkkbl220OOjmhEpbjmN1GSLiQ0H1N57oOo51T5Ous=; b=F/y+d7CDbP2hxH33JHvOJ7F4+cKQVH4hFqrN+wRWVVSc7lVnEWagg0/gEbz01csbGM 32VFqJyKpZ0kTR9LsJinbx5LuPmPgRKuHfmCs22JUH1kGd7NH5bJ++mjBOQsyPOyW3hU gS+3gEHnt1xfcQeR6mDL0+iV7QwtX9I9UQTSRRf9SaL6QsH+NnOiU2CQzSdbB1FKnS7S uBiNCeAA3atLcyVyKgqvMyfYhJaB/Lxp6/4vh/KxewzeywV84RXITmtE8PfPqF09V7e7 u4D6BEFP4+4dIz8cQ8yEg0s8zsDNXXtd6jPqL4VLB+yJgtGVBWX2njJXfnckL+FrXWcs PQzg== X-Gm-Message-State: AC+VfDwW5ePsBIwWrib9c8QXmY7zdb8PJouWOW/vnJ98BGrvsIE6op6L kpwyHuQascc0GmZFOnX7flg= X-Received: by 2002:a05:6a21:999d:b0:120:6b8e:9033 with SMTP id ve29-20020a056a21999d00b001206b8e9033mr7862832pzb.22.1687341749208; Wed, 21 Jun 2023 03:02:29 -0700 (PDT) Received: from localhost.localdomain (2001-b400-e254-4eda-2716-05ea-20f5-b048.emome-ip6.hinet.net. [2001:b400:e254:4eda:2716:5ea:20f5:b048]) by smtp.gmail.com with ESMTPSA id g2-20020aa78742000000b0064f46570bb7sm2611196pfo.167.2023.06.21.03.02.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 03:02:28 -0700 (PDT) From: Victor Shih To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, benchuanggli@gmail.com, HL.Liu@genesyslogic.com.tw, Greg.tu@genesyslogic.com.tw, takahiro.akashi@linaro.org, dlunev@chromium.org, Victor Shih , Ben Chuang , Victor Shih Subject: [PATCH V8 10/23] mmc: sdhci-uhs2: add reset function and uhs2_mode function Date: Wed, 21 Jun 2023 18:01:38 +0800 Message-Id: <20230621100151.6329-11-victorshihgli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230621100151.6329-1-victorshihgli@gmail.com> References: <20230621100151.6329-1-victorshihgli@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1769306867557946215?= X-GMAIL-MSGID: =?utf-8?q?1769306867557946215?= From: Victor Shih Sdhci_uhs2_reset() does a UHS-II specific reset operation. Updates in V8: - Adjust the position of matching brackets. Updates in V6: - Remove unnecessary functions and simplify code. Signed-off-by: Ben Chuang Signed-off-by: AKASHI Takahiro Signed-off-by: Victor Shih --- drivers/mmc/host/sdhci-uhs2.c | 45 +++++++++++++++++++++++++++++++++++ drivers/mmc/host/sdhci-uhs2.h | 2 ++ 2 files changed, 47 insertions(+) diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c index e339821d3504..dfc80a7f1bad 100644 --- a/drivers/mmc/host/sdhci-uhs2.c +++ b/drivers/mmc/host/sdhci-uhs2.c @@ -10,7 +10,9 @@ * Author: AKASHI Takahiro */ +#include #include +#include #include "sdhci.h" #include "sdhci-uhs2.h" @@ -49,6 +51,49 @@ void sdhci_uhs2_dump_regs(struct sdhci_host *host) } EXPORT_SYMBOL_GPL(sdhci_uhs2_dump_regs); +/*****************************************************************************\ + * * + * Low level functions * + * * +\*****************************************************************************/ + +bool sdhci_uhs2_mode(struct sdhci_host *host) +{ + return host->mmc->flags & MMC_UHS2_SUPPORT; +} + +/** + * sdhci_uhs2_reset - invoke SW reset + * @host: SDHCI host + * @mask: Control mask + * + * Invoke SW reset, depending on a bit in @mask and wait for completion. + */ +void sdhci_uhs2_reset(struct sdhci_host *host, u16 mask) +{ + unsigned long timeout; + u32 val; + + sdhci_writew(host, mask, SDHCI_UHS2_SW_RESET); + + if (mask & SDHCI_UHS2_SW_RESET_FULL) + host->clock = 0; + + /* Wait max 100 ms */ + timeout = 100000; + + /* hw clears the bit when it's done */ + if (read_poll_timeout_atomic(sdhci_readw, val, !(val & mask), 10, + timeout, true, host, SDHCI_UHS2_SW_RESET)) { + pr_err("%s: %s: Reset 0x%x never completed.\n", __func__, + mmc_hostname(host->mmc), (int)mask); + pr_err("%s: clean reset bit\n", mmc_hostname(host->mmc)); + sdhci_writeb(host, 0, SDHCI_UHS2_SW_RESET); + return; + } +} +EXPORT_SYMBOL_GPL(sdhci_uhs2_reset); + /*****************************************************************************\ * * * Driver init/exit * diff --git a/drivers/mmc/host/sdhci-uhs2.h b/drivers/mmc/host/sdhci-uhs2.h index 2bfe18d29bca..8253d50f7852 100644 --- a/drivers/mmc/host/sdhci-uhs2.h +++ b/drivers/mmc/host/sdhci-uhs2.h @@ -177,5 +177,7 @@ struct sdhci_host; void sdhci_uhs2_dump_regs(struct sdhci_host *host); +bool sdhci_uhs2_mode(struct sdhci_host *host); +void sdhci_uhs2_reset(struct sdhci_host *host, u16 mask); #endif /* __SDHCI_UHS2_H */