36c4010b7e9425eba8d93c1c35eb5db84ff498b4
[openwrt/staging/blocktrron.git] /
1 From 7842c69dc55c25e47ed1b940ba7d8c89a06687cb Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Fri, 24 Mar 2023 15:45:50 +0100
4 Subject: [PATCH 0595/1085] drm/vc4: hvs: Change prototype of __vc4_hvs_alloc
5 to pass registers
6
7 The BCM2712 HVS has registers to report the size of the various SRAM the
8 driver uses, and their size actually differ depending on the stepping.
9
10 The initialisation of the memory pools happen in the __vc4_hvs_alloc()
11 function that also allocates the main HVS structure, that will then hold
12 the pointer to the memory mapping of the registers.
13
14 This creates some kind of circular dependency that we can break by
15 passing the mapping pointer as an argument for __vc4_hvs_alloc() to use
16 to query to get the SRAM sizes and initialise the memory pools
17 accordingly.
18
19 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
20 ---
21 drivers/gpu/drm/vc4/tests/vc4_mock.c | 2 +-
22 drivers/gpu/drm/vc4/vc4_drv.h | 4 +++-
23 drivers/gpu/drm/vc4/vc4_hvs.c | 16 ++++++++++------
24 3 files changed, 14 insertions(+), 8 deletions(-)
25
26 --- a/drivers/gpu/drm/vc4/tests/vc4_mock.c
27 +++ b/drivers/gpu/drm/vc4/tests/vc4_mock.c
28 @@ -180,7 +180,7 @@ static struct vc4_dev *__mock_device(str
29 vc4->dev = dev;
30 vc4->gen = gen;
31
32 - vc4->hvs = __vc4_hvs_alloc(vc4, NULL);
33 + vc4->hvs = __vc4_hvs_alloc(vc4, NULL, NULL);
34 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4->hvs);
35
36 drm = &vc4->base;
37 --- a/drivers/gpu/drm/vc4/vc4_drv.h
38 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
39 @@ -1048,7 +1048,9 @@ void vc4_irq_reset(struct drm_device *de
40
41 /* vc4_hvs.c */
42 extern struct platform_driver vc4_hvs_driver;
43 -struct vc4_hvs *__vc4_hvs_alloc(struct vc4_dev *vc4, struct platform_device *pdev);
44 +struct vc4_hvs *__vc4_hvs_alloc(struct vc4_dev *vc4,
45 + void __iomem *regs,
46 + struct platform_device *pdev);
47 void vc4_hvs_stop_channel(struct vc4_hvs *hvs, unsigned int output);
48 int vc4_hvs_get_fifo_from_output(struct vc4_hvs *hvs, unsigned int output);
49 u8 vc4_hvs_get_fifo_frame_count(struct vc4_hvs *hvs, unsigned int fifo);
50 --- a/drivers/gpu/drm/vc4/vc4_hvs.c
51 +++ b/drivers/gpu/drm/vc4/vc4_hvs.c
52 @@ -1242,7 +1242,9 @@ int vc4_hvs_debugfs_init(struct drm_mino
53 return 0;
54 }
55
56 -struct vc4_hvs *__vc4_hvs_alloc(struct vc4_dev *vc4, struct platform_device *pdev)
57 +struct vc4_hvs *__vc4_hvs_alloc(struct vc4_dev *vc4,
58 + void __iomem *regs,
59 + struct platform_device *pdev)
60 {
61 struct drm_device *drm = &vc4->base;
62 struct vc4_hvs *hvs;
63 @@ -1252,6 +1254,7 @@ struct vc4_hvs *__vc4_hvs_alloc(struct v
64 return ERR_PTR(-ENOMEM);
65
66 hvs->vc4 = vc4;
67 + hvs->regs = regs;
68 hvs->pdev = pdev;
69
70 spin_lock_init(&hvs->mm_lock);
71 @@ -1451,16 +1454,17 @@ static int vc4_hvs_bind(struct device *d
72 struct drm_device *drm = dev_get_drvdata(master);
73 struct vc4_dev *vc4 = to_vc4_dev(drm);
74 struct vc4_hvs *hvs = NULL;
75 + void __iomem *regs;
76 int ret;
77
78 - hvs = __vc4_hvs_alloc(vc4, NULL);
79 + regs = vc4_ioremap_regs(pdev, 0);
80 + if (IS_ERR(regs))
81 + return PTR_ERR(regs);
82 +
83 + hvs = __vc4_hvs_alloc(vc4, regs, pdev);
84 if (IS_ERR(hvs))
85 return PTR_ERR(hvs);
86
87 - hvs->regs = vc4_ioremap_regs(pdev, 0);
88 - if (IS_ERR(hvs->regs))
89 - return PTR_ERR(hvs->regs);
90 -
91 hvs->regset.base = hvs->regs;
92 hvs->regset.regs = vc4_hvs_regs;
93 hvs->regset.nregs = ARRAY_SIZE(vc4_hvs_regs);