diff options
author | 2025-02-04 19:28:01 +0200 | |
---|---|---|
committer | 2025-02-05 16:25:57 +0100 | |
commit | 11e77776b58af4bd05d1d0432e16428234b6bc86 (patch) | |
tree | cd042308f41b3ec9bd1389bfb4dabc7e88804c66 | |
parent | Merge branch 'for-v6.15/samsung-soc-dt-bindings' into next/drivers (diff) | |
download | wireguard-linux-11e77776b58af4bd05d1d0432e16428234b6bc86.tar.xz wireguard-linux-11e77776b58af4bd05d1d0432e16428234b6bc86.zip |
soc: samsung: usi: add a routine for unconfiguring the ip
Add a devm_add_action_or_reset() routine for unconfiguring the USI IP
block whenever the device gets removed.
Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
Link: https://lore.kernel.org/r/20250204172803.3425496-3-ivo.ivanov.ivanov1@gmail.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
-rw-r--r-- | drivers/soc/samsung/exynos-usi.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/soc/samsung/exynos-usi.c b/drivers/soc/samsung/exynos-usi.c index 1fda8d72f687..48d89e7e9518 100644 --- a/drivers/soc/samsung/exynos-usi.c +++ b/drivers/soc/samsung/exynos-usi.c @@ -174,6 +174,30 @@ static int exynos_usi_configure(struct exynos_usi *usi) return 0; } +static void exynos_usi_unconfigure(void *data) +{ + struct exynos_usi *usi = data; + u32 val; + int ret; + + ret = clk_bulk_prepare_enable(usi->data->num_clks, usi->clks); + if (ret) + return; + + /* Make sure that we've stopped providing the clock to USI IP */ + val = readl(usi->regs + USI_OPTION); + val &= ~USI_OPTION_CLKREQ_ON; + val |= ~USI_OPTION_CLKSTOP_ON; + writel(val, usi->regs + USI_OPTION); + + /* Set USI block state to reset */ + val = readl(usi->regs + USI_CON); + val |= USI_CON_RESET; + writel(val, usi->regs + USI_CON); + + clk_bulk_disable_unprepare(usi->data->num_clks, usi->clks); +} + static int exynos_usi_parse_dt(struct device_node *np, struct exynos_usi *usi) { int ret; @@ -251,6 +275,10 @@ static int exynos_usi_probe(struct platform_device *pdev) if (ret) return ret; + ret = devm_add_action_or_reset(&pdev->dev, exynos_usi_unconfigure, usi); + if (ret) + return ret; + /* Make it possible to embed protocol nodes into USI np */ return of_platform_populate(np, NULL, NULL, dev); } |