* [PATCH v5 0/6] Add support for i.MX8ULP's SIM LPAV
@ 2025-11-14 13:37 Laurentiu Mihalcea
2025-11-14 13:37 ` [PATCH v5 1/6] reset: imx8mp-audiomix: Drop unneeded macros Laurentiu Mihalcea
` (5 more replies)
0 siblings, 6 replies; 16+ messages in thread
From: Laurentiu Mihalcea @ 2025-11-14 13:37 UTC (permalink / raw)
To: Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Fabio Estevam,
Philipp Zabel, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
The LPAV System Integration Module (SIM) is an IP found inside i.MX8ULP's
LPAV subsystem, which offers clock gating, reset line
assertion/de-assertion, and various other misc. options.
This series adds support for the IP by introducing a new clock HW provider
driver and by modifying i.MX8MP's AUDIOMIX block control reset driver to
allow it to be used for i.MX8ULP's SIM LPAV as well.
This series is a spin-off from [1].
[1]: https://lore.kernel.org/lkml/20240922174225.75948-1-laurentiumihalcea111@gmail.com/
---
Changes in v5:
* drop patches that were already picked up by Philipp/Abel.
* include the "bits.h" header.
* replace mask with bit index.
* link to v4: https://lore.kernel.org/lkml/20251104120301.913-1-laurentiumihalcea111@gmail.com/
Changes in v4:
* shorten commit message for patch 5
* drop base from "struct imx8mp_audiomix_reset" and use local variable
* imx8mp_audiomix_reset_get_regmap() now takes "struct imx8mp_audiomix_reset *"
as its argument instead of a "struct device *"
* use base pointer as the data argument for devm_add_action_or_reset()
* shorten commit message for patch 6
* drop regmap field from "struct clk_imx8ulp_sim_lpav_data", use local
variable and let devres manage it
* drop base field from "struct clk_imx8ulp_sim_lpav_data", use local
variable and let devres manage it.
* CONFIG_CLK_IMX8ULP now selects CONFIG_AUXILIARY_BUS, which is needed
for devm_auxiliary_device_create().
* drop static definition of "struct regmap_config" and change to using
local one in the clock driver.
* link to v3: https://lore.kernel.org/lkml/20251029135229.890-1-laurentiumihalcea111@gmail.com/
Changes in v3:
* rename "lpav_bus", "hifi_core", and "hifi_plat" to "bus", "core", "plat"
* don't assign the "name" field of "struct clk_parent_data". Previously, we
were assigning the local parent name to this field, which wouldn't have
worked anyways if, for whatever reason, the fallback mechanism would kick in.
* replace the whole auxiliary reset driver creation chunk by
a single devm_auxiliary_device_create() call.
* replace the "shift" field from "struct imx8mp_reset_map" with the usage of
ffs()
* shorten commit description for patch 6
* cast "id->driver_data" to "void *" instead of the previous
"const struct imx8mp_reset_info *", which makes the line shorter.
* open question resulting from Peng Fan's comment on V2: how to access
interconnect QoS registers? do we need to model the sim_lpav as an
interconnect provider as well or is it fine to have another interconnect
provider that references the sim_lpav node and accesses its registers
via regmap (dev_get_regmap(), specifically, NOT syscon).
* link to v2: https://lore.kernel.org/lkml/20251017112025.11997-1-laurentiumihalcea111@gmail.com/
Changes in v2:
* drop redundant description for "#clock-cells"/"#reset-cells" properties
from binding
* make "mux-controller" and "#reset-cells" properties mandatory
* add "mux-controller" child to binding example node
* drop the compatiblity with syscon - this was never actually needed and
it was done to allow using "mmio-mux", which requires a syscon parent
* modify the auxiliary reset driver to use regmap - this will allow the
mux controller, clock control and reset control APIs to use the same
spinlock.
* rename "imx8ulp-reset-sim-lpav.h" to "fsl,imx8ulp-sim-lpav.h"
* drop the "IMX8ULP_CLK_SIM_LPAV_END" macro, which doesn't belong to the
binding headers
* fix the values of "IMX8MP_AUDIOMIX_EARC_RESET_MASK" and
"IMX8MP_AUDIOMIX_EARC_PHY_RESET_MASK", which were previously incorrect
* drop redundant macros from auxiliary reset driver - replace their
occurrences with their values
* squash the binding-related macro additions into the binding patch
* add mux-controller child node to the sim_lpav node
* make the "gates" array static
* link to v1: https://lore.kernel.org/lkml/20250804155407.285353-1-laurentiumihalcea111@gmail.com/
---
Laurentiu Mihalcea (6):
reset: imx8mp-audiomix: Drop unneeded macros
reset: imx8mp-audiomix: Replace mask with bit index
reset: imx8mp-audiomix: Switch to using regmap API
reset: imx8mp-audiomix: Extend the driver usage
reset: imx8mp-audiomix: Support i.MX8ULP SIM LPAV
arm64: dts: imx8ulp: add sim lpav node
arch/arm64/boot/dts/freescale/imx8ulp.dtsi | 17 +++
drivers/reset/reset-imx8mp-audiomix.c | 170 +++++++++++++++------
2 files changed, 141 insertions(+), 46 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v5 1/6] reset: imx8mp-audiomix: Drop unneeded macros
2025-11-14 13:37 [PATCH v5 0/6] Add support for i.MX8ULP's SIM LPAV Laurentiu Mihalcea
@ 2025-11-14 13:37 ` Laurentiu Mihalcea
2025-11-14 15:48 ` Philipp Zabel
2025-11-14 13:37 ` [PATCH v5 2/6] reset: imx8mp-audiomix: Replace mask with bit index Laurentiu Mihalcea
` (4 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Laurentiu Mihalcea @ 2025-11-14 13:37 UTC (permalink / raw)
To: Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Fabio Estevam,
Philipp Zabel, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
The macros defining the mask values for the EARC, EARC PHY resets,
and the DSP RUN_STALL signal can be dropped as they are not and will
not be used anywhere else except to set the value of the "mask" field
from "struct imx8mp_reset_map". In this particular case, based on the
name of the "mask" field, you can already deduce what these values are
for, which is why defining macros for them doesn't offer any new
information, nor does it help with the code readability.
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
drivers/reset/reset-imx8mp-audiomix.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c
index eceb37ff5dc5..acfa92b15329 100644
--- a/drivers/reset/reset-imx8mp-audiomix.c
+++ b/drivers/reset/reset-imx8mp-audiomix.c
@@ -6,6 +6,7 @@
#include <dt-bindings/reset/imx8mp-reset-audiomix.h>
#include <linux/auxiliary_bus.h>
+#include <linux/bits.h>
#include <linux/device.h>
#include <linux/io.h>
#include <linux/module.h>
@@ -14,11 +15,7 @@
#include <linux/reset-controller.h>
#define IMX8MP_AUDIOMIX_EARC_RESET_OFFSET 0x200
-#define IMX8MP_AUDIOMIX_EARC_RESET_MASK BIT(0)
-#define IMX8MP_AUDIOMIX_EARC_PHY_RESET_MASK BIT(1)
-
#define IMX8MP_AUDIOMIX_DSP_RUNSTALL_OFFSET 0x108
-#define IMX8MP_AUDIOMIX_DSP_RUNSTALL_MASK BIT(5)
struct imx8mp_reset_map {
unsigned int offset;
@@ -29,17 +26,17 @@ struct imx8mp_reset_map {
static const struct imx8mp_reset_map reset_map[] = {
[IMX8MP_AUDIOMIX_EARC_RESET] = {
.offset = IMX8MP_AUDIOMIX_EARC_RESET_OFFSET,
- .mask = IMX8MP_AUDIOMIX_EARC_RESET_MASK,
+ .mask = BIT(0),
.active_low = true,
},
[IMX8MP_AUDIOMIX_EARC_PHY_RESET] = {
.offset = IMX8MP_AUDIOMIX_EARC_RESET_OFFSET,
- .mask = IMX8MP_AUDIOMIX_EARC_PHY_RESET_MASK,
+ .mask = BIT(1),
.active_low = true,
},
[IMX8MP_AUDIOMIX_DSP_RUNSTALL] = {
.offset = IMX8MP_AUDIOMIX_DSP_RUNSTALL_OFFSET,
- .mask = IMX8MP_AUDIOMIX_DSP_RUNSTALL_MASK,
+ .mask = BIT(5),
.active_low = false,
},
};
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 2/6] reset: imx8mp-audiomix: Replace mask with bit index
2025-11-14 13:37 [PATCH v5 0/6] Add support for i.MX8ULP's SIM LPAV Laurentiu Mihalcea
2025-11-14 13:37 ` [PATCH v5 1/6] reset: imx8mp-audiomix: Drop unneeded macros Laurentiu Mihalcea
@ 2025-11-14 13:37 ` Laurentiu Mihalcea
2025-11-14 15:48 ` Philipp Zabel
2025-11-21 15:38 ` Frank Li
2025-11-14 13:37 ` [PATCH v5 3/6] reset: imx8mp-audiomix: Switch to using regmap API Laurentiu Mihalcea
` (3 subsequent siblings)
5 siblings, 2 replies; 16+ messages in thread
From: Laurentiu Mihalcea @ 2025-11-14 13:37 UTC (permalink / raw)
To: Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Fabio Estevam,
Philipp Zabel, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Replace the reset map mask with the bit index to make it clear that all
reset lines are managed by exactly 1 bit.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
drivers/reset/reset-imx8mp-audiomix.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c
index acfa92b15329..d993c294c548 100644
--- a/drivers/reset/reset-imx8mp-audiomix.c
+++ b/drivers/reset/reset-imx8mp-audiomix.c
@@ -19,24 +19,24 @@
struct imx8mp_reset_map {
unsigned int offset;
- unsigned int mask;
+ unsigned int bit;
bool active_low;
};
static const struct imx8mp_reset_map reset_map[] = {
[IMX8MP_AUDIOMIX_EARC_RESET] = {
.offset = IMX8MP_AUDIOMIX_EARC_RESET_OFFSET,
- .mask = BIT(0),
+ .bit = 0,
.active_low = true,
},
[IMX8MP_AUDIOMIX_EARC_PHY_RESET] = {
.offset = IMX8MP_AUDIOMIX_EARC_RESET_OFFSET,
- .mask = BIT(1),
+ .bit = 1,
.active_low = true,
},
[IMX8MP_AUDIOMIX_DSP_RUNSTALL] = {
.offset = IMX8MP_AUDIOMIX_DSP_RUNSTALL_OFFSET,
- .mask = BIT(5),
+ .bit = 5,
.active_low = false,
},
};
@@ -60,7 +60,7 @@ static int imx8mp_audiomix_update(struct reset_controller_dev *rcdev,
unsigned int mask, offset, active_low;
unsigned long reg, flags;
- mask = reset_map[id].mask;
+ mask = BIT(reset_map[id].bit);
offset = reset_map[id].offset;
active_low = reset_map[id].active_low;
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 3/6] reset: imx8mp-audiomix: Switch to using regmap API
2025-11-14 13:37 [PATCH v5 0/6] Add support for i.MX8ULP's SIM LPAV Laurentiu Mihalcea
2025-11-14 13:37 ` [PATCH v5 1/6] reset: imx8mp-audiomix: Drop unneeded macros Laurentiu Mihalcea
2025-11-14 13:37 ` [PATCH v5 2/6] reset: imx8mp-audiomix: Replace mask with bit index Laurentiu Mihalcea
@ 2025-11-14 13:37 ` Laurentiu Mihalcea
2025-11-14 15:49 ` Philipp Zabel
2025-11-21 15:43 ` Frank Li
2025-11-14 13:37 ` [PATCH v5 4/6] reset: imx8mp-audiomix: Extend the driver usage Laurentiu Mihalcea
` (2 subsequent siblings)
5 siblings, 2 replies; 16+ messages in thread
From: Laurentiu Mihalcea @ 2025-11-14 13:37 UTC (permalink / raw)
To: Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Fabio Estevam,
Philipp Zabel, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Switch to using the regmap API to allow performing register operations
under the same lock. This is needed for cases such as i.MX8ULP's SIM LPAV
where clock gating, reset control and MUX-ing is performed via the same
register (i.e. SYSCTRL0) and different subsystem APIs.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
drivers/reset/reset-imx8mp-audiomix.c | 92 +++++++++++++++++----------
1 file changed, 57 insertions(+), 35 deletions(-)
diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c
index d993c294c548..35df9bd5f71a 100644
--- a/drivers/reset/reset-imx8mp-audiomix.c
+++ b/drivers/reset/reset-imx8mp-audiomix.c
@@ -12,6 +12,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
+#include <linux/regmap.h>
#include <linux/reset-controller.h>
#define IMX8MP_AUDIOMIX_EARC_RESET_OFFSET 0x200
@@ -43,8 +44,7 @@ static const struct imx8mp_reset_map reset_map[] = {
struct imx8mp_audiomix_reset {
struct reset_controller_dev rcdev;
- spinlock_t lock; /* protect register read-modify-write cycle */
- void __iomem *base;
+ struct regmap *regmap;
};
static struct imx8mp_audiomix_reset *to_imx8mp_audiomix_reset(struct reset_controller_dev *rcdev)
@@ -56,26 +56,14 @@ static int imx8mp_audiomix_update(struct reset_controller_dev *rcdev,
unsigned long id, bool assert)
{
struct imx8mp_audiomix_reset *priv = to_imx8mp_audiomix_reset(rcdev);
- void __iomem *reg_addr = priv->base;
- unsigned int mask, offset, active_low;
- unsigned long reg, flags;
+ unsigned int mask, offset, active_low, val;
mask = BIT(reset_map[id].bit);
offset = reset_map[id].offset;
active_low = reset_map[id].active_low;
+ val = (active_low ^ assert) << reset_map[id].bit;
- spin_lock_irqsave(&priv->lock, flags);
-
- reg = readl(reg_addr + offset);
- if (active_low ^ assert)
- reg |= mask;
- else
- reg &= ~mask;
- writel(reg, reg_addr + offset);
-
- spin_unlock_irqrestore(&priv->lock, flags);
-
- return 0;
+ return regmap_update_bits(priv->regmap, offset, mask, val);
}
static int imx8mp_audiomix_reset_assert(struct reset_controller_dev *rcdev,
@@ -95,6 +83,52 @@ static const struct reset_control_ops imx8mp_audiomix_reset_ops = {
.deassert = imx8mp_audiomix_reset_deassert,
};
+static const struct regmap_config regmap_config = {
+ .reg_bits = 32,
+ .val_bits = 32,
+ .reg_stride = 4,
+};
+
+/* assumption: registered only if not using parent regmap */
+static void imx8mp_audiomix_reset_iounmap(void *data)
+{
+ void __iomem *base = (void __iomem *)data;
+
+ iounmap(base);
+}
+
+static int imx8mp_audiomix_reset_get_regmap(struct imx8mp_audiomix_reset *priv)
+{
+ void __iomem *base;
+ struct device *dev;
+ int ret;
+
+ dev = priv->rcdev.dev;
+
+ /* try to use the parent's regmap */
+ priv->regmap = dev_get_regmap(dev->parent, NULL);
+ if (priv->regmap)
+ return 0;
+
+ /* ... if that's not possible then initialize the regmap right now */
+ base = of_iomap(dev->parent->of_node, 0);
+ if (!base)
+ return dev_err_probe(dev, -ENOMEM, "failed to iomap address space\n");
+
+ ret = devm_add_action_or_reset(dev,
+ imx8mp_audiomix_reset_iounmap,
+ (void __force *)base);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to register action\n");
+
+ priv->regmap = devm_regmap_init_mmio(dev, base, ®map_config);
+ if (IS_ERR(priv->regmap))
+ return dev_err_probe(dev, PTR_ERR(priv->regmap),
+ "failed to initialize regmap\n");
+
+ return 0;
+}
+
static int imx8mp_audiomix_reset_probe(struct auxiliary_device *adev,
const struct auxiliary_device_id *id)
{
@@ -106,36 +140,25 @@ static int imx8mp_audiomix_reset_probe(struct auxiliary_device *adev,
if (!priv)
return -ENOMEM;
- spin_lock_init(&priv->lock);
-
priv->rcdev.owner = THIS_MODULE;
priv->rcdev.nr_resets = ARRAY_SIZE(reset_map);
priv->rcdev.ops = &imx8mp_audiomix_reset_ops;
priv->rcdev.of_node = dev->parent->of_node;
priv->rcdev.dev = dev;
priv->rcdev.of_reset_n_cells = 1;
- priv->base = of_iomap(dev->parent->of_node, 0);
- if (!priv->base)
- return -ENOMEM;
dev_set_drvdata(dev, priv);
+ ret = imx8mp_audiomix_reset_get_regmap(priv);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to get regmap\n");
+
ret = devm_reset_controller_register(dev, &priv->rcdev);
if (ret)
- goto out_unmap;
+ return dev_err_probe(dev, ret,
+ "failed to register reset controller\n");
return 0;
-
-out_unmap:
- iounmap(priv->base);
- return ret;
-}
-
-static void imx8mp_audiomix_reset_remove(struct auxiliary_device *adev)
-{
- struct imx8mp_audiomix_reset *priv = dev_get_drvdata(&adev->dev);
-
- iounmap(priv->base);
}
static const struct auxiliary_device_id imx8mp_audiomix_reset_ids[] = {
@@ -148,7 +171,6 @@ MODULE_DEVICE_TABLE(auxiliary, imx8mp_audiomix_reset_ids);
static struct auxiliary_driver imx8mp_audiomix_reset_driver = {
.probe = imx8mp_audiomix_reset_probe,
- .remove = imx8mp_audiomix_reset_remove,
.id_table = imx8mp_audiomix_reset_ids,
};
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 4/6] reset: imx8mp-audiomix: Extend the driver usage
2025-11-14 13:37 [PATCH v5 0/6] Add support for i.MX8ULP's SIM LPAV Laurentiu Mihalcea
` (2 preceding siblings ...)
2025-11-14 13:37 ` [PATCH v5 3/6] reset: imx8mp-audiomix: Switch to using regmap API Laurentiu Mihalcea
@ 2025-11-14 13:37 ` Laurentiu Mihalcea
2025-11-14 16:02 ` Philipp Zabel
2025-11-14 13:37 ` [PATCH v5 5/6] reset: imx8mp-audiomix: Support i.MX8ULP SIM LPAV Laurentiu Mihalcea
2025-11-14 13:37 ` [PATCH v5 6/6] arm64: dts: imx8ulp: add sim lpav node Laurentiu Mihalcea
5 siblings, 1 reply; 16+ messages in thread
From: Laurentiu Mihalcea @ 2025-11-14 13:37 UTC (permalink / raw)
To: Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Fabio Estevam,
Philipp Zabel, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Switch to per-device reset map to allow reusing the driver for other NXP
block control IPs.
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
drivers/reset/reset-imx8mp-audiomix.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c
index 35df9bd5f71a..d3396f37d1ff 100644
--- a/drivers/reset/reset-imx8mp-audiomix.c
+++ b/drivers/reset/reset-imx8mp-audiomix.c
@@ -24,7 +24,12 @@ struct imx8mp_reset_map {
bool active_low;
};
-static const struct imx8mp_reset_map reset_map[] = {
+struct imx8mp_reset_info {
+ const struct imx8mp_reset_map *map;
+ int num_lines;
+};
+
+static const struct imx8mp_reset_map imx8mp_reset_map[] = {
[IMX8MP_AUDIOMIX_EARC_RESET] = {
.offset = IMX8MP_AUDIOMIX_EARC_RESET_OFFSET,
.bit = 0,
@@ -42,9 +47,15 @@ static const struct imx8mp_reset_map reset_map[] = {
},
};
+static const struct imx8mp_reset_info imx8mp_reset_info = {
+ .map = imx8mp_reset_map,
+ .num_lines = ARRAY_SIZE(imx8mp_reset_map),
+};
+
struct imx8mp_audiomix_reset {
struct reset_controller_dev rcdev;
struct regmap *regmap;
+ const struct imx8mp_reset_info *rinfo;
};
static struct imx8mp_audiomix_reset *to_imx8mp_audiomix_reset(struct reset_controller_dev *rcdev)
@@ -56,6 +67,7 @@ static int imx8mp_audiomix_update(struct reset_controller_dev *rcdev,
unsigned long id, bool assert)
{
struct imx8mp_audiomix_reset *priv = to_imx8mp_audiomix_reset(rcdev);
+ const struct imx8mp_reset_map *reset_map = priv->rinfo->map;
unsigned int mask, offset, active_low, val;
mask = BIT(reset_map[id].bit);
@@ -141,7 +153,8 @@ static int imx8mp_audiomix_reset_probe(struct auxiliary_device *adev,
return -ENOMEM;
priv->rcdev.owner = THIS_MODULE;
- priv->rcdev.nr_resets = ARRAY_SIZE(reset_map);
+ priv->rinfo = (void *)id->driver_data;
+ priv->rcdev.nr_resets = priv->rinfo->num_lines;
priv->rcdev.ops = &imx8mp_audiomix_reset_ops;
priv->rcdev.of_node = dev->parent->of_node;
priv->rcdev.dev = dev;
@@ -164,6 +177,7 @@ static int imx8mp_audiomix_reset_probe(struct auxiliary_device *adev,
static const struct auxiliary_device_id imx8mp_audiomix_reset_ids[] = {
{
.name = "clk_imx8mp_audiomix.reset",
+ .driver_data = (kernel_ulong_t)&imx8mp_reset_info,
},
{ }
};
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 5/6] reset: imx8mp-audiomix: Support i.MX8ULP SIM LPAV
2025-11-14 13:37 [PATCH v5 0/6] Add support for i.MX8ULP's SIM LPAV Laurentiu Mihalcea
` (3 preceding siblings ...)
2025-11-14 13:37 ` [PATCH v5 4/6] reset: imx8mp-audiomix: Extend the driver usage Laurentiu Mihalcea
@ 2025-11-14 13:37 ` Laurentiu Mihalcea
2025-11-14 16:09 ` Philipp Zabel
2025-11-14 13:37 ` [PATCH v5 6/6] arm64: dts: imx8ulp: add sim lpav node Laurentiu Mihalcea
5 siblings, 1 reply; 16+ messages in thread
From: Laurentiu Mihalcea @ 2025-11-14 13:37 UTC (permalink / raw)
To: Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Fabio Estevam,
Philipp Zabel, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Support i.MX8ULP's SIM LPAV by adding its reset map definition.
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
drivers/reset/reset-imx8mp-audiomix.c | 45 +++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c
index d3396f37d1ff..83fc8bcf80ab 100644
--- a/drivers/reset/reset-imx8mp-audiomix.c
+++ b/drivers/reset/reset-imx8mp-audiomix.c
@@ -3,6 +3,7 @@
* Copyright 2024 NXP
*/
+#include <dt-bindings/reset/fsl,imx8ulp-sim-lpav.h>
#include <dt-bindings/reset/imx8mp-reset-audiomix.h>
#include <linux/auxiliary_bus.h>
@@ -18,6 +19,8 @@
#define IMX8MP_AUDIOMIX_EARC_RESET_OFFSET 0x200
#define IMX8MP_AUDIOMIX_DSP_RUNSTALL_OFFSET 0x108
+#define IMX8ULP_SIM_LPAV_SYSCTRL0_OFFSET 0x8
+
struct imx8mp_reset_map {
unsigned int offset;
unsigned int bit;
@@ -52,6 +55,44 @@ static const struct imx8mp_reset_info imx8mp_reset_info = {
.num_lines = ARRAY_SIZE(imx8mp_reset_map),
};
+static const struct imx8mp_reset_map imx8ulp_reset_map[] = {
+ [IMX8ULP_SIM_LPAV_HIFI4_DSP_DBG_RST] = {
+ .offset = IMX8ULP_SIM_LPAV_SYSCTRL0_OFFSET,
+ .bit = 25,
+ .active_low = false,
+ },
+ [IMX8ULP_SIM_LPAV_HIFI4_DSP_RST] = {
+ .offset = IMX8ULP_SIM_LPAV_SYSCTRL0_OFFSET,
+ .bit = 16,
+ .active_low = false,
+ },
+ [IMX8ULP_SIM_LPAV_HIFI4_DSP_STALL] = {
+ .offset = IMX8ULP_SIM_LPAV_SYSCTRL0_OFFSET,
+ .bit = 13,
+ .active_low = false,
+ },
+ [IMX8ULP_SIM_LPAV_DSI_RST_BYTE_N] = {
+ .offset = IMX8ULP_SIM_LPAV_SYSCTRL0_OFFSET,
+ .bit = 5,
+ .active_low = true,
+ },
+ [IMX8ULP_SIM_LPAV_DSI_RST_ESC_N] = {
+ .offset = IMX8ULP_SIM_LPAV_SYSCTRL0_OFFSET,
+ .bit = 4,
+ .active_low = true,
+ },
+ [IMX8ULP_SIM_LPAV_DSI_RST_DPI_N] = {
+ .offset = IMX8ULP_SIM_LPAV_SYSCTRL0_OFFSET,
+ .bit = 3,
+ .active_low = true,
+ },
+};
+
+static const struct imx8mp_reset_info imx8ulp_reset_info = {
+ .map = imx8ulp_reset_map,
+ .num_lines = ARRAY_SIZE(imx8ulp_reset_map),
+};
+
struct imx8mp_audiomix_reset {
struct reset_controller_dev rcdev;
struct regmap *regmap;
@@ -179,6 +220,10 @@ static const struct auxiliary_device_id imx8mp_audiomix_reset_ids[] = {
.name = "clk_imx8mp_audiomix.reset",
.driver_data = (kernel_ulong_t)&imx8mp_reset_info,
},
+ {
+ .name = "clk_imx8ulp_sim_lpav.reset",
+ .driver_data = (kernel_ulong_t)&imx8ulp_reset_info,
+ },
{ }
};
MODULE_DEVICE_TABLE(auxiliary, imx8mp_audiomix_reset_ids);
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 6/6] arm64: dts: imx8ulp: add sim lpav node
2025-11-14 13:37 [PATCH v5 0/6] Add support for i.MX8ULP's SIM LPAV Laurentiu Mihalcea
` (4 preceding siblings ...)
2025-11-14 13:37 ` [PATCH v5 5/6] reset: imx8mp-audiomix: Support i.MX8ULP SIM LPAV Laurentiu Mihalcea
@ 2025-11-14 13:37 ` Laurentiu Mihalcea
5 siblings, 0 replies; 16+ messages in thread
From: Laurentiu Mihalcea @ 2025-11-14 13:37 UTC (permalink / raw)
To: Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Fabio Estevam,
Philipp Zabel, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Add DT node for the SIM LPAV module.
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
arch/arm64/boot/dts/freescale/imx8ulp.dtsi | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/arch/arm64/boot/dts/freescale/imx8ulp.dtsi b/arch/arm64/boot/dts/freescale/imx8ulp.dtsi
index 13b01f3aa2a4..9b5d98766512 100644
--- a/arch/arm64/boot/dts/freescale/imx8ulp.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8ulp.dtsi
@@ -776,6 +776,23 @@ edma2: dma-controller@2d800000 {
"ch28", "ch29", "ch30", "ch31";
};
+ sim_lpav: clock-controller@2da50000 {
+ compatible = "fsl,imx8ulp-sim-lpav";
+ reg = <0x2da50000 0x10000>;
+ clocks = <&cgc2 IMX8ULP_CLK_LPAV_BUS_DIV>,
+ <&cgc2 IMX8ULP_CLK_HIFI_DIVCORE>,
+ <&cgc2 IMX8ULP_CLK_HIFI_DIVPLAT>;
+ clock-names = "bus", "core", "plat";
+ #clock-cells = <1>;
+ #reset-cells = <1>;
+
+ sim_lpav_mux: mux-controller {
+ compatible = "reg-mux";
+ #mux-control-cells = <1>;
+ mux-reg-masks = <0x8 0x00000200>;
+ };
+ };
+
cgc2: clock-controller@2da60000 {
compatible = "fsl,imx8ulp-cgc2";
reg = <0x2da60000 0x10000>;
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v5 1/6] reset: imx8mp-audiomix: Drop unneeded macros
2025-11-14 13:37 ` [PATCH v5 1/6] reset: imx8mp-audiomix: Drop unneeded macros Laurentiu Mihalcea
@ 2025-11-14 15:48 ` Philipp Zabel
0 siblings, 0 replies; 16+ messages in thread
From: Philipp Zabel @ 2025-11-14 15:48 UTC (permalink / raw)
To: Laurentiu Mihalcea, Krzysztof Kozlowski, Conor Dooley, Shawn Guo,
Fabio Estevam, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
On Fr, 2025-11-14 at 05:37 -0800, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> The macros defining the mask values for the EARC, EARC PHY resets,
> and the DSP RUN_STALL signal can be dropped as they are not and will
> not be used anywhere else except to set the value of the "mask" field
> from "struct imx8mp_reset_map". In this particular case, based on the
> name of the "mask" field, you can already deduce what these values are
> for, which is why defining macros for them doesn't offer any new
> information, nor does it help with the code readability.
>
> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
regards
Philipp
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 2/6] reset: imx8mp-audiomix: Replace mask with bit index
2025-11-14 13:37 ` [PATCH v5 2/6] reset: imx8mp-audiomix: Replace mask with bit index Laurentiu Mihalcea
@ 2025-11-14 15:48 ` Philipp Zabel
2025-11-21 15:38 ` Frank Li
1 sibling, 0 replies; 16+ messages in thread
From: Philipp Zabel @ 2025-11-14 15:48 UTC (permalink / raw)
To: Laurentiu Mihalcea, Krzysztof Kozlowski, Conor Dooley, Shawn Guo,
Fabio Estevam, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
On Fr, 2025-11-14 at 05:37 -0800, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> Replace the reset map mask with the bit index to make it clear that all
> reset lines are managed by exactly 1 bit.
>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
regards
Philipp
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 3/6] reset: imx8mp-audiomix: Switch to using regmap API
2025-11-14 13:37 ` [PATCH v5 3/6] reset: imx8mp-audiomix: Switch to using regmap API Laurentiu Mihalcea
@ 2025-11-14 15:49 ` Philipp Zabel
2025-11-21 15:43 ` Frank Li
1 sibling, 0 replies; 16+ messages in thread
From: Philipp Zabel @ 2025-11-14 15:49 UTC (permalink / raw)
To: Laurentiu Mihalcea, Krzysztof Kozlowski, Conor Dooley, Shawn Guo,
Fabio Estevam, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
On Fr, 2025-11-14 at 05:37 -0800, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> Switch to using the regmap API to allow performing register operations
> under the same lock. This is needed for cases such as i.MX8ULP's SIM LPAV
> where clock gating, reset control and MUX-ing is performed via the same
> register (i.e. SYSCTRL0) and different subsystem APIs.
>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
regards
Philipp
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 4/6] reset: imx8mp-audiomix: Extend the driver usage
2025-11-14 13:37 ` [PATCH v5 4/6] reset: imx8mp-audiomix: Extend the driver usage Laurentiu Mihalcea
@ 2025-11-14 16:02 ` Philipp Zabel
2025-11-21 9:29 ` Laurentiu Mihalcea
0 siblings, 1 reply; 16+ messages in thread
From: Philipp Zabel @ 2025-11-14 16:02 UTC (permalink / raw)
To: Laurentiu Mihalcea, Krzysztof Kozlowski, Conor Dooley, Shawn Guo,
Fabio Estevam, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
On Fr, 2025-11-14 at 05:37 -0800, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> Switch to per-device reset map to allow reusing the driver for other NXP
> block control IPs.
>
> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> ---
> drivers/reset/reset-imx8mp-audiomix.c | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c
> index 35df9bd5f71a..d3396f37d1ff 100644
> --- a/drivers/reset/reset-imx8mp-audiomix.c
> +++ b/drivers/reset/reset-imx8mp-audiomix.c
> @@ -24,7 +24,12 @@ struct imx8mp_reset_map {
> bool active_low;
> };
>
> -static const struct imx8mp_reset_map reset_map[] = {
> +struct imx8mp_reset_info {
> + const struct imx8mp_reset_map *map;
> + int num_lines;
> +};
> +
> +static const struct imx8mp_reset_map imx8mp_reset_map[] = {
> [IMX8MP_AUDIOMIX_EARC_RESET] = {
> .offset = IMX8MP_AUDIOMIX_EARC_RESET_OFFSET,
> .bit = 0,
> @@ -42,9 +47,15 @@ static const struct imx8mp_reset_map reset_map[] = {
> },
> };
>
> +static const struct imx8mp_reset_info imx8mp_reset_info = {
> + .map = imx8mp_reset_map,
> + .num_lines = ARRAY_SIZE(imx8mp_reset_map),
> +};
> +
> struct imx8mp_audiomix_reset {
> struct reset_controller_dev rcdev;
> struct regmap *regmap;
> + const struct imx8mp_reset_info *rinfo;
Since only rinfo->map is used in imx8mp_audiomix_update(), you could
directly store a
const struct imx8mp_reset_map *map;
regards
Philipp
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 5/6] reset: imx8mp-audiomix: Support i.MX8ULP SIM LPAV
2025-11-14 13:37 ` [PATCH v5 5/6] reset: imx8mp-audiomix: Support i.MX8ULP SIM LPAV Laurentiu Mihalcea
@ 2025-11-14 16:09 ` Philipp Zabel
0 siblings, 0 replies; 16+ messages in thread
From: Philipp Zabel @ 2025-11-14 16:09 UTC (permalink / raw)
To: Laurentiu Mihalcea, Krzysztof Kozlowski, Conor Dooley, Shawn Guo,
Fabio Estevam, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
On Fr, 2025-11-14 at 05:37 -0800, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> Support i.MX8ULP's SIM LPAV by adding its reset map definition.
>
> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
> drivers/reset/reset-imx8mp-audiomix.c | 45 +++++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c
> index d3396f37d1ff..83fc8bcf80ab 100644
> --- a/drivers/reset/reset-imx8mp-audiomix.c
> +++ b/drivers/reset/reset-imx8mp-audiomix.c
> @@ -3,6 +3,7 @@
> * Copyright 2024 NXP
> */
>
> +#include <dt-bindings/reset/fsl,imx8ulp-sim-lpav.h>
This now depends on 3b521bf8c512 ("dt-bindings: clock: document 8ULP's
SIM LPAV").
regards
Philipp
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 4/6] reset: imx8mp-audiomix: Extend the driver usage
2025-11-14 16:02 ` Philipp Zabel
@ 2025-11-21 9:29 ` Laurentiu Mihalcea
2025-11-21 15:18 ` Philipp Zabel
0 siblings, 1 reply; 16+ messages in thread
From: Laurentiu Mihalcea @ 2025-11-21 9:29 UTC (permalink / raw)
To: Philipp Zabel, Krzysztof Kozlowski, Conor Dooley, Shawn Guo,
Fabio Estevam, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
On 11/14/2025 8:02 AM, Philipp Zabel wrote:
> On Fr, 2025-11-14 at 05:37 -0800, Laurentiu Mihalcea wrote:
>> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>>
>> Switch to per-device reset map to allow reusing the driver for other NXP
>> block control IPs.
>>
>> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
>> Reviewed-by: Frank Li <Frank.Li@nxp.com>
>> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>> ---
>> drivers/reset/reset-imx8mp-audiomix.c | 18 ++++++++++++++++--
>> 1 file changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c
>> index 35df9bd5f71a..d3396f37d1ff 100644
>> --- a/drivers/reset/reset-imx8mp-audiomix.c
>> +++ b/drivers/reset/reset-imx8mp-audiomix.c
>> @@ -24,7 +24,12 @@ struct imx8mp_reset_map {
>> bool active_low;
>> };
>>
>> -static const struct imx8mp_reset_map reset_map[] = {
>> +struct imx8mp_reset_info {
>> + const struct imx8mp_reset_map *map;
>> + int num_lines;
>> +};
>> +
>> +static const struct imx8mp_reset_map imx8mp_reset_map[] = {
>> [IMX8MP_AUDIOMIX_EARC_RESET] = {
>> .offset = IMX8MP_AUDIOMIX_EARC_RESET_OFFSET,
>> .bit = 0,
>> @@ -42,9 +47,15 @@ static const struct imx8mp_reset_map reset_map[] = {
>> },
>> };
>>
>> +static const struct imx8mp_reset_info imx8mp_reset_info = {
>> + .map = imx8mp_reset_map,
>> + .num_lines = ARRAY_SIZE(imx8mp_reset_map),
>> +};
>> +
>> struct imx8mp_audiomix_reset {
>> struct reset_controller_dev rcdev;
>> struct regmap *regmap;
>> + const struct imx8mp_reset_info *rinfo;
> Since only rinfo->map is used in imx8mp_audiomix_update(), you could
> directly store a
>
> const struct imx8mp_reset_map *map;
hm, that is true, but I wonder if instead of replacing "rinfo" with "map", it would be better to
keep "rinfo" and add an out-of-bounds check for the reset ID in imx8mp_audiomix_update().
Something like:
if (id >= priv->rinfo->num_lines)
return -EINVAL;
we are stuck with "struct imx8mp_reset_info" so might as well fully make use of it?
>
>
> regards
> Philipp
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 4/6] reset: imx8mp-audiomix: Extend the driver usage
2025-11-21 9:29 ` Laurentiu Mihalcea
@ 2025-11-21 15:18 ` Philipp Zabel
0 siblings, 0 replies; 16+ messages in thread
From: Philipp Zabel @ 2025-11-21 15:18 UTC (permalink / raw)
To: Laurentiu Mihalcea, Krzysztof Kozlowski, Conor Dooley, Shawn Guo,
Fabio Estevam, Daniel Baluta, Shengjiu Wang, Frank Li
Cc: devicetree, imx, linux-arm-kernel, linux-kernel,
Pengutronix Kernel Team
On Fr, 2025-11-21 at 01:29 -0800, Laurentiu Mihalcea wrote:
> On 11/14/2025 8:02 AM, Philipp Zabel wrote:
> > On Fr, 2025-11-14 at 05:37 -0800, Laurentiu Mihalcea wrote:
> > > From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> > >
> > > Switch to per-device reset map to allow reusing the driver for other NXP
> > > block control IPs.
> > >
> > > Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
> > > Reviewed-by: Frank Li <Frank.Li@nxp.com>
> > > Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> > > ---
> > > drivers/reset/reset-imx8mp-audiomix.c | 18 ++++++++++++++++--
> > > 1 file changed, 16 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c
> > > index 35df9bd5f71a..d3396f37d1ff 100644
> > > --- a/drivers/reset/reset-imx8mp-audiomix.c
> > > +++ b/drivers/reset/reset-imx8mp-audiomix.c
> > > @@ -24,7 +24,12 @@ struct imx8mp_reset_map {
> > > bool active_low;
> > > };
> > >
> > > -static const struct imx8mp_reset_map reset_map[] = {
> > > +struct imx8mp_reset_info {
> > > + const struct imx8mp_reset_map *map;
> > > + int num_lines;
> > > +};
> > > +
> > > +static const struct imx8mp_reset_map imx8mp_reset_map[] = {
> > > [IMX8MP_AUDIOMIX_EARC_RESET] = {
> > > .offset = IMX8MP_AUDIOMIX_EARC_RESET_OFFSET,
> > > .bit = 0,
> > > @@ -42,9 +47,15 @@ static const struct imx8mp_reset_map reset_map[] = {
> > > },
> > > };
> > >
> > > +static const struct imx8mp_reset_info imx8mp_reset_info = {
> > > + .map = imx8mp_reset_map,
> > > + .num_lines = ARRAY_SIZE(imx8mp_reset_map),
> > > +};
> > > +
> > > struct imx8mp_audiomix_reset {
> > > struct reset_controller_dev rcdev;
> > > struct regmap *regmap;
> > > + const struct imx8mp_reset_info *rinfo;
> > Since only rinfo->map is used in imx8mp_audiomix_update(), you could
> > directly store a
> >
> > const struct imx8mp_reset_map *map;
>
>
> hm, that is true, but I wonder if instead of replacing "rinfo" with "map", it would be better to
>
> keep "rinfo" and add an out-of-bounds check for the reset ID in imx8mp_audiomix_update().
>
> Something like:
>
>
> if (id >= priv->rinfo->num_lines)
>
> return -EINVAL;
>
>
> we are stuck with "struct imx8mp_reset_info" so might as well fully make use of it?
There is no need to check this again. You copy rinfo->num_lines into
rcdev.nr_resets, which is checked in of_reset_simple_xlate() before the
reset_control is even handed to the consumer.
regards
Philipp
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 2/6] reset: imx8mp-audiomix: Replace mask with bit index
2025-11-14 13:37 ` [PATCH v5 2/6] reset: imx8mp-audiomix: Replace mask with bit index Laurentiu Mihalcea
2025-11-14 15:48 ` Philipp Zabel
@ 2025-11-21 15:38 ` Frank Li
1 sibling, 0 replies; 16+ messages in thread
From: Frank Li @ 2025-11-21 15:38 UTC (permalink / raw)
To: Laurentiu Mihalcea
Cc: Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Fabio Estevam,
Philipp Zabel, Daniel Baluta, Shengjiu Wang, devicetree, imx,
linux-arm-kernel, linux-kernel, Pengutronix Kernel Team
On Fri, Nov 14, 2025 at 05:37:34AM -0800, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> Replace the reset map mask with the bit index to make it clear that all
> reset lines are managed by exactly 1 bit.
I don't think there are benefit because I met some periphal need a magic
number to reset.
>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> ---
> drivers/reset/reset-imx8mp-audiomix.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c
> index acfa92b15329..d993c294c548 100644
> --- a/drivers/reset/reset-imx8mp-audiomix.c
> +++ b/drivers/reset/reset-imx8mp-audiomix.c
> @@ -19,24 +19,24 @@
>
> struct imx8mp_reset_map {
> unsigned int offset;
> - unsigned int mask;
> + unsigned int bit;
> bool active_low;
> };
>
> static const struct imx8mp_reset_map reset_map[] = {
> [IMX8MP_AUDIOMIX_EARC_RESET] = {
> .offset = IMX8MP_AUDIOMIX_EARC_RESET_OFFSET,
> - .mask = BIT(0),
> + .bit = 0,
> .active_low = true,
> },
> [IMX8MP_AUDIOMIX_EARC_PHY_RESET] = {
> .offset = IMX8MP_AUDIOMIX_EARC_RESET_OFFSET,
> - .mask = BIT(1),
> + .bit = 1,
> .active_low = true,
> },
> [IMX8MP_AUDIOMIX_DSP_RUNSTALL] = {
> .offset = IMX8MP_AUDIOMIX_DSP_RUNSTALL_OFFSET,
> - .mask = BIT(5),
> + .bit = 5,
> .active_low = false,
> },
> };
> @@ -60,7 +60,7 @@ static int imx8mp_audiomix_update(struct reset_controller_dev *rcdev,
> unsigned int mask, offset, active_low;
> unsigned long reg, flags;
>
> - mask = reset_map[id].mask;
> + mask = BIT(reset_map[id].bit);
> offset = reset_map[id].offset;
> active_low = reset_map[id].active_low;
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 3/6] reset: imx8mp-audiomix: Switch to using regmap API
2025-11-14 13:37 ` [PATCH v5 3/6] reset: imx8mp-audiomix: Switch to using regmap API Laurentiu Mihalcea
2025-11-14 15:49 ` Philipp Zabel
@ 2025-11-21 15:43 ` Frank Li
1 sibling, 0 replies; 16+ messages in thread
From: Frank Li @ 2025-11-21 15:43 UTC (permalink / raw)
To: Laurentiu Mihalcea
Cc: Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Fabio Estevam,
Philipp Zabel, Daniel Baluta, Shengjiu Wang, devicetree, imx,
linux-arm-kernel, linux-kernel, Pengutronix Kernel Team
On Fri, Nov 14, 2025 at 05:37:35AM -0800, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> Switch to using the regmap API to allow performing register operations
> under the same lock. This is needed for cases such as i.MX8ULP's SIM LPAV
> where clock gating, reset control and MUX-ing is performed via the same
> register (i.e. SYSCTRL0) and different subsystem APIs.
>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/reset/reset-imx8mp-audiomix.c | 92 +++++++++++++++++----------
> 1 file changed, 57 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c
> index d993c294c548..35df9bd5f71a 100644
> --- a/drivers/reset/reset-imx8mp-audiomix.c
> +++ b/drivers/reset/reset-imx8mp-audiomix.c
> @@ -12,6 +12,7 @@
> #include <linux/module.h>
> #include <linux/of.h>
> #include <linux/of_address.h>
> +#include <linux/regmap.h>
> #include <linux/reset-controller.h>
>
> #define IMX8MP_AUDIOMIX_EARC_RESET_OFFSET 0x200
> @@ -43,8 +44,7 @@ static const struct imx8mp_reset_map reset_map[] = {
>
> struct imx8mp_audiomix_reset {
> struct reset_controller_dev rcdev;
> - spinlock_t lock; /* protect register read-modify-write cycle */
> - void __iomem *base;
> + struct regmap *regmap;
> };
>
> static struct imx8mp_audiomix_reset *to_imx8mp_audiomix_reset(struct reset_controller_dev *rcdev)
> @@ -56,26 +56,14 @@ static int imx8mp_audiomix_update(struct reset_controller_dev *rcdev,
> unsigned long id, bool assert)
> {
> struct imx8mp_audiomix_reset *priv = to_imx8mp_audiomix_reset(rcdev);
> - void __iomem *reg_addr = priv->base;
> - unsigned int mask, offset, active_low;
> - unsigned long reg, flags;
> + unsigned int mask, offset, active_low, val;
>
> mask = BIT(reset_map[id].bit);
> offset = reset_map[id].offset;
> active_low = reset_map[id].active_low;
> + val = (active_low ^ assert) << reset_map[id].bit;
>
> - spin_lock_irqsave(&priv->lock, flags);
> -
> - reg = readl(reg_addr + offset);
> - if (active_low ^ assert)
> - reg |= mask;
> - else
> - reg &= ~mask;
> - writel(reg, reg_addr + offset);
> -
> - spin_unlock_irqrestore(&priv->lock, flags);
> -
> - return 0;
> + return regmap_update_bits(priv->regmap, offset, mask, val);
> }
>
> static int imx8mp_audiomix_reset_assert(struct reset_controller_dev *rcdev,
> @@ -95,6 +83,52 @@ static const struct reset_control_ops imx8mp_audiomix_reset_ops = {
> .deassert = imx8mp_audiomix_reset_deassert,
> };
>
> +static const struct regmap_config regmap_config = {
> + .reg_bits = 32,
> + .val_bits = 32,
> + .reg_stride = 4,
> +};
> +
> +/* assumption: registered only if not using parent regmap */
> +static void imx8mp_audiomix_reset_iounmap(void *data)
> +{
> + void __iomem *base = (void __iomem *)data;
> +
> + iounmap(base);
> +}
> +
> +static int imx8mp_audiomix_reset_get_regmap(struct imx8mp_audiomix_reset *priv)
> +{
> + void __iomem *base;
> + struct device *dev;
> + int ret;
> +
> + dev = priv->rcdev.dev;
> +
> + /* try to use the parent's regmap */
> + priv->regmap = dev_get_regmap(dev->parent, NULL);
> + if (priv->regmap)
> + return 0;
> +
> + /* ... if that's not possible then initialize the regmap right now */
> + base = of_iomap(dev->parent->of_node, 0);
> + if (!base)
> + return dev_err_probe(dev, -ENOMEM, "failed to iomap address space\n");
> +
> + ret = devm_add_action_or_reset(dev,
> + imx8mp_audiomix_reset_iounmap,
> + (void __force *)base);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to register action\n");
> +
> + priv->regmap = devm_regmap_init_mmio(dev, base, ®map_config);
> + if (IS_ERR(priv->regmap))
> + return dev_err_probe(dev, PTR_ERR(priv->regmap),
> + "failed to initialize regmap\n");
> +
> + return 0;
> +}
> +
> static int imx8mp_audiomix_reset_probe(struct auxiliary_device *adev,
> const struct auxiliary_device_id *id)
> {
> @@ -106,36 +140,25 @@ static int imx8mp_audiomix_reset_probe(struct auxiliary_device *adev,
> if (!priv)
> return -ENOMEM;
>
> - spin_lock_init(&priv->lock);
> -
> priv->rcdev.owner = THIS_MODULE;
> priv->rcdev.nr_resets = ARRAY_SIZE(reset_map);
> priv->rcdev.ops = &imx8mp_audiomix_reset_ops;
> priv->rcdev.of_node = dev->parent->of_node;
> priv->rcdev.dev = dev;
> priv->rcdev.of_reset_n_cells = 1;
> - priv->base = of_iomap(dev->parent->of_node, 0);
> - if (!priv->base)
> - return -ENOMEM;
>
> dev_set_drvdata(dev, priv);
>
> + ret = imx8mp_audiomix_reset_get_regmap(priv);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to get regmap\n");
> +
> ret = devm_reset_controller_register(dev, &priv->rcdev);
> if (ret)
> - goto out_unmap;
> + return dev_err_probe(dev, ret,
> + "failed to register reset controller\n");
>
> return 0;
> -
> -out_unmap:
> - iounmap(priv->base);
> - return ret;
> -}
> -
> -static void imx8mp_audiomix_reset_remove(struct auxiliary_device *adev)
> -{
> - struct imx8mp_audiomix_reset *priv = dev_get_drvdata(&adev->dev);
> -
> - iounmap(priv->base);
> }
>
> static const struct auxiliary_device_id imx8mp_audiomix_reset_ids[] = {
> @@ -148,7 +171,6 @@ MODULE_DEVICE_TABLE(auxiliary, imx8mp_audiomix_reset_ids);
>
> static struct auxiliary_driver imx8mp_audiomix_reset_driver = {
> .probe = imx8mp_audiomix_reset_probe,
> - .remove = imx8mp_audiomix_reset_remove,
> .id_table = imx8mp_audiomix_reset_ids,
> };
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2025-11-21 15:43 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-14 13:37 [PATCH v5 0/6] Add support for i.MX8ULP's SIM LPAV Laurentiu Mihalcea
2025-11-14 13:37 ` [PATCH v5 1/6] reset: imx8mp-audiomix: Drop unneeded macros Laurentiu Mihalcea
2025-11-14 15:48 ` Philipp Zabel
2025-11-14 13:37 ` [PATCH v5 2/6] reset: imx8mp-audiomix: Replace mask with bit index Laurentiu Mihalcea
2025-11-14 15:48 ` Philipp Zabel
2025-11-21 15:38 ` Frank Li
2025-11-14 13:37 ` [PATCH v5 3/6] reset: imx8mp-audiomix: Switch to using regmap API Laurentiu Mihalcea
2025-11-14 15:49 ` Philipp Zabel
2025-11-21 15:43 ` Frank Li
2025-11-14 13:37 ` [PATCH v5 4/6] reset: imx8mp-audiomix: Extend the driver usage Laurentiu Mihalcea
2025-11-14 16:02 ` Philipp Zabel
2025-11-21 9:29 ` Laurentiu Mihalcea
2025-11-21 15:18 ` Philipp Zabel
2025-11-14 13:37 ` [PATCH v5 5/6] reset: imx8mp-audiomix: Support i.MX8ULP SIM LPAV Laurentiu Mihalcea
2025-11-14 16:09 ` Philipp Zabel
2025-11-14 13:37 ` [PATCH v5 6/6] arm64: dts: imx8ulp: add sim lpav node Laurentiu Mihalcea
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).