Message ID | 20250218085712.66690-4-daniel.baluta@nxp.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | imx8mp: Add support to Run/Stall DSP via reset API | expand |
On Di, 2025-02-18 at 10:57 +0200, Daniel Baluta wrote: > For EARC and EARC PHY the reset happens when clearing the reset bits. > Refactor assert/deassert function in order to take into account > the active_low configuratin option. ^ missing 'o'. > > Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> > --- > drivers/reset/reset-imx8mp-audiomix.c | 45 ++++++++++++++------------- > 1 file changed, 23 insertions(+), 22 deletions(-) > > diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c > index 6b1666c4e069..8cc0a6b58cbc 100644 > --- a/drivers/reset/reset-imx8mp-audiomix.c > +++ b/drivers/reset/reset-imx8mp-audiomix.c > @@ -23,16 +23,19 @@ > struct imx8mp_reset_map { > unsigned int offset; > unsigned int mask; > + bool active_low; > }; > > 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, > + .active_low = true, > }, > [IMX8MP_AUDIOMIX_EARC_PHY] = { > .offset = IMX8MP_AUDIOMIX_EARC_OFFSET, > .mask = IMX8MP_AUDIOMIX_EARC_PHY_RESET_MASK, > + .active_low = true, > }, > > }; > @@ -48,48 +51,46 @@ static struct imx8mp_audiomix_reset *to_imx8mp_audiomix_reset(struct reset_contr > return container_of(rcdev, struct imx8mp_audiomix_reset, rcdev); > } > > -static int imx8mp_audiomix_reset_assert(struct reset_controller_dev *rcdev, > - unsigned long id) > +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, reg; > - unsigned long flags; > + unsigned int mask, offset, active_low; > + unsigned long reg, flags; Nitpick, I would make active_low bool, like assert. Otherwise, Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> regards Philipp
On Tue, Feb 18, 2025 at 10:57:10AM +0200, Daniel Baluta wrote: >For EARC and EARC PHY the reset happens when clearing the reset bits. >Refactor assert/deassert function in order to take into account >the active_low configuratin option. > >Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> >--- > drivers/reset/reset-imx8mp-audiomix.c | 45 ++++++++++++++------------- > 1 file changed, 23 insertions(+), 22 deletions(-) > >diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c >index 6b1666c4e069..8cc0a6b58cbc 100644 >--- a/drivers/reset/reset-imx8mp-audiomix.c >+++ b/drivers/reset/reset-imx8mp-audiomix.c >@@ -23,16 +23,19 @@ > struct imx8mp_reset_map { > unsigned int offset; > unsigned int mask; >+ bool active_low; How about using u32 flags? Then it will be easy to extend to add new FLAG in future in case. If you tend to use bool, also ok to me: Reviewed-by: Peng Fan <peng.fan@nxp.com>
On Tue, Feb 18, 2025 at 10:30:21AM +0100, Philipp Zabel wrote: > On Di, 2025-02-18 at 10:57 +0200, Daniel Baluta wrote: > > For EARC and EARC PHY the reset happens when clearing the reset bits. > > Refactor assert/deassert function in order to take into account > > the active_low configuratin option. > ^ > missing 'o'. run ./scripts/checkpatch.pl -g HEAD --strict --codespell Frank > > > > > Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> > > --- > > drivers/reset/reset-imx8mp-audiomix.c | 45 ++++++++++++++------------- > > 1 file changed, 23 insertions(+), 22 deletions(-) > > > > diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c > > index 6b1666c4e069..8cc0a6b58cbc 100644 > > --- a/drivers/reset/reset-imx8mp-audiomix.c > > +++ b/drivers/reset/reset-imx8mp-audiomix.c > > @@ -23,16 +23,19 @@ > > struct imx8mp_reset_map { > > unsigned int offset; > > unsigned int mask; > > + bool active_low; > > }; > > > > 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, > > + .active_low = true, > > }, > > [IMX8MP_AUDIOMIX_EARC_PHY] = { > > .offset = IMX8MP_AUDIOMIX_EARC_OFFSET, > > .mask = IMX8MP_AUDIOMIX_EARC_PHY_RESET_MASK, > > + .active_low = true, > > }, > > > > }; > > @@ -48,48 +51,46 @@ static struct imx8mp_audiomix_reset *to_imx8mp_audiomix_reset(struct reset_contr > > return container_of(rcdev, struct imx8mp_audiomix_reset, rcdev); > > } > > > > -static int imx8mp_audiomix_reset_assert(struct reset_controller_dev *rcdev, > > - unsigned long id) > > +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, reg; > > - unsigned long flags; > > + unsigned int mask, offset, active_low; > > + unsigned long reg, flags; > > Nitpick, I would make active_low bool, like assert. Otherwise, > > Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> > > regards > Philipp
On Tue, Feb 18, 2025 at 10:57:10AM +0200, Daniel Baluta wrote: > For EARC and EARC PHY the reset happens when clearing the reset bits. > Refactor assert/deassert function in order to take into account > the active_low configuratin option. > > Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> > --- > drivers/reset/reset-imx8mp-audiomix.c | 45 ++++++++++++++------------- > 1 file changed, 23 insertions(+), 22 deletions(-) > > diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c > index 6b1666c4e069..8cc0a6b58cbc 100644 > --- a/drivers/reset/reset-imx8mp-audiomix.c > +++ b/drivers/reset/reset-imx8mp-audiomix.c > @@ -23,16 +23,19 @@ > struct imx8mp_reset_map { > unsigned int offset; > unsigned int mask; > + bool active_low; > }; > > 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, > + .active_low = true, > }, > [IMX8MP_AUDIOMIX_EARC_PHY] = { > .offset = IMX8MP_AUDIOMIX_EARC_OFFSET, > .mask = IMX8MP_AUDIOMIX_EARC_PHY_RESET_MASK, > + .active_low = true, > }, > > }; > @@ -48,48 +51,46 @@ static struct imx8mp_audiomix_reset *to_imx8mp_audiomix_reset(struct reset_contr > return container_of(rcdev, struct imx8mp_audiomix_reset, rcdev); > } > > -static int imx8mp_audiomix_reset_assert(struct reset_controller_dev *rcdev, > - unsigned long id) > +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, reg; > - unsigned long flags; > + unsigned int mask, offset, active_low; > + unsigned long reg, flags; > > if (id >= IMX8MP_AUDIOMIX_RESET_NUM) > return -EINVAL; > > mask = reset_map[id].mask; > offset = reset_map[id].offset; > + active_low = reset_map[id].active_low; > > spin_lock_irqsave(&priv->lock, flags); > + > reg = readl(reg_addr + offset); > - writel(reg & ~mask, 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; > } > > + > +static int imx8mp_audiomix_reset_assert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + return imx8mp_audiomix_update(rcdev, id, true); > +} > + > static int imx8mp_audiomix_reset_deassert(struct reset_controller_dev *rcdev, > unsigned long id) > { > - struct imx8mp_audiomix_reset *priv = to_imx8mp_audiomix_reset(rcdev); > - void __iomem *reg_addr = priv->base; > - unsigned int mask, offset, reg; > - unsigned long flags; > - > - 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 + offset); > - writel(reg | mask, reg_addr + offset); > - spin_unlock_irqrestore(&priv->lock, flags); > - > - return 0; > + return imx8mp_audiomix_update(rcdev, id, false); > } > > static const struct reset_control_ops imx8mp_audiomix_reset_ops = { > -- > 2.25.1 >
diff --git a/drivers/reset/reset-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c index 6b1666c4e069..8cc0a6b58cbc 100644 --- a/drivers/reset/reset-imx8mp-audiomix.c +++ b/drivers/reset/reset-imx8mp-audiomix.c @@ -23,16 +23,19 @@ struct imx8mp_reset_map { unsigned int offset; unsigned int mask; + bool active_low; }; 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, + .active_low = true, }, [IMX8MP_AUDIOMIX_EARC_PHY] = { .offset = IMX8MP_AUDIOMIX_EARC_OFFSET, .mask = IMX8MP_AUDIOMIX_EARC_PHY_RESET_MASK, + .active_low = true, }, }; @@ -48,48 +51,46 @@ static struct imx8mp_audiomix_reset *to_imx8mp_audiomix_reset(struct reset_contr return container_of(rcdev, struct imx8mp_audiomix_reset, rcdev); } -static int imx8mp_audiomix_reset_assert(struct reset_controller_dev *rcdev, - unsigned long id) +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, reg; - unsigned long flags; + unsigned int mask, offset, active_low; + unsigned long reg, flags; if (id >= IMX8MP_AUDIOMIX_RESET_NUM) return -EINVAL; mask = reset_map[id].mask; offset = reset_map[id].offset; + active_low = reset_map[id].active_low; spin_lock_irqsave(&priv->lock, flags); + reg = readl(reg_addr + offset); - writel(reg & ~mask, 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; } + +static int imx8mp_audiomix_reset_assert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + return imx8mp_audiomix_update(rcdev, id, true); +} + static int imx8mp_audiomix_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id) { - struct imx8mp_audiomix_reset *priv = to_imx8mp_audiomix_reset(rcdev); - void __iomem *reg_addr = priv->base; - unsigned int mask, offset, reg; - unsigned long flags; - - 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 + offset); - writel(reg | mask, reg_addr + offset); - spin_unlock_irqrestore(&priv->lock, flags); - - return 0; + return imx8mp_audiomix_update(rcdev, id, false); } static const struct reset_control_ops imx8mp_audiomix_reset_ops = {
For EARC and EARC PHY the reset happens when clearing the reset bits. Refactor assert/deassert function in order to take into account the active_low configuratin option. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> --- drivers/reset/reset-imx8mp-audiomix.c | 45 ++++++++++++++------------- 1 file changed, 23 insertions(+), 22 deletions(-)