Skip to content

Commit 6f0e817

Browse files
TE-N-ShengjiuWangabelvesa
authored andcommitted
clk: imx: clk-audiomix: Add reset controller
Audiomix block control can be a reset controller for Enhanced Audio Return Channel (EARC), which is one of modules in this audiomix subsystem. The reset controller is supported by the auxiliary device framework. Signed-off-by: Shengjiu Wang <[email protected]> Reviewed-by: Frank Li <[email protected]> Reviewed-by: Marco Felsch <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Abel Vesa <[email protected]>
1 parent d7d9ef1 commit 6f0e817

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

drivers/clk/imx/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ config CLK_IMX8MP
8181
tristate "IMX8MP CCM Clock Driver"
8282
depends on ARCH_MXC || COMPILE_TEST
8383
select MXC_CLK
84+
select AUXILIARY_BUS if RESET_CONTROLLER
8485
help
8586
Build the driver for i.MX8MP CCM Clock Driver
8687

drivers/clk/imx/clk-imx8mp-audiomix.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Copyright (C) 2022 Marek Vasut <[email protected]>
66
*/
77

8+
#include <linux/auxiliary_bus.h>
89
#include <linux/clk-provider.h>
910
#include <linux/device.h>
1011
#include <linux/io.h>
@@ -13,6 +14,7 @@
1314
#include <linux/of.h>
1415
#include <linux/platform_device.h>
1516
#include <linux/pm_runtime.h>
17+
#include <linux/slab.h>
1618

1719
#include <dt-bindings/clock/imx8mp-clock.h>
1820

@@ -217,6 +219,63 @@ struct clk_imx8mp_audiomix_priv {
217219
struct clk_hw_onecell_data clk_data;
218220
};
219221

222+
#if IS_ENABLED(CONFIG_RESET_CONTROLLER)
223+
224+
static void clk_imx8mp_audiomix_reset_unregister_adev(void *_adev)
225+
{
226+
struct auxiliary_device *adev = _adev;
227+
228+
auxiliary_device_delete(adev);
229+
auxiliary_device_uninit(adev);
230+
}
231+
232+
static void clk_imx8mp_audiomix_reset_adev_release(struct device *dev)
233+
{
234+
struct auxiliary_device *adev = to_auxiliary_dev(dev);
235+
236+
kfree(adev);
237+
}
238+
239+
static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
240+
struct clk_imx8mp_audiomix_priv *priv)
241+
{
242+
struct auxiliary_device *adev __free(kfree) = NULL;
243+
int ret;
244+
245+
if (!of_property_present(dev->of_node, "#reset-cells"))
246+
return 0;
247+
248+
adev = kzalloc(sizeof(*adev), GFP_KERNEL);
249+
if (!adev)
250+
return -ENOMEM;
251+
252+
adev->name = "reset";
253+
adev->dev.parent = dev;
254+
adev->dev.release = clk_imx8mp_audiomix_reset_adev_release;
255+
256+
ret = auxiliary_device_init(adev);
257+
if (ret)
258+
return ret;
259+
260+
ret = auxiliary_device_add(adev);
261+
if (ret) {
262+
auxiliary_device_uninit(adev);
263+
return ret;
264+
}
265+
266+
return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev,
267+
no_free_ptr(adev));
268+
}
269+
270+
#else /* !CONFIG_RESET_CONTROLLER */
271+
272+
static int clk_imx8mp_audiomix_reset_controller_register(struct clk_imx8mp_audiomix_priv *priv)
273+
{
274+
return 0;
275+
}
276+
277+
#endif /* !CONFIG_RESET_CONTROLLER */
278+
220279
static void clk_imx8mp_audiomix_save_restore(struct device *dev, bool save)
221280
{
222281
struct clk_imx8mp_audiomix_priv *priv = dev_get_drvdata(dev);
@@ -337,6 +396,10 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev)
337396
if (ret)
338397
goto err_clk_register;
339398

399+
ret = clk_imx8mp_audiomix_reset_controller_register(dev, priv);
400+
if (ret)
401+
goto err_clk_register;
402+
340403
pm_runtime_put_sync(dev);
341404
return 0;
342405

0 commit comments

Comments
 (0)