b99102f6d2f02fabdb3726c0875a4f3fddd752c9
[openwrt/staging/robimarko.git] /
1 From d57ee5afedf0b1b9a9afb29357c484acda5a40af Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Tue, 19 May 2020 14:54:28 +0100
4 Subject: [PATCH] drm/vc4: Adopt the dma configuration from the HVS or
5 V3D component
6
7 vc4_drv isn't necessarily under the /soc node in DT as it is a
8 virtual device, but it is the one that does the allocations.
9 The DMA addresses are consumed by primarily the HVS or V3D, and
10 those require VideoCore cache alias address mapping, and so will be
11 under /soc.
12
13 During probe find the a suitable device node for HVS or V3D,
14 and adopt the DMA configuration of that node.
15
16 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
17 ---
18 drivers/gpu/drm/vc4/vc4_drv.c | 18 ++++++++++++++++++
19 1 file changed, 18 insertions(+)
20
21 --- a/drivers/gpu/drm/vc4/vc4_drv.c
22 +++ b/drivers/gpu/drm/vc4/vc4_drv.c
23 @@ -246,6 +246,14 @@ static void vc4_match_add_drivers(struct
24 }
25 }
26
27 +const struct of_device_id vc4_dma_range_matches[] = {
28 + { .compatible = "brcm,bcm2835-hvs" },
29 + { .compatible = "brcm,bcm2835-v3d" },
30 + { .compatible = "brcm,cygnus-v3d" },
31 + { .compatible = "brcm,vc4-v3d" },
32 + {}
33 +};
34 +
35 static int vc4_drm_bind(struct device *dev)
36 {
37 struct platform_device *pdev = to_platform_device(dev);
38 @@ -263,6 +271,16 @@ static int vc4_drm_bind(struct device *d
39 vc4_drm_driver.driver_features &= ~DRIVER_RENDER;
40 of_node_put(node);
41
42 + node = of_find_matching_node_and_match(NULL, vc4_dma_range_matches,
43 + NULL);
44 + if (node) {
45 + ret = of_dma_configure(dev, node, true);
46 + of_node_put(node);
47 +
48 + if (ret)
49 + return ret;
50 + }
51 +
52 vc4 = devm_drm_dev_alloc(dev, &vc4_drm_driver, struct vc4_dev, base);
53 if (IS_ERR(vc4))
54 return PTR_ERR(vc4);