c54ab0d360295a393116555b64f699c65fe86944
[openwrt/staging/ansuel.git] /
1 From a68e8ffc3314612b0d00d491c8cdd61ae1d9af4e Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Tue, 25 Apr 2023 10:12:32 +0200
4 Subject: [PATCH] drm/vc4: txp: Introduce structure to deal with revision
5 differences
6
7 The BCM2712 will have several TXP with small differences. Let's add a
8 structure tied to the compatible to deal with those differences.
9
10 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
11 ---
12 drivers/gpu/drm/vc4/tests/vc4_mock.c | 4 ++--
13 drivers/gpu/drm/vc4/vc4_drv.h | 6 +++++-
14 drivers/gpu/drm/vc4/vc4_txp.c | 23 ++++++++++++++++-------
15 3 files changed, 23 insertions(+), 10 deletions(-)
16
17 --- a/drivers/gpu/drm/vc4/tests/vc4_mock.c
18 +++ b/drivers/gpu/drm/vc4/tests/vc4_mock.c
19 @@ -51,7 +51,7 @@ struct vc4_mock_desc {
20
21 static const struct vc4_mock_desc vc4_mock =
22 VC4_MOCK_DESC(
23 - VC4_MOCK_CRTC_DESC(&vc4_txp_crtc_data,
24 + VC4_MOCK_CRTC_DESC(&vc4_txp_data.base,
25 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_TXP,
26 DRM_MODE_ENCODER_VIRTUAL,
27 DRM_MODE_CONNECTOR_WRITEBACK)),
28 @@ -77,7 +77,7 @@ static const struct vc4_mock_desc vc4_mo
29
30 static const struct vc4_mock_desc vc5_mock =
31 VC4_MOCK_DESC(
32 - VC4_MOCK_CRTC_DESC(&vc4_txp_crtc_data,
33 + VC4_MOCK_CRTC_DESC(&vc4_txp_data.base,
34 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_TXP,
35 DRM_MODE_ENCODER_VIRTUAL,
36 DRM_MODE_CONNECTOR_WRITEBACK)),
37 --- a/drivers/gpu/drm/vc4/vc4_drv.h
38 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
39 @@ -561,7 +561,11 @@ struct vc4_crtc_data {
40 int hvs_output;
41 };
42
43 -extern const struct vc4_crtc_data vc4_txp_crtc_data;
44 +struct vc4_txp_data {
45 + struct vc4_crtc_data base;
46 +};
47 +
48 +extern const struct vc4_txp_data vc4_txp_data;
49
50 struct vc4_pv_data {
51 struct vc4_crtc_data base;
52 --- a/drivers/gpu/drm/vc4/vc4_txp.c
53 +++ b/drivers/gpu/drm/vc4/vc4_txp.c
54 @@ -159,6 +159,7 @@
55
56 struct vc4_txp {
57 struct vc4_crtc base;
58 + const struct vc4_txp_data *data;
59
60 struct platform_device *pdev;
61
62 @@ -488,17 +489,20 @@ static irqreturn_t vc4_txp_interrupt(int
63 return IRQ_HANDLED;
64 }
65
66 -const struct vc4_crtc_data vc4_txp_crtc_data = {
67 - .name = "txp",
68 - .debugfs_name = "txp_regs",
69 - .hvs_available_channels = BIT(2),
70 - .hvs_output = 2,
71 +const struct vc4_txp_data vc4_txp_data = {
72 + .base = {
73 + .name = "txp",
74 + .debugfs_name = "txp_regs",
75 + .hvs_available_channels = BIT(2),
76 + .hvs_output = 2,
77 + },
78 };
79
80 static int vc4_txp_bind(struct device *dev, struct device *master, void *data)
81 {
82 struct platform_device *pdev = to_platform_device(dev);
83 struct drm_device *drm = dev_get_drvdata(master);
84 + const struct vc4_txp_data *txp_data;
85 struct vc4_encoder *vc4_encoder;
86 struct drm_encoder *encoder;
87 struct vc4_crtc *vc4_crtc;
88 @@ -513,6 +517,11 @@ static int vc4_txp_bind(struct device *d
89 if (!txp)
90 return -ENOMEM;
91
92 + txp_data = of_device_get_match_data(dev);
93 + if (!txp_data)
94 + return -ENODEV;
95 +
96 + txp->data = txp_data;
97 txp->pdev = pdev;
98 txp->regs = vc4_ioremap_regs(pdev, 0);
99 if (IS_ERR(txp->regs))
100 @@ -523,7 +532,7 @@ static int vc4_txp_bind(struct device *d
101 vc4_crtc->regset.regs = txp_regs;
102 vc4_crtc->regset.nregs = ARRAY_SIZE(txp_regs);
103
104 - ret = vc4_crtc_init(drm, pdev, vc4_crtc, &vc4_txp_crtc_data,
105 + ret = vc4_crtc_init(drm, pdev, vc4_crtc, &txp_data->base,
106 &vc4_txp_crtc_funcs, &vc4_txp_crtc_helper_funcs, true);
107 if (ret)
108 return ret;
109 @@ -584,7 +593,7 @@ static int vc4_txp_remove(struct platfor
110 }
111
112 static const struct of_device_id vc4_txp_dt_match[] = {
113 - { .compatible = "brcm,bcm2835-txp" },
114 + { .compatible = "brcm,bcm2835-txp", .data = &vc4_txp_data },
115 { /* sentinel */ },
116 };
117