From patchwork Mon May 20 10:11:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 164582 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp93912ili; Mon, 20 May 2019 03:12:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRVMVQ6CTDTRitII6JAsznRWTaWPwrQEEQxPHDrTmTu+Hwa93C3p6V5krv+nfsR3xEpjra X-Received: by 2002:a63:8149:: with SMTP id t70mr75646815pgd.134.1558347164035; Mon, 20 May 2019 03:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558347164; cv=none; d=google.com; s=arc-20160816; b=egKr+TH91JnVcG3znR9mqQU485c/JtlHQzmtB+f7wtu5FJgwEudCObHLv+RDmBTuh7 6IXWMPhRpG7Kyx9axjZKakEdFjkkf+rfdePOzjuyxqPLsGcuNWVucxIEs2AYOqxt4zeR qKhhZlWcze/GXgMD9ZuixEZHqlGqkPDmZMmVzkF6Sh687URSKe0wpG5huV+nzfv88Y8e 1dLKCCVEbv/K5ewe+LTClPMcSkqkrZZkF688UBMmPwdMV4mYxjXlQyw2dvPjDVac6Uyq 9SH8s7f3PIP/cW4y2q4Gz9bnqr7P4l0OgGAmGklseDbON+YX8XQy5QIX9+iVzqdwiIIB /3PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=HpWLJW0AsyMzUk7aFfWV1G46hR6bm2Fq1Ta1KdUw0ic=; b=wTGxeqrdCxi/TEqryw3rOHaoa9ytIPLgi45629BwlCHgJxVCjmrrIYfwxiHzKzDwMw SNNyYCj8mEcsNVnJARVTYp8zPpzoyFPbRIjxFZbypZSa4KbD9rnd+RwrwlZESbmnIBuG ZmyzImB0MYZOnZU5jl1GlFkJgyphAC2eJi/DaoHcZWrN5ApcxN/awRlok84nLxyAYUYF dcZ1xUT/iIVcoU8Ca57XF2ZRs9sA3yymUe1eQsMdK2PjKDLOXoQnc1vXc/jd83b6KvYX qbO7qIoBFnnDRqjx/2QgmeEjLTrR5BwXOTrB+HfUI4AR/a6VQegoPSl+GrYbCTv+QY34 gqtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DTIHo9/m"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n4si17101172pgq.69.2019.05.20.03.12.43; Mon, 20 May 2019 03:12:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DTIHo9/m"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732470AbfETKMm (ORCPT + 30 others); Mon, 20 May 2019 06:12:42 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35666 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732445AbfETKMh (ORCPT ); Mon, 20 May 2019 06:12:37 -0400 Received: by mail-pf1-f193.google.com with SMTP id t87so6996051pfa.2 for ; Mon, 20 May 2019 03:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=HpWLJW0AsyMzUk7aFfWV1G46hR6bm2Fq1Ta1KdUw0ic=; b=DTIHo9/mhznHhmMPsPg2GreBFfHF6EqewzBibeH6J1rwd6xeG3CJaiSCAzzM0YX1tO rDYGkQdhqxkOfEx0wELCbz7sxgZ+bOojR87F94462mSYPW3J5rhmvbmhzad45atYa0WH 9hO34uiRK2xFzSLn3r61HSZ0Ru7VfMkZcb3mClqKzRsMRRr9QQ8RtgBlhpuWyVBDiIRm enY5MU3j77jwUVAX0AOhzawX9LeWp4YlatlPNLWMFrmF2sBHw97X6F6PS++hkNI1XozR PNaWJDkBBRlDIPXBgEIjqdEHxh6uIZLsAT3Zqhjy0nijV3nkFeIYannK9MLNIPhACU2C l+yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=HpWLJW0AsyMzUk7aFfWV1G46hR6bm2Fq1Ta1KdUw0ic=; b=Io4rfPFb1bYjzbn5lhZHHCiVEeFMRSXsZ3gRL7u5cSNnm/8xkhlcZ/nG4Wp6jwQzZ1 dyhiM86mnrVe2i8Xdiq5x19c4DAnyjqmO9P3wCHSU5lyOaHCKl2n37m1znG80PUDzD3F nz5VDy5Dj3DZrLukocSDE20O6MTmDAmr0a0c/ggQM0yF4VPoJm8RvCG9wHKYoD/K1Rz9 SNp1sI9YwQiCLI11OL9YzD3JkBVbr/6TZoMucNq5xHql8YAPUvAOweY8ClR1RBcZ14rR iRugR5r9+RJPGSohYYmPaDsCHRQf59qJcXpAFLsJ+OMzQU2eMeOIgfCTpR1+pAdCwcgG Z/NQ== X-Gm-Message-State: APjAAAX5qmJfBdXkcvosO1hBBFrzIolXFvpxEiaG9UDFe+HiLRZJaqkJ 9D7atF1kpGMhwhmYTsRt5fbV1g== X-Received: by 2002:a63:e451:: with SMTP id i17mr74906860pgk.312.1558347156596; Mon, 20 May 2019 03:12:36 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id b3sm30098127pfr.146.2019.05.20.03.12.32 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 May 2019 03:12:36 -0700 (PDT) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org, zhang.lyra@gmail.com, orsonzhai@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, arnd@arndb.de, olof@lixom.net Cc: baolin.wang@linaro.org, vincent.guittot@linaro.org, arm@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 3/9] mmc: sdhci-sprd: Add optional gate clock support Date: Mon, 20 May 2019 18:11:56 +0800 Message-Id: <16b895cf30c235dc656eeed5888069b6266ab5f8.1558346019.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For the Spreadtrum SC9860 platform, we should enable another gate clock '2x_enable' to make the SD host controller work well. Signed-off-by: Baolin Wang --- drivers/mmc/host/sdhci-sprd.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) -- 1.7.9.5 Acked-by: Adrian Hunter diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c index e741491..31ba7d6 100644 --- a/drivers/mmc/host/sdhci-sprd.c +++ b/drivers/mmc/host/sdhci-sprd.c @@ -60,6 +60,7 @@ struct sdhci_sprd_host { u32 version; struct clk *clk_sdio; struct clk *clk_enable; + struct clk *clk_2x_enable; u32 base_rate; int flags; /* backup of host attribute */ }; @@ -364,6 +365,10 @@ static int sdhci_sprd_probe(struct platform_device *pdev) } sprd_host->clk_enable = clk; + clk = devm_clk_get(&pdev->dev, "2x_enable"); + if (!IS_ERR(clk)) + sprd_host->clk_2x_enable = clk; + ret = clk_prepare_enable(sprd_host->clk_sdio); if (ret) goto pltfm_free; @@ -372,6 +377,10 @@ static int sdhci_sprd_probe(struct platform_device *pdev) if (ret) goto clk_disable; + ret = clk_prepare_enable(sprd_host->clk_2x_enable); + if (ret) + goto clk_disable2; + sdhci_sprd_init_config(host); host->version = sdhci_readw(host, SDHCI_HOST_VERSION); sprd_host->version = ((host->version & SDHCI_VENDOR_VER_MASK) >> @@ -408,6 +417,9 @@ static int sdhci_sprd_probe(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); + clk_disable_unprepare(sprd_host->clk_2x_enable); + +clk_disable2: clk_disable_unprepare(sprd_host->clk_enable); clk_disable: @@ -427,6 +439,7 @@ static int sdhci_sprd_remove(struct platform_device *pdev) mmc_remove_host(mmc); clk_disable_unprepare(sprd_host->clk_sdio); clk_disable_unprepare(sprd_host->clk_enable); + clk_disable_unprepare(sprd_host->clk_2x_enable); mmc_free_host(mmc); @@ -449,6 +462,7 @@ static int sdhci_sprd_runtime_suspend(struct device *dev) clk_disable_unprepare(sprd_host->clk_sdio); clk_disable_unprepare(sprd_host->clk_enable); + clk_disable_unprepare(sprd_host->clk_2x_enable); return 0; } @@ -459,19 +473,28 @@ static int sdhci_sprd_runtime_resume(struct device *dev) struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host); int ret; - ret = clk_prepare_enable(sprd_host->clk_enable); + ret = clk_prepare_enable(sprd_host->clk_2x_enable); if (ret) return ret; + ret = clk_prepare_enable(sprd_host->clk_enable); + if (ret) + goto clk_2x_disable; + ret = clk_prepare_enable(sprd_host->clk_sdio); - if (ret) { - clk_disable_unprepare(sprd_host->clk_enable); - return ret; - } + if (ret) + goto clk_disable; sdhci_runtime_resume_host(host); - return 0; + +clk_disable: + clk_disable_unprepare(sprd_host->clk_enable); + +clk_2x_disable: + clk_disable_unprepare(sprd_host->clk_2x_enable); + + return ret; } #endif