Commit 560ee7e9 authored by Phil Edworthy's avatar Phil Edworthy Committed by Mark Brown

spi: dw: Add support for an optional interface clock

The Synopsys SSI Controller has an interface clock, but most SoCs hide
this away. However, on some SoCs you need to explicitly enable the
interface clock in order to access the registers. Therefore, add support
for an optional interface clock.
Signed-off-by: default avatarPhil Edworthy <phil.edworthy@renesas.com>
Signed-off-by: default avatarGareth Williams <gareth.williams.jx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2f324ac7
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
struct dw_spi_mmio { struct dw_spi_mmio {
struct dw_spi dws; struct dw_spi dws;
struct clk *clk; struct clk *clk;
struct clk *pclk;
void *priv; void *priv;
}; };
...@@ -172,6 +173,14 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -172,6 +173,14 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
/* Optional clock needed to access the registers */
dwsmmio->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
if (IS_ERR(dwsmmio->pclk))
return PTR_ERR(dwsmmio->pclk);
ret = clk_prepare_enable(dwsmmio->pclk);
if (ret)
goto out_clk;
dws->bus_num = pdev->id; dws->bus_num = pdev->id;
dws->max_freq = clk_get_rate(dwsmmio->clk); dws->max_freq = clk_get_rate(dwsmmio->clk);
...@@ -199,6 +208,8 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -199,6 +208,8 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
return 0; return 0;
out: out:
clk_disable_unprepare(dwsmmio->pclk);
out_clk:
clk_disable_unprepare(dwsmmio->clk); clk_disable_unprepare(dwsmmio->clk);
return ret; return ret;
} }
...@@ -208,6 +219,7 @@ static int dw_spi_mmio_remove(struct platform_device *pdev) ...@@ -208,6 +219,7 @@ static int dw_spi_mmio_remove(struct platform_device *pdev)
struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev); struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev);
dw_spi_remove_host(&dwsmmio->dws); dw_spi_remove_host(&dwsmmio->dws);
clk_disable_unprepare(dwsmmio->pclk);
clk_disable_unprepare(dwsmmio->clk); clk_disable_unprepare(dwsmmio->clk);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment