From patchwork Wed Oct 19 11:06:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Shih X-Patchwork-Id: 5246 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp273459wrs; Wed, 19 Oct 2022 04:42:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4bAxZ1kD2E4qJyfXDm7vlg0oXjWqWuSxsRyH1qsrlUU+RgEjott9LBpfRd0O3tU3ynp+GD X-Received: by 2002:a17:90b:4c8c:b0:20b:d3f:3c8a with SMTP id my12-20020a17090b4c8c00b0020b0d3f3c8amr9077654pjb.219.1666179734522; Wed, 19 Oct 2022 04:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666179734; cv=none; d=google.com; s=arc-20160816; b=htkWovcZ6hsd/hVHoEfSCP5dXt7UEMZJHLDUMjYTpHhldv92RXGfNwsGQDro5Fr/mG t6FtERwJCf5u+KQlfGdd38yG9Ld18EPPLsH9p20IKrOfp6S0+UjS0CvlyxnT+5HZra72 ygUYHot/pLe4XyLNGPM12NQGz8YExE54uSm9UP7pze1HeBRowb/ZYNrv8Ywk5u/VHgfc FP+LBgO1J/SM0TxyWNZ/jdbim1EEswTwn9oLR3Rj8P44vco0OgWGhGJaIE36j5ZJ5Ym/ UKPVMWu0zodXtFV4E+maiS1JyBi29i0+6TaV5Py9p6USjR9Ib/9b3ip/cpep9DRO0XVc Z4JQ== 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=PTXOWmjLDmmd0AthIyoirfTIKVO51onpGqfIS2mHoBI=; b=lLYduYgEj4k8C+xizo0gKogHAOGOBuJ4TFN5xfxCSMI6hDVTnP7i3LXMSsiSEmEg0M rDuCy1KAfNBXXx5Ag+MtizQHzrDiVW2r33NVsOD4rK0nBqrDow+GZ8e8ZsRTnsYGnedX NjzIM1i2Eeu9KmENbXArW8JhoPDZMAHFonbQrFTvW+nEwygdc/pVOt+VfR92TZl5rjEI cv0a/j2Np1RgR9dNlNw8/muoTRdAhvJ04u/u5ab7sDLrLv7H3ismz6uGpiRk3D7wCV6H rvnbyYqvl1M7ei+hYSj5NujMegOBllEvC7eEDC2Wn8mFQpceUfFd3ZMdEbn+H+OBEsvW RRYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=o01ykx0o; 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 c4-20020a633504000000b0044a0b2e174asi19031253pga.83.2022.10.19.04.42.01; Wed, 19 Oct 2022 04:42:14 -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=o01ykx0o; 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 S231976AbiJSLdp (ORCPT + 99 others); Wed, 19 Oct 2022 07:33:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232059AbiJSLdQ (ORCPT ); Wed, 19 Oct 2022 07:33:16 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFAA88305F; Wed, 19 Oct 2022 04:09:54 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id t12-20020a17090a3b4c00b0020b04251529so16435539pjf.5; Wed, 19 Oct 2022 04:09:53 -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=PTXOWmjLDmmd0AthIyoirfTIKVO51onpGqfIS2mHoBI=; b=o01ykx0o1Uau/DvacEVzay+sQisMbr+3E4LrPwBMPTBHNUK4YkC5zpihdyUtqS+iFG Kf2wNnLTvzcG/UDPdKyn6w0oAamUa2Uo3sdYTjEDOZW7psheNyvoKFIyr6G2bJ6ywcuE uOCZeV6RUL5umefz72sBmguQ+KLac1u0l3lK3fjtH+AioIVXZ2p8LRIi4qvSUVDynbd+ tpMDDSzPRdVtV/ESOaKYG3TFLciCgfHMTIi4gWbm1CG8qYdaHRbe6Ww3w//+ahntdodI lAAkyZ0e5BF3UeT7tjnSJ8iEG0CSPyQPiKyWPWyWLhPWG3EQvo1aXKAzJR81pg7uIg44 e/Eg== 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=PTXOWmjLDmmd0AthIyoirfTIKVO51onpGqfIS2mHoBI=; b=aT23C+f0/TdLCmbeRR6TBBcHSF33i0flp4Uqq3yzXeCgBEIRwCE3f1SaRtfRfsa//o 8lWNfgU0I2unjBo9oA3G15Y/Nq43b9shawo4QwVFLYWdLJcSwadZwlHT2ExYXif4b1cQ /Lt0BpgJvvI2g8vrwlkWM0nFPd+92Hlvncf6rymDhyB8b0r6Tm7c9+Z3TleSk2TCMbGw /fUlb3GAJBs+SaKCI/TjJ6od8wEhJ7HZ50NCCwg5+Q8RvDB6vlVRthvMU2nIB8SLcoay ggLwD3KhMy3RiNDE9OZZAEm3nT/G+KEB9yNe42KaD0oLX0Kro85PmIg/DZAneScJoZ3d bFuQ== X-Gm-Message-State: ACrzQf04uyIcJBNRW3sbh5Ej74niVzpd4yQ2ZfoChCjQ2e1Ws7dlDTUE 0yR5XksaZyaEy4sqJkTBdto= X-Received: by 2002:a17:902:d486:b0:181:33f0:f60b with SMTP id c6-20020a170902d48600b0018133f0f60bmr7979575plg.174.1666177669450; Wed, 19 Oct 2022 04:07:49 -0700 (PDT) Received: from localhost.localdomain (2001-b400-e258-8c34-821b-9613-557f-bd8d.emome-ip6.hinet.net. [2001:b400:e258:8c34:821b:9613:557f:bd8d]) by smtp.gmail.com with ESMTPSA id cc11-20020a17090af10b00b0020dc318a43esm8696225pjb.25.2022.10.19.04.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 04:07:49 -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: Wed, 19 Oct 2022 19:06:38 +0800 Message-Id: <20221019110647.11076-18-victor.shih@genesyslogic.com.tw> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221019110647.11076-1-victor.shih@genesyslogic.com.tw> References: <20221019110647.11076-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?1747116081248394911?= X-GMAIL-MSGID: =?utf-8?q?1747116081248394911?= 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 9ceae552c323..afaca5d96938 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 * @@ -560,6 +592,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; }