From patchwork Thu Oct 24 20:18:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13849675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 707F8D0E415 for ; Thu, 24 Oct 2024 20:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TppAUiDXkUFwSrv2A2knMxXHQkH96XkM3sjE1E2labc=; b=ga42FXkzHwjbWvLLzfBFzT2zqr 0I2bKJwqPgJfVj8GfHIwWfJvSLt65KiIdHyW6eGtgLoxT07q+U3E9537CPwPoW0pLYmLZXzhhxMnH cv/Jg/YgzNTQfqa54vqInMNHdaCg36ynBq3uqf5dQkRRQZNWvsqlbRsi0NuvZrVVztRvq1MH9bOaG rxTIg+9tiLo6ACXKhKKr+gTI0+03pdq2hJCDl8WiLvHczAPxG16WBih1Uz97n8OK1MCYT7fBcy70t s4hzdT7jT5fOJNL8HoGBb1Wf46sZd9hRRuP/M34nf8QwWEk7H8rUirZGV5ExJgOEJUT2XiLQQ4uep avq+kfPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t44Sr-00000001jXn-1FYz; Thu, 24 Oct 2024 20:29:49 +0000 Received: from mout.gmx.net ([212.227.15.18]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t44IJ-00000001iBa-3yZm for linux-arm-kernel@lists.infradead.org; Thu, 24 Oct 2024 20:18:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1729801126; x=1730405926; i=wahrenst@gmx.net; bh=TppAUiDXkUFwSrv2A2knMxXHQkH96XkM3sjE1E2labc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=fkSSPrHfP8zuCDU0FQvXVesIFe0r59OPVPafqp13z6faJWuN+qe9m8e4Wvn/zVXo kTXnXzVpL406wexjvAHBkZlM8oDg22VDJYQaHIUgCBeOaNFzPkOG4cbtEETBYVOEo kPLkb46PkQL2fA5BoO8y0+FH1fxAAjwOOnJ3smndqfO8Yh6i/ICbpf/WmEcSEBoJL h/73jMD2QqGUZT35cLHcmrJ8W2zWgktTBiiQze2yMoFhFH6gnxfz0EXSxW1A+nyXN F6g87zasR9YzlQb9YfmImwH9soaYjAHlT3vHL0gmUWrO9g/sPCQ4r74ZbLzF+9yyM nC0HwqL5dtKEx+o5Eg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MZTqW-1tQfdw22Z4-00TIze; Thu, 24 Oct 2024 22:18:46 +0200 From: Stefan Wahren To: Russell King , Florian Fainelli , Ray Jui , Scott Branden , Vinod Koul , Ulf Hansson , Minas Harutyunyan , Greg Kroah-Hartman Cc: Lukas Wunner , Peter Robinson , linux-arm-kernel@lists.infradead.org, kernel-list@raspberrypi.com, bcm-kernel-feedback-list@broadcom.com, dmaengine@vger.kernel.org, linux-mmc@vger.kernel.org, linux-usb@vger.kernel.org, Stefan Wahren Subject: [PATCH 4/9] mmc: bcm2835: Introduce proper clock handling Date: Thu, 24 Oct 2024 22:18:32 +0200 Message-Id: <20241024201837.79927-5-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241024201837.79927-1-wahrenst@gmx.net> References: <20241024201837.79927-1-wahrenst@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:N3tKX4mSMl82K77Rqp30pHjdPKnfkJo5HTAHo86MD9OPHY0F2/v V5Z5RNm/VpCjv/E8YtDmv8A3Cie1520lbzwFOj9pefuP7NUdj1eoNNLqFn5HIUy/u1gjJhw ZiDYAGyHuN3F7GGNcGbHR4Oc0cXc3dhBvYTx2o3EnK8a2iV04dlFpjky5ngicZreQTthbBV EOT3LnUTA5oinVOI59jZQ== UI-OutboundReport: notjunk:1;M01:P0:BM4IuQddS9U=;c2AS344vTTYGtGZcIMh+jqcDywx sJEWBxyaT0tqBhihI5NGhQxC8EcLjeYqW6ZwLRZ1580Xo+S6cTVgWtyR+IjXC5HqTUwhCfgjR +tNlG6U2nbHFAvIeMHN5Cz8xQIOfapRRqpAECdQ/NvfcXWOTszC9SKUCpzSYsY8qZcgi3P53c t1u5K/b+pRnuAtWASpwERgu9qplnGc178WJE92gFFoYvvsID7DLa/OGZECg+QdVXVYWC+ImOA Wqv5YHIWrr1fTtugZKw8QNkiYheSXlCSCNv1DKOkCOoGBgBkKtRI2C58K4trSfS8HAD9fnc/I I+JHcX1BGp4UVy4HARdhRBmZlzPNiMjfvSvWj+tDw6SqAEBvIryvcc6Y0bjrRj045SQjPIOUw Jrjuto4RfZ1uCsYCe7v0oU5oulw7/IVxA11DvLaFUn2PyBTOeGnZOU3Ry+L4MO7WWNL6t5t1/ GEFeoi91Vx/cK04O5cjhvp63xDRUe54FXR1oe+zUgHfk3SsATOit5GXfiWZe4at8k+0PVrvKl n1cU6pAP4ge4IIbdbR9Uxi2SpwwNGaEJfD3DLbwikI870UaNSDbGj7sHywAVnkfOUfv0EECRC LBSPTOfBNCr7/v9Zk3V+yr7r/21m+nFcWfm6dEHai+Kjsi0tTxQXAGI7vJFTR1eklcfaeil3d 7iay6oaBxsHGbWz2xfpOq2LwKUECb0hzkBy0UuSnhOE5EBmQFi3Ae74Yv0h0GqGEAY9H93TTW C9ad9W8MV4BupQNF7d+F5o97DMwwKCHd8JXqf4nHPevojPpqvDDVzb0hSdNOGXLwtFEwMTiPc s0XDmfh7vMc1ap35fZMpzwMw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241024_131856_418786_999EE6CA X-CRM114-Status: GOOD ( 17.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The custom sdhost controller on BCM2835 is feed by the critical VPU clock. In preparation for PM suspend/resume support, add a proper clock handling to the driver like in the other clock consumers (e.g. I2C). Move the clock handling behind mmc_of_parse(), because it could return with -EPROBE_DEFER and we want to minimize potential clock operation during boot phase. Signed-off-by: Stefan Wahren --- drivers/mmc/host/bcm2835.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) -- 2.34.1 diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index 3d3eda5a337c..107666b7c1c8 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -148,6 +148,7 @@ struct bcm2835_host { void __iomem *ioaddr; u32 phys_addr; + struct clk *clk; struct platform_device *pdev; unsigned int clock; /* Current clock speed */ @@ -1345,7 +1346,6 @@ static int bcm2835_add_host(struct bcm2835_host *host) static int bcm2835_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct clk *clk; struct bcm2835_host *host; struct mmc_host *mmc; const __be32 *regaddr_p; @@ -1393,15 +1393,6 @@ static int bcm2835_probe(struct platform_device *pdev) /* Ignore errors to fall back to PIO mode */ } - - clk = devm_clk_get(dev, NULL); - if (IS_ERR(clk)) { - ret = dev_err_probe(dev, PTR_ERR(clk), "could not get clk\n"); - goto err; - } - - host->max_clk = clk_get_rate(clk); - host->irq = platform_get_irq(pdev, 0); if (host->irq < 0) { ret = host->irq; @@ -1412,16 +1403,30 @@ static int bcm2835_probe(struct platform_device *pdev) if (ret) goto err; - ret = bcm2835_add_host(host); + host->clk = devm_clk_get(dev, NULL); + if (IS_ERR(host->clk)) { + ret = dev_err_probe(dev, PTR_ERR(host->clk), "could not get clk\n"); + goto err; + } + + ret = clk_prepare_enable(host->clk); if (ret) goto err; + host->max_clk = clk_get_rate(host->clk); + + ret = bcm2835_add_host(host); + if (ret) + goto err_clk; + platform_set_drvdata(pdev, host); dev_dbg(dev, "%s -> OK\n", __func__); return 0; +err_clk: + clk_disable_unprepare(host->clk); err: dev_dbg(dev, "%s -> err %d\n", __func__, ret); if (host->dma_chan_rxtx) @@ -1445,6 +1450,8 @@ static void bcm2835_remove(struct platform_device *pdev) cancel_work_sync(&host->dma_work); cancel_delayed_work_sync(&host->timeout_work); + clk_disable_unprepare(host->clk); + if (host->dma_chan_rxtx) dma_release_channel(host->dma_chan_rxtx);