drm/vc4: Adopt the dma configuration from the HVS or V3D component
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Tue, 19 May 2020 13:54:28 +0000 (14:54 +0100)
committerpopcornmix <popcornmix@gmail.com>
Wed, 1 Jul 2020 15:34:05 +0000 (16:34 +0100)
vc4_drv isn't necessarily under the /soc node in DT as it is a
virtual device, but it is the one that does the allocations.
The DMA addresses are consumed by primarily the HVS or V3D, and
those require VideoCore cache alias address mapping, and so will be
under /soc.

During probe find the a suitable device node for HVS or V3D,
and adopt the DMA configuration of that node.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/gpu/drm/vc4/vc4_drv.c

index f45cad6..4a70047 100644 (file)
@@ -249,6 +249,14 @@ static void vc4_match_add_drivers(struct device *dev,
        }
 }
 
+const struct of_device_id vc4_dma_range_matches[] = {
+       { .compatible = "brcm,bcm2835-hvs" },
+       { .compatible = "brcm,bcm2835-v3d" },
+       { .compatible = "brcm,cygnus-v3d" },
+       { .compatible = "brcm,vc4-v3d" },
+       {}
+};
+
 static int vc4_drm_bind(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
@@ -269,6 +277,16 @@ static int vc4_drm_bind(struct device *dev)
                vc4_drm_driver.driver_features &= ~DRIVER_RENDER;
        of_node_put(node);
 
+       node = of_find_matching_node_and_match(NULL, vc4_dma_range_matches,
+                                              NULL);
+       if (node) {
+               ret = of_dma_configure(dev, node, true);
+               of_node_put(node);
+
+               if (ret)
+                       return ret;
+       }
+
        drm = drm_dev_alloc(&vc4_drm_driver, dev);
        if (IS_ERR(drm))
                return PTR_ERR(drm);