mmc: bcm2835: Introduce proper clock handling

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>
Message-ID: <20241025103621.4780-5-wahrenst@gmx.net>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
Stefan Wahren 2024-10-25 12:36:16 +02:00 committed by Ulf Hansson
parent 9d3b4e52fd
commit e6dc7d2eec

View File

@ -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);