diff mbox series

[2/4] mailbox: qcom-apcs-ipc: Assign OF node to clock controller child device

Message ID 20250506-qcom-apcs-mailbox-cc-v1-2-b54dddb150a5@linaro.org
State Accepted
Commit d0b497df02e9b2ebcb5771c7b16e424c0614a366
Headers show
Series mailbox: qcom-apcs-ipc: Avoid circular dependency with clock controller | expand

Commit Message

Stephan Gerhold May 6, 2025, 1:10 p.m. UTC
Currently, the child device for the clock controller inside the APCS block
is created without any OF node assigned, so the drivers need to rely on the
parent device for obtaining any resources.

Add support for defining the clock controller inside a "clock-controller"
subnode to break up circular dependencies between the mailbox and required
parent clocks of the clock controller. For backwards compatibility, if the
subnode is not defined, reuse the OF node from the parent device.

Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org>
---
 drivers/mailbox/qcom-apcs-ipc-mailbox.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

Jassi Brar May 26, 2025, 7:47 p.m. UTC | #1
On Tue, May 6, 2025 at 8:10 AM Stephan Gerhold
<stephan.gerhold@linaro.org> wrote:
>
> Currently, the child device for the clock controller inside the APCS block
> is created without any OF node assigned, so the drivers need to rely on the
> parent device for obtaining any resources.
>
> Add support for defining the clock controller inside a "clock-controller"
> subnode to break up circular dependencies between the mailbox and required
> parent clocks of the clock controller. For backwards compatibility, if the
> subnode is not defined, reuse the OF node from the parent device.
>
> Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org>
> ---
>  drivers/mailbox/qcom-apcs-ipc-mailbox.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mailbox/qcom-apcs-ipc-mailbox.c b/drivers/mailbox/qcom-apcs-ipc-mailbox.c
> index 11c41e935a3619b74ad0f5e2d82699ca8aa05722..8b24ec0fa191efc975625d9b9270140ad1fe7b9b 100644
> --- a/drivers/mailbox/qcom-apcs-ipc-mailbox.c
> +++ b/drivers/mailbox/qcom-apcs-ipc-mailbox.c
> @@ -116,10 +116,18 @@ static int qcom_apcs_ipc_probe(struct platform_device *pdev)
>         }
>
>         if (apcs_data->clk_name) {
> -               apcs->clk = platform_device_register_data(&pdev->dev,
> -                                                         apcs_data->clk_name,
> -                                                         PLATFORM_DEVID_AUTO,
> -                                                         NULL, 0);
> +               struct device_node *np = of_get_child_by_name(pdev->dev.of_node,
> +                                                             "clock-controller");
> +               struct platform_device_info pdevinfo = {
> +                       .parent = &pdev->dev,
> +                       .name = apcs_data->clk_name,
> +                       .id = PLATFORM_DEVID_AUTO,
> +                       .fwnode = of_fwnode_handle(np) ?: pdev->dev.fwnode,
> +                       .of_node_reused = !np,
> +               };
> +
> +               apcs->clk = platform_device_register_full(&pdevinfo);
> +               of_node_put(np);
>                 if (IS_ERR(apcs->clk))
>                         dev_err(&pdev->dev, "failed to register APCS clk\n");
>         }
>

I see the dt change is acked by the DT maintainer. I have no problem
with this patch and can merge, but do you want to wait for ack from
some Qcom dev?

thanks
Dmitry Baryshkov May 28, 2025, 7:21 p.m. UTC | #2
On Tue, May 06, 2025 at 03:10:09PM +0200, Stephan Gerhold wrote:
> Currently, the child device for the clock controller inside the APCS block
> is created without any OF node assigned, so the drivers need to rely on the
> parent device for obtaining any resources.
> 
> Add support for defining the clock controller inside a "clock-controller"
> subnode to break up circular dependencies between the mailbox and required
> parent clocks of the clock controller. For backwards compatibility, if the
> subnode is not defined, reuse the OF node from the parent device.
> 
> Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org>
> ---
>  drivers/mailbox/qcom-apcs-ipc-mailbox.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
diff mbox series

Patch

diff --git a/drivers/mailbox/qcom-apcs-ipc-mailbox.c b/drivers/mailbox/qcom-apcs-ipc-mailbox.c
index 11c41e935a3619b74ad0f5e2d82699ca8aa05722..8b24ec0fa191efc975625d9b9270140ad1fe7b9b 100644
--- a/drivers/mailbox/qcom-apcs-ipc-mailbox.c
+++ b/drivers/mailbox/qcom-apcs-ipc-mailbox.c
@@ -116,10 +116,18 @@  static int qcom_apcs_ipc_probe(struct platform_device *pdev)
 	}
 
 	if (apcs_data->clk_name) {
-		apcs->clk = platform_device_register_data(&pdev->dev,
-							  apcs_data->clk_name,
-							  PLATFORM_DEVID_AUTO,
-							  NULL, 0);
+		struct device_node *np = of_get_child_by_name(pdev->dev.of_node,
+							      "clock-controller");
+		struct platform_device_info pdevinfo = {
+			.parent = &pdev->dev,
+			.name = apcs_data->clk_name,
+			.id = PLATFORM_DEVID_AUTO,
+			.fwnode = of_fwnode_handle(np) ?: pdev->dev.fwnode,
+			.of_node_reused = !np,
+		};
+
+		apcs->clk = platform_device_register_full(&pdevinfo);
+		of_node_put(np);
 		if (IS_ERR(apcs->clk))
 			dev_err(&pdev->dev, "failed to register APCS clk\n");
 	}