forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/gpu/drm/armada/armada_drv.c
....@@ -1,18 +1,24 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2012 Russell King
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 as
6
- * published by the Free Software Foundation.
74 */
5
+
86 #include <linux/clk.h>
97 #include <linux/component.h>
108 #include <linux/module.h>
119 #include <linux/of_graph.h>
10
+#include <linux/platform_device.h>
11
+
1212 #include <drm/drm_atomic_helper.h>
13
-#include <drm/drm_crtc_helper.h>
13
+#include <drm/drm_drv.h>
14
+#include <drm/drm_ioctl.h>
15
+#include <drm/drm_managed.h>
16
+#include <drm/drm_prime.h>
17
+#include <drm/drm_probe_helper.h>
1418 #include <drm/drm_fb_helper.h>
1519 #include <drm/drm_of.h>
20
+#include <drm/drm_vblank.h>
21
+
1622 #include "armada_crtc.h"
1723 #include "armada_drm.h"
1824 #include "armada_gem.h"
....@@ -43,8 +49,7 @@
4349 .name = "armada-drm",
4450 .desc = "Armada SoC DRM",
4551 .date = "20120730",
46
- .driver_features = DRIVER_GEM | DRIVER_MODESET |
47
- DRIVER_PRIME | DRIVER_ATOMIC,
52
+ .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
4853 .ioctls = armada_ioctls,
4954 .fops = &armada_drm_fops,
5055 };
....@@ -82,25 +87,23 @@
8287 "armada-drm"))
8388 return -EBUSY;
8489
85
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
86
- if (!priv)
87
- return -ENOMEM;
88
-
89
- /*
90
- * The drm_device structure must be at the start of
91
- * armada_private for drm_dev_put() to work correctly.
92
- */
93
- BUILD_BUG_ON(offsetof(struct armada_private, drm) != 0);
94
-
95
- ret = drm_dev_init(&priv->drm, &armada_drm_driver, dev);
96
- if (ret) {
97
- dev_err(dev, "[" DRM_NAME ":%s] drm_dev_init failed: %d\n",
98
- __func__, ret);
99
- kfree(priv);
100
- return ret;
90
+ priv = devm_drm_dev_alloc(dev, &armada_drm_driver,
91
+ struct armada_private, drm);
92
+ if (IS_ERR(priv)) {
93
+ dev_err(dev, "[" DRM_NAME ":%s] devm_drm_dev_alloc failed: %li\n",
94
+ __func__, PTR_ERR(priv));
95
+ return PTR_ERR(priv);
10196 }
10297
103
- priv->drm.dev_private = priv;
98
+ /* Remove early framebuffers */
99
+ ret = drm_fb_helper_remove_conflicting_framebuffers(NULL,
100
+ "armada-drm-fb",
101
+ false);
102
+ if (ret) {
103
+ dev_err(dev, "[" DRM_NAME ":%s] can't kick out simple-fb: %d\n",
104
+ __func__, ret);
105
+ return ret;
106
+ }
104107
105108 dev_set_drvdata(dev, &priv->drm);
106109
....@@ -157,26 +160,25 @@
157160 err_kms:
158161 drm_mode_config_cleanup(&priv->drm);
159162 drm_mm_takedown(&priv->linear);
160
- drm_dev_put(&priv->drm);
161163 return ret;
162164 }
163165
164166 static void armada_drm_unbind(struct device *dev)
165167 {
166168 struct drm_device *drm = dev_get_drvdata(dev);
167
- struct armada_private *priv = drm->dev_private;
169
+ struct armada_private *priv = drm_to_armada_dev(drm);
168170
169171 drm_kms_helper_poll_fini(&priv->drm);
170172 armada_fbdev_fini(&priv->drm);
171173
172174 drm_dev_unregister(&priv->drm);
173175
176
+ drm_atomic_helper_shutdown(&priv->drm);
177
+
174178 component_unbind_all(dev, &priv->drm);
175179
176180 drm_mode_config_cleanup(&priv->drm);
177181 drm_mm_takedown(&priv->linear);
178
-
179
- drm_dev_put(&priv->drm);
180182 }
181183
182184 static int compare_of(struct device *dev, void *data)
....@@ -191,23 +193,15 @@
191193 }
192194
193195 static void armada_add_endpoints(struct device *dev,
194
- struct component_match **match, struct device_node *port)
196
+ struct component_match **match, struct device_node *dev_node)
195197 {
196198 struct device_node *ep, *remote;
197199
198
- for_each_child_of_node(port, ep) {
200
+ for_each_endpoint_of_node(dev_node, ep) {
199201 remote = of_graph_get_remote_port_parent(ep);
200
- if (!remote || !of_device_is_available(remote)) {
201
- of_node_put(remote);
202
- continue;
203
- } else if (!of_device_is_available(remote->parent)) {
204
- dev_warn(dev, "parent device of %pOF is not available\n",
205
- remote);
206
- of_node_put(remote);
207
- continue;
208
- }
209
-
210
- drm_of_component_match_add(dev, match, compare_of, remote);
202
+ if (remote && of_device_is_available(remote))
203
+ drm_of_component_match_add(dev, match, compare_of,
204
+ remote);
211205 of_node_put(remote);
212206 }
213207 }
....@@ -229,7 +223,6 @@
229223
230224 if (dev->platform_data) {
231225 char **devices = dev->platform_data;
232
- struct device_node *port;
233226 struct device *d;
234227 int i;
235228
....@@ -245,10 +238,8 @@
245238 for (i = 0; devices[i]; i++) {
246239 d = bus_find_device_by_name(&platform_bus_type, NULL,
247240 devices[i]);
248
- if (d && d->of_node) {
249
- for_each_child_of_node(d->of_node, port)
250
- armada_add_endpoints(dev, &match, port);
251
- }
241
+ if (d && d->of_node)
242
+ armada_add_endpoints(dev, &match, d->of_node);
252243 put_device(d);
253244 }
254245 }
....@@ -305,7 +296,7 @@
305296 }
306297 module_exit(armada_drm_exit);
307298
308
-MODULE_AUTHOR("Russell King <rmk+kernel@arm.linux.org.uk>");
299
+MODULE_AUTHOR("Russell King <rmk+kernel@armlinux.org.uk>");
309300 MODULE_DESCRIPTION("Armada DRM Driver");
310301 MODULE_LICENSE("GPL");
311302 MODULE_ALIAS("platform:armada-drm");