Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10697061rwp; Fri, 21 Jul 2023 03:36:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlERKWNZHtHJHK4aKtfuJsYIavHpP3xlvbIlKudjUtLoHOQCao8ZvmLhLop7WnsYtTKph4Bt X-Received: by 2002:a05:6a21:7892:b0:117:3c00:77ea with SMTP id bf18-20020a056a21789200b001173c0077eamr2632767pzc.0.1689935806009; Fri, 21 Jul 2023 03:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689935805; cv=none; d=google.com; s=arc-20160816; b=jFUowVZhlUO30nwNnK1nZxHmsiHB19GqmCAFaWaEm7zAkYPvhsT44L2jCN1gaRayTC tD2C17j1ShXCJ4KNPI2rVnmicnT28adH0uspgMWi2aMseMC+Lwoy2e2rEL1WnG9WhnI2 oIdaYhprjL3jSSTs3CAAczgEYaFhEtYa6fjLmXxMnwbE0mQwhcS7c9uhzqom1MOsv2aw L5DL7IqEnBnsqCHJk3A6JVtZjzQAyhFvLG3OVbwPbRRoPdePQB+7Fxcqs6lylvv+2dIp KOeUDFY+hiv6GzyWZ+OSRUjRbtv/0XXQ3lDb4fWNWPUFiGpQTQs9K9NzypDWOTqfOVi9 sH+Q== 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=ApQkYa+7ITeXyR53N3Ps2jrm/Xu6rmALu2+c9eFoCWc=; fh=fI4q009785iZEQbMo9mPiCtk2O+O6Kfjq5womanK3eI=; b=dL6l0K9vZZ04j04Q4YBaYKb6oa5NuApMt/us7Nqhwh5bCpQpaq4KZMBO20es2JlpLl kSc/8qGfq5nuHpGbfRm0TSp4H9LQdQvyRIaeTpM01+Ck28s4OdAMmtYZ+3RGG+InULKJ i/6vUfyWUPYmYf4JDyJC+LdYo0T7B02WUkOm7/LcozEv96T2LShpb82xmwH5KzuLdElH wpTZ/721yQ2T6p1ry3omC6QGmZigkqYBf4sZdPAtR57Jj8Zcom5tx4qkYgGU9Ma9n/hI nPquMYGFYS86mKhKfcPKm4jqDn6KEhFlG3z236alNnTDqCIj2ZHcyo3OSqhvgACx/BlI YACQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="BHTLVZ5/"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a6-20020a056a000c8600b0068240c29150si2967130pfv.227.2023.07.21.03.36.33; Fri, 21 Jul 2023 03:36:45 -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="BHTLVZ5/"; 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 S229970AbjGUKPY (ORCPT + 99 others); Fri, 21 Jul 2023 06:15:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230263AbjGUKOp (ORCPT ); Fri, 21 Jul 2023 06:14:45 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 695CF1B6; Fri, 21 Jul 2023 03:14:44 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1b89b75dc1cso19654915ad.1; Fri, 21 Jul 2023 03:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689934484; x=1690539284; 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=ApQkYa+7ITeXyR53N3Ps2jrm/Xu6rmALu2+c9eFoCWc=; b=BHTLVZ5/psukcykFo5NaIXBP/SgwFIHbVRsSFQbtd7zlWCttq090qzNJGqVfV6TtHj TvwKAXqf/vsTgzodnh9c+eEafn0U8gc79tR5qk0HVzRxkMuqS+1oR/gGC+gmSUSnPfj7 COiSaD1GWspiC86SWqGcTojXdshjPhpdIOzhIwb/sCJ4HzGdzl7rMGGROvjp3WzopGMR 3SZiuyZA/g4TMXbtTQm0wQqSOzcM1IgfnyvF++0jrE7u9kw91GvgxJZGrcrJJ0tslxVW AodwAPJ44Gs4EPcYk0aVrh8Eof0Eggu2Cm/z+HbwTCa9SyG5ry3f430dF755W6vt4Gmd Mw5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689934484; x=1690539284; 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=ApQkYa+7ITeXyR53N3Ps2jrm/Xu6rmALu2+c9eFoCWc=; b=lcgXdgpVTU3rePtIKe69BxyKZXif+HLJsJhq/UTucHkAZaOB7C27B3U8fFwKnOu6qz HRh8kX8Fm5mK/ldOTZTacuYnq/Oyn6vi8Oz1PvdqnuaGMyWCwcspFTQrbTq1sMJb6xG8 oY6s61ZnW6Vl91LdvBE2lvd36cKRu0nGuLz7Mz8KiiMKgNUX4WJ0pqdv5WruMucrZN8A 1sbXqV8WUAmIHpxf33pIXVGHRUC7P/jpJIUQpuFsE4edFg1uNMutED20yMVk+CU6+yDv ZIrdkMcCtpvjNGA8z6EQ9nTD+QUlNyESlCcpdSz7Jfy0/1SHjMwj+TSaEnKhuScM5BKt 0gpQ== X-Gm-Message-State: ABy/qLa/jkYsxDxlc90FwEWj9rHRLN9L76n14n1mVpPt4w/ISWghFM8G IiP0gh3wdAQFduCZUPUAj5s= X-Received: by 2002:a17:902:b697:b0:1b9:d335:1740 with SMTP id c23-20020a170902b69700b001b9d3351740mr1858654pls.2.1689934483858; Fri, 21 Jul 2023 03:14:43 -0700 (PDT) Received: from localhost.localdomain (2001-b400-e23e-6b0d-6c46-3684-497a-06ee.emome-ip6.hinet.net. [2001:b400:e23e:6b0d:6c46:3684:497a:6ee]) by smtp.gmail.com with ESMTPSA id y1-20020a170902b48100b001b86492d724sm3050719plr.223.2023.07.21.03.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 03:14:43 -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 V9 10/23] mmc: sdhci-uhs2: add reset function and uhs2_mode function Date: Fri, 21 Jul 2023 18:13:36 +0800 Message-Id: <20230721101349.12387-11-victorshihgli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230721101349.12387-1-victorshihgli@gmail.com> References: <20230721101349.12387-1-victorshihgli@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_BLOCKED,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 From: Victor Shih Sdhci_uhs2_reset() does a UHS-II specific reset operation. Signed-off-by: Ben Chuang Signed-off-by: AKASHI Takahiro Signed-off-by: Victor Shih --- Updates in V8: - Adjust the position of matching brackets. Updates in V6: - Remove unnecessary functions and simplify code. --- 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 */ -- 2.25.1