Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2031613rdf; Mon, 6 Nov 2023 02:42:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEH56I2u7f1vglz+lesybCEcZg6r06WXiE4IeVF7+lMkEDCU6Uboe8c05850n7+CHtoCJgH X-Received: by 2002:a17:903:1104:b0:1c9:dfb8:a5a0 with SMTP id n4-20020a170903110400b001c9dfb8a5a0mr33977606plh.10.1699267330214; Mon, 06 Nov 2023 02:42:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699267330; cv=none; d=google.com; s=arc-20160816; b=pQ/sAWDlrwnkF7JaV2rN5dPPwWKde9/UpJgcg+Vv3CV0msyqp+5hsPGiSWsM3KGg7q Ag27UIcmAfuamQlmxtwGeQBdmStSMC4SuGokChQeRlFyzGBowI41Gr1m1Qm98e9YV+WQ ND++Zs1WV85CpBntnqW9g38ES1CgIDUzAERUp6SkejkaoNhGejhOs7JgJz1e8dZwuOqG G33fEhOXswN0Npln5KjIYqSDxIME0y9auJz88rUWA+OGUV9YT2hfgpJT1W8yVLuhgvAU hltRV2GR/m08DCaY+t3sxpo6xc5Wn+heNfozEmd0vMhU5iP3/wFlbHKoYeEpB3K9VdDz EU1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=z6McYZIO3NYjoMPGUiseXQrMofonkUPMIwg3L7VCs54=; fh=EOWwISSUy3TLtLo1RAmMIFkh/CxXiTWGS9ALoL0FNnA=; b=qqJA6aLGW0yIC2FwvIycRjetRZyExUGGnLwITCsdtmNMc2B6JqnE9mp6NLf3nL4kpf zV7oo7N3wachylsI+U+4uGpuu/25bU65QIVrEgGfDG4Sk78/mSlx+FVJPIn1DPbOaBtQ HkNU37r6KHSOp8JxtmDshiyNYxHK0AXdhi7KUYz10gOBFlA/X0D0AFu0k2UA1WYKqna9 yuR4Cyb27dCwsEgIdjsAyBcP6HyHOwhE5/JyeAcjtJrCqKZdVLyNBhuQ6xghFv3ZGbXg b9gb1qpyuD11hKplMQfIqA7pZQDAM3D/z9YbbJXk9IZQ58wL2C1Gc3tWKNk4ZSFueGTB T2ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id w18-20020a170902d11200b001c732b6869csi7435676plw.63.2023.11.06.02.42.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 02:42:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C8EFE807590A; Mon, 6 Nov 2023 02:41:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231159AbjKFKlA (ORCPT + 99 others); Mon, 6 Nov 2023 05:41:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbjKFKk7 (ORCPT ); Mon, 6 Nov 2023 05:40:59 -0500 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11134FA; Mon, 6 Nov 2023 02:40:53 -0800 (PST) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 3A6AeZRI049532; Mon, 6 Nov 2023 18:40:35 +0800 (+08) (envelope-from Wenchao.Chen@unisoc.com) Received: from SHDLP.spreadtrum.com (shmbx05.spreadtrum.com [10.29.1.56]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4SP76T0Zynz2M0tVJ; Mon, 6 Nov 2023 18:35:45 +0800 (CST) Received: from xm9614pcu.spreadtrum.com (10.13.2.29) by shmbx05.spreadtrum.com (10.29.1.56) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Mon, 6 Nov 2023 18:40:33 +0800 From: Wenchao Chen To: , , , CC: , , , , , Wenchao Chen Subject: [PATCH] mmc: sdhci-sprd: Fix the clock switch Date: Mon, 6 Nov 2023 18:40:18 +0800 Message-ID: <20231106104018.29179-1-wenchao.chen@unisoc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.13.2.29] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To shmbx05.spreadtrum.com (10.29.1.56) X-MAIL: SHSQR01.spreadtrum.com 3A6AeZRI049532 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 02:41:04 -0800 (PST) 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 --- 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