From: Daniel Baluta <daniel.baluta@nxp.com>
To: p.zabel@pengutronix.de, shawnguo@kernel.org, mathieu.poirier@linaro.org
Cc: s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, andersson@kernel.org,
linux-remoteproc@vger.kernel.org, iuliana.prodan@nxp.com,
laurentiu.mihalcea@nxp.com, shengjiu.wang@nxp.com,
Frank.Li@nxp.com, krzk@kernel.org,
Daniel Baluta <daniel.baluta@nxp.com>
Subject: [PATCH 2/5] reset: imx8mp-audiomix: Prepare the code for more reset bits
Date: Tue, 18 Feb 2025 10:57:09 +0200 [thread overview]
Message-ID: <20250218085712.66690-3-daniel.baluta@nxp.com> (raw)
In-Reply-To: <20250218085712.66690-1-daniel.baluta@nxp.com>
Current code supports EARC PHY Software Reset and EARC Software
Reset but it is not easily extensible to more reset bits.
So, refactor the code in order to easily allow more reset bits
in the future.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
drivers/reset/reset-imx8mp-audiomix.c | 53 ++++++++++++++++++++++-----
1 file changed, 43 insertions(+), 10 deletions(-)
diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c
index 1fe21980a66c..6b1666c4e069 100644
--- a/drivers/reset/reset-imx8mp-audiomix.c
+++ b/drivers/reset/reset-imx8mp-audiomix.c
@@ -12,7 +12,30 @@
#include <linux/reset-controller.h>
#define IMX8MP_AUDIOMIX_EARC_OFFSET 0x200
-#define IMX8MP_AUDIOMIX_EARC_RESET_MASK 0x3
+#define IMX8MP_AUDIOMIX_EARC_RESET_MASK 0x1
+#define IMX8MP_AUDIOMIX_EARC_PHY_RESET_MASK 0x2
+
+#define IMX8MP_AUDIOMIX_EARC 0
+#define IMX8MP_AUDIOMIX_EARC_PHY 1
+
+#define IMX8MP_AUDIOMIX_RESET_NUM 2
+
+struct imx8mp_reset_map {
+ unsigned int offset;
+ unsigned int mask;
+};
+
+static const struct imx8mp_reset_map reset_map[IMX8MP_AUDIOMIX_RESET_NUM] = {
+ [IMX8MP_AUDIOMIX_EARC] = {
+ .offset = IMX8MP_AUDIOMIX_EARC_OFFSET,
+ .mask = IMX8MP_AUDIOMIX_EARC_RESET_MASK,
+ },
+ [IMX8MP_AUDIOMIX_EARC_PHY] = {
+ .offset = IMX8MP_AUDIOMIX_EARC_OFFSET,
+ .mask = IMX8MP_AUDIOMIX_EARC_PHY_RESET_MASK,
+ },
+
+};
struct imx8mp_audiomix_reset {
struct reset_controller_dev rcdev;
@@ -30,13 +53,18 @@ static int imx8mp_audiomix_reset_assert(struct reset_controller_dev *rcdev,
{
struct imx8mp_audiomix_reset *priv = to_imx8mp_audiomix_reset(rcdev);
void __iomem *reg_addr = priv->base;
- unsigned int mask, reg;
+ unsigned int mask, offset, reg;
unsigned long flags;
- mask = BIT(id);
+ if (id >= IMX8MP_AUDIOMIX_RESET_NUM)
+ return -EINVAL;
+
+ mask = reset_map[id].mask;
+ offset = reset_map[id].offset;
+
spin_lock_irqsave(&priv->lock, flags);
- reg = readl(reg_addr + IMX8MP_AUDIOMIX_EARC_OFFSET);
- writel(reg & ~mask, reg_addr + IMX8MP_AUDIOMIX_EARC_OFFSET);
+ reg = readl(reg_addr + offset);
+ writel(reg & ~mask, reg_addr + offset);
spin_unlock_irqrestore(&priv->lock, flags);
return 0;
@@ -47,13 +75,18 @@ static int imx8mp_audiomix_reset_deassert(struct reset_controller_dev *rcdev,
{
struct imx8mp_audiomix_reset *priv = to_imx8mp_audiomix_reset(rcdev);
void __iomem *reg_addr = priv->base;
- unsigned int mask, reg;
+ unsigned int mask, offset, reg;
unsigned long flags;
- mask = BIT(id);
+ if (id >= IMX8MP_AUDIOMIX_RESET_NUM)
+ return -EINVAL;
+
+ mask = reset_map[id].mask;
+ offset = reset_map[id].offset;
+
spin_lock_irqsave(&priv->lock, flags);
- reg = readl(reg_addr + IMX8MP_AUDIOMIX_EARC_OFFSET);
- writel(reg | mask, reg_addr + IMX8MP_AUDIOMIX_EARC_OFFSET);
+ reg = readl(reg_addr + offset);
+ writel(reg | mask, reg_addr + offset);
spin_unlock_irqrestore(&priv->lock, flags);
return 0;
@@ -78,7 +111,7 @@ static int imx8mp_audiomix_reset_probe(struct auxiliary_device *adev,
spin_lock_init(&priv->lock);
priv->rcdev.owner = THIS_MODULE;
- priv->rcdev.nr_resets = fls(IMX8MP_AUDIOMIX_EARC_RESET_MASK);
+ priv->rcdev.nr_resets = IMX8MP_AUDIOMIX_RESET_NUM;
priv->rcdev.ops = &imx8mp_audiomix_reset_ops;
priv->rcdev.of_node = dev->parent->of_node;
priv->rcdev.dev = dev;
--
2.25.1
next prev parent reply other threads:[~2025-02-18 8:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-18 8:57 [PATCH 0/5] imx8mp: Add support to Run/Stall DSP via reset API Daniel Baluta
2025-02-18 8:57 ` [PATCH 1/5] reset: imx8mp-audiomix: Add prefix for internal macro Daniel Baluta
2025-02-18 9:23 ` Philipp Zabel
2025-02-18 15:51 ` Frank Li
2025-02-19 3:09 ` Peng Fan
2025-02-18 8:57 ` Daniel Baluta [this message]
2025-02-18 9:26 ` [PATCH 2/5] reset: imx8mp-audiomix: Prepare the code for more reset bits Philipp Zabel
2025-02-18 15:08 ` Peng Fan
2025-02-18 15:55 ` Frank Li
2025-02-19 8:21 ` Daniel Baluta
2025-02-18 8:57 ` [PATCH 3/5] reset: imx8mp-audiomix: Introduce active_low configuration option Daniel Baluta
2025-02-18 9:30 ` Philipp Zabel
2025-02-18 15:58 ` Frank Li
2025-02-18 15:11 ` Peng Fan
2025-02-18 15:59 ` Frank Li
2025-02-18 8:57 ` [PATCH 4/5] reset: imx8mp-audiomix: Add support for DSP run/stall Daniel Baluta
2025-02-18 9:31 ` Philipp Zabel
2025-02-18 15:12 ` Peng Fan
2025-02-18 16:00 ` Frank Li
2025-02-18 8:57 ` [PATCH 5/5] imx_dsp_rproc: Use reset controller API to control the DSP Daniel Baluta
2025-02-18 9:35 ` Philipp Zabel
2025-02-19 8:46 ` Daniel Baluta
2025-02-19 3:08 ` Peng Fan
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=20250218085712.66690-3-daniel.baluta@nxp.com \
--to=daniel.baluta@nxp.com \
--cc=Frank.Li@nxp.com \
--cc=andersson@kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=iuliana.prodan@nxp.com \
--cc=kernel@pengutronix.de \
--cc=krzk@kernel.org \
--cc=laurentiu.mihalcea@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=p.zabel@pengutronix.de \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=shengjiu.wang@nxp.com \
/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