aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/armada/armada_drv.c68
1 files changed, 19 insertions, 49 deletions
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 1cbb080f0c4a..77ab93d60125 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -11,6 +11,7 @@
11#include <linux/of_graph.h> 11#include <linux/of_graph.h>
12#include <drm/drmP.h> 12#include <drm/drmP.h>
13#include <drm/drm_crtc_helper.h> 13#include <drm/drm_crtc_helper.h>
14#include <drm/drm_of.h>
14#include "armada_crtc.h" 15#include "armada_crtc.h"
15#include "armada_drm.h" 16#include "armada_drm.h"
16#include "armada_gem.h" 17#include "armada_gem.h"
@@ -262,43 +263,29 @@ static void armada_add_endpoints(struct device *dev,
262 } 263 }
263} 264}
264 265
265static int armada_drm_find_components(struct device *dev, 266static const struct component_master_ops armada_master_ops = {
266 struct component_match **match) 267 .bind = armada_drm_bind,
267{ 268 .unbind = armada_drm_unbind,
268 struct device_node *port; 269};
269 int i;
270
271 if (dev->of_node) {
272 struct device_node *np = dev->of_node;
273
274 for (i = 0; ; i++) {
275 port = of_parse_phandle(np, "ports", i);
276 if (!port)
277 break;
278
279 component_match_add(dev, match, compare_of, port);
280 of_node_put(port);
281 }
282 270
283 if (i == 0) { 271static int armada_drm_probe(struct platform_device *pdev)
284 dev_err(dev, "missing 'ports' property\n"); 272{
285 return -ENODEV; 273 struct component_match *match = NULL;
286 } 274 struct device *dev = &pdev->dev;
275 int ret;
287 276
288 for (i = 0; ; i++) { 277 ret = drm_of_component_probe(dev, compare_dev_name, &armada_master_ops);
289 port = of_parse_phandle(np, "ports", i); 278 if (ret != -EINVAL)
290 if (!port) 279 return ret;
291 break;
292 280
293 armada_add_endpoints(dev, match, port); 281 if (dev->platform_data) {
294 of_node_put(port);
295 }
296 } else if (dev->platform_data) {
297 char **devices = dev->platform_data; 282 char **devices = dev->platform_data;
283 struct device_node *port;
298 struct device *d; 284 struct device *d;
285 int i;
299 286
300 for (i = 0; devices[i]; i++) 287 for (i = 0; devices[i]; i++)
301 component_match_add(dev, match, compare_dev_name, 288 component_match_add(dev, &match, compare_dev_name,
302 devices[i]); 289 devices[i]);
303 290
304 if (i == 0) { 291 if (i == 0) {
@@ -308,32 +295,15 @@ static int armada_drm_find_components(struct device *dev,
308 295
309 for (i = 0; devices[i]; i++) { 296 for (i = 0; devices[i]; i++) {
310 d = bus_find_device_by_name(&platform_bus_type, NULL, 297 d = bus_find_device_by_name(&platform_bus_type, NULL,
311 devices[i]); 298 devices[i]);
312 if (d && d->of_node) { 299 if (d && d->of_node) {
313 for_each_child_of_node(d->of_node, port) 300 for_each_child_of_node(d->of_node, port)
314 armada_add_endpoints(dev, match, port); 301 armada_add_endpoints(dev, &match, port);
315 } 302 }
316 put_device(d); 303 put_device(d);
317 } 304 }
318 } 305 }
319 306
320 return 0;
321}
322
323static const struct component_master_ops armada_master_ops = {
324 .bind = armada_drm_bind,
325 .unbind = armada_drm_unbind,
326};
327
328static int armada_drm_probe(struct platform_device *pdev)
329{
330 struct component_match *match = NULL;
331 int ret;
332
333 ret = armada_drm_find_components(&pdev->dev, &match);
334 if (ret < 0)
335 return ret;
336
337 return component_master_add_with_match(&pdev->dev, &armada_master_ops, 307 return component_master_add_with_match(&pdev->dev, &armada_master_ops,
338 match); 308 match);
339} 309}