[PATCH RFC 065/111] staging: etnaviv: allow non-DT use
Lucas Stach
l.stach at pengutronix.de
Thu Apr 2 08:30:07 PDT 2015
From: Russell King <rmk+kernel at arm.linux.org.uk>
Signed-off-by: Russell King <rmk+kernel at arm.linux.org.uk>
---
drivers/staging/etnaviv/etnaviv_drv.c | 50 ++++++++++++++++++++---------------
drivers/staging/etnaviv/etnaviv_gpu.c | 18 ++++++++++---
2 files changed, 42 insertions(+), 26 deletions(-)
diff --git a/drivers/staging/etnaviv/etnaviv_drv.c b/drivers/staging/etnaviv/etnaviv_drv.c
index 3dba228265ea..568615154845 100644
--- a/drivers/staging/etnaviv/etnaviv_drv.c
+++ b/drivers/staging/etnaviv/etnaviv_drv.c
@@ -566,24 +566,6 @@ static int etnaviv_compare(struct device *dev, void *data)
return dev->of_node == np;
}
-static int etnaviv_add_components(struct device *master, struct master *m)
-{
- struct device_node *child_np;
- int ret = 0;
-
- for_each_available_child_of_node(master->of_node, child_np) {
- DRM_INFO("add child %s\n", child_np->name);
-
- ret = component_master_add_child(m, etnaviv_compare, child_np);
- if (ret) {
- of_node_put(child_np);
- break;
- }
- }
-
- return ret;
-}
-
static int etnaviv_bind(struct device *dev)
{
return drm_platform_init(&etnaviv_drm_driver, to_platform_device(dev));
@@ -595,21 +577,43 @@ static void etnaviv_unbind(struct device *dev)
}
static const struct component_master_ops etnaviv_master_ops = {
- .add_components = etnaviv_add_components,
.bind = etnaviv_bind,
.unbind = etnaviv_unbind,
};
+static int compare_str(struct device *dev, void *data)
+{
+ return !strcmp(dev_name(dev), data);
+}
+
static int etnaviv_pdev_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
-
- of_platform_populate(node, NULL, NULL, dev);
+ struct component_match *match = NULL;
dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
- return component_master_add(&pdev->dev, &etnaviv_master_ops);
+ if (node) {
+ struct device_node *child_np;
+
+ of_platform_populate(node, NULL, NULL, dev);
+
+ for_each_available_child_of_node(node, child_np) {
+ DRM_INFO("add child %s\n", child_np->name);
+
+ component_match_add(dev, &match, etnaviv_compare,
+ child_np);
+ }
+ } else if (dev->platform_data) {
+ char **names = dev->platform_data;
+ unsigned i;
+
+ for (i = 0; names[i]; i++)
+ component_match_add(dev, &match, compare_str, names[i]);
+ }
+
+ return component_master_add_with_match(dev, &etnaviv_master_ops, match);
}
static int etnaviv_pdev_remove(struct platform_device *pdev)
@@ -661,3 +665,5 @@ module_exit(etnaviv_exit);
MODULE_AUTHOR("Rob Clark <robdclark at gmail.com");
MODULE_DESCRIPTION("etnaviv DRM Driver");
MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:vivante");
+MODULE_DEVICE_TABLE(of, dt_match);
diff --git a/drivers/staging/etnaviv/etnaviv_gpu.c b/drivers/staging/etnaviv/etnaviv_gpu.c
index 92a28f11bab6..30abf443f2c9 100644
--- a/drivers/staging/etnaviv/etnaviv_gpu.c
+++ b/drivers/staging/etnaviv/etnaviv_gpu.c
@@ -26,6 +26,10 @@
#include "state_hi.xml.h"
#include "cmdstream.xml.h"
+static const struct platform_device_id gpu_ids[] = {
+ { .name = "etnaviv-gpu,2d", .driver_data = ETNA_PIPE_2D, },
+ { },
+};
/*
* Driver functions:
@@ -1059,9 +1063,16 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
if (!gpu)
return -ENOMEM;
- match = of_match_device(etnaviv_gpu_match, &pdev->dev);
- if (!match)
+ if (pdev->dev.of_node) {
+ match = of_match_device(etnaviv_gpu_match, &pdev->dev);
+ if (!match)
+ return -EINVAL;
+ gpu->pipe = (int)match->data;
+ } else if (pdev->id_entry) {
+ gpu->pipe = pdev->id_entry->driver_data;
+ } else {
return -EINVAL;
+ }
gpu->dev = &pdev->dev;
@@ -1101,8 +1112,6 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
if (IS_ERR(gpu->clk_shader))
gpu->clk_shader = NULL;
- gpu->pipe = (int)match->data;
-
/* TODO: figure out max mapped size */
dev_set_drvdata(dev, gpu);
@@ -1132,4 +1141,5 @@ struct platform_driver etnaviv_gpu_driver = {
},
.probe = etnaviv_gpu_platform_probe,
.remove = etnaviv_gpu_platform_remove,
+ .id_table = gpu_ids,
};
--
2.1.4
More information about the dri-devel
mailing list