From patchwork Mon Oct 17 09:11:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Shih X-Patchwork-Id: 3315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1347826wrs; Mon, 17 Oct 2022 02:18:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6r3C48uGh1z3FXX6XopYcv4w86wBNlgcfulgPn2QXth20AjouZ2R3fJCHG6hP8Otgg+REs X-Received: by 2002:a17:902:be18:b0:178:b9c9:97b8 with SMTP id r24-20020a170902be1800b00178b9c997b8mr10685756pls.38.1665998311692; Mon, 17 Oct 2022 02:18:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665998311; cv=none; d=google.com; s=arc-20160816; b=HZvLCGcRciWKoJ/2V4dU8NyQKWYwAIKPcipQZqWpiAT5e80ODaDYadTKWoL4yeWZ+0 TcNLW/wX++PaIAPC/jUG5guzMxRteUljp+VdNcR1yMBfqO5PyWcQWXqrf7zMe95a4JXj KdWE2TK0tTrSJygoEVL/uAPlgh1UcDtQtDSBIEbHVmH+Chy5HTneq6mkL1d0rRlIwAjc dWLN9G/Q+lGJcadTs+Tar5SriSkocYCJy4oTN4v6jSekao+ROYV+ydXC6M1yED/IhWqX lSLstTORasA7IaraCBLhmoGiUf8MqhG7Grab8ankDEOWJ/mecJyAa9L+ic+XBn7bD7Hv 8FMw== 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=tA2UmIKVuRoeoJ0BqAsA6/5RpJhUljcvAx2HKfeYlvY=; b=snuf3VOqh7lyYeZMYGLn+yLbL5Agf8M19UpdZBgq2nVoWwdEIrWaiJYIUWh6ciqDlt TzXGL3t8/+37FsM0H9HW6b3vXSjCzgYOf4VonXm1AXph1y5cAgRHqw53J5e5X3VYJY9l 4pIb0usqi33PVVMqZ9L5wT9UrKwa1zPB3gJ6N6PwgVkGqx0V3//mp16VYiXQpyCivNQ1 PqhKqWVoOoo+EHw888MeHczvzGf0SptRK2sBLcJkbNa7SnENA4SLLgS8cw6E4rP2kKBs a2FaTGUob/ufjz+6NsQcFx+RMj22aUMl+5G42gjzMMxRu74IimzlmuOW7IrMrSsumZkn tJaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Sr4PYEf5; 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 t18-20020a170902e85200b0017f77922b11si13584685plg.84.2022.10.17.02.18.18; Mon, 17 Oct 2022 02:18:31 -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=20210112 header.b=Sr4PYEf5; 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 S231241AbiJQJOW (ORCPT + 99 others); Mon, 17 Oct 2022 05:14:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231134AbiJQJN2 (ORCPT ); Mon, 17 Oct 2022 05:13:28 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C6F14D4D2; Mon, 17 Oct 2022 02:13:09 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id gf8so10400047pjb.5; Mon, 17 Oct 2022 02:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=tA2UmIKVuRoeoJ0BqAsA6/5RpJhUljcvAx2HKfeYlvY=; b=Sr4PYEf5wQLycM2jIu7gAXfNqeWkBXd3bQDKSgDYmZdhEVQ8hffMW2O/3E9d4DDSIS iMX+EcW/+mPQqM1dVtavf9vl3PGl8J6qCMZvdIPlOsOChUj0dvxu0VB54pkhJ7WEPWU1 xfnMhX/zH2bU1haCFaJUxubX6NMIOfXB9EXMWkYRuhIaqyKan8QFMFPbYnEN37ll73oV KWYKcv3jgtBSQCisqgHkFhwVVkx0WF4odL3BBVmRk8szRD0fqCPn96Bz7MMaZONa5l2r P0snWRJ/vih/+ddPui3dVR7uHK/xis17kSaE8uENx5jS8XFh3qNZQ49rIeLQXYB5lOAZ oVfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=tA2UmIKVuRoeoJ0BqAsA6/5RpJhUljcvAx2HKfeYlvY=; b=fKFTr9866xPjb8VdM/kBQxsjqSsmB8GIlG8Vy3kD7YwZuFLChHd2c8IDPi+cQokdTd evjuxhWTFCoP/CXZHJHPpSA4gfiKJlU3E975YFN9ExiwopcDUY7aYZCrn7zHf3UER+8D v8NKmdTlDMpQtVy9Xowr6jTAz6GQ6bw0L2KHXGXtd9oR/cliEzOY2KZUGe/Tk32yqi21 +e825dVStsc6kUPXG/J0/VIiJJ4+Qcj4VY43UScFY1HJf/G+jehWQv3f1KCn1V0geWju VpWvJePcOc/Ve+HzaehD/NC7OxjpDBddsW2p06Px28KNvVA+JXjGVryyYtn0VahCB6W+ bxvw== X-Gm-Message-State: ACrzQf2HT4HErVoYFpOzTm+IoLsR8FTKegNcz4/y04i07Cvp+nbPJpKn UbpRxi6asc3ak8qioLc9SUI= X-Received: by 2002:a17:90b:17c7:b0:20b:7cb:9397 with SMTP id me7-20020a17090b17c700b0020b07cb9397mr26969871pjb.191.1665997981401; Mon, 17 Oct 2022 02:13:01 -0700 (PDT) Received: from localhost.localdomain (2001-b400-e258-8c34-4ca3-4989-34c1-7890.emome-ip6.hinet.net. [2001:b400:e258:8c34:4ca3:4989:34c1:7890]) by smtp.gmail.com with ESMTPSA id t22-20020a170902b21600b0017f75bc7a61sm6091996plr.166.2022.10.17.02.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 02:13:00 -0700 (PDT) From: Victor Shih X-Google-Original-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 Subject: [PATCH V5 17/26] mmc: sdhci-uhs2: add clock operations Date: Mon, 17 Oct 2022 17:11:44 +0800 Message-Id: <20221017091153.454873-18-victor.shih@genesyslogic.com.tw> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221017091153.454873-1-victor.shih@genesyslogic.com.tw> References: <20221017091153.454873-1-victor.shih@genesyslogic.com.tw> 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746925845504595931?= X-GMAIL-MSGID: =?utf-8?q?1746925845504595931?= 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 --- drivers/mmc/host/sdhci-uhs2.c | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c index 145508918486..3f3665d7990c 100644 --- a/drivers/mmc/host/sdhci-uhs2.c +++ b/drivers/mmc/host/sdhci-uhs2.c @@ -11,6 +11,7 @@ */ #include +#include #include #include "sdhci.h" @@ -403,6 +404,37 @@ 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); + u32 val; + /* 20ms */ + int timeout_us = 20000; + + clk |= SDHCI_CLOCK_CARD_EN; + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); + + if (read_poll_timeout_atomic(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 1; + } + return 0; +} + /*****************************************************************************\ * * * Driver init/exit * @@ -564,6 +596,10 @@ static int sdhci_uhs2_host_ops_init(struct sdhci_host *host) if (!host->mmc_host_ops.uhs2_detect_init) host->mmc_host_ops.uhs2_detect_init = sdhci_uhs2_do_detect_init; + if (!host->mmc_host_ops.uhs2_disable_clk) + host->mmc_host_ops.uhs2_disable_clk = sdhci_uhs2_disable_clk; + if (!host->mmc_host_ops.uhs2_enable_clk) + host->mmc_host_ops.uhs2_enable_clk = sdhci_uhs2_enable_clk; return 0; }