forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/gpu/drm/msm/dsi/dsi.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 and
6
- * only version 2 as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
124 */
135
146 #include "dsi.h"
....@@ -29,7 +21,7 @@
2921
3022 phy_node = of_parse_phandle(pdev->dev.of_node, "phys", 0);
3123 if (!phy_node) {
32
- dev_err(&pdev->dev, "cannot find phy device\n");
24
+ DRM_DEV_ERROR(&pdev->dev, "cannot find phy device\n");
3325 return -ENXIO;
3426 }
3527
....@@ -41,8 +33,13 @@
4133
4234 of_node_put(phy_node);
4335
44
- if (!phy_pdev || !msm_dsi->phy) {
45
- dev_err(&pdev->dev, "%s: phy driver is not ready\n", __func__);
36
+ if (!phy_pdev) {
37
+ DRM_DEV_ERROR(&pdev->dev, "%s: phy driver is not ready\n", __func__);
38
+ return -EPROBE_DEFER;
39
+ }
40
+ if (!msm_dsi->phy) {
41
+ put_device(&phy_pdev->dev);
42
+ DRM_DEV_ERROR(&pdev->dev, "%s: phy driver is not ready\n", __func__);
4643 return -EPROBE_DEFER;
4744 }
4845
....@@ -83,6 +80,7 @@
8380 return ERR_PTR(-ENOMEM);
8481 DBG("dsi probed=%p", msm_dsi);
8582
83
+ msm_dsi->id = -1;
8684 msm_dsi->pdev = pdev;
8785 platform_set_drvdata(pdev, msm_dsi);
8886
....@@ -117,8 +115,13 @@
117115
118116 DBG("");
119117 msm_dsi = dsi_init(pdev);
120
- if (IS_ERR(msm_dsi))
121
- return PTR_ERR(msm_dsi);
118
+ if (IS_ERR(msm_dsi)) {
119
+ /* Don't fail the bind if the dsi port is not connected */
120
+ if (PTR_ERR(msm_dsi) == -ENODEV)
121
+ return 0;
122
+ else
123
+ return PTR_ERR(msm_dsi);
124
+ }
122125
123126 priv->dsi[msm_dsi->id] = msm_dsi;
124127
....@@ -163,6 +166,8 @@
163166
164167 static const struct dev_pm_ops dsi_pm_ops = {
165168 SET_RUNTIME_PM_OPS(msm_dsi_runtime_suspend, msm_dsi_runtime_resume, NULL)
169
+ SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
170
+ pm_runtime_force_resume)
166171 };
167172
168173 static struct platform_driver dsi_driver = {
....@@ -200,11 +205,17 @@
200205 return -EINVAL;
201206
202207 priv = dev->dev_private;
208
+
209
+ if (priv->num_bridges == ARRAY_SIZE(priv->bridges)) {
210
+ DRM_DEV_ERROR(dev->dev, "too many bridges\n");
211
+ return -ENOSPC;
212
+ }
213
+
203214 msm_dsi->dev = dev;
204215
205216 ret = msm_dsi_host_modeset_init(msm_dsi->host, dev);
206217 if (ret) {
207
- dev_err(dev->dev, "failed to modeset init host: %d\n", ret);
218
+ DRM_DEV_ERROR(dev->dev, "failed to modeset init host: %d\n", ret);
208219 goto fail;
209220 }
210221
....@@ -218,7 +229,7 @@
218229 msm_dsi->bridge = msm_dsi_manager_bridge_init(msm_dsi->id);
219230 if (IS_ERR(msm_dsi->bridge)) {
220231 ret = PTR_ERR(msm_dsi->bridge);
221
- dev_err(dev->dev, "failed to create dsi bridge: %d\n", ret);
232
+ DRM_DEV_ERROR(dev->dev, "failed to create dsi bridge: %d\n", ret);
222233 msm_dsi->bridge = NULL;
223234 goto fail;
224235 }
....@@ -240,12 +251,14 @@
240251
241252 if (IS_ERR(msm_dsi->connector)) {
242253 ret = PTR_ERR(msm_dsi->connector);
243
- dev_err(dev->dev,
254
+ DRM_DEV_ERROR(dev->dev,
244255 "failed to create dsi connector: %d\n", ret);
245256 msm_dsi->connector = NULL;
246257 goto fail;
247258 }
248259
260
+ msm_dsi_manager_setup_encoder(msm_dsi->id);
261
+
249262 priv->bridges[priv->num_bridges++] = msm_dsi->bridge;
250263 priv->connectors[priv->num_connectors++] = msm_dsi->connector;
251264