From 31b6d913ab7cfd524e645d1f1bdc19928af1cef2 Mon Sep 17 00:00:00 2001 From: Santosh Reddy Galma Date: Fri, 23 Sep 2022 06:49:41 +0000 Subject: [PATCH] platform: dce: add device_link b/w display and dce - add the device link between display and DCE such that DCE KMD module will enter suspend after display suspend is complete and DCE KMD module resumes early before display resumes as DCE bootstrap has to be complete for display to proceed with initialization. Bug 3685062 Bug 3826630 Signed-off-by: Santosh Reddy Galma Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2780892 Reviewed-by: svcacv Reviewed-by: Mahesh Kumar Reviewed-by: Arun Swain Change-Id: I4d84d8b5723747d984f0883aba697a5a0a0a21bf Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2824217 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: svc_kernel_abi Tested-by: Mahesh Kumar GVS: Gerrit_Virtual_Submit --- drivers/platform/tegra/dce/dce-module.c | 26 ++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/platform/tegra/dce/dce-module.c b/drivers/platform/tegra/dce/dce-module.c index a8a6676b..aaba1de6 100644 --- a/drivers/platform/tegra/dce/dce-module.c +++ b/drivers/platform/tegra/dce/dce-module.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -19,6 +19,7 @@ #include #include #include +#include /** * The following platform info is needed for backdoor @@ -168,6 +169,16 @@ static int dce_req_interrupts(struct platform_device *pdev) return ret; } +static int match_display_dev(struct device *dev, const void *data) +{ + if ((dev != NULL) && (dev->of_node != NULL)) { + if (of_device_is_compatible(dev->of_node, "nvidia,tegra234-display")) + return 1; + } + + return 0; +} + static int tegra_dce_probe(struct platform_device *pdev) { int err = 0; @@ -175,6 +186,8 @@ static int tegra_dce_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct dce_platform_data *pdata = NULL; const struct of_device_id *match = NULL; + struct device *c_dev; + struct device_link *link; match = of_match_device(tegra_dce_of_match, dev); if (!match) { @@ -225,6 +238,17 @@ static int tegra_dce_probe(struct platform_device *pdev) dce_init_debug(d); #endif + c_dev = bus_find_device(&platform_bus_type, NULL, NULL, match_display_dev); + if (c_dev != NULL) { + dce_info(d, "Found display consumer device"); + link = device_link_add(c_dev, dev, + DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_SUPPLIER); + if (link == NULL) { + dce_err(d, "Failed to create device link to %s\n", dev_name(c_dev)); + return -EINVAL; + } + } + return 0; req_intr_err: