From patchwork Fri Sep 15 09:43:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Shih X-Patchwork-Id: 140568 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1203328vqi; Fri, 15 Sep 2023 10:19:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHeu+mGzHow9A3+fIJJrz70v0PPvz9rKYvDhPssnt6USqgUuyM2dJF3BStGwkrxMcYF4/gI X-Received: by 2002:a05:6a21:998a:b0:14e:509:1d7b with SMTP id ve10-20020a056a21998a00b0014e05091d7bmr2668619pzb.8.1694798380047; Fri, 15 Sep 2023 10:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694798380; cv=none; d=google.com; s=arc-20160816; b=FaDnH6yl2/BLpQGr5lZ4/tbkH88rXJbikqtYB5JERHYJ30rMh00CcuoQaVlIaoki4k QTfEHvUYqvA0WcdzBZUYG/aGbCk6mWD0CCURYiQTD+IsP46hP/LE115rYy8XkGmgEENi kyenag78TAuElsjusgF5L8Y70IxnNo+MV1LDaKzpKV7Y3bstWpuY0MB7nlCTnLNhe0qD 2nj+rYZpjuI7S7cx35mk5h/FxijjSwjOnjWu5JgQTpnFCYedgN9ToqoKT0JBmtm4hRtA IH4oKFX57JuyGKK+X2tjSMu0fDQQnMoHIpl+kzjWd08CXdGd7I8V3qE2GN4f5vZd1b6n up1Q== 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=foX0JP3DAWSOOC0u2+6IXCRMxX6qZKC8TnZGDqevErY=; fh=y5fk6vguAkbcel7KoRWpitGO8B8BpGYTQpzSdaI/dY4=; b=y68e2/XkGJxN8sr/WII6KdhXoOD2iXRSisD4PLvaqL9/tCWLBo04frhtuM6ipd/kLG rXpgGT4YcmwVKaKfh6d/AIhbm6bc1ZztHTc02cuHRuCCSBjlk7LwuEJsTw+cmrcQn9zv XT3v1q3z0JF/EsFe1N5kMB1WFZsGM98yvt83rGWAb6O+GiY9H17QSKyI5J8wMbeaNdPY 4QXJptTl8lITFk56CTujqbI8I0t65Ep0NsCADfR3Q4Sctg1U/qc9PfORVY4iaoXbStYT 41sG1VntiQco4dZSJVUCoY1kVE1abbtjZAmXgY2kxALBmmWFNsayZ+BsxYLrKKXiH0Ow Lpmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="A/CJjLG2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e9-20020a6558c9000000b00565336a3cf5si3639307pgu.491.2023.09.15.10.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 10:19:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="A/CJjLG2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E216F81D477C; Fri, 15 Sep 2023 02:46:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233871AbjIOJpr (ORCPT + 32 others); Fri, 15 Sep 2023 05:45:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233922AbjIOJpi (ORCPT ); Fri, 15 Sep 2023 05:45:38 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1956B30EF; Fri, 15 Sep 2023 02:44:43 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-577f6205f42so1445820a12.1; Fri, 15 Sep 2023 02:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694771082; x=1695375882; darn=vger.kernel.org; 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=foX0JP3DAWSOOC0u2+6IXCRMxX6qZKC8TnZGDqevErY=; b=A/CJjLG2eR6JCiWFz2hsIwBqwkiZjXdDFjs9RF5bqrhkDpI+gf+LvMkERRJJG1od0w gOkqrOUa9U73aaN31+BCkm0bXOc5M4QWiVFJcajmE0WfHDR7r1ba/vzfQSG8M6CjcMyA ma54XhKjoMlRrzLM26RZcfcY2yOY4pYI1BQkMahqkUWScrL3I525BFy5zhk+1cPDbmqK hl9+5oV4xOy7vjeSF7ptLSFwUSibAZR9LambySRrF4dlxKbJgHTcQ4Ybr3CAXdN7tnso F5Taom4FDvOHX0yB9TzmdQ3XwmixwY97KFN9fO7pOxGaO6SpHMJPpGbHS4/Uefl5OvT6 gUFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694771082; x=1695375882; 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=foX0JP3DAWSOOC0u2+6IXCRMxX6qZKC8TnZGDqevErY=; b=JAmOVzlk8o9EjYuJtBlprqGiYnVxjT6ksXvhobL5yygcyDDWPRJIPJsaszp+JvLhkZ V8U2D1sJq9Ktos0ErRR7eWvRZQEQX4X2N3hrgg9+gXLIGcBi7N8ekqfwet/bui1WnmrU aTr5TaH3Ii/0Pg1Ct4HlSLwKbmULr5aRWxtFTTdZw3ZWn2jcGECiWQnAG+ks52b5mJYM m8rRp5KQvNGgwMfTazbd7PLI9RCPyY7syBNWjazXj2U3Keh3ZO7MidJbNGiKbobGIGte mETfh0tSG6he3RFmqifsZFIRrxyu5Kwfb3rv0wFqXokY/5WEFjC31KdYWsD0y2EnFc7r x7Rg== X-Gm-Message-State: AOJu0YzyX3yrudr9DgVRZRn26X/GejN8uSrRECii9XCKBazYbAv04TSO ZVR7KDbB/m7/BSUWr/rlMWY= X-Received: by 2002:a17:90a:1fc8:b0:26b:2538:d717 with SMTP id z8-20020a17090a1fc800b0026b2538d717mr907420pjz.25.1694771082557; Fri, 15 Sep 2023 02:44:42 -0700 (PDT) Received: from localhost.localdomain (2001-b400-e2a6-6d77-d32f-f490-6688-3d32.emome-ip6.hinet.net. [2001:b400:e2a6:6d77:d32f:f490:6688:3d32]) by smtp.gmail.com with ESMTPSA id x4-20020a17090a530400b0025023726fc4sm4432794pjh.26.2023.09.15.02.44.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 02:44:42 -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 V12 16/23] mmc: sdhci-uhs2: add clock operations Date: Fri, 15 Sep 2023 17:43:44 +0800 Message-Id: <20230915094351.11120-17-victorshihgli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915094351.11120-1-victorshihgli@gmail.com> References: <20230915094351.11120-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 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 15 Sep 2023 02:46:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777124905665379265 X-GMAIL-MSGID: 1777124905665379265 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 Acked-by: Adrian Hunter --- 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 *