lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231106104018.29179-1-wenchao.chen@unisoc.com>
Date:   Mon, 6 Nov 2023 18:40:18 +0800
From:   Wenchao Chen <wenchao.chen@...soc.com>
To:     <ulf.hansson@...aro.org>, <zhang.lyra@...il.com>,
        <orsonzhai@...il.com>, <baolin.wang@...ux.alibaba.com>
CC:     <linux-mmc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <wenchao.chen666@...il.com>, <zhenxiong.lai@...soc.com>,
        <yuelin.tang@...soc.com>, Wenchao Chen <wenchao.chen@...soc.com>
Subject: [PATCH] mmc: sdhci-sprd: Fix the clock switch

Some SOCs have a "1x_enable" clock that needs to be turned on and off
in probe, remove and runtime pm.

Fixes: fb8bd90f83c4 ("mmc: sdhci-sprd: Add Spreadtrum's initial host controller")
Signed-off-by: Wenchao Chen <wenchao.chen@...soc.com>
---
 drivers/mmc/host/sdhci-sprd.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index 6b84ba27e6ab..3367f924dc5b 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -83,6 +83,7 @@ struct sdhci_sprd_host {
 	u32 version;
 	struct clk *clk_sdio;
 	struct clk *clk_enable;
+	struct clk *clk_1x_enable;
 	struct clk *clk_2x_enable;
 	struct pinctrl *pinctrl;
 	struct pinctrl_state *pins_uhs;
@@ -784,6 +785,10 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
 	}
 	sprd_host->clk_enable = clk;
 
+	clk = devm_clk_get(&pdev->dev, "1x_enable");
+	if (!IS_ERR(clk))
+		sprd_host->clk_1x_enable = clk;
+
 	clk = devm_clk_get(&pdev->dev, "2x_enable");
 	if (!IS_ERR(clk))
 		sprd_host->clk_2x_enable = clk;
@@ -793,12 +798,16 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
 		goto pltfm_free;
 
 	ret = clk_prepare_enable(sprd_host->clk_enable);
+	if (ret)
+		goto clk_sdio_disable;
+
+	ret = clk_prepare_enable(sprd_host->clk_1x_enable);
 	if (ret)
 		goto clk_disable;
 
 	ret = clk_prepare_enable(sprd_host->clk_2x_enable);
 	if (ret)
-		goto clk_disable2;
+		goto clk_1x_disable;
 
 	sdhci_sprd_init_config(host);
 	host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
@@ -858,10 +867,13 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
 
 	clk_disable_unprepare(sprd_host->clk_2x_enable);
 
-clk_disable2:
-	clk_disable_unprepare(sprd_host->clk_enable);
+clk_1x_disable:
+	clk_disable_unprepare(sprd_host->clk_1x_enable);
 
 clk_disable:
+	clk_disable_unprepare(sprd_host->clk_enable);
+
+clk_sdio_disable:
 	clk_disable_unprepare(sprd_host->clk_sdio);
 
 pltfm_free:
@@ -878,6 +890,7 @@ static void sdhci_sprd_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(sprd_host->clk_sdio);
 	clk_disable_unprepare(sprd_host->clk_enable);
+	clk_disable_unprepare(sprd_host->clk_1x_enable);
 	clk_disable_unprepare(sprd_host->clk_2x_enable);
 
 	sdhci_pltfm_free(pdev);
@@ -900,6 +913,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_1x_enable);
 	clk_disable_unprepare(sprd_host->clk_2x_enable);
 
 	return 0;
@@ -915,10 +929,14 @@ static int sdhci_sprd_runtime_resume(struct device *dev)
 	if (ret)
 		return ret;
 
-	ret = clk_prepare_enable(sprd_host->clk_enable);
+	ret = clk_prepare_enable(sprd_host->clk_1x_enable);
 	if (ret)
 		goto clk_2x_disable;
 
+	ret = clk_prepare_enable(sprd_host->clk_enable);
+	if (ret)
+		goto clk_1x_disable;
+
 	ret = clk_prepare_enable(sprd_host->clk_sdio);
 	if (ret)
 		goto clk_disable;
@@ -931,6 +949,9 @@ static int sdhci_sprd_runtime_resume(struct device *dev)
 clk_disable:
 	clk_disable_unprepare(sprd_host->clk_enable);
 
+clk_1x_disable:
+	clk_disable_unprepare(sprd_host->clk_1x_enable);
+
 clk_2x_disable:
 	clk_disable_unprepare(sprd_host->clk_2x_enable);
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ