Commit 7830c0ef authored by Dinh Nguyen's avatar Dinh Nguyen Committed by Mark Brown

spi: dw: add reset control

Add mechanism to get the reset control and deassert it in order to bring
the IP out of reset.
Signed-off-by: default avatarLiang Jin J <liang.j.jin@ericsson.com>
Signed-off-by: default avatarDinh Nguyen <dinguyen@kernel.org>
Link: https://lore.kernel.org/r/20200529155806.16758-1-dinguyen@kernel.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent ecfbd3cf
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/property.h> #include <linux/property.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/reset.h>
#include "spi-dw.h" #include "spi-dw.h"
...@@ -29,6 +30,7 @@ struct dw_spi_mmio { ...@@ -29,6 +30,7 @@ struct dw_spi_mmio {
struct clk *clk; struct clk *clk;
struct clk *pclk; struct clk *pclk;
void *priv; void *priv;
struct reset_control *rstc;
}; };
#define MSCC_CPU_SYSTEM_CTRL_GENERAL_CTRL 0x24 #define MSCC_CPU_SYSTEM_CTRL_GENERAL_CTRL 0x24
...@@ -224,6 +226,14 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -224,6 +226,14 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
if (ret) if (ret)
goto out_clk; goto out_clk;
/* find an optional reset controller */
dwsmmio->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, "spi");
if (IS_ERR(dwsmmio->rstc)) {
ret = PTR_ERR(dwsmmio->rstc);
goto out_clk;
}
reset_control_deassert(dwsmmio->rstc);
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);
...@@ -257,6 +267,8 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -257,6 +267,8 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
clk_disable_unprepare(dwsmmio->pclk); clk_disable_unprepare(dwsmmio->pclk);
out_clk: out_clk:
clk_disable_unprepare(dwsmmio->clk); clk_disable_unprepare(dwsmmio->clk);
reset_control_assert(dwsmmio->rstc);
return ret; return ret;
} }
...@@ -268,6 +280,7 @@ static int dw_spi_mmio_remove(struct platform_device *pdev) ...@@ -268,6 +280,7 @@ static int dw_spi_mmio_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
clk_disable_unprepare(dwsmmio->pclk); clk_disable_unprepare(dwsmmio->pclk);
clk_disable_unprepare(dwsmmio->clk); clk_disable_unprepare(dwsmmio->clk);
reset_control_assert(dwsmmio->rstc);
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