* [PATCH 1/4] clk: eyeq: use the auxiliary device creation helper
2025-06-11 12:53 [PATCH 0/4] clk: use the auxiliary device creation helper Jerome Brunet
@ 2025-06-11 12:53 ` Jerome Brunet
2025-06-11 12:53 ` [PATCH 2/4] reset: eyeq: drop device_set_of_node_from_dev() done by parent Jerome Brunet
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Jerome Brunet @ 2025-06-11 12:53 UTC (permalink / raw)
To: Vladimir Kondratiev, Gregory CLEMENT, Théo Lebrun,
Michael Turquette, Stephen Boyd, Philipp Zabel, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Neil Armstrong, Kevin Hilman, Martin Blumenstingl
Cc: linux-mips, linux-clk, linux-kernel, imx, linux-arm-kernel,
linux-amlogic, Jerome Brunet
The auxiliary device creation of this driver is simple enough to
use the available auxiliary device creation helper.
Use it and remove some boilerplate code.
Tested-by: Théo Lebrun <theo.lebrun@bootlin.com> # On Mobileye EyeQ5
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/clk/clk-eyeq.c | 57 +++++++++++---------------------------------------
1 file changed, 12 insertions(+), 45 deletions(-)
diff --git a/drivers/clk/clk-eyeq.c b/drivers/clk/clk-eyeq.c
index 640c25788487f8cf6fb4431ed6fb612cf099f114..4094f34af05b488545cc87043fb3352968515a78 100644
--- a/drivers/clk/clk-eyeq.c
+++ b/drivers/clk/clk-eyeq.c
@@ -322,38 +322,18 @@ static void eqc_probe_init_fixed_factors(struct device *dev,
}
}
-static void eqc_auxdev_release(struct device *dev)
-{
- struct auxiliary_device *adev = to_auxiliary_dev(dev);
-
- kfree(adev);
-}
-
-static int eqc_auxdev_create(struct device *dev, void __iomem *base,
- const char *name, u32 id)
+static void eqc_auxdev_create_optional(struct device *dev, void __iomem *base,
+ const char *name)
{
struct auxiliary_device *adev;
- int ret;
-
- adev = kzalloc(sizeof(*adev), GFP_KERNEL);
- if (!adev)
- return -ENOMEM;
-
- adev->name = name;
- adev->dev.parent = dev;
- adev->dev.platform_data = (void __force *)base;
- adev->dev.release = eqc_auxdev_release;
- adev->id = id;
- ret = auxiliary_device_init(adev);
- if (ret)
- return ret;
-
- ret = auxiliary_device_add(adev);
- if (ret)
- auxiliary_device_uninit(adev);
-
- return ret;
+ if (name) {
+ adev = devm_auxiliary_device_create(dev, name,
+ (void __force *)base);
+ if (!adev)
+ dev_warn(dev, "failed creating auxiliary device %s.%s\n",
+ KBUILD_MODNAME, name);
+ }
}
static int eqc_probe(struct platform_device *pdev)
@@ -365,7 +345,6 @@ static int eqc_probe(struct platform_device *pdev)
unsigned int i, clk_count;
struct resource *res;
void __iomem *base;
- int ret;
data = device_get_match_data(dev);
if (!data)
@@ -379,21 +358,9 @@ static int eqc_probe(struct platform_device *pdev)
if (!base)
return -ENOMEM;
- /* Init optional reset auxiliary device. */
- if (data->reset_auxdev_name) {
- ret = eqc_auxdev_create(dev, base, data->reset_auxdev_name, 0);
- if (ret)
- dev_warn(dev, "failed creating auxiliary device %s.%s: %d\n",
- KBUILD_MODNAME, data->reset_auxdev_name, ret);
- }
-
- /* Init optional pinctrl auxiliary device. */
- if (data->pinctrl_auxdev_name) {
- ret = eqc_auxdev_create(dev, base, data->pinctrl_auxdev_name, 0);
- if (ret)
- dev_warn(dev, "failed creating auxiliary device %s.%s: %d\n",
- KBUILD_MODNAME, data->pinctrl_auxdev_name, ret);
- }
+ /* Init optional auxiliary devices. */
+ eqc_auxdev_create_optional(dev, base, data->reset_auxdev_name);
+ eqc_auxdev_create_optional(dev, base, data->pinctrl_auxdev_name);
if (data->pll_count + data->div_count + data->fixed_factor_count == 0)
return 0; /* Zero clocks, we are done. */
--
2.47.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/4] reset: eyeq: drop device_set_of_node_from_dev() done by parent
2025-06-11 12:53 [PATCH 0/4] clk: use the auxiliary device creation helper Jerome Brunet
2025-06-11 12:53 ` [PATCH 1/4] clk: eyeq: " Jerome Brunet
@ 2025-06-11 12:53 ` Jerome Brunet
2025-06-11 12:53 ` [PATCH 3/4] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper Jerome Brunet
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Jerome Brunet @ 2025-06-11 12:53 UTC (permalink / raw)
To: Vladimir Kondratiev, Gregory CLEMENT, Théo Lebrun,
Michael Turquette, Stephen Boyd, Philipp Zabel, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Neil Armstrong, Kevin Hilman, Martin Blumenstingl
Cc: linux-mips, linux-clk, linux-kernel, imx, linux-arm-kernel,
linux-amlogic, Jerome Brunet
From: Théo Lebrun <theo.lebrun@bootlin.com>
Our parent driver (clk-eyeq) now does the
device_set_of_node_from_dev(dev, dev->parent)
call through the newly introduced devm_auxiliary_device_create() helper.
Doing it again in the reset-eyeq probe would be redundant.
Drop both the WARN_ON() and the device_set_of_node_from_dev() call.
Also fix the following comment that talks about "our newfound OF node".
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/reset/reset-eyeq.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/reset/reset-eyeq.c b/drivers/reset/reset-eyeq.c
index 02d50041048b42921e3e511148cd29f215b5fc5e..8018fa895427bb1e51ea23b99803dc7fe6108421 100644
--- a/drivers/reset/reset-eyeq.c
+++ b/drivers/reset/reset-eyeq.c
@@ -420,17 +420,8 @@ static int eqr_probe(struct auxiliary_device *adev,
int ret;
/*
- * We are an auxiliary device of clk-eyeq. We do not have an OF node by
- * default; let's reuse our parent's OF node.
- */
- WARN_ON(dev->of_node);
- device_set_of_node_from_dev(dev, dev->parent);
- if (!dev->of_node)
- return -ENODEV;
-
- /*
- * Using our newfound OF node, we can get match data. We cannot use
- * device_get_match_data() because it does not match reused OF nodes.
+ * Get match data. We cannot use device_get_match_data() because it does
+ * not accept reused OF nodes; see device_set_of_node_from_dev().
*/
match = of_match_node(dev->driver->of_match_table, dev->of_node);
if (!match || !match->data)
--
2.47.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 3/4] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
2025-06-11 12:53 [PATCH 0/4] clk: use the auxiliary device creation helper Jerome Brunet
2025-06-11 12:53 ` [PATCH 1/4] clk: eyeq: " Jerome Brunet
2025-06-11 12:53 ` [PATCH 2/4] reset: eyeq: drop device_set_of_node_from_dev() done by parent Jerome Brunet
@ 2025-06-11 12:53 ` Jerome Brunet
2025-06-11 16:48 ` Frank Li
2025-06-11 12:53 ` [PATCH 4/4] clk: amlogic: axg-audio: use the auxiliary reset driver Jerome Brunet
2025-06-23 13:29 ` (subset) [PATCH 0/4] clk: use the auxiliary device creation helper Jerome Brunet
4 siblings, 1 reply; 8+ messages in thread
From: Jerome Brunet @ 2025-06-11 12:53 UTC (permalink / raw)
To: Vladimir Kondratiev, Gregory CLEMENT, Théo Lebrun,
Michael Turquette, Stephen Boyd, Philipp Zabel, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Neil Armstrong, Kevin Hilman, Martin Blumenstingl
Cc: linux-mips, linux-clk, linux-kernel, imx, linux-arm-kernel,
linux-amlogic, Jerome Brunet
The auxiliary device creation of this driver is simple enough to
use the available auxiliary device creation helper.
Use it and remove some boilerplate code.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/clk/imx/clk-imx8mp-audiomix.c | 49 ++++++-----------------------------
1 file changed, 8 insertions(+), 41 deletions(-)
diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
index 775f62dddb11d8cfd17a4ebf7a677ef399c5e617..765fb1f5bd4fa2b039d7414abd89471438ee41dd 100644
--- a/drivers/clk/imx/clk-imx8mp-audiomix.c
+++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
@@ -230,61 +230,28 @@ struct clk_imx8mp_audiomix_priv {
#if IS_ENABLED(CONFIG_RESET_CONTROLLER)
-static void clk_imx8mp_audiomix_reset_unregister_adev(void *_adev)
+static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev)
{
- struct auxiliary_device *adev = _adev;
-
- auxiliary_device_delete(adev);
- auxiliary_device_uninit(adev);
-}
-
-static void clk_imx8mp_audiomix_reset_adev_release(struct device *dev)
-{
- struct auxiliary_device *adev = to_auxiliary_dev(dev);
-
- kfree(adev);
-}
-
-static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
- struct clk_imx8mp_audiomix_priv *priv)
-{
- struct auxiliary_device *adev __free(kfree) = NULL;
- int ret;
+ struct auxiliary_device *adev;
if (!of_property_present(dev->of_node, "#reset-cells"))
return 0;
- adev = kzalloc(sizeof(*adev), GFP_KERNEL);
+ adev = devm_auxiliary_device_create(dev, "reset", NULL);
if (!adev)
- return -ENOMEM;
-
- adev->name = "reset";
- adev->dev.parent = dev;
- adev->dev.release = clk_imx8mp_audiomix_reset_adev_release;
-
- ret = auxiliary_device_init(adev);
- if (ret)
- return ret;
+ return -ENODEV;
- ret = auxiliary_device_add(adev);
- if (ret) {
- auxiliary_device_uninit(adev);
- return ret;
- }
-
- return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev,
- no_free_ptr(adev));
+ return 0;
}
#else /* !CONFIG_RESET_CONTROLLER */
-static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
- struct clk_imx8mp_audiomix_priv *priv)
+static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev)
{
return 0;
}
-#endif /* !CONFIG_RESET_CONTROLLER */
+#endif
static void clk_imx8mp_audiomix_save_restore(struct device *dev, bool save)
{
@@ -408,7 +375,7 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev)
if (ret)
goto err_clk_register;
- ret = clk_imx8mp_audiomix_reset_controller_register(dev, priv);
+ ret = clk_imx8mp_audiomix_reset_controller_register(dev);
if (ret)
goto err_clk_register;
--
2.47.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 3/4] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
2025-06-11 12:53 ` [PATCH 3/4] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper Jerome Brunet
@ 2025-06-11 16:48 ` Frank Li
2025-06-23 9:04 ` Jerome Brunet
0 siblings, 1 reply; 8+ messages in thread
From: Frank Li @ 2025-06-11 16:48 UTC (permalink / raw)
To: Jerome Brunet
Cc: Vladimir Kondratiev, Gregory CLEMENT, Théo Lebrun,
Michael Turquette, Stephen Boyd, Philipp Zabel, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Neil Armstrong, Kevin Hilman, Martin Blumenstingl,
linux-mips, linux-clk, linux-kernel, imx, linux-arm-kernel,
linux-amlogic
On Wed, Jun 11, 2025 at 02:53:58PM +0200, Jerome Brunet wrote:
> The auxiliary device creation of this driver is simple enough to
> use the available auxiliary device creation helper.
>
> Use it and remove some boilerplate code.
Actaully, you also remove unused struct clk_imx8mp_audiomix_priv *priv
at clk_imx8mp_audiomix_reset_controller_register().
Please add it into comments.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
>
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---
> drivers/clk/imx/clk-imx8mp-audiomix.c | 49 ++++++-----------------------------
> 1 file changed, 8 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
> index 775f62dddb11d8cfd17a4ebf7a677ef399c5e617..765fb1f5bd4fa2b039d7414abd89471438ee41dd 100644
> --- a/drivers/clk/imx/clk-imx8mp-audiomix.c
> +++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
> @@ -230,61 +230,28 @@ struct clk_imx8mp_audiomix_priv {
>
> #if IS_ENABLED(CONFIG_RESET_CONTROLLER)
>
> -static void clk_imx8mp_audiomix_reset_unregister_adev(void *_adev)
> +static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev)
> {
> - struct auxiliary_device *adev = _adev;
> -
> - auxiliary_device_delete(adev);
> - auxiliary_device_uninit(adev);
> -}
> -
> -static void clk_imx8mp_audiomix_reset_adev_release(struct device *dev)
> -{
> - struct auxiliary_device *adev = to_auxiliary_dev(dev);
> -
> - kfree(adev);
> -}
> -
> -static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
> - struct clk_imx8mp_audiomix_priv *priv)
> -{
> - struct auxiliary_device *adev __free(kfree) = NULL;
> - int ret;
> + struct auxiliary_device *adev;
>
> if (!of_property_present(dev->of_node, "#reset-cells"))
> return 0;
>
> - adev = kzalloc(sizeof(*adev), GFP_KERNEL);
> + adev = devm_auxiliary_device_create(dev, "reset", NULL);
> if (!adev)
> - return -ENOMEM;
> -
> - adev->name = "reset";
> - adev->dev.parent = dev;
> - adev->dev.release = clk_imx8mp_audiomix_reset_adev_release;
> -
> - ret = auxiliary_device_init(adev);
> - if (ret)
> - return ret;
> + return -ENODEV;
>
> - ret = auxiliary_device_add(adev);
> - if (ret) {
> - auxiliary_device_uninit(adev);
> - return ret;
> - }
> -
> - return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev,
> - no_free_ptr(adev));
> + return 0;
> }
>
> #else /* !CONFIG_RESET_CONTROLLER */
>
> -static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
> - struct clk_imx8mp_audiomix_priv *priv)
> +static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev)
> {
> return 0;
> }
>
> -#endif /* !CONFIG_RESET_CONTROLLER */
> +#endif
>
> static void clk_imx8mp_audiomix_save_restore(struct device *dev, bool save)
> {
> @@ -408,7 +375,7 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev)
> if (ret)
> goto err_clk_register;
>
> - ret = clk_imx8mp_audiomix_reset_controller_register(dev, priv);
> + ret = clk_imx8mp_audiomix_reset_controller_register(dev);
> if (ret)
> goto err_clk_register;
>
>
> --
> 2.47.2
>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 3/4] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
2025-06-11 16:48 ` Frank Li
@ 2025-06-23 9:04 ` Jerome Brunet
0 siblings, 0 replies; 8+ messages in thread
From: Jerome Brunet @ 2025-06-23 9:04 UTC (permalink / raw)
To: Frank Li
Cc: Vladimir Kondratiev, Gregory CLEMENT, Théo Lebrun,
Michael Turquette, Stephen Boyd, Philipp Zabel, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Neil Armstrong, Kevin Hilman, Martin Blumenstingl,
linux-mips, linux-clk, linux-kernel, imx, linux-arm-kernel,
linux-amlogic
On Wed 11 Jun 2025 at 12:48, Frank Li <Frank.li@nxp.com> wrote:
> On Wed, Jun 11, 2025 at 02:53:58PM +0200, Jerome Brunet wrote:
>> The auxiliary device creation of this driver is simple enough to
>> use the available auxiliary device creation helper.
>>
>> Use it and remove some boilerplate code.
>
> Actaully, you also remove unused struct clk_imx8mp_audiomix_priv *priv
> at clk_imx8mp_audiomix_reset_controller_register().
>
> Please add it into comments.
That's merely a side effect of removing the boilerplate code.
Like for the other changes of the same kind, I don't think listing the
symbols removed would be useful to the change description
>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
>
>>
>> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
>> ---
>> drivers/clk/imx/clk-imx8mp-audiomix.c | 49 ++++++-----------------------------
>> 1 file changed, 8 insertions(+), 41 deletions(-)
>>
>> diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
>> index 775f62dddb11d8cfd17a4ebf7a677ef399c5e617..765fb1f5bd4fa2b039d7414abd89471438ee41dd 100644
>> --- a/drivers/clk/imx/clk-imx8mp-audiomix.c
>> +++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
>> @@ -230,61 +230,28 @@ struct clk_imx8mp_audiomix_priv {
>>
>> #if IS_ENABLED(CONFIG_RESET_CONTROLLER)
>>
>> -static void clk_imx8mp_audiomix_reset_unregister_adev(void *_adev)
>> +static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev)
>> {
>> - struct auxiliary_device *adev = _adev;
>> -
>> - auxiliary_device_delete(adev);
>> - auxiliary_device_uninit(adev);
>> -}
>> -
>> -static void clk_imx8mp_audiomix_reset_adev_release(struct device *dev)
>> -{
>> - struct auxiliary_device *adev = to_auxiliary_dev(dev);
>> -
>> - kfree(adev);
>> -}
>> -
>> -static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
>> - struct clk_imx8mp_audiomix_priv *priv)
>> -{
>> - struct auxiliary_device *adev __free(kfree) = NULL;
>> - int ret;
>> + struct auxiliary_device *adev;
>>
>> if (!of_property_present(dev->of_node, "#reset-cells"))
>> return 0;
>>
>> - adev = kzalloc(sizeof(*adev), GFP_KERNEL);
>> + adev = devm_auxiliary_device_create(dev, "reset", NULL);
>> if (!adev)
>> - return -ENOMEM;
>> -
>> - adev->name = "reset";
>> - adev->dev.parent = dev;
>> - adev->dev.release = clk_imx8mp_audiomix_reset_adev_release;
>> -
>> - ret = auxiliary_device_init(adev);
>> - if (ret)
>> - return ret;
>> + return -ENODEV;
>>
>> - ret = auxiliary_device_add(adev);
>> - if (ret) {
>> - auxiliary_device_uninit(adev);
>> - return ret;
>> - }
>> -
>> - return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev,
>> - no_free_ptr(adev));
>> + return 0;
>> }
>>
>> #else /* !CONFIG_RESET_CONTROLLER */
>>
>> -static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
>> - struct clk_imx8mp_audiomix_priv *priv)
>> +static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev)
>> {
>> return 0;
>> }
>>
>> -#endif /* !CONFIG_RESET_CONTROLLER */
>> +#endif
>>
>> static void clk_imx8mp_audiomix_save_restore(struct device *dev, bool save)
>> {
>> @@ -408,7 +375,7 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev)
>> if (ret)
>> goto err_clk_register;
>>
>> - ret = clk_imx8mp_audiomix_reset_controller_register(dev, priv);
>> + ret = clk_imx8mp_audiomix_reset_controller_register(dev);
>> if (ret)
>> goto err_clk_register;
>>
>>
>> --
>> 2.47.2
>>
--
Jerome
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/4] clk: amlogic: axg-audio: use the auxiliary reset driver
2025-06-11 12:53 [PATCH 0/4] clk: use the auxiliary device creation helper Jerome Brunet
` (2 preceding siblings ...)
2025-06-11 12:53 ` [PATCH 3/4] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper Jerome Brunet
@ 2025-06-11 12:53 ` Jerome Brunet
2025-06-23 13:29 ` (subset) [PATCH 0/4] clk: use the auxiliary device creation helper Jerome Brunet
4 siblings, 0 replies; 8+ messages in thread
From: Jerome Brunet @ 2025-06-11 12:53 UTC (permalink / raw)
To: Vladimir Kondratiev, Gregory CLEMENT, Théo Lebrun,
Michael Turquette, Stephen Boyd, Philipp Zabel, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Neil Armstrong, Kevin Hilman, Martin Blumenstingl
Cc: linux-mips, linux-clk, linux-kernel, imx, linux-arm-kernel,
linux-amlogic, Jerome Brunet
Remove the implementation of the reset driver in axg audio
clock driver and migrate to the one provided by reset framework
on the auxiliary bus.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/clk/meson/Kconfig | 3 +-
drivers/clk/meson/axg-audio.c | 114 +++++-------------------------------------
2 files changed, 15 insertions(+), 102 deletions(-)
diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig
index ff003dc5ab20d904c91fc34c701ba499a11d0b63..5c669b2e2f268c7608c8d9c64bba3c5b54da39b2 100644
--- a/drivers/clk/meson/Kconfig
+++ b/drivers/clk/meson/Kconfig
@@ -106,7 +106,8 @@ config COMMON_CLK_AXG_AUDIO
select COMMON_CLK_MESON_SCLK_DIV
select COMMON_CLK_MESON_CLKC_UTILS
select REGMAP_MMIO
- select RESET_CONTROLLER
+ select AUXILIARY_BUS
+ imply RESET_MESON_AUX
help
Support for the audio clock controller on AmLogic A113D devices,
aka axg, Say Y if you want audio subsystem to work.
diff --git a/drivers/clk/meson/axg-audio.c b/drivers/clk/meson/axg-audio.c
index 9df627b142f89788966ede0262aaaf39e13f0b49..3948f5d0faca372dd5cc4ed6dc95f9c89fe5bae8 100644
--- a/drivers/clk/meson/axg-audio.c
+++ b/drivers/clk/meson/axg-audio.c
@@ -4,6 +4,7 @@
* Author: Jerome Brunet <jbrunet@baylibre.com>
*/
+#include <linux/auxiliary_bus.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/init.h>
@@ -12,7 +13,6 @@
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/reset.h>
-#include <linux/reset-controller.h>
#include <linux/slab.h>
#include "meson-clkc-utils.h"
@@ -1678,84 +1678,6 @@ static struct clk_regmap *const sm1_clk_regmaps[] = {
&sm1_earcrx_dmac_clk,
};
-struct axg_audio_reset_data {
- struct reset_controller_dev rstc;
- struct regmap *map;
- unsigned int offset;
-};
-
-static void axg_audio_reset_reg_and_bit(struct axg_audio_reset_data *rst,
- unsigned long id,
- unsigned int *reg,
- unsigned int *bit)
-{
- unsigned int stride = regmap_get_reg_stride(rst->map);
-
- *reg = (id / (stride * BITS_PER_BYTE)) * stride;
- *reg += rst->offset;
- *bit = id % (stride * BITS_PER_BYTE);
-}
-
-static int axg_audio_reset_update(struct reset_controller_dev *rcdev,
- unsigned long id, bool assert)
-{
- struct axg_audio_reset_data *rst =
- container_of(rcdev, struct axg_audio_reset_data, rstc);
- unsigned int offset, bit;
-
- axg_audio_reset_reg_and_bit(rst, id, &offset, &bit);
-
- regmap_update_bits(rst->map, offset, BIT(bit),
- assert ? BIT(bit) : 0);
-
- return 0;
-}
-
-static int axg_audio_reset_status(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- struct axg_audio_reset_data *rst =
- container_of(rcdev, struct axg_audio_reset_data, rstc);
- unsigned int val, offset, bit;
-
- axg_audio_reset_reg_and_bit(rst, id, &offset, &bit);
-
- regmap_read(rst->map, offset, &val);
-
- return !!(val & BIT(bit));
-}
-
-static int axg_audio_reset_assert(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- return axg_audio_reset_update(rcdev, id, true);
-}
-
-static int axg_audio_reset_deassert(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- return axg_audio_reset_update(rcdev, id, false);
-}
-
-static int axg_audio_reset_toggle(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- int ret;
-
- ret = axg_audio_reset_assert(rcdev, id);
- if (ret)
- return ret;
-
- return axg_audio_reset_deassert(rcdev, id);
-}
-
-static const struct reset_control_ops axg_audio_rstc_ops = {
- .assert = axg_audio_reset_assert,
- .deassert = axg_audio_reset_deassert,
- .reset = axg_audio_reset_toggle,
- .status = axg_audio_reset_status,
-};
-
static struct regmap_config axg_audio_regmap_cfg = {
.reg_bits = 32,
.val_bits = 32,
@@ -1766,8 +1688,7 @@ struct audioclk_data {
struct clk_regmap *const *regmap_clks;
unsigned int regmap_clk_num;
struct meson_clk_hw_data hw_clks;
- unsigned int reset_offset;
- unsigned int reset_num;
+ const char *rst_drvname;
unsigned int max_register;
};
@@ -1775,7 +1696,7 @@ static int axg_audio_clkc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
const struct audioclk_data *data;
- struct axg_audio_reset_data *rst;
+ struct auxiliary_device *auxdev;
struct regmap *map;
void __iomem *regs;
struct clk_hw *hw;
@@ -1834,22 +1755,15 @@ static int axg_audio_clkc_probe(struct platform_device *pdev)
if (ret)
return ret;
- /* Stop here if there is no reset */
- if (!data->reset_num)
- return 0;
-
- rst = devm_kzalloc(dev, sizeof(*rst), GFP_KERNEL);
- if (!rst)
- return -ENOMEM;
-
- rst->map = map;
- rst->offset = data->reset_offset;
- rst->rstc.nr_resets = data->reset_num;
- rst->rstc.ops = &axg_audio_rstc_ops;
- rst->rstc.of_node = dev->of_node;
- rst->rstc.owner = THIS_MODULE;
+ /* Register auxiliary reset driver when applicable */
+ if (data->rst_drvname) {
+ auxdev = __devm_auxiliary_device_create(dev, dev->driver->name,
+ data->rst_drvname, NULL, 0);
+ if (!auxdev)
+ return -ENODEV;
+ }
- return devm_reset_controller_register(dev, &rst->rstc);
+ return 0;
}
static const struct audioclk_data axg_audioclk_data = {
@@ -1869,8 +1783,7 @@ static const struct audioclk_data g12a_audioclk_data = {
.hws = g12a_audio_hw_clks,
.num = ARRAY_SIZE(g12a_audio_hw_clks),
},
- .reset_offset = AUDIO_SW_RESET,
- .reset_num = 26,
+ .rst_drvname = "rst-g12a",
.max_register = AUDIO_CLK_SPDIFOUT_B_CTRL,
};
@@ -1881,8 +1794,7 @@ static const struct audioclk_data sm1_audioclk_data = {
.hws = sm1_audio_hw_clks,
.num = ARRAY_SIZE(sm1_audio_hw_clks),
},
- .reset_offset = AUDIO_SM1_SW_RESET0,
- .reset_num = 39,
+ .rst_drvname = "rst-sm1",
.max_register = AUDIO_EARCRX_DMAC_CLK_CTRL,
};
--
2.47.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: (subset) [PATCH 0/4] clk: use the auxiliary device creation helper
2025-06-11 12:53 [PATCH 0/4] clk: use the auxiliary device creation helper Jerome Brunet
` (3 preceding siblings ...)
2025-06-11 12:53 ` [PATCH 4/4] clk: amlogic: axg-audio: use the auxiliary reset driver Jerome Brunet
@ 2025-06-23 13:29 ` Jerome Brunet
4 siblings, 0 replies; 8+ messages in thread
From: Jerome Brunet @ 2025-06-23 13:29 UTC (permalink / raw)
To: Vladimir Kondratiev, Gregory CLEMENT, Théo Lebrun,
Michael Turquette, Stephen Boyd, Philipp Zabel, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Neil Armstrong, Kevin Hilman, Martin Blumenstingl,
Jerome Brunet
Cc: linux-mips, linux-clk, linux-kernel, imx, linux-arm-kernel,
linux-amlogic
Applied to clk-meson (clk-meson-next), thanks!
[4/4] clk: amlogic: axg-audio: use the auxiliary reset driver
https://github.com/BayLibre/clk-meson/commit/301b96e0668a
Best regards,
--
Jerome
^ permalink raw reply [flat|nested] 8+ messages in thread