From: Ulf Hansson <ulf.hansson@linaro.org>
To: Stefan Wahren <wahrenst@gmx.net>
Cc: Russell King <linux@armlinux.org.uk>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>,
Vinod Koul <vkoul@kernel.org>,
Minas Harutyunyan <hminas@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Lukas Wunner <lukas@wunner.de>,
Peter Robinson <pbrobinson@gmail.com>,
"Ivan T . Ivanov" <iivanov@suse.de>,
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
Subject: Re: [PATCH V5 4/9] mmc: bcm2835: Introduce proper clock handling
Date: Mon, 28 Oct 2024 12:43:58 +0100 [thread overview]
Message-ID: <CAPDyKFqwozGppFLJhjTc86nW1rodZymBbVZr+VpN4e2J3VowMQ@mail.gmail.com> (raw)
In-Reply-To: <20241025103621.4780-5-wahrenst@gmx.net>
On Fri, 25 Oct 2024 at 12:36, Stefan Wahren <wahrenst@gmx.net> wrote:
>
> 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 <wahrenst@gmx.net>
Applied for next, thanks!
Kind regards
Uffe
> ---
> drivers/mmc/host/bcm2835.c | 29 ++++++++++++++++++-----------
> 1 file changed, 18 insertions(+), 11 deletions(-)
>
> 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);
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2024-10-28 11:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 10:36 [PATCH V5 0/9] ARM: bcm2835: Implement initial S2Idle for Raspberry Pi Stefan Wahren
2024-10-25 10:36 ` [PATCH V5 1/9] Revert "usb: dwc2: Skip clock gating on Broadcom SoCs" Stefan Wahren
2024-10-29 9:44 ` Ivan T . Ivanov
2024-10-25 10:36 ` [PATCH V5 2/9] dmaengine: bcm2835-dma: add suspend/resume pm support Stefan Wahren
2024-11-09 17:37 ` Stefan Wahren
2024-12-02 16:52 ` Vinod Koul
2024-12-02 18:51 ` Stefan Wahren
2024-12-04 12:27 ` Vinod Koul
2024-10-25 10:36 ` [PATCH V5 3/9] mmc: bcm2835: Fix type of current clock speed Stefan Wahren
2024-10-28 11:43 ` Ulf Hansson
2024-10-25 10:36 ` [PATCH V5 4/9] mmc: bcm2835: Introduce proper clock handling Stefan Wahren
2024-10-28 11:43 ` Ulf Hansson [this message]
2024-10-25 10:36 ` [PATCH V5 5/9] mmc: bcm2835: add suspend/resume pm support Stefan Wahren
2024-10-28 10:56 ` Ulf Hansson
2024-10-25 10:36 ` [PATCH V5 6/9] usb: dwc2: gadget: Introduce register restore flags Stefan Wahren
2024-10-25 10:36 ` [PATCH V5 7/9] usb: dwc2: Refactor backup/restore of registers Stefan Wahren
2024-10-25 10:36 ` [PATCH V5 8/9] usb: dwc2: Implement recovery after PM domain off Stefan Wahren
2024-10-25 10:36 ` [PATCH V5 9/9] ARM: bcm2835_defconfig: Enable SUSPEND Stefan Wahren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPDyKFqwozGppFLJhjTc86nW1rodZymBbVZr+VpN4e2J3VowMQ@mail.gmail.com \
--to=ulf.hansson@linaro.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=dmaengine@vger.kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=hminas@synopsys.com \
--cc=iivanov@suse.de \
--cc=kernel-list@raspberrypi.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lukas@wunner.de \
--cc=pbrobinson@gmail.com \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
--cc=vkoul@kernel.org \
--cc=wahrenst@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).