Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5114734ybi; Tue, 4 Jun 2019 01:16:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrznuXmfJh/AMua7T5GjS12pww+/od5BW46zxWqw7kyy8eqc07lBrl63n0xLm3hHX1iEhd X-Received: by 2002:a17:90a:cb0a:: with SMTP id z10mr35786907pjt.101.1559636209639; Tue, 04 Jun 2019 01:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559636209; cv=none; d=google.com; s=arc-20160816; b=ix6jCnE7ISa0xKFp3/R9GqMFN0J+q0JmUdUzq8q+fsiV/s+Sp3GSUeDOWe3UUeg3Zr X+13ORXQc1BZaSZjd1Mz/+qdSxwtluVzeyvKAmjw0WhtD80h0JDlN8v20qjBJcvc8JWM lh1E8No6jzBkheIRtA7A9Yz/dkqC86SFcSLJvLz7xe9KvlY+zrfd+DBsg1H0s5Uq6erf AElW/z4EImWjwmQDVLrmgByMN7zGQedswM6LQKEzveeX606XKTIRQGogt+bsOc6pXAeq uzPX1QF++D5SRploY7pMCEhUqXpZrvL/ycfDGzsoLcKzPFBrbLSe5F4tPg4l+4kfzGad egLg== 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=FdrxifC9VKJDfmhJlZCtT+SJXQU8nyEdMzYOjCE23wE=; b=zgwMfLkJpMEVD2TZAem4t7zigatzqJbElLOlJXLubOBpVVw5f7gxqkBcsrFW4mg5Ua nd8id3nhoakqUvHEyZkS1RHbXs5rvO9+egf6g92sQN0pGCKWPu6OZRyLYrlLTu2ESZ4T zQNHQKUkO6Sa2F2V4esx6/l8X9mk5z9OEqYM7PtVnaavxCRFs8rM8132At4UVkDBNMXr 95MT1WZcZKl85SQDW3HuMg9DB4ra5aZ8sChxp+bTCstlLkN+cTwb5jb95+PIRCP93bO4 OYu8gDIdX48uzHTLL1dP7ExPjz4uSOb4KOWxj+XTMMsFtf9soDujHC3QCO/TBqECrL+E LGiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O+2GCVHo; 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 e13si21254763pgi.176.2019.06.04.01.16.32; Tue, 04 Jun 2019 01:16:49 -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=O+2GCVHo; 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 S1727080AbfFDIPE (ORCPT + 99 others); Tue, 4 Jun 2019 04:15:04 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:43596 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727058AbfFDIPD (ORCPT ); Tue, 4 Jun 2019 04:15:03 -0400 Received: by mail-pl1-f195.google.com with SMTP id cl9so2929706plb.10 for ; Tue, 04 Jun 2019 01:15:02 -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=FdrxifC9VKJDfmhJlZCtT+SJXQU8nyEdMzYOjCE23wE=; b=O+2GCVHo8+jdVe0br2gCJmuVnoyN4ac5Q7dhggvalzYPiUr+vQUkbbNC7rkfnG/DMc Po9EnLA2txYJNYbCrgFTev4bagodznF/DhZ9ndevRxjnCflMa2CwWoR1iVBRqmrNGZhr 6ajDgOfmCMYdyDcsNoyNSHvDeqsSB9N7tBPXRUpbID/7kXrqXOAlXM6/ujiDUcHeJ1Na Cl2K8MyOB4vbDBYM0Cg/SoLMUchkU1OA+KdEsjrCfciLpldwdMyZVr/j/L9QG5gSdY64 bnykp/4rdv3o9rQoqFm+Y7Mzq++0RgDOJOy74UVZSB378K3GAr+Sh03UEiXRAIYzVGUE iGEw== 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=FdrxifC9VKJDfmhJlZCtT+SJXQU8nyEdMzYOjCE23wE=; b=IcJtSdOnnBQbGAqMVj3gkT3VU79FOiINrL36mnKXwON8iFsKs8v8zwnfXoKEwP1OkC kYpy/X0GQQtM0CAQZWaaq9f8jMrTVWkZQeViLGfyaXJOVBPZaSREr775ZUjF5tZP656L 6RrK4wgi9hgk9K+1n84bPw3K0pDrmrRij3eGVOGu9k51auc+RJ0TrbtAR5WYla1BOtd0 mGGAOh+yCcTwktM9TfP/Zt/nwjkctj9bw4rPtlinP1dCCjHTO+TskP/56ckJ9YI+mgjw aOQQ+QBS+VDrNYYZYesQKcFInZnxnuEl0m4GbddLtYaRaFyWUlMhqplP4KNQOBX0QKf2 aYAg== X-Gm-Message-State: APjAAAWHlg/wYpb/2WHK97cb2egnQxEE6sst1VeOFjvqIwoej5r7Ph3s YfPumqsPHKK+h6YBxOR5H6AtHg== X-Received: by 2002:a17:902:7e0e:: with SMTP id b14mr9660980plm.257.1559636102504; Tue, 04 Jun 2019 01:15:02 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id j4sm14818804pgc.56.2019.06.04.01.14.58 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Jun 2019 01:15:02 -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 v2 3/9] mmc: sdhci-sprd: Add optional gate clock support Date: Tue, 4 Jun 2019 16:14:23 +0800 Message-Id: <3bd7f5b0d4c78b75f8c4067a34f79396b4fd0a5c.1559635435.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 Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-sprd.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) 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 -- 1.7.9.5