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
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.
10 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
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(-)
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 {
21 static const struct vc4_mock_desc vc4_mock =
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
30 static const struct vc4_mock_desc vc5_mock =
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 {
43 -extern const struct vc4_crtc_data vc4_txp_crtc_data;
44 +struct vc4_txp_data {
45 + struct vc4_crtc_data base;
48 +extern const struct vc4_txp_data vc4_txp_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
58 + const struct vc4_txp_data *data;
60 struct platform_device *pdev;
62 @@ -488,17 +489,20 @@ static irqreturn_t vc4_txp_interrupt(int
66 -const struct vc4_crtc_data vc4_txp_crtc_data = {
68 - .debugfs_name = "txp_regs",
69 - .hvs_available_channels = BIT(2),
71 +const struct vc4_txp_data vc4_txp_data = {
74 + .debugfs_name = "txp_regs",
75 + .hvs_available_channels = BIT(2),
80 static int vc4_txp_bind(struct device *dev, struct device *master, void *data)
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
92 + txp_data = of_device_get_match_data(dev);
96 + txp->data = txp_data;
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);
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);
109 @@ -584,7 +593,7 @@ static int vc4_txp_remove(struct platfor
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 },