Re: [PATCH v2 3/8] clk: imx: add driver for imx8ulp's sim lpav

Peng Fan
2025-10-22T12:51:13Z

Hi Laurentiu,

On Fri, Oct 17, 2025 at 04:20:20AM -0700, Laurentiu Mihalcea wrote:
>From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
>The i.MX8ULP System Integration Module (SIM) LPAV module is a block
>control module found inside the LPAV subsystem, which offers some clock
>gating options and reset line assertion/de-assertion capabilities.
>
>Therefore, the clock gate management is supported by registering the
>module's driver as a clock provider, while the reset capabilities are
>managed via the auxiliary device API to allow the DT node to act as a
>reset and clock provider.
>
>Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>---
....
>+struct clk_imx8ulp_sim_lpav_data {
>+ void __iomem *base;
>+ struct regmap *regmap;
>+ spinlock_t lock; /* shared by MUX, clock gate and reset */
>+ unsigned long flags; /* for spinlock usage */

This does not need to be here, put it as function local variable should
be fine.

>+ struct clk_hw_onecell_data clk_data; /* keep last */
>+};
>+
>+struct clk_imx8ulp_sim_lpav_gate {
>+ const char *name;
>+ int id;
>+ const struct clk_parent_data parent;
>+ u8 bit;
>+};
>+
>+static struct clk_imx8ulp_sim_lpav_gate gates[] = {
>+ IMX8ULP_HIFI_CLK_GATE("hifi_core", CORE, "hifi_core", 17),
>+ IMX8ULP_HIFI_CLK_GATE("hifi_pbclk", PBCLK, "lpav_bus", 18),
>+ IMX8ULP_HIFI_CLK_GATE("hifi_plat", PLAT, "hifi_plat", 19)

For the parent name, my understanding is they should be the one
from clk-imx8ulp.c, but I not find them, or may I miss something?

>+};
>+
>+#ifdef CONFIG_RESET_CONTROLLER
>+static void clk_imx8ulp_sim_lpav_aux_reset_release(struct device *dev)
>+{
>+ struct auxiliary_device *adev = to_auxiliary_dev(dev);
>+
>+ kfree(adev);
>+}
>+
>+static void clk_imx8ulp_sim_lpav_unregister_aux_reset(void *data)
>+{
>+ struct auxiliary_device *adev = data;
>+
>+ auxiliary_device_delete(adev);
>+ auxiliary_device_uninit(adev);
>+}
>+
>+static int clk_imx8ulp_sim_lpav_register_aux_reset(struct platform_device *pdev)
>+{
>+ struct auxiliary_device *adev __free(kfree) = NULL;
>+ int ret;
>+
>+ adev = kzalloc(sizeof(*adev), GFP_KERNEL);
>+ if (!adev)
>+ return -ENOMEM;
>+
>+ adev->name = "reset";
>+ adev->dev.parent = &pdev->dev;
>+ adev->dev.release = clk_imx8ulp_sim_lpav_aux_reset_release;
>+
>+ ret = auxiliary_device_init(adev);
>+ if (ret) {
>+ dev_err(&pdev->dev, "failed to initialize aux dev\n");
>+ return ret;
>+ }
>+
>+ ret = auxiliary_device_add(adev);
>+ if (ret) {
>+ auxiliary_device_uninit(adev);
>+ dev_err(&pdev->dev, "failed to add aux dev\n");
>+ return ret;
>+ }
>+
>+ return devm_add_action_or_reset(&pdev->dev,
>+ clk_imx8ulp_sim_lpav_unregister_aux_reset,
>+ no_free_ptr(adev));

clk_imx8ulp_sim_lpav_unregister_aux_reset() clean up the resources, if
moving this before auxiliary_device_add(), then no need
auxiliary_device_uninit() when add fails?

>+}

Regards
Peng