From 247099050b2b7b6f704393cda65bc54cd0610908 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Tue, 5 Dec 2023 18:29:34 +0000
Subject: [PATCH 0763/1085] drm/vc4: Mop and moplet have different register
 offsets for high addr

MOP uses register offset 0x24 for the high bits of the address,
whilst Moplet uses 0x1c.

Handle this difference between the block types.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 drivers/gpu/drm/vc4/vc4_drv.h | 1 +
 drivers/gpu/drm/vc4/vc4_txp.c | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -549,6 +549,7 @@ struct vc4_crtc_data {
 struct vc4_txp_data {
 	struct vc4_crtc_data	base;
 	enum vc4_encoder_type encoder_type;
+	unsigned int high_addr_ptr_reg;
 	unsigned int has_byte_enable:1;
 	unsigned int size_minus_one:1;
 	unsigned int supports_40bit_addresses:1;
--- a/drivers/gpu/drm/vc4/vc4_txp.c
+++ b/drivers/gpu/drm/vc4/vc4_txp.c
@@ -145,7 +145,8 @@
 /* Number of lines received and committed to memory. */
 #define TXP_PROGRESS		0x10
 
-#define TXP_DST_PTR_HIGH	0x1c
+#define TXP_DST_PTR_HIGH_MOPLET	0x1c
+#define TXP_DST_PTR_HIGH_MOP	0x24
 
 #define TXP_READ(offset)								\
 	({										\
@@ -334,10 +335,11 @@ static void vc4_txp_connector_atomic_com
 
 	gem = drm_fb_dma_get_gem_obj(fb, 0);
 	addr = gem->dma_addr + fb->offsets[0];
+
 	TXP_WRITE(TXP_DST_PTR, lower_32_bits(addr));
 
 	if (txp_data->supports_40bit_addresses)
-		TXP_WRITE(TXP_DST_PTR_HIGH, upper_32_bits(addr) & 0xff);
+		TXP_WRITE(txp_data->high_addr_ptr_reg, upper_32_bits(addr) & 0xff);
 
 	TXP_WRITE(TXP_DST_PITCH, fb->pitches[0]);
 
@@ -516,6 +518,7 @@ const struct vc4_txp_data bcm2712_mop_da
 		.hvs_output = 2,
 	},
 	.encoder_type = VC4_ENCODER_TYPE_TXP0,
+	.high_addr_ptr_reg = TXP_DST_PTR_HIGH_MOP,
 	.has_byte_enable = true,
 	.size_minus_one = true,
 	.supports_40bit_addresses = true,
@@ -529,6 +532,7 @@ const struct vc4_txp_data bcm2712_moplet
 		.hvs_output = 4,
 	},
 	.encoder_type = VC4_ENCODER_TYPE_TXP1,
+	.high_addr_ptr_reg = TXP_DST_PTR_HIGH_MOPLET,
 	.size_minus_one = true,
 	.supports_40bit_addresses = true,
 };
