Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2158811rdf; Mon, 6 Nov 2023 06:26:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFL2a8Si/WoOYQ2gtVxr4ttdBsx2/uEcw7Ll9V7bn3k3BiO0kLWYeHFERPYGDs544x3fcnw X-Received: by 2002:a05:6808:1a27:b0:3ae:554b:6c57 with SMTP id bk39-20020a0568081a2700b003ae554b6c57mr35431400oib.11.1699280805295; Mon, 06 Nov 2023 06:26:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699280805; cv=none; d=google.com; s=arc-20160816; b=eoyJ+mF56ZQp6coRekK+fjfldfEvPN53S8Eox5kIMqnjCIw86fBb6xmLYQ6eyauD4r ElfRvxer3RgDOifhlLMvr++7Kjkk3rjKps2x/4yP5ktqBto63x5OzHf+/FPz1/f8qSb7 jAomp0C1F54lVz6/IoKUWOxHqb9VveZVpvMmUcXvuYBXUoOhEIQbXewG/aTsMxTrK+Fv JdbxD1YbNTHbt+pzDtHdF3smjGCwPtt1hRwjoMVjEsLEyPDGV+OsX1H3lSJ9OJJHjhJT EHbJSgSa+7Tnlo9BFvQHv7F3K4jjMqrwMnI00oeyUBCaHRxBGfznkD7Jf4bUpBIGtKNy mRkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=clebCQm1+LBapUz3ORAAhgjPSPUNZu8n0M4MtoluA3A=; fh=F3UnqIe7Cv2H7wsoUQKJbLL3hvwyA7W3aE64VxcC1VI=; b=UR6jELXquH2NMIsLfLEMmlNliMyIaP7Y6vBtTS9yxTcjU8QzMZh/ZqAOa5kvA0RuLH YPLvvoixDrHOd/4lj02A1TlRp+AdWCyA542wluxJykLjQjkL7bAnquvHgw8P9PM3rrA7 IIy3Rphue3L9ZOouapPyZgH1VmTdZ0TIXF4H8T3DJ3Yn44Z2QSq3P53UAgpT0gCvuxvB iv1JX35s7xxJmMPje+o0oWFXP9qa9EmLrccjUOSt2rgq/dXfhYk9MYMHQqWxLRaOhkqf c1jnYpRS7Wc52GA7d4TBC8Ue/JhSv1e9bQAAmRu5VKUKD8iNXX/sP4+qcpzZ4BHh6cGZ a8jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=izHuTFs6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id t2-20020a056a00138200b006c21aeb4041si8585611pfg.125.2023.11.06.06.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 06:26:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=izHuTFs6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 55065803FF85; Mon, 6 Nov 2023 06:26:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231671AbjKFO0R (ORCPT + 99 others); Mon, 6 Nov 2023 09:26:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231800AbjKFO0N (ORCPT ); Mon, 6 Nov 2023 09:26:13 -0500 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D177BD51 for ; Mon, 6 Nov 2023 06:26:09 -0800 (PST) Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-da7238b3eb4so3374980276.1 for ; Mon, 06 Nov 2023 06:26:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699280768; x=1699885568; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=clebCQm1+LBapUz3ORAAhgjPSPUNZu8n0M4MtoluA3A=; b=izHuTFs6nSpiQocOEUbAdQQKi4oY4J15jeSfl0MlKsXZYQKc3UrqoKx79JMsTyRgXx TOConcjbYjTFxxpn7hf+ldOklrF/hQoWLvvO+m58dP5TFGHPIMU0M75iANxJxJ7qRePf tGvJEcqQwO5LFClfAyMHBmD33Fe7mJDS/8xpFKqW2YeqIWaOq2ThySgTeCy+ws9Ld6LC kmC7S7vpxwQi2Lro8i5wxVi7IcGeXuJjOuXf7dQRelL2M5L5kff3g3RyuUCFyc9zZ0/6 16l7YpiwykFe+maFkBB4c8N+GtrdazjpWEVtyApx5ORvZazBriQOP4vUihCn/CE9JqkR nppQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699280768; x=1699885568; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=clebCQm1+LBapUz3ORAAhgjPSPUNZu8n0M4MtoluA3A=; b=hsfyjJubGuIesfZ6OsxnkEG+sLD3ugebUo814hnGgVu6xJy3UKhJD8M+IGb11DsVfD EzdvxOvVdcyDv130R0YD4d5LIiVTwa2KwgMWAqbkYra8lKVPQdiAFWUQE23fA3sXToap SRMU7hQCJpQ4tgm7ZzOYvNzz8Abh2tOkMQ4Ta9eEf2ACCn+jDDklQWCMxXgoCMZyW1jH qrlLusXz0ue18RfF2H8ZVs1xH95Ml6mLguLrVD3HBMazLmr7vtNtqnMpDa0IwoRRgfiW hzWBUrAqp7JTnd7WKzzr5uGBMlThTEKHwIAMlLdrxkCr/K0s2SywcEN97zrfXbnKR++k PzBw== X-Gm-Message-State: AOJu0YwLzKPxZvWj1XuxNFNjsmUxHnE2VwlP886liEl5Gt5lVS80CMkZ PlzHBAwJrISb/7EJ9+WuT36gg/x0LJ6R7scxCE2v3A== X-Received: by 2002:a25:db11:0:b0:da0:4c63:f648 with SMTP id g17-20020a25db11000000b00da04c63f648mr28557922ybf.6.1699280768250; Mon, 06 Nov 2023 06:26:08 -0800 (PST) MIME-Version: 1.0 References: <20231106104018.29179-1-wenchao.chen@unisoc.com> In-Reply-To: <20231106104018.29179-1-wenchao.chen@unisoc.com> From: Ulf Hansson Date: Mon, 6 Nov 2023 15:25:32 +0100 Message-ID: Subject: Re: [PATCH] mmc: sdhci-sprd: Fix the clock switch To: Wenchao Chen Cc: zhang.lyra@gmail.com, orsonzhai@gmail.com, baolin.wang@linux.alibaba.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, wenchao.chen666@gmail.com, zhenxiong.lai@unisoc.com, yuelin.tang@unisoc.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Mon, 06 Nov 2023 06:26:37 -0800 (PST) On Mon, 6 Nov 2023 at 11:40, Wenchao Chen wrote: > > Some SOCs have a "1x_enable" clock that needs to be turned on and off > in probe, remove and runtime pm. Well, first of all, what is a "1x_enable" clock and why do we need it? Moreover, the clock needs to be described as a part of the DT bindings for the sdhci-sprd mmc controller. That said, it looks like the binding for the sdhci-sprd controller needs to be converted to the yaml format first, can you please have a look at that too? > > Fixes: fb8bd90f83c4 ("mmc: sdhci-sprd: Add Spreadtrum's initial host controller") > Signed-off-by: Wenchao Chen Kind regards Uffe > --- > 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 >