Skip to content

Commit 7830c0e

Browse files
Dinh Nguyenbroonie
authored andcommitted
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: Liang Jin J <[email protected]> Signed-off-by: Dinh Nguyen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ecfbd3c commit 7830c0e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/spi/spi-dw-mmio.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/acpi.h>
2020
#include <linux/property.h>
2121
#include <linux/regmap.h>
22+
#include <linux/reset.h>
2223

2324
#include "spi-dw.h"
2425

@@ -29,6 +30,7 @@ struct dw_spi_mmio {
2930
struct clk *clk;
3031
struct clk *pclk;
3132
void *priv;
33+
struct reset_control *rstc;
3234
};
3335

3436
#define MSCC_CPU_SYSTEM_CTRL_GENERAL_CTRL 0x24
@@ -224,6 +226,14 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
224226
if (ret)
225227
goto out_clk;
226228

229+
/* find an optional reset controller */
230+
dwsmmio->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, "spi");
231+
if (IS_ERR(dwsmmio->rstc)) {
232+
ret = PTR_ERR(dwsmmio->rstc);
233+
goto out_clk;
234+
}
235+
reset_control_deassert(dwsmmio->rstc);
236+
227237
dws->bus_num = pdev->id;
228238

229239
dws->max_freq = clk_get_rate(dwsmmio->clk);
@@ -257,6 +267,8 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
257267
clk_disable_unprepare(dwsmmio->pclk);
258268
out_clk:
259269
clk_disable_unprepare(dwsmmio->clk);
270+
reset_control_assert(dwsmmio->rstc);
271+
260272
return ret;
261273
}
262274

@@ -268,6 +280,7 @@ static int dw_spi_mmio_remove(struct platform_device *pdev)
268280
pm_runtime_disable(&pdev->dev);
269281
clk_disable_unprepare(dwsmmio->pclk);
270282
clk_disable_unprepare(dwsmmio->clk);
283+
reset_control_assert(dwsmmio->rstc);
271284

272285
return 0;
273286
}

0 commit comments

Comments
 (0)