[d-kernel] [PATCH vtry2 5/7] drm/bridge: dw-hdmi: refreshed hw revision 0x2a support patch

Alexey Sheplyakov asheplyakov на basealt.ru
Пт Сен 2 10:33:42 MSK 2022


The hardware needs non-zero register shift (from DTB), and
a special conf0 parameter.
With this patch I can use HDMI audio on Baikal-M SoC.

Signed-off-by: Alexey Sheplyakov <asheplyakov на basealt.ru>
---
 .../display/bridge/synopsys,dw-hdmi.yaml       |  7 +++++++
 .../drm/bridge/synopsys/dw-hdmi-ahb-audio.c    | 18 +++++++++---------
 .../gpu/drm/bridge/synopsys/dw-hdmi-audio.h    |  2 +-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c      | 12 ++++++++----
 4 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/bridge/synopsys,dw-hdmi.yaml b/Documentation/devicetree/bindings/display/bridge/synopsys,dw-hdmi.yaml
index 9be44a682e67..b86365ebb650 100644
--- a/Documentation/devicetree/bindings/display/bridge/synopsys,dw-hdmi.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/synopsys,dw-hdmi.yaml
@@ -31,6 +31,13 @@ properties:
       - enum: [1, 4]
     default: 1
 
+  ahb-audio-regshift:
+    description:
+      AHB audio registers offset shift
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 2]
+    default: 0
+
   clocks:
     minItems: 2
     maxItems: 5
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
index 8ea999aac4bf..9faae3604c2e 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
@@ -135,24 +135,24 @@ struct snd_dw_hdmi {
 static inline void dw_hdmi_writeb_relaxed(u8 value, const struct dw_hdmi_audio_data *data, int offset)
 {
 	void __iomem *base = data->base;
-	if (data->reg_offset != 0)
-		offset <<= data->reg_offset;
+	if (data->regshift != 0)
+		offset <<= data->regshift;
 	writeb_relaxed(value, base + offset);
 }
 
 static inline void dw_hdmi_writeb(u8 value, const struct dw_hdmi_audio_data *data, int offset)
 {
 	void __iomem *base = data->base;
-	if (data->reg_offset != 0)
-		offset <<= data->reg_offset;
+	if (data->regshift != 0)
+		offset <<= data->regshift;
 	writeb(value, base + offset);
 }
 
 static inline u8 dw_hdmi_readb(const struct dw_hdmi_audio_data *data, int offset)
 {
 	void __iomem *base = data->base;
-	if (data->reg_offset != 0)
-		offset <<= data->reg_offset;
+	if (data->regshift != 0)
+		offset <<= data->regshift;
 	return readb(base + offset);
 
 }
@@ -160,8 +160,8 @@ static inline u8 dw_hdmi_readb(const struct dw_hdmi_audio_data *data, int offset
 static inline u8 dw_hdmi_readb_relaxed(const struct dw_hdmi_audio_data *data, int offset)
 {
 	void __iomem *base = data->base;
-	if (data->reg_offset != 0)
-		offset <<= data->reg_offset;
+	if (data->regshift != 0)
+		offset <<= data->regshift;
 	return readb_relaxed(base + offset);
 }
 
@@ -451,7 +451,7 @@ static int dw_hdmi_prepare(struct snd_pcm_substream *substream)
 			HDMI_AHB_DMA_CONF0_INCR8;
 		threshold = 128;
 		break;
-	case 0x2a: /* this revision is used in Baikal-M SoC */
+	case 0x2a:
 		conf0 = HDMI_AHB_DMA_CONF0_BURST_MODE |
 			HDMI_AHB_DMA_CONF0_INCR16;
 		threshold = 128;
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h
index bc8468fe52a0..3250588d39ff 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h
@@ -10,7 +10,7 @@ struct dw_hdmi_audio_data {
 	int irq;
 	struct dw_hdmi *hdmi;
 	u8 *(*get_eld)(struct dw_hdmi *hdmi);
-	unsigned reg_offset;
+	unsigned regshift;
 };
 
 struct dw_hdmi_i2s_audio_data {
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index 573c9820030e..0472ab97ea39 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -3441,11 +3441,15 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
 		audio.irq = irq;
 		audio.hdmi = hdmi;
 		audio.get_eld = hdmi_audio_get_eld;
-		audio.reg_offset = 0;
+		if (of_property_read_u32(np, "ahb-audio-regshift", &audio.regshift) != 0) {
+			audio.regshift = 0;
+		} else {
+			dev_dbg(dev, "set audio.regshift=%u from DTB\n", audio.regshift);
+		}
 		if (of_device_is_compatible(np, "baikal,hdmi")) {
-			audio.reg_offset = 2;
-			dev_info(dev, "setting audio.reg_offset=%d for BE-M1000 SoC\n",
-				 audio.reg_offset);
+			audio.regshift = 2;
+			dev_info(dev, "setting audio.regshift=%d for BE-M1000 SoC\n",
+				 audio.regshift);
 		}
 		hdmi->enable_audio = dw_hdmi_ahb_audio_enable;
 		hdmi->disable_audio = dw_hdmi_ahb_audio_disable;
-- 
2.33.3



Подробная информация о списке рассылки devel-kernel