From patchwork Fri Jul 21 10:13:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Shih X-Patchwork-Id: 123768 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp113519vqg; Fri, 21 Jul 2023 03:44:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlEWbtIn54QeZg7eeeBm9ielhj4QIUauaXSSiPrl3GpuzJAb2jWTy633XUwsIDMLCmhAZ9rr X-Received: by 2002:a17:902:ecc9:b0:1b8:8702:1e7c with SMTP id a9-20020a170902ecc900b001b887021e7cmr3145842plh.33.1689936255815; Fri, 21 Jul 2023 03:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689936255; cv=none; d=google.com; s=arc-20160816; b=lSf/mjmIqPlO977BWIm/3ZNTf8MqGI/us86iRwRpPaTjmXz3WpC1+/WR2fr8YVqEeP BMpKAb3K4cvcNjzPqRL6ncsVn5Dyx2W+gZz3phVhNwsvh9Yb4atxSHdxJDiIPLySBH4a f60lmSDbVoPw34G3mAOE3JX6ZROmQ4Gl6CPaVT3j7/B42st0Jfm+iBHRObxsVxX5AwCG aZG2+EAod3nkwNUvem0tr8+GjJqWbZBYuPvFn51Q7vfytfMYuNYFzWBAgMnQRj3gTp9I Eo9hgtxA7bW7VdKsBk5Svwv75f0M6hk9kS7i/jMD1PVe7dB7A292InslXvrQNmb7oY+Y Su4Q== 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=nrhnPYVVEOXhcGUIlQiYMK3xWKJ+IT6xWZbZF9JpGsE=; fh=fI4q009785iZEQbMo9mPiCtk2O+O6Kfjq5womanK3eI=; b=mmArqpZ061cO83mUsnBOJvf4Kl2nTQi2JUcNbbpFrPBnWLk7XmazIdKpbcGflN7KXj Xg1g9wdvJ+P5Ska46NUVc4hwvKlVEvDb4j3JKf/4ZLgGD1LqCzgvQ6WW0j9RBQj2j5Pq SvCDHS8Gve0Yt2YYLfdU1nQyaTiFDWiMrhgI3SFjZmnFE4+6Vg+i3mc3aM5U5dwEsAJC ZKKx8p3NwzP44e+eF5NfMrR8hjQIihgMc0BSH83IS+TaZixnJHS5rg3dYLvDika5cAWr xL8r/CxbhxgK+kNk0XcJPd1ZIPGR/y6LHezAqhtebZfz5i9GzQ1n3YsSbPNfPQQWVDOj 9edw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=oNe5fTzl; 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 w4-20020a170902e88400b001b8a67f1c10si2891334plg.468.2023.07.21.03.44.02; Fri, 21 Jul 2023 03:44:15 -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=oNe5fTzl; 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 S231893AbjGUKQl (ORCPT + 99 others); Fri, 21 Jul 2023 06:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232026AbjGUKQM (ORCPT ); Fri, 21 Jul 2023 06:16:12 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6401830F5; Fri, 21 Jul 2023 03:15:18 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1b852785a65so12742225ad.0; Fri, 21 Jul 2023 03:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689934504; x=1690539304; 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=nrhnPYVVEOXhcGUIlQiYMK3xWKJ+IT6xWZbZF9JpGsE=; b=oNe5fTzlTyIkjHKhCVUDLn812lys3fEawVuUMM7mlDn6Rw9Bvqwi8QLMuPQHraazYa Sk3O51eIyDxtGVVyEKqTIirb9NMd6i2RD4vW4z++Qnkbi9zMjHNSJ1aJIo50OoiEwWdD DFXyOdoA7kKfRsz1riUNXVPLzZh5UdjBgfYuQaJUWD4lqN5fTqS8ho43fvWNiTC9Kr6R /Dp6+za1MGYSNSuM6g7AcI+QygwBfg8C8QKyyG+q1eP1aPWRrZ0clFCdNBjEreESBXBW ONdwHUaMDsULsnlmCEljaEdpDwkh6U87AnBlzdJovOukFDxR5Ebbq677k9yoJBaAegMp 9/lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689934504; x=1690539304; 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=nrhnPYVVEOXhcGUIlQiYMK3xWKJ+IT6xWZbZF9JpGsE=; b=jbQcYxF7RWQ5E8rtwnoadxxehiDv22tfLqSi5jNOaXpnJCYEOiaPZbrxwvsUEiM39c EZITQgpouBBIgK3T9K63sAET6emaVDqwWi/J3vs5FxhsSI8QSOixcPVRE/P+CYMXOR7r f+yXjKsOrOahRyvXhe9GnRTtX0plzx3bJn+oNYvlNzF5urkxaraMfikEjfxJI5jtTIjE LmTUyz9Tr1k4RfuEhNR8huIPqVQd+dHKB90XzqAIeKirSzARQ7xLIwafDzD4CPcDTghi 1cw5oj5X0QGgJgQ573AXVo3Xw5EkQ/YIL/uHuVZS+5m/IQPpCr9Q48B+IVU34qwDhplc dDVg== X-Gm-Message-State: ABy/qLa1vKPh0nD+OVJiJzLWc0dS+YQjhebO/Ep3VhO3z8hEdSmDszFN urBO7xXYXYIUv2n1HL2X9kA= X-Received: by 2002:a17:902:ea0a:b0:1b0:3d03:4179 with SMTP id s10-20020a170902ea0a00b001b03d034179mr1901228plg.6.1689934504401; Fri, 21 Jul 2023 03:15:04 -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.15.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 03:15:04 -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 16/23] mmc: sdhci-uhs2: add clock operations Date: Fri, 21 Jul 2023 18:13:42 +0800 Message-Id: <20230721101349.12387-17-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 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: INBOX X-GMAIL-THRID: 1772026599255612291 X-GMAIL-MSGID: 1772026599255612291 From: Victor Shih This is a sdhci version of mmc's uhs2_[enable|disable]_clk operations. Signed-off-by: Ben Chuang Signed-off-by: AKASHI Takahiro Signed-off-by: Victor Shih --- Updates in V8: - Remove unnecessary include file. - read_poll_timeout() to instead of read_poll_timeout_atomic() in sdhci_uhs2_enable_clk(). - Put the comment on the end and put the lines in descending line length in sdhci_uhs2_enable_clk(). - Modify return value in sdhci_uhs2_enable_clk(). Updates in V6: - Remove unnecessary functions. --- drivers/mmc/host/sdhci-uhs2.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c index 4c2a56629ab3..af1b0c5e48fd 100644 --- a/drivers/mmc/host/sdhci-uhs2.c +++ b/drivers/mmc/host/sdhci-uhs2.c @@ -329,6 +329,36 @@ static int sdhci_uhs2_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) return 0; } +static int sdhci_uhs2_disable_clk(struct mmc_host *mmc) +{ + struct sdhci_host *host = mmc_priv(mmc); + u16 clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); + + clk &= ~SDHCI_CLOCK_CARD_EN; + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); + + return 0; +} + +static int sdhci_uhs2_enable_clk(struct mmc_host *mmc) +{ + struct sdhci_host *host = mmc_priv(mmc); + u16 clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); + int timeout_us = 20000; /* 20ms */ + u32 val; + + clk |= SDHCI_CLOCK_CARD_EN; + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); + + if (read_poll_timeout(sdhci_readw, val, (val & SDHCI_CLOCK_INT_STABLE), + 10, timeout_us, true, host, SDHCI_CLOCK_CONTROL)) { + pr_err("%s: Internal clock never stabilised.\n", mmc_hostname(host->mmc)); + sdhci_dumpregs(host); + return -EIO; + } + return 0; +} + /*****************************************************************************\ * * * Driver init/exit *