public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
To: Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Sam Protsenko <semen.protsenko@linaro.org>,
	Peter Griffin <peter.griffin@linaro.org>
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v5 2/4] soc: samsung: usi: add a routine for unconfiguring the ip
Date: Thu,  9 Jan 2025 11:03:23 +0200	[thread overview]
Message-ID: <20250109090325.595475-3-ivo.ivanov.ivanov1@gmail.com> (raw)
In-Reply-To: <20250109090325.595475-1-ivo.ivanov.ivanov1@gmail.com>

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>
---
 drivers/soc/samsung/exynos-usi.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/soc/samsung/exynos-usi.c b/drivers/soc/samsung/exynos-usi.c
index 114352695..4b84f481b 100644
--- a/drivers/soc/samsung/exynos-usi.c
+++ b/drivers/soc/samsung/exynos-usi.c
@@ -174,6 +174,23 @@ 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;
+
+	/* 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);
+}
+
 static int exynos_usi_parse_dt(struct device_node *np, struct exynos_usi *usi)
 {
 	int ret;
@@ -251,6 +268,10 @@ static int exynos_usi_probe(struct platform_device *pdev)
 			return PTR_ERR(usi->regs);
 	}
 
+	ret = devm_add_action_or_reset(&pdev->dev, exynos_usi_unconfigure, usi);
+	if (ret)
+		return ret;
+
 	ret = exynos_usi_configure(usi);
 	if (ret)
 		return ret;
-- 
2.43.0


  parent reply	other threads:[~2025-01-09  9:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09  9:03 [PATCH v5 0/4] soc: samsung: usi: implement support for USIv1 Ivaylo Ivanov
2025-01-09  9:03 ` [PATCH v5 1/4] dt-bindings: soc: samsung: usi: add USIv1 and samsung,exynos8895-usi Ivaylo Ivanov
2025-01-09  9:03 ` Ivaylo Ivanov [this message]
2025-01-14 17:59   ` [PATCH v5 2/4] soc: samsung: usi: add a routine for unconfiguring the ip Krzysztof Kozlowski
2025-01-14 21:59     ` Ivaylo Ivanov
2025-01-15  8:25       ` Krzysztof Kozlowski
2025-01-14 18:03   ` Krzysztof Kozlowski
2025-01-14 21:57     ` Ivaylo Ivanov
2025-01-15  8:24       ` Krzysztof Kozlowski
2025-01-09  9:03 ` [PATCH v5 3/4] soc: samsung: usi: implement support for USIv1 and exynos8895 Ivaylo Ivanov
2025-01-09  9:03 ` [PATCH v5 4/4] arm64: dts: exynos: update all samsung,mode constants Ivaylo Ivanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250109090325.595475-3-ivo.ivanov.ivanov1@gmail.com \
    --to=ivo.ivanov.ivanov1@gmail.com \
    --cc=alim.akhtar@samsung.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=peter.griffin@linaro.org \
    --cc=robh@kernel.org \
    --cc=semen.protsenko@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox