]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
clk: imx: clk-audiomix: Add reset controller
authorShengjiu Wang <shengjiu.wang@nxp.com>
Fri, 14 Jun 2024 07:42:00 +0000 (15:42 +0800)
committerAbel Vesa <abel.vesa@linaro.org>
Fri, 21 Jun 2024 04:44:01 +0000 (07:44 +0300)
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 <shengjiu.wang@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Link: https://lore.kernel.org/r/1718350923-21392-3-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
drivers/clk/imx/Kconfig
drivers/clk/imx/clk-imx8mp-audiomix.c

index 6da0fba68225e434529eb2ec3317343477a74aeb..6ff6d934848a3bc0203734e1ef3b29ec1fb43a84 100644 (file)
@@ -81,6 +81,7 @@ config CLK_IMX8MP
        tristate "IMX8MP CCM Clock Driver"
        depends on ARCH_MXC || COMPILE_TEST
        select MXC_CLK
+       select AUXILIARY_BUS if RESET_CONTROLLER
        help
            Build the driver for i.MX8MP CCM Clock Driver
 
index b381d6f784c89092ca79662bcc63c4a0ec533d41..517b1f88661b91df124f1642b36722ad15e101f7 100644 (file)
@@ -5,6 +5,7 @@
  * Copyright (C) 2022 Marek Vasut <marex@denx.de>
  */
 
+#include <linux/auxiliary_bus.h>
 #include <linux/clk-provider.h>
 #include <linux/device.h>
 #include <linux/io.h>
@@ -13,6 +14,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/slab.h>
 
 #include <dt-bindings/clock/imx8mp-clock.h>
 
@@ -217,6 +219,63 @@ struct clk_imx8mp_audiomix_priv {
        struct clk_hw_onecell_data clk_data;
 };
 
+#if IS_ENABLED(CONFIG_RESET_CONTROLLER)
+
+static void clk_imx8mp_audiomix_reset_unregister_adev(void *_adev)
+{
+       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;
+
+       if (!of_property_present(dev->of_node, "#reset-cells"))
+               return 0;
+
+       adev = kzalloc(sizeof(*adev), GFP_KERNEL);
+       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;
+
+       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));
+}
+
+#else /* !CONFIG_RESET_CONTROLLER */
+
+static int clk_imx8mp_audiomix_reset_controller_register(struct clk_imx8mp_audiomix_priv *priv)
+{
+       return 0;
+}
+
+#endif /* !CONFIG_RESET_CONTROLLER */
+
 static void clk_imx8mp_audiomix_save_restore(struct device *dev, bool save)
 {
        struct clk_imx8mp_audiomix_priv *priv = dev_get_drvdata(dev);
@@ -337,6 +396,10 @@ 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);
+       if (ret)
+               goto err_clk_register;
+
        pm_runtime_put_sync(dev);
        return 0;