Skip to contentSkip to conversation

video: dw_hdmi: Support Vendor PHY

PATCH Superseded Jagan Teki 6 participants 28 messages Dec 11, 2023 – Dec 18, 2023

Subsystems (8)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

cover video: dw_hdmi: Support Vendor PHY

Unlike RK3399, Sunxi/Meson DW HDMI the new Rockchip SoC Rk3328 would support external vendor PHY with DW HDMI chip.

Support this vendor PHY by adding new platform PHY ops via DW HDMI driver and call the respective generic phy from platform driver code.

This series tested in RK3328 with 1080p (1920x1080) resolution.

Patch 0001/0005: Support Vendor PHY
Patch 0006/0008: VOP extension for win, dsp offsets Patch 0009/0010: RK3328 VOP, HDMI clocks
Patch 0011: Rockchip Inno HDMI PHY
Patch 0012: RK3328 HDMI driver
Patch 0013: RK3328 VOP driver
Patch 0014/0017: Enable HDMI Out for RK3328

Importent:
One pontential issues is that Linux HDMI out on RK3328 has effected by this patchset as I wouldn't find any relation or clue.

[    0.752016] Loading compiled-in X.509 certificates
[    0.787796] inno_hdmi_phy_rk3328_clk_recalc_rate: parent 24000000
[    0.788391] inno-hdmi-phy ff430000.phy: inno_hdmi_phy_rk3328_clk_recalc_rate rate 148500000 vco 148500000
[    0.798353] rockchip-drm display-subsystem: bound ff370000.vop (ops vop_component_ops)
[    0.799403] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-0v9 not found, using dummy regulator
[    0.800288] rk_iommu ff373f00.iommu: Enable stall request timed out, status: 0x00004b
[    0.801131] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-1v8 not found, using dummy regulator
[    0.802056] rk_iommu ff373f00.iommu: Disable paging request timed out, status: 0x00004b
[    0.803233] dwhdmi-rockchip ff3c0000.hdmi: Detected HDMI TX controller v2.11a with HDCP (inno_dw_hdmi_phy2)
[    0.805355] dwhdmi-rockchip ff3c0000.hdmi: registered DesignWare HDMI I2C bus driver
[    0.808769] rockchip-drm display-subsystem: bound ff3c0000.hdmi (ops dw_hdmi_rockchip_ops)
[    0.810869] [drm] Initialized rockchip 1.0.0 20140818 for display-subsystem on minor 0

The only way I can use Linux HDMI by disabling IOMMU or support disable-iommu link for RK3328 via DT [1].

[1] https://www.spinics.net/lists/devicetree/msg605124.html

Any inputs?
Jagan.

Jagan Teki (17):
video: rockchip: hdmi: Detect hpd after controller init
video: dw_hdmi: Add Vendor PHY handling
video: dw_hdmi: Extend the HPD detection
video: dw_hdmi: Add read_hpd hook
video: dw_hdmi: Add setup_hpd hook
video: rockchip: vop: Simplify rkvop_enable
video: rockchip: vop: Add win offset support
video: rockchip: vop: Add dsp offset support
clk: rockchip: rk3328: Add VOP clk support
clk: rk3328: Add get hdmiphy clock
phy: rockchip: Add Rockchip INNO HDMI PHY driver
video: rockchip: Add rk3328 hdmi support
video: rockchip: Add rk3328 vop support
ARM: dts: rk3328: Enable VOP for bootph-all
rockchip: Enable preconsole for rk3328
configs: evb-rk3328: Enable vidconsole for rk3328
configs: Enable HDMI Out for ROC-RK3328-CC

 arch/arm/dts/rk3328-u-boot.dtsi               |   4 +
 .../include/asm/arch-rockchip/cru_rk3328.h    |  34 +
 arch/arm/mach-rockchip/Kconfig                |   1 +
 common/Kconfig                                |   2 +-
 configs/roc-cc-rk3328_defconfig               |   5 +
 drivers/clk/rockchip/clk_rk3328.c             | 100 +-
 drivers/phy/rockchip/Kconfig                  |   7 +
 drivers/phy/rockchip/Makefile                 |   1 +
 drivers/phy/rockchip/phy-rockchip-inno-hdmi.c | 885 ++++++++++++++++++
 drivers/video/dw_hdmi.c                       |  48 +-
 drivers/video/meson/meson_dw_hdmi.c           |  11 +-
 drivers/video/rockchip/Makefile               |   2 +
 drivers/video/rockchip/rk3328_hdmi.c          | 131 +++
 drivers/video/rockchip/rk3328_vop.c           |  66 ++
 drivers/video/rockchip/rk3399_hdmi.c          |   8 +-
 drivers/video/rockchip/rk_hdmi.c              |  12 +-
 drivers/video/rockchip/rk_hdmi.h              |   3 +
 drivers/video/rockchip/rk_vop.c               |  44 +-
 drivers/video/rockchip/rk_vop.h               |   4 +
 drivers/video/sunxi/sunxi_dw_hdmi.c           |  19 +-
 include/configs/evb_rk3328.h                  |   5 +
 include/configs/rk3328_common.h               |   1 +
 include/dw_hdmi.h                             |  17 +-
 23 files changed, 1371 insertions(+), 39 deletions(-)
 create mode 100644 drivers/phy/rockchip/phy-rockchip-inno-hdmi.c
 create mode 100644 drivers/video/rockchip/rk3328_hdmi.c
 create mode 100644 drivers/video/rockchip/rk3328_vop.c
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/17 video: rockchip: hdmi: Detect hpd after controller init

From: Jagan Teki <[email protected]>

HDP is a hardware connector event, so detect the same once the controller and attached PHY initialization are done.

---
 drivers/video/rockchip/rk_hdmi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/video/rockchip/rk_hdmi.c +3 -3
index 8dcd4d5964..b75a174489 100644
@@ -112,14 +112,14 @@ int rk_hdmi_probe(struct udevice *dev)
 	struct dw_hdmi *hdmi = &priv->hdmi;
 	int ret;
 
+	dw_hdmi_init(hdmi);
+	dw_hdmi_phy_init(hdmi);
+
 	ret = dw_hdmi_phy_wait_for_hpd(hdmi);
 	if (ret < 0) {
 		debug("hdmi can not get hpd signal\n");
 		return -1;
 	}
 
-	dw_hdmi_init(hdmi);
-	dw_hdmi_phy_init(hdmi);
-
 	return 0;
 }
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH 2/17 video: dw_hdmi: Add Vendor PHY handling

In reply to Jagan Teki

From: Jagan Teki <[email protected]>

DW HDMI support Vendor PHY like Rockchip RK3328 Inno HDMI PHY.

Extend the vendor phy handling by adding platform phy hooks.

---
 drivers/video/dw_hdmi.c              | 29 +++++++++++++++++++++++++++-
 drivers/video/meson/meson_dw_hdmi.c  | 11 ++++++++++-
 drivers/video/rockchip/rk3399_hdmi.c |  8 +++++++-
 drivers/video/rockchip/rk_hdmi.c     |  2 +-
 drivers/video/sunxi/sunxi_dw_hdmi.c  | 11 ++++++++++-
 include/dw_hdmi.h                    | 14 +++++++++++++-
 6 files changed, 69 insertions(+), 6 deletions(-)
drivers/video/dw_hdmi.c +28 -1
index c4fbb18294..ea12a09407 100644
@@ -988,7 +988,7 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid)
 
 	hdmi_av_composer(hdmi, edid);
 
-	ret = hdmi->phy_set(hdmi, edid->pixelclock.typ);
+	ret = hdmi->ops->phy_set(hdmi, edid->pixelclock.typ);
 	if (ret)
 		return ret;
 
@@ -1009,10 +1009,37 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid)
 	return 0;
 }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_synopsys_phy_ops = {
+	.phy_set = dw_hdmi_phy_cfg,
+};
+
+static void dw_hdmi_detect_phy(struct dw_hdmi *hdmi)
+{
+	if (!hdmi->data)
+		return;
+
+	/* hook Synopsys PHYs ops */
+	if (!hdmi->data->phy_force_vendor) {
+		hdmi->ops = &dw_hdmi_synopsys_phy_ops;
+		return;
+	}
+
+	/* Vendor HDMI PHYs must assign phy_ops in plat_data */
+	if (!hdmi->data->phy_ops) {
+		printf("Unsupported Vendor HDMI phy_ops\n");
+		return;
+	}
+
+	/* hook Vendor HDMI PHYs ops */
+	hdmi->ops = hdmi->data->phy_ops;
+}
+
 void dw_hdmi_init(struct dw_hdmi *hdmi)
 {
 	uint ih_mute;
 
+	dw_hdmi_detect_phy(hdmi);
+
 	/*
 	 * boot up defaults are:
 	 * hdmi_ih_mute   = 0x03 (disabled)
drivers/video/meson/meson_dw_hdmi.c +10 -1
index 5db01904b5..63ca3ac52e 100644
@@ -375,6 +375,15 @@ static int meson_dw_hdmi_wait_hpd(struct dw_hdmi *hdmi)
 	return -ETIMEDOUT;
 }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_meson_phy_ops = {
+	.phy_set = meson_dw_hdmi_phy_cfg,
+};
+
+static const struct dw_hdmi_plat_data dw_hdmi_meson_plat_data = {
+	.phy_force_vendor = true,
+	.phy_ops = &dw_hdmi_meson_phy_ops,
+};
+
 static int meson_dw_hdmi_probe(struct udevice *dev)
 {
 	struct meson_dw_hdmi *priv = dev_get_priv(dev);
@@ -397,7 +406,7 @@ static int meson_dw_hdmi_probe(struct udevice *dev)
 
 	priv->hdmi.hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24;
 	priv->hdmi.hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_YUV8_1X24;
-	priv->hdmi.phy_set = meson_dw_hdmi_phy_init;
+	priv->hdmi.data = &dw_hdmi_meson_plat_data;
 	if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A))
 		priv->hdmi.reg_io_width = 1;
 	else {
drivers/video/rockchip/rk3399_hdmi.c +7 -1
index 3041360c6e..b32139a8a6 100644
@@ -64,8 +64,14 @@ static const struct dm_display_ops rk3399_hdmi_ops = {
 	.enable = rk3399_hdmi_enable,
 };
 
+static const struct dw_hdmi_plat_data rk3399_hdmi_drv_data = {
+};
+
 static const struct udevice_id rk3399_hdmi_ids[] = {
-	{ .compatible = "rockchip,rk3399-dw-hdmi" },
+	{
+		.compatible = "rockchip,rk3399-dw-hdmi",
+		.data = (ulong)&rk3399_hdmi_drv_data
+	},
 	{ }
 };
 
drivers/video/rockchip/rk_hdmi.c +1 -1
index b75a174489..e34f532cd6 100644
@@ -83,6 +83,7 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
 	struct rk_hdmi_priv *priv = dev_get_priv(dev);
 	struct dw_hdmi *hdmi = &priv->hdmi;
 
+	hdmi->data = (const struct dw_hdmi_plat_data *)dev_get_driver_data(dev);
 	hdmi->ioaddr = (ulong)dev_read_addr(dev);
 	hdmi->mpll_cfg = rockchip_mpll_cfg;
 	hdmi->phy_cfg = rockchip_phy_config;
@@ -90,7 +91,6 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
 	/* hdmi->i2c_clk_{high,low} are set up by the SoC driver */
 
 	hdmi->reg_io_width = 4;
-	hdmi->phy_set = dw_hdmi_phy_cfg;
 
 	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
drivers/video/sunxi/sunxi_dw_hdmi.c +10 -1
index 0324a050d0..4b67a1614e 100644
@@ -369,6 +369,15 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
 	return 0;
 }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_sunxi_phy_ops = {
+	.phy_set = sunxi_dw_hdmi_phy_cfg,
+};
+
+static const struct dw_hdmi_plat_data dw_hdmi_sunxi_plat_data = {
+	.phy_force_vendor = true,
+	.phy_ops = &dw_hdmi_sunxi_phy_ops,
+};
+
 static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
 {
 	struct sunxi_dw_hdmi_priv *priv = dev_get_priv(dev);
@@ -379,7 +388,7 @@ static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
 	hdmi->i2c_clk_high = 0xd8;
 	hdmi->i2c_clk_low = 0xfe;
 	hdmi->reg_io_width = 1;
-	hdmi->phy_set = sunxi_dw_hdmi_phy_cfg;
+	hdmi->data = &dw_hdmi_sunxi_plat_data;
 
 	ret = reset_get_bulk(dev, &priv->resets);
 	if (ret)
include/dw_hdmi.h +13 -1
index 8acae3839f..4ad8b39f84 100644
@@ -534,6 +534,17 @@ struct hdmi_data_info {
 	struct hdmi_vmode video_mode;
 };
 
+struct dw_hdmi;
+
+struct dw_hdmi_phy_ops {
+	int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
+};
+
+struct dw_hdmi_plat_data {
+	bool phy_force_vendor;
+	const struct dw_hdmi_phy_ops *phy_ops;
+};
+
 struct dw_hdmi {
 	ulong ioaddr;
 	const struct hdmi_mpll_config *mpll_cfg;
@@ -543,8 +554,9 @@ struct dw_hdmi {
 	u8 reg_io_width;
 	struct hdmi_data_info hdmi_data;
 	struct udevice *ddc_bus;
+	const struct dw_hdmi_phy_ops *ops;
+	const struct dw_hdmi_plat_data *data;
 
-	int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
 	void (*write_reg)(struct dw_hdmi *hdmi, u8 val, int offset);
 	u8 (*read_reg)(struct dw_hdmi *hdmi, int offset);
 };
Signature · 1 line
2.25.1
maintainer
#3 lore raw

Re: [PATCH 02/17] video: dw_hdmi: Add Vendor PHY handling

Quoted 72 lines · Jagan Teki

From: Jagan Teki <[email protected]>

DW HDMI support Vendor PHY like Rockchip RK3328 Inno HDMI PHY.

Extend the vendor phy handling by adding platform phy hooks.

---
  drivers/video/dw_hdmi.c              | 29 +++++++++++++++++++++++++++-
  drivers/video/meson/meson_dw_hdmi.c  | 11 ++++++++++-
  drivers/video/rockchip/rk3399_hdmi.c |  8 +++++++-
  drivers/video/rockchip/rk_hdmi.c     |  2 +-
  drivers/video/sunxi/sunxi_dw_hdmi.c  | 11 ++++++++++-
  include/dw_hdmi.h                    | 14 +++++++++++++-
  6 files changed, 69 insertions(+), 6 deletions(-)
drivers/video/dw_hdmi.c +28 -1
index c4fbb18294..ea12a09407 100644
@@ -988,7 +988,7 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid)
 
  	hdmi_av_composer(hdmi, edid);
 
-	ret = hdmi->phy_set(hdmi, edid->pixelclock.typ);
+	ret = hdmi->ops->phy_set(hdmi, edid->pixelclock.typ);
  	if (ret)
  		return ret;
 
@@ -1009,10 +1009,37 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid)
  	return 0;
  }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_synopsys_phy_ops = {
+	.phy_set = dw_hdmi_phy_cfg,
+};
+
+static void dw_hdmi_detect_phy(struct dw_hdmi *hdmi)
+{
+	if (!hdmi->data)
+		return;
+
+	/* hook Synopsys PHYs ops */
+	if (!hdmi->data->phy_force_vendor) {
+		hdmi->ops = &dw_hdmi_synopsys_phy_ops;
+		return;
+	}
+
+	/* Vendor HDMI PHYs must assign phy_ops in plat_data */
+	if (!hdmi->data->phy_ops) {
+		printf("Unsupported Vendor HDMI phy_ops\n");
+		return;
+	}
+
+	/* hook Vendor HDMI PHYs ops */
+	hdmi->ops = hdmi->data->phy_ops;
+}
+
  void dw_hdmi_init(struct dw_hdmi *hdmi)
  {
  	uint ih_mute;
 
+	dw_hdmi_detect_phy(hdmi);
+
  	/*
  	 * boot up defaults are:
  	 * hdmi_ih_mute   = 0x03 (disabled)
drivers/video/meson/meson_dw_hdmi.c +0 -0
index 5db01904b5..63ca3ac52e 100644

drivers/video/meson/meson_dw_hdmi.c static int meson_dw_hdmi_wait_hpd(struct dw_hdmi *hdmi) · line 379

Quoted 5 lines
drivers/video/meson/meson_dw_hdmi.c +2 -0
@@ -375,6 +375,15 @@ static int meson_dw_hdmi_wait_hpd(struct dw_hdmi *hdmi)
  	return -ETIMEDOUT;
  }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_meson_phy_ops = {
+	.phy_set = meson_dw_hdmi_phy_cfg,

Pretty sure this should be meson_dw_hdmi_phy_init

Quoted 96 lines
drivers/video/meson/meson_dw_hdmi.c +8 -1
+};
+
+static const struct dw_hdmi_plat_data dw_hdmi_meson_plat_data = {
+	.phy_force_vendor = true,
+	.phy_ops = &dw_hdmi_meson_phy_ops,
+};
+
  static int meson_dw_hdmi_probe(struct udevice *dev)
  {
  	struct meson_dw_hdmi *priv = dev_get_priv(dev);
@@ -397,7 +406,7 @@ static int meson_dw_hdmi_probe(struct udevice *dev)
 
  	priv->hdmi.hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24;
  	priv->hdmi.hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_YUV8_1X24;
-	priv->hdmi.phy_set = meson_dw_hdmi_phy_init;
+	priv->hdmi.data = &dw_hdmi_meson_plat_data;
  	if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A))
  		priv->hdmi.reg_io_width = 1;
  	else {
drivers/video/rockchip/rk3399_hdmi.c +7 -1
index 3041360c6e..b32139a8a6 100644
@@ -64,8 +64,14 @@ static const struct dm_display_ops rk3399_hdmi_ops = {
  	.enable = rk3399_hdmi_enable,
  };
 
+static const struct dw_hdmi_plat_data rk3399_hdmi_drv_data = {
+};
+
  static const struct udevice_id rk3399_hdmi_ids[] = {
-	{ .compatible = "rockchip,rk3399-dw-hdmi" },
+	{
+		.compatible = "rockchip,rk3399-dw-hdmi",
+		.data = (ulong)&rk3399_hdmi_drv_data
+	},
  	{ }
  };
 
drivers/video/rockchip/rk_hdmi.c +1 -1
index b75a174489..e34f532cd6 100644
@@ -83,6 +83,7 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
  	struct rk_hdmi_priv *priv = dev_get_priv(dev);
  	struct dw_hdmi *hdmi = &priv->hdmi;
 
+	hdmi->data = (const struct dw_hdmi_plat_data *)dev_get_driver_data(dev);
  	hdmi->ioaddr = (ulong)dev_read_addr(dev);
  	hdmi->mpll_cfg = rockchip_mpll_cfg;
  	hdmi->phy_cfg = rockchip_phy_config;
@@ -90,7 +91,6 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
  	/* hdmi->i2c_clk_{high,low} are set up by the SoC driver */
 
  	hdmi->reg_io_width = 4;
-	hdmi->phy_set = dw_hdmi_phy_cfg;
 
  	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
drivers/video/sunxi/sunxi_dw_hdmi.c +10 -1
index 0324a050d0..4b67a1614e 100644
@@ -369,6 +369,15 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
  	return 0;
  }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_sunxi_phy_ops = {
+	.phy_set = sunxi_dw_hdmi_phy_cfg,
+};
+
+static const struct dw_hdmi_plat_data dw_hdmi_sunxi_plat_data = {
+	.phy_force_vendor = true,
+	.phy_ops = &dw_hdmi_sunxi_phy_ops,
+};
+
  static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
  {
  	struct sunxi_dw_hdmi_priv *priv = dev_get_priv(dev);
@@ -379,7 +388,7 @@ static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
  	hdmi->i2c_clk_high = 0xd8;
  	hdmi->i2c_clk_low = 0xfe;
  	hdmi->reg_io_width = 1;
-	hdmi->phy_set = sunxi_dw_hdmi_phy_cfg;
+	hdmi->data = &dw_hdmi_sunxi_plat_data;
 
  	ret = reset_get_bulk(dev, &priv->resets);
  	if (ret)
include/dw_hdmi.h +0 -0
index 8acae3839f..4ad8b39f84 100644
@@ -534,6 +534,17 @@ struct hdmi_data_info {
  	struct hdmi_vmode video_mode;
  };
 

include/dw_hdmi.h struct hdmi_data_info { · line 546

Quoted 10 lines
include/dw_hdmi.h +10 -0
+struct dw_hdmi;
+
+struct dw_hdmi_phy_ops {
+	int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
+};
+
+struct dw_hdmi_plat_data {
+	bool phy_force_vendor;
+	const struct dw_hdmi_phy_ops *phy_ops;
+};

Why do you need a separate phy_ops and this phy_force_vendor ?

Simply use the provided phy_ops is pointer != NULL

I think simply use a single struct passed as pdata to have:

if (!hdmi->data)

	hdmi->ops = &dw_hdmi_synopsys_phy_ops;
else
	/* hook Vendor HDMI PHYs ops */
	hdmi->ops = hdmi->data;

Neil

Quoted 15 lines
include/dw_hdmi.h +3 -1
+
  struct dw_hdmi {
  	ulong ioaddr;
  	const struct hdmi_mpll_config *mpll_cfg;
@@ -543,8 +554,9 @@ struct dw_hdmi {
  	u8 reg_io_width;
  	struct hdmi_data_info hdmi_data;
  	struct udevice *ddc_bus;
+	const struct dw_hdmi_phy_ops *ops;
+	const struct dw_hdmi_plat_data *data;
 
-	int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
  	void (*write_reg)(struct dw_hdmi *hdmi, u8 val, int offset);
  	u8 (*read_reg)(struct dw_hdmi *hdmi, int offset);
  };
author
#4 lore raw

Re: [PATCH 02/17] video: dw_hdmi: Add Vendor PHY handling

Quoted 77 lines · Neil Armstrong
Quoted 75 lines · Jagan Teki

From: Jagan Teki <[email protected]>

DW HDMI support Vendor PHY like Rockchip RK3328 Inno HDMI PHY.

Extend the vendor phy handling by adding platform phy hooks.

---
  drivers/video/dw_hdmi.c              | 29 +++++++++++++++++++++++++++-
  drivers/video/meson/meson_dw_hdmi.c  | 11 ++++++++++-
  drivers/video/rockchip/rk3399_hdmi.c |  8 +++++++-
  drivers/video/rockchip/rk_hdmi.c     |  2 +-
  drivers/video/sunxi/sunxi_dw_hdmi.c  | 11 ++++++++++-
  include/dw_hdmi.h                    | 14 +++++++++++++-
  6 files changed, 69 insertions(+), 6 deletions(-)
drivers/video/dw_hdmi.c +28 -1
index c4fbb18294..ea12a09407 100644
@@ -988,7 +988,7 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid)
 
      hdmi_av_composer(hdmi, edid);
 
-     ret = hdmi->phy_set(hdmi, edid->pixelclock.typ);
+     ret = hdmi->ops->phy_set(hdmi, edid->pixelclock.typ);
      if (ret)
              return ret;
 
@@ -1009,10 +1009,37 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid)
      return 0;
  }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_synopsys_phy_ops = {
+     .phy_set = dw_hdmi_phy_cfg,
+};
+
+static void dw_hdmi_detect_phy(struct dw_hdmi *hdmi)
+{
+     if (!hdmi->data)
+             return;
+
+     /* hook Synopsys PHYs ops */
+     if (!hdmi->data->phy_force_vendor) {
+             hdmi->ops = &dw_hdmi_synopsys_phy_ops;
+             return;
+     }
+
+     /* Vendor HDMI PHYs must assign phy_ops in plat_data */
+     if (!hdmi->data->phy_ops) {
+             printf("Unsupported Vendor HDMI phy_ops\n");
+             return;
+     }
+
+     /* hook Vendor HDMI PHYs ops */
+     hdmi->ops = hdmi->data->phy_ops;
+}
+
  void dw_hdmi_init(struct dw_hdmi *hdmi)
  {
      uint ih_mute;
 
+     dw_hdmi_detect_phy(hdmi);
+
      /*
       * boot up defaults are:
       * hdmi_ih_mute   = 0x03 (disabled)
drivers/video/meson/meson_dw_hdmi.c +0 -0
index 5db01904b5..63ca3ac52e 100644
@@ -375,6 +375,15 @@ static int meson_dw_hdmi_wait_hpd(struct dw_hdmi *hdmi)
      return -ETIMEDOUT;
  }
 
Quoted 4 lines

drivers/video/meson/meson_dw_hdmi.c static int meson_dw_hdmi_wait_hpd(struct dw_hdmi *hdmi) · line 379

Quoted 2 lines
drivers/video/meson/meson_dw_hdmi.c +2 -0
+static const struct dw_hdmi_phy_ops dw_hdmi_meson_phy_ops = {
+     .phy_set = meson_dw_hdmi_phy_cfg,

Pretty sure this should be meson_dw_hdmi_phy_init

Correct, I will update this.

Quoted 112 lines
Quoted 97 lines
drivers/video/meson/meson_dw_hdmi.c +8 -1
+};
+
+static const struct dw_hdmi_plat_data dw_hdmi_meson_plat_data = {
+     .phy_force_vendor = true,
+     .phy_ops = &dw_hdmi_meson_phy_ops,
+};
+
  static int meson_dw_hdmi_probe(struct udevice *dev)
  {
      struct meson_dw_hdmi *priv = dev_get_priv(dev);
@@ -397,7 +406,7 @@ static int meson_dw_hdmi_probe(struct udevice *dev)
 
      priv->hdmi.hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24;
      priv->hdmi.hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_YUV8_1X24;
-     priv->hdmi.phy_set = meson_dw_hdmi_phy_init;
+     priv->hdmi.data = &dw_hdmi_meson_plat_data;
      if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A))
              priv->hdmi.reg_io_width = 1;
      else {
drivers/video/rockchip/rk3399_hdmi.c +7 -1
index 3041360c6e..b32139a8a6 100644
@@ -64,8 +64,14 @@ static const struct dm_display_ops rk3399_hdmi_ops = {
      .enable = rk3399_hdmi_enable,
  };
 
+static const struct dw_hdmi_plat_data rk3399_hdmi_drv_data = {
+};
+
  static const struct udevice_id rk3399_hdmi_ids[] = {
-     { .compatible = "rockchip,rk3399-dw-hdmi" },
+     {
+             .compatible = "rockchip,rk3399-dw-hdmi",
+             .data = (ulong)&rk3399_hdmi_drv_data
+     },
      { }
  };
 
drivers/video/rockchip/rk_hdmi.c +1 -1
index b75a174489..e34f532cd6 100644
@@ -83,6 +83,7 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
      struct rk_hdmi_priv *priv = dev_get_priv(dev);
      struct dw_hdmi *hdmi = &priv->hdmi;
 
+     hdmi->data = (const struct dw_hdmi_plat_data *)dev_get_driver_data(dev);
      hdmi->ioaddr = (ulong)dev_read_addr(dev);
      hdmi->mpll_cfg = rockchip_mpll_cfg;
      hdmi->phy_cfg = rockchip_phy_config;
@@ -90,7 +91,6 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
      /* hdmi->i2c_clk_{high,low} are set up by the SoC driver */
 
      hdmi->reg_io_width = 4;
-     hdmi->phy_set = dw_hdmi_phy_cfg;
 
      priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
drivers/video/sunxi/sunxi_dw_hdmi.c +10 -1
index 0324a050d0..4b67a1614e 100644
@@ -369,6 +369,15 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
      return 0;
  }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_sunxi_phy_ops = {
+     .phy_set = sunxi_dw_hdmi_phy_cfg,
+};
+
+static const struct dw_hdmi_plat_data dw_hdmi_sunxi_plat_data = {
+     .phy_force_vendor = true,
+     .phy_ops = &dw_hdmi_sunxi_phy_ops,
+};
+
  static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
  {
      struct sunxi_dw_hdmi_priv *priv = dev_get_priv(dev);
@@ -379,7 +388,7 @@ static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
      hdmi->i2c_clk_high = 0xd8;
      hdmi->i2c_clk_low = 0xfe;
      hdmi->reg_io_width = 1;
-     hdmi->phy_set = sunxi_dw_hdmi_phy_cfg;
+     hdmi->data = &dw_hdmi_sunxi_plat_data;
 
      ret = reset_get_bulk(dev, &priv->resets);
      if (ret)
include/dw_hdmi.h +0 -0
index 8acae3839f..4ad8b39f84 100644
@@ -534,6 +534,17 @@ struct hdmi_data_info {
      struct hdmi_vmode video_mode;
  };
 

include/dw_hdmi.h struct hdmi_data_info { · line 546

Quoted 10 lines
include/dw_hdmi.h +10 -0
+struct dw_hdmi;
+
+struct dw_hdmi_phy_ops {
+     int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
+};
+
+struct dw_hdmi_plat_data {
+     bool phy_force_vendor;
+     const struct dw_hdmi_phy_ops *phy_ops;
+};

Why do you need a separate phy_ops and this phy_force_vendor ?

Simply use the provided phy_ops is pointer != NULL

Quoted 7 lines

I think simply use a single struct passed as pdata to have:

if (!hdmi->data)

        hdmi->ops = &dw_hdmi_synopsys_phy_ops;
else
        /* hook Vendor HDMI PHYs ops */
        hdmi->ops = hdmi->data;

This logic seems not proper according to DW HDMI vendor phy support.

phy_set -> dw_hdmi_phy_cfg in dw_hdmi.c is what synopsys default phy ops set. and reset defined in their hdmi drivers are vendor-related. So only rk3399 has default synopsys phy_set but meson, sunxi and this rk3328 has vendor phy ops. We need to define plat_data with phy_ops and phy_force_vendor flag to support this setup.

Thanks,
Jagan.

#5 lore raw

Re: [PATCH 02/17] video: dw_hdmi: Add Vendor PHY handling

In reply to Jagan Teki

Hi Jagan,

Quoted 8 lines · Jagan Teki

From: Jagan Teki <[email protected]>

DW HDMI support Vendor PHY like Rockchip RK3328 Inno HDMI PHY.

Extend the vendor phy handling by adding platform phy hooks.

Quoted 9 lines
---
 drivers/video/dw_hdmi.c              | 29 +++++++++++++++++++++++++++-
 drivers/video/meson/meson_dw_hdmi.c  | 11 ++++++++++-
 drivers/video/rockchip/rk3399_hdmi.c |  8 +++++++-
 drivers/video/rockchip/rk_hdmi.c     |  2 +-
 drivers/video/sunxi/sunxi_dw_hdmi.c  | 11 ++++++++++-
 include/dw_hdmi.h                    | 14 +++++++++++++-
 6 files changed, 69 insertions(+), 6 deletions(-)

Isn't there a PHY framework we should use in U-Boot?

Regards,
Sim on

Quoted 172 lines
drivers/video/dw_hdmi.c +28 -1
index c4fbb18294..ea12a09407 100644
@@ -988,7 +988,7 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid)
 
        hdmi_av_composer(hdmi, edid);
 
-       ret = hdmi->phy_set(hdmi, edid->pixelclock.typ);
+       ret = hdmi->ops->phy_set(hdmi, edid->pixelclock.typ);
        if (ret)
                return ret;
 
@@ -1009,10 +1009,37 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid)
        return 0;
 }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_synopsys_phy_ops = {
+       .phy_set = dw_hdmi_phy_cfg,
+};
+
+static void dw_hdmi_detect_phy(struct dw_hdmi *hdmi)
+{
+       if (!hdmi->data)
+               return;
+
+       /* hook Synopsys PHYs ops */
+       if (!hdmi->data->phy_force_vendor) {
+               hdmi->ops = &dw_hdmi_synopsys_phy_ops;
+               return;
+       }
+
+       /* Vendor HDMI PHYs must assign phy_ops in plat_data */
+       if (!hdmi->data->phy_ops) {
+               printf("Unsupported Vendor HDMI phy_ops\n");
+               return;
+       }
+
+       /* hook Vendor HDMI PHYs ops */
+       hdmi->ops = hdmi->data->phy_ops;
+}
+
 void dw_hdmi_init(struct dw_hdmi *hdmi)
 {
        uint ih_mute;
 
+       dw_hdmi_detect_phy(hdmi);
+
        /*
         * boot up defaults are:
         * hdmi_ih_mute   = 0x03 (disabled)
drivers/video/meson/meson_dw_hdmi.c +10 -1
index 5db01904b5..63ca3ac52e 100644
@@ -375,6 +375,15 @@ static int meson_dw_hdmi_wait_hpd(struct dw_hdmi *hdmi)
        return -ETIMEDOUT;
 }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_meson_phy_ops = {
+       .phy_set = meson_dw_hdmi_phy_cfg,
+};
+
+static const struct dw_hdmi_plat_data dw_hdmi_meson_plat_data = {
+       .phy_force_vendor = true,
+       .phy_ops = &dw_hdmi_meson_phy_ops,
+};
+
 static int meson_dw_hdmi_probe(struct udevice *dev)
 {
        struct meson_dw_hdmi *priv = dev_get_priv(dev);
@@ -397,7 +406,7 @@ static int meson_dw_hdmi_probe(struct udevice *dev)
 
        priv->hdmi.hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24;
        priv->hdmi.hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_YUV8_1X24;
-       priv->hdmi.phy_set = meson_dw_hdmi_phy_init;
+       priv->hdmi.data = &dw_hdmi_meson_plat_data;
        if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A))
                priv->hdmi.reg_io_width = 1;
        else {
drivers/video/rockchip/rk3399_hdmi.c +7 -1
index 3041360c6e..b32139a8a6 100644
@@ -64,8 +64,14 @@ static const struct dm_display_ops rk3399_hdmi_ops = {
        .enable = rk3399_hdmi_enable,
 };
 
+static const struct dw_hdmi_plat_data rk3399_hdmi_drv_data = {
+};
+
 static const struct udevice_id rk3399_hdmi_ids[] = {
-       { .compatible = "rockchip,rk3399-dw-hdmi" },
+       {
+               .compatible = "rockchip,rk3399-dw-hdmi",
+               .data = (ulong)&rk3399_hdmi_drv_data
+       },
        { }
 };
 
drivers/video/rockchip/rk_hdmi.c +1 -1
index b75a174489..e34f532cd6 100644
@@ -83,6 +83,7 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
        struct rk_hdmi_priv *priv = dev_get_priv(dev);
        struct dw_hdmi *hdmi = &priv->hdmi;
 
+       hdmi->data = (const struct dw_hdmi_plat_data *)dev_get_driver_data(dev);
        hdmi->ioaddr = (ulong)dev_read_addr(dev);
        hdmi->mpll_cfg = rockchip_mpll_cfg;
        hdmi->phy_cfg = rockchip_phy_config;
@@ -90,7 +91,6 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
        /* hdmi->i2c_clk_{high,low} are set up by the SoC driver */
 
        hdmi->reg_io_width = 4;
-       hdmi->phy_set = dw_hdmi_phy_cfg;
 
        priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
drivers/video/sunxi/sunxi_dw_hdmi.c +10 -1
index 0324a050d0..4b67a1614e 100644
@@ -369,6 +369,15 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
        return 0;
 }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_sunxi_phy_ops = {
+       .phy_set = sunxi_dw_hdmi_phy_cfg,
+};
+
+static const struct dw_hdmi_plat_data dw_hdmi_sunxi_plat_data = {
+       .phy_force_vendor = true,
+       .phy_ops = &dw_hdmi_sunxi_phy_ops,
+};
+
 static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
 {
        struct sunxi_dw_hdmi_priv *priv = dev_get_priv(dev);
@@ -379,7 +388,7 @@ static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
        hdmi->i2c_clk_high = 0xd8;
        hdmi->i2c_clk_low = 0xfe;
        hdmi->reg_io_width = 1;
-       hdmi->phy_set = sunxi_dw_hdmi_phy_cfg;
+       hdmi->data = &dw_hdmi_sunxi_plat_data;
 
        ret = reset_get_bulk(dev, &priv->resets);
        if (ret)
include/dw_hdmi.h +11 -0
index 8acae3839f..4ad8b39f84 100644
@@ -534,6 +534,17 @@ struct hdmi_data_info {
        struct hdmi_vmode video_mode;
 };
 
+struct dw_hdmi;
+
+struct dw_hdmi_phy_ops {
+       int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
+};
+
+struct dw_hdmi_plat_data {
+       bool phy_force_vendor;
+       const struct dw_hdmi_phy_ops *phy_ops;
+};
+
 struct dw_hdmi {
        ulong ioaddr;
        const struct hdmi_mpll_config *mpll_cfg;

include/dw_hdmi.h struct dw_hdmi { · line 557

Quoted 4 lines
include/dw_hdmi.h +1 -0
@@ -543,8 +554,9 @@ struct dw_hdmi {
        u8 reg_io_width;
        struct hdmi_data_info hdmi_data;
        struct udevice *ddc_bus;
+       const struct dw_hdmi_phy_ops *ops;

??

We should use phy.h I believe. Having said that, it sorely needs a proper conversion to driver model.

Quoted 9 lines
include/dw_hdmi.h +1 -2
+       const struct dw_hdmi_plat_data *data;
 
-       int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
        void (*write_reg)(struct dw_hdmi *hdmi, u8 val, int offset);
        u8 (*read_reg)(struct dw_hdmi *hdmi, int offset);
 };
--

2.25.1

Regards,
Simon

author
#6 lore raw

Re: [PATCH 02/17] video: dw_hdmi: Add Vendor PHY handling

Hi Simon,

Quoted 22 lines · Simon Glass

Hi Jagan,

Quoted 8 lines · Jagan Teki

From: Jagan Teki <[email protected]>

DW HDMI support Vendor PHY like Rockchip RK3328 Inno HDMI PHY.

Extend the vendor phy handling by adding platform phy hooks.

Quoted 9 lines
---
 drivers/video/dw_hdmi.c              | 29 +++++++++++++++++++++++++++-
 drivers/video/meson/meson_dw_hdmi.c  | 11 ++++++++++-
 drivers/video/rockchip/rk3399_hdmi.c |  8 +++++++-
 drivers/video/rockchip/rk_hdmi.c     |  2 +-
 drivers/video/sunxi/sunxi_dw_hdmi.c  | 11 ++++++++++-
 include/dw_hdmi.h                    | 14 +++++++++++++-
 6 files changed, 69 insertions(+), 6 deletions(-)
Quoted 1 line

Isn't there a PHY framework we should use in U-Boot?

Yes, the driver is using generic PHY.

Quoted 183 lines

Regards,
Sim on

Quoted 172 lines
drivers/video/dw_hdmi.c +28 -1
index c4fbb18294..ea12a09407 100644
@@ -988,7 +988,7 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid)
 
        hdmi_av_composer(hdmi, edid);
 
-       ret = hdmi->phy_set(hdmi, edid->pixelclock.typ);
+       ret = hdmi->ops->phy_set(hdmi, edid->pixelclock.typ);
        if (ret)
                return ret;
 
@@ -1009,10 +1009,37 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid)
        return 0;
 }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_synopsys_phy_ops = {
+       .phy_set = dw_hdmi_phy_cfg,
+};
+
+static void dw_hdmi_detect_phy(struct dw_hdmi *hdmi)
+{
+       if (!hdmi->data)
+               return;
+
+       /* hook Synopsys PHYs ops */
+       if (!hdmi->data->phy_force_vendor) {
+               hdmi->ops = &dw_hdmi_synopsys_phy_ops;
+               return;
+       }
+
+       /* Vendor HDMI PHYs must assign phy_ops in plat_data */
+       if (!hdmi->data->phy_ops) {
+               printf("Unsupported Vendor HDMI phy_ops\n");
+               return;
+       }
+
+       /* hook Vendor HDMI PHYs ops */
+       hdmi->ops = hdmi->data->phy_ops;
+}
+
 void dw_hdmi_init(struct dw_hdmi *hdmi)
 {
        uint ih_mute;
 
+       dw_hdmi_detect_phy(hdmi);
+
        /*
         * boot up defaults are:
         * hdmi_ih_mute   = 0x03 (disabled)
drivers/video/meson/meson_dw_hdmi.c +10 -1
index 5db01904b5..63ca3ac52e 100644
@@ -375,6 +375,15 @@ static int meson_dw_hdmi_wait_hpd(struct dw_hdmi *hdmi)
        return -ETIMEDOUT;
 }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_meson_phy_ops = {
+       .phy_set = meson_dw_hdmi_phy_cfg,
+};
+
+static const struct dw_hdmi_plat_data dw_hdmi_meson_plat_data = {
+       .phy_force_vendor = true,
+       .phy_ops = &dw_hdmi_meson_phy_ops,
+};
+
 static int meson_dw_hdmi_probe(struct udevice *dev)
 {
        struct meson_dw_hdmi *priv = dev_get_priv(dev);
@@ -397,7 +406,7 @@ static int meson_dw_hdmi_probe(struct udevice *dev)
 
        priv->hdmi.hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24;
        priv->hdmi.hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_YUV8_1X24;
-       priv->hdmi.phy_set = meson_dw_hdmi_phy_init;
+       priv->hdmi.data = &dw_hdmi_meson_plat_data;
        if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A))
                priv->hdmi.reg_io_width = 1;
        else {
drivers/video/rockchip/rk3399_hdmi.c +7 -1
index 3041360c6e..b32139a8a6 100644
@@ -64,8 +64,14 @@ static const struct dm_display_ops rk3399_hdmi_ops = {
        .enable = rk3399_hdmi_enable,
 };
 
+static const struct dw_hdmi_plat_data rk3399_hdmi_drv_data = {
+};
+
 static const struct udevice_id rk3399_hdmi_ids[] = {
-       { .compatible = "rockchip,rk3399-dw-hdmi" },
+       {
+               .compatible = "rockchip,rk3399-dw-hdmi",
+               .data = (ulong)&rk3399_hdmi_drv_data
+       },
        { }
 };
 
drivers/video/rockchip/rk_hdmi.c +1 -1
index b75a174489..e34f532cd6 100644
@@ -83,6 +83,7 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
        struct rk_hdmi_priv *priv = dev_get_priv(dev);
        struct dw_hdmi *hdmi = &priv->hdmi;
 
+       hdmi->data = (const struct dw_hdmi_plat_data *)dev_get_driver_data(dev);
        hdmi->ioaddr = (ulong)dev_read_addr(dev);
        hdmi->mpll_cfg = rockchip_mpll_cfg;
        hdmi->phy_cfg = rockchip_phy_config;
@@ -90,7 +91,6 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
        /* hdmi->i2c_clk_{high,low} are set up by the SoC driver */
 
        hdmi->reg_io_width = 4;
-       hdmi->phy_set = dw_hdmi_phy_cfg;
 
        priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
drivers/video/sunxi/sunxi_dw_hdmi.c +10 -1
index 0324a050d0..4b67a1614e 100644
@@ -369,6 +369,15 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
        return 0;
 }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_sunxi_phy_ops = {
+       .phy_set = sunxi_dw_hdmi_phy_cfg,
+};
+
+static const struct dw_hdmi_plat_data dw_hdmi_sunxi_plat_data = {
+       .phy_force_vendor = true,
+       .phy_ops = &dw_hdmi_sunxi_phy_ops,
+};
+
 static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
 {
        struct sunxi_dw_hdmi_priv *priv = dev_get_priv(dev);
@@ -379,7 +388,7 @@ static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
        hdmi->i2c_clk_high = 0xd8;
        hdmi->i2c_clk_low = 0xfe;
        hdmi->reg_io_width = 1;
-       hdmi->phy_set = sunxi_dw_hdmi_phy_cfg;
+       hdmi->data = &dw_hdmi_sunxi_plat_data;
 
        ret = reset_get_bulk(dev, &priv->resets);
        if (ret)
include/dw_hdmi.h +11 -0
index 8acae3839f..4ad8b39f84 100644
@@ -534,6 +534,17 @@ struct hdmi_data_info {
        struct hdmi_vmode video_mode;
 };
 
+struct dw_hdmi;
+
+struct dw_hdmi_phy_ops {
+       int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
+};
+
+struct dw_hdmi_plat_data {
+       bool phy_force_vendor;
+       const struct dw_hdmi_phy_ops *phy_ops;
+};
+
 struct dw_hdmi {
        ulong ioaddr;
        const struct hdmi_mpll_config *mpll_cfg;

include/dw_hdmi.h struct dw_hdmi { · line 557

Quoted 4 lines
include/dw_hdmi.h +1 -0
@@ -543,8 +554,9 @@ struct dw_hdmi {
        u8 reg_io_width;
        struct hdmi_data_info hdmi_data;
        struct udevice *ddc_bus;
+       const struct dw_hdmi_phy_ops *ops;

??

Quoted 2 lines

We should use phy.h I believe. Having said that, it sorely needs a proper conversion to driver model.

As I said, the driver uses generic phy with phy_ops. The above ops are dw hdmi platform phy ops that driver uses internally for rk3328. DW HDMI is also available for rk3228, so internal platform phy ops can vary. The generic phy ops in the driver will call platform phy ops via driver data.

Jagan.

author
#7 lore raw

PATCH 3/17 video: dw_hdmi: Extend the HPD detection

In reply to Jagan Teki

From: Jagan Teki <[email protected]>

HPD detection on some DW HDMIdesigned SoC's would need to read and setup the HPD status explicitly.

So, extend the HPD detection code by adding the dw_hdmi_detect_hpd function and move the default detection code caller there.

The new read and setup hdp will integrate the same function in later patches.

---
 drivers/video/dw_hdmi.c             | 13 +++++++++++++
 drivers/video/rockchip/rk_hdmi.c    |  8 +++-----
 drivers/video/sunxi/sunxi_dw_hdmi.c |  8 +++-----
 include/dw_hdmi.h                   |  1 +
 4 files changed, 20 insertions(+), 10 deletions(-)
drivers/video/dw_hdmi.c +13 -0
index ea12a09407..0a597206f0 100644
@@ -936,6 +936,19 @@ int dw_hdmi_phy_wait_for_hpd(struct dw_hdmi *hdmi)
 	return -1;
 }
 
+int dw_hdmi_detect_hpd(struct dw_hdmi *hdmi)
+{
+	int ret;
+
+	ret = dw_hdmi_phy_wait_for_hpd(hdmi);
+	if (ret < 0) {
+		debug("hdmi can not get hpd signal\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
 void dw_hdmi_phy_init(struct dw_hdmi *hdmi)
 {
 	/* enable phy i2cm done irq */
drivers/video/rockchip/rk_hdmi.c +3 -5
index e34f532cd6..8a65f2440e 100644
@@ -115,11 +115,9 @@ int rk_hdmi_probe(struct udevice *dev)
 	dw_hdmi_init(hdmi);
 	dw_hdmi_phy_init(hdmi);
 
-	ret = dw_hdmi_phy_wait_for_hpd(hdmi);
-	if (ret < 0) {
-		debug("hdmi can not get hpd signal\n");
-		return -1;
-	}
+	ret = dw_hdmi_detect_hpd(hdmi);
+	if (ret < 0)
+		return ret;
 
 	return 0;
 }
drivers/video/sunxi/sunxi_dw_hdmi.c +3 -5
index 4b67a1614e..513276d812 100644
@@ -358,11 +358,9 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
 
 	sunxi_dw_hdmi_phy_init(&priv->hdmi);
 
-	ret = dw_hdmi_phy_wait_for_hpd(&priv->hdmi);
-	if (ret < 0) {
-		debug("hdmi can not get hpd signal\n");
-		return -1;
-	}
+	ret = dw_hdmi_detect_hpd(&priv->hdmi);
+	if (ret < 0)
+		return ret;
 
 	dw_hdmi_init(&priv->hdmi);
 
include/dw_hdmi.h +1 -0
index 4ad8b39f84..756560e092 100644
@@ -568,5 +568,6 @@ void dw_hdmi_phy_init(struct dw_hdmi *hdmi);
 int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid);
 int dw_hdmi_read_edid(struct dw_hdmi *hdmi, u8 *buf, int buf_size);
 void dw_hdmi_init(struct dw_hdmi *hdmi);
+int dw_hdmi_detect_hpd(struct dw_hdmi *hdmi);
 
 #endif
Signature · 1 line
2.25.1
author
#8 lore raw

PATCH 4/17 video: dw_hdmi: Add read_hpd hook

In reply to Jagan Teki

From: Jagan Teki <[email protected]>

Add support for DW HDMI Read HPD status.

---
 drivers/video/dw_hdmi.c | 3 +++
 include/dw_hdmi.h       | 1 +
 2 files changed, 4 insertions(+)
drivers/video/dw_hdmi.c +3 -0
index 0a597206f0..172e6b45a6 100644
@@ -946,6 +946,9 @@ int dw_hdmi_detect_hpd(struct dw_hdmi *hdmi)
 		return -ENODEV;
 	}
 
+	if (hdmi->ops->read_hpd)
+		hdmi->ops->read_hpd(hdmi, true);
+
 	return 0;
 }
 
include/dw_hdmi.h +1 -0
index 756560e092..d6de472cee 100644
@@ -538,6 +538,7 @@ struct dw_hdmi;
 
 struct dw_hdmi_phy_ops {
 	int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
+	void (*read_hpd)(struct dw_hdmi *hdmi, bool hdp_status);
 };
 
 struct dw_hdmi_plat_data {
Signature · 1 line
2.25.1
author
#9 lore raw

PATCH 5/17 video: dw_hdmi: Add setup_hpd hook

In reply to Jagan Teki

From: Jagan Teki <[email protected]>

Add support for DW HDMI Setup HPD status.

---
 drivers/video/dw_hdmi.c | 3 +++
 include/dw_hdmi.h       | 1 +
 2 files changed, 4 insertions(+)
drivers/video/dw_hdmi.c +3 -0
index 172e6b45a6..3e0e20e59b 100644
@@ -1080,4 +1080,7 @@ void dw_hdmi_init(struct dw_hdmi *hdmi)
 
 	/* enable i2c client nack % arbitration error irq */
 	hdmi_write(hdmi, ~0x44, HDMI_I2CM_CTLINT);
+
+	if (hdmi->ops->setup_hpd)
+		hdmi->ops->setup_hpd(hdmi);
 }
include/dw_hdmi.h +1 -0
index d6de472cee..9a44b9e90c 100644
@@ -539,6 +539,7 @@ struct dw_hdmi;
 struct dw_hdmi_phy_ops {
 	int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
 	void (*read_hpd)(struct dw_hdmi *hdmi, bool hdp_status);
+	void (*setup_hpd)(struct dw_hdmi *hdmi);
 };
 
 struct dw_hdmi_plat_data {
Signature · 1 line
2.25.1
author
#10 lore raw

PATCH 6/17 video: rockchip: vop: Simplify rkvop_enable

In reply to Jagan Teki

From: Jagan Teki <[email protected]>

Get the regs from priv pointer instead of passing it an argument.

This would simplify the code and better readability.

---
 drivers/video/rockchip/rk_vop.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/video/rockchip/rk_vop.c +4 -4
index c514e2a0e4..158ba7cbf6 100644
@@ -39,11 +39,13 @@ enum vop_pol {
 	DCLK_INVERT    = 3
 };
 
-static void rkvop_enable(struct udevice *dev, struct rk3288_vop *regs, ulong fbbase,
+static void rkvop_enable(struct udevice *dev, ulong fbbase,
 			 int fb_bits_per_pixel,
 			 const struct display_timing *edid,
 			 struct reset_ctl *dclk_rst)
 {
+	struct rk_vop_priv *priv = dev_get_priv(dev);
+	struct rk3288_vop *regs = priv->regs;
 	u32 lb_mode;
 	u32 rgb_mode;
 	u32 hactive = edid->hactive.typ;
@@ -243,9 +245,7 @@ static void rkvop_mode_set(struct udevice *dev,
 static int rk_display_init(struct udevice *dev, ulong fbbase, ofnode ep_node)
 {
 	struct video_priv *uc_priv = dev_get_uclass_priv(dev);
-	struct rk_vop_priv *priv = dev_get_priv(dev);
 	int vop_id, remote_vop_id;
-	struct rk3288_vop *regs = priv->regs;
 	struct display_timing timing;
 	struct udevice *disp;
 	int ret;
@@ -380,7 +380,7 @@ static int rk_display_init(struct udevice *dev, ulong fbbase, ofnode ep_node)
 		return ret;
 	}
 
-	rkvop_enable(dev, regs, fbbase, 1 << l2bpp, &timing, &dclk_rst);
+	rkvop_enable(dev, fbbase, 1 << l2bpp, &timing, &dclk_rst);
 
 	ret = display_enable(disp, 1 << l2bpp, &timing);
 	if (ret)
Signature · 1 line
2.25.1
author
#11 lore raw

PATCH 7/17 video: rockchip: vop: Add win offset support

In reply to Jagan Teki

From: Jagan Teki <[email protected]>

Unlike RK3399, RK3288 the Newer Rockchip SoC's like RK3328 have different offsets for win registers.

Group the win register set via win_regs pointers so that win_offset would point the win_regs to access for any changes in the offset value.

---
 drivers/video/rockchip/rk_vop.c | 22 +++++++++++++---------
 drivers/video/rockchip/rk_vop.h |  2 ++
 2 files changed, 15 insertions(+), 9 deletions(-)
drivers/video/rockchip/rk_vop.c +13 -9
index 158ba7cbf6..b719a4e4ea 100644
@@ -46,6 +46,7 @@ static void rkvop_enable(struct udevice *dev, ulong fbbase,
 {
 	struct rk_vop_priv *priv = dev_get_priv(dev);
 	struct rk3288_vop *regs = priv->regs;
+	struct rk3288_vop *win_regs = priv->regs + priv->win_offset;
 	u32 lb_mode;
 	u32 rgb_mode;
 	u32 hactive = edid->hactive.typ;
@@ -53,32 +54,32 @@ static void rkvop_enable(struct udevice *dev, ulong fbbase,
 	int ret;
 
 	writel(V_ACT_WIDTH(hactive - 1) | V_ACT_HEIGHT(vactive - 1),
-	       &regs->win0_act_info);
+	       &win_regs->win0_act_info);
 
 	writel(V_DSP_XST(edid->hsync_len.typ + edid->hback_porch.typ) |
 	       V_DSP_YST(edid->vsync_len.typ + edid->vback_porch.typ),
-	       &regs->win0_dsp_st);
+	       &win_regs->win0_dsp_st);
 
 	writel(V_DSP_WIDTH(hactive - 1) |
 		V_DSP_HEIGHT(vactive - 1),
-		&regs->win0_dsp_info);
+		&win_regs->win0_dsp_info);
 
-	clrsetbits_le32(&regs->win0_color_key, M_WIN0_KEY_EN | M_WIN0_KEY_COLOR,
+	clrsetbits_le32(&win_regs->win0_color_key, M_WIN0_KEY_EN | M_WIN0_KEY_COLOR,
 			V_WIN0_KEY_EN(0) | V_WIN0_KEY_COLOR(0));
 
 	switch (fb_bits_per_pixel) {
 	case 16:
 		rgb_mode = RGB565;
-		writel(V_RGB565_VIRWIDTH(hactive), &regs->win0_vir);
+		writel(V_RGB565_VIRWIDTH(hactive), &win_regs->win0_vir);
 		break;
 	case 24:
 		rgb_mode = RGB888;
-		writel(V_RGB888_VIRWIDTH(hactive), &regs->win0_vir);
+		writel(V_RGB888_VIRWIDTH(hactive), &win_regs->win0_vir);
 		break;
 	case 32:
 	default:
 		rgb_mode = ARGB8888;
-		writel(V_ARGB888_VIRWIDTH(hactive), &regs->win0_vir);
+		writel(V_ARGB888_VIRWIDTH(hactive), &win_regs->win0_vir);
 		break;
 	}
 
@@ -91,12 +92,12 @@ static void rkvop_enable(struct udevice *dev, ulong fbbase,
 	else
 		lb_mode = LB_RGB_1280X8;
 
-	clrsetbits_le32(&regs->win0_ctrl0,
+	clrsetbits_le32(&win_regs->win0_ctrl0,
 			M_WIN0_LB_MODE | M_WIN0_DATA_FMT | M_WIN0_EN,
 			V_WIN0_LB_MODE(lb_mode) | V_WIN0_DATA_FMT(rgb_mode) |
 			V_WIN0_EN(1));
 
-	writel(fbbase, &regs->win0_yrgb_mst);
+	writel(fbbase, &win_regs->win0_yrgb_mst);
 	writel(0x01, &regs->reg_cfg_done); /* enable reg config */
 
 	ret = reset_assert(dclk_rst);
@@ -415,6 +416,8 @@ int rk_vop_probe(struct udevice *dev)
 {
 	struct video_uc_plat *plat = dev_get_uclass_plat(dev);
 	struct rk_vop_priv *priv = dev_get_priv(dev);
+	struct rkvop_driverdata *ops =
+		(struct rkvop_driverdata *)dev_get_driver_data(dev);
 	int ret = 0;
 	ofnode port, node;
 	struct reset_ctl ahb_rst;
@@ -448,6 +451,7 @@ int rk_vop_probe(struct udevice *dev)
 #endif
 
 	priv->regs = dev_read_addr_ptr(dev);
+	priv->win_offset = ops->win_offset;
 
 	/*
 	 * Try all the ports until we find one that works. In practice this
drivers/video/rockchip/rk_vop.h +2 -0
index 0528fb23f5..909f5602e5 100644
@@ -11,6 +11,7 @@
 struct rk_vop_priv {
 	void *grf;
 	void *regs;
+	int win_offset;
 };
 
 enum vop_features {
@@ -18,6 +19,7 @@ enum vop_features {
 };
 
 struct rkvop_driverdata {
+	int win_offset;
 	/* configuration */
 	u32 features;
 	/* block-specific setters/getters */
Signature · 1 line
2.25.1
author
#12 lore raw

PATCH 8/17 video: rockchip: vop: Add dsp offset support

In reply to Jagan Teki

From: Jagan Teki <[email protected]>

Unlike RK3399, RK3288 the Newer Rockchip SoC's like RK3328 have different offsets for dsp registers.

Group the dsp register set via dsp_regs pointers so that dsp_offset would point the dsp_regs to access for any changes in the offset value.

---
 drivers/video/rockchip/rk_vop.c | 14 ++++++++------
 drivers/video/rockchip/rk_vop.h |  2 ++
 2 files changed, 10 insertions(+), 6 deletions(-)
drivers/video/rockchip/rk_vop.c +8 -6
index b719a4e4ea..acc02e5d7c 100644
@@ -165,6 +165,7 @@ static void rkvop_mode_set(struct udevice *dev,
 {
 	struct rk_vop_priv *priv = dev_get_priv(dev);
 	struct rk3288_vop *regs = priv->regs;
+	struct rk3288_vop *dsp_regs = priv->regs + priv->dsp_offset;
 	struct rkvop_driverdata *data =
 		(struct rkvop_driverdata *)dev_get_driver_data(dev);
 
@@ -198,27 +199,27 @@ static void rkvop_mode_set(struct udevice *dev,
 
 	writel(V_HSYNC(hsync_len) |
 	       V_HORPRD(hsync_len + hback_porch + hactive + hfront_porch),
-			&regs->dsp_htotal_hs_end);
+			&dsp_regs->dsp_htotal_hs_end);
 
 	writel(V_HEAP(hsync_len + hback_porch + hactive) |
 	       V_HASP(hsync_len + hback_porch),
-	       &regs->dsp_hact_st_end);
+	       &dsp_regs->dsp_hact_st_end);
 
 	writel(V_VSYNC(vsync_len) |
 	       V_VERPRD(vsync_len + vback_porch + vactive + vfront_porch),
-	       &regs->dsp_vtotal_vs_end);
+	       &dsp_regs->dsp_vtotal_vs_end);
 
 	writel(V_VAEP(vsync_len + vback_porch + vactive)|
 	       V_VASP(vsync_len + vback_porch),
-	       &regs->dsp_vact_st_end);
+	       &dsp_regs->dsp_vact_st_end);
 
 	writel(V_HEAP(hsync_len + hback_porch + hactive) |
 	       V_HASP(hsync_len + hback_porch),
-	       &regs->post_dsp_hact_info);
+	       &dsp_regs->post_dsp_hact_info);
 
 	writel(V_VAEP(vsync_len + vback_porch + vactive)|
 	       V_VASP(vsync_len + vback_porch),
-	       &regs->post_dsp_vact_info);
+	       &dsp_regs->post_dsp_vact_info);
 
 	writel(0x01, &regs->reg_cfg_done); /* enable reg config */
 }
@@ -452,6 +453,7 @@ int rk_vop_probe(struct udevice *dev)
 
 	priv->regs = dev_read_addr_ptr(dev);
 	priv->win_offset = ops->win_offset;
+	priv->dsp_offset = ops->dsp_offset;
 
 	/*
 	 * Try all the ports until we find one that works. In practice this
drivers/video/rockchip/rk_vop.h +2 -0
index 909f5602e5..eba68d87c4 100644
@@ -12,6 +12,7 @@ struct rk_vop_priv {
 	void *grf;
 	void *regs;
 	int win_offset;
+	int dsp_offset;
 };
 
 enum vop_features {
@@ -20,6 +21,7 @@ enum vop_features {
 
 struct rkvop_driverdata {
 	int win_offset;
+	int dsp_offset;
 	/* configuration */
 	u32 features;
 	/* block-specific setters/getters */
Signature · 1 line
2.25.1
author
#13 lore raw

PATCH 9/17 clk: rockchip: rk3328: Add VOP clk support

In reply to Jagan Teki

From: Jagan Teki <[email protected]>

VOP get and set clock would needed for VOP drivers.

Add support for it.

---
 .../include/asm/arch-rockchip/cru_rk3328.h    | 34 ++++++++
 drivers/clk/rockchip/clk_rk3328.c             | 83 ++++++++++++++++++-
 2 files changed, 115 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-rockchip/cru_rk3328.h +34 -0
index 226744d67d..4ad1d33e05 100644
@@ -62,6 +62,40 @@ check_member(rk3328_cru, sdmmc_ext_con[1], 0x39c);
 enum apll_frequencies {
 	APLL_816_MHZ,
 	APLL_600_MHZ,
+
+	/* CRU_CLK_SEL37_CON */
+	ACLK_VIO_PLL_SEL_CPLL		= 0,
+	ACLK_VIO_PLL_SEL_GPLL		= 1,
+	ACLK_VIO_PLL_SEL_HDMIPHY	= 2,
+	ACLK_VIO_PLL_SEL_USB480M	= 3,
+	ACLK_VIO_PLL_SEL_SHIFT		= 6,
+	ACLK_VIO_PLL_SEL_MASK		= 3 << ACLK_VIO_PLL_SEL_SHIFT,
+	ACLK_VIO_DIV_CON_SHIFT		= 0,
+	ACLK_VIO_DIV_CON_MASK		= 0x1f << ACLK_VIO_DIV_CON_SHIFT,
+	HCLK_VIO_DIV_CON_SHIFT		= 8,
+	HCLK_VIO_DIV_CON_MASK		= 0x1f << HCLK_VIO_DIV_CON_SHIFT,
+
+	/* CRU_CLK_SEL39_CON */
+	ACLK_VOP_PLL_SEL_CPLL		= 0,
+	ACLK_VOP_PLL_SEL_GPLL		= 1,
+	ACLK_VOP_PLL_SEL_HDMIPHY	= 2,
+	ACLK_VOP_PLL_SEL_USB480M	= 3,
+	ACLK_VOP_PLL_SEL_SHIFT		= 6,
+	ACLK_VOP_PLL_SEL_MASK		= 3 << ACLK_VOP_PLL_SEL_SHIFT,
+	ACLK_VOP_DIV_CON_SHIFT		= 0,
+	ACLK_VOP_DIV_CON_MASK		= 0x1f << ACLK_VOP_DIV_CON_SHIFT,
+
+	/* CRU_CLK_SEL40_CON */
+	DCLK_LCDC_PLL_SEL_GPLL		= 0,
+	DCLK_LCDC_PLL_SEL_CPLL		= 1,
+	DCLK_LCDC_PLL_SEL_SHIFT		= 0,
+	DCLK_LCDC_PLL_SEL_MASK		= 1 << DCLK_LCDC_PLL_SEL_SHIFT,
+	DCLK_LCDC_SEL_HDMIPHY		= 0,
+	DCLK_LCDC_SEL_PLL		= 1,
+	DCLK_LCDC_SEL_SHIFT		= 1,
+	DCLK_LCDC_SEL_MASK		= 1 << DCLK_LCDC_SEL_SHIFT,
+	DCLK_LCDC_DIV_CON_SHIFT		= 8,
+	DCLK_LCDC_DIV_CON_MASK		= 0xFf << DCLK_LCDC_DIV_CON_SHIFT,
 };
 
 void rk3328_configure_cpu(struct rk3328_cru *cru,
drivers/clk/rockchip/clk_rk3328.c +81 -2

105 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#14 lore raw

PATCH 10/17 clk: rk3328: Add get hdmiphy clock

In reply to Jagan Teki

From: Jagan Teki <[email protected]>

Add support to get the hdmiphy clock for RK3328 PCLK_HDMIPHY.

---
 drivers/clk/rockchip/clk_rk3328.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/clk/rockchip/clk_rk3328.c +17 -0
index 7fcf84f08e..5a4a555d36 100644
@@ -179,6 +179,10 @@ enum {
 	CLK_I2C3_DIV_CON_SHIFT		= 8,
 	CLK_I2C2_PLL_SEL_SHIFT		= 7,
 	CLK_I2C2_DIV_CON_SHIFT		= 0,
+
+	/* CLKSEL_CON40 */
+	CLK_HDMIPHY_DIV_CON_SHIFT	= 3,
+	CLK_HDMIPHY_DIV_CON_MASK	= 0x7 << CLK_HDMIPHY_DIV_CON_SHIFT,
 };
 
 #define VCO_MAX_KHZ	(3200 * (MHz / KHz))
@@ -656,6 +660,16 @@ static ulong rk3328_vop_set_clk(struct rk3328_clk_priv *priv,
 }
 #endif
 
+static ulong rk3328_hdmiphy_get_clk(struct rk3328_cru *cru)
+{
+	u32 div, con;
+
+	con = readl(&cru->clksel_con[40]);
+	div = (con & CLK_HDMIPHY_DIV_CON_MASK) >> CLK_HDMIPHY_DIV_CON_SHIFT;
+
+	return DIV_TO_RATE(GPLL_HZ, div);
+}
+
 static ulong rk3328_clk_get_rate(struct clk *clk)
 {
 	struct rk3328_clk_priv *priv = dev_get_priv(clk->dev);
@@ -685,6 +699,9 @@ static ulong rk3328_clk_get_rate(struct clk *clk)
 	case SCLK_SPI:
 		rate = rk3328_spi_get_clk(priv->cru);
 		break;
+	case PCLK_HDMIPHY:
+		rate = rk3328_hdmiphy_get_clk(priv->cru);
+		break;
 	default:
 		return -ENOENT;
 	}
Signature · 1 line
2.25.1
author
#15 lore raw

PATCH 11/17 phy: rockchip: Add Rockchip INNO HDMI PHY driver

In reply to Jagan Teki

From: Jagan Teki <[email protected]>

Add Rockchip INNO HDMI PHY driver for RK3328.

Reference from linux-next phy-rockchip-inno-hdmi driver.

---
 drivers/phy/rockchip/Kconfig                  |   7 +
 drivers/phy/rockchip/Makefile                 |   1 +
 drivers/phy/rockchip/phy-rockchip-inno-hdmi.c | 885 ++++++++++++++++++
 3 files changed, 893 insertions(+)
 create mode 100644 drivers/phy/rockchip/phy-rockchip-inno-hdmi.c
drivers/phy/rockchip/Kconfig +7 -0
index 0247d93ab4..80128335d5 100644
@@ -12,6 +12,13 @@ config PHY_ROCKCHIP_INNO_DSIDPHY
 	help
 	  Support for Rockchip MIPI DPHY with Innosilicon IP block.
 
+config PHY_ROCKCHIP_INNO_HDMI
+	bool "Rockchip INNO HDMI PHY Driver"
+	depends on ARCH_ROCKCHIP
+	select PHY
+	help
+	  Enable this to support the Rockchip Innosilicon HDMI PHY.
+
 config PHY_ROCKCHIP_INNO_USB2
 	bool "Rockchip INNO USB2PHY Driver"
 	depends on ARCH_ROCKCHIP
drivers/phy/rockchip/Makefile +1 -0
index 7fdbd10797..0420017425 100644
@@ -3,6 +3,7 @@
 # Copyright (C) 2020 Amarula Solutions(India)
 #
 
+obj-$(CONFIG_PHY_ROCKCHIP_INNO_HDMI)	+= phy-rockchip-inno-hdmi.o
 obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2)	+= phy-rockchip-inno-usb2.o
 obj-$(CONFIG_PHY_ROCKCHIP_NANENG_COMBOPHY) += phy-rockchip-naneng-combphy.o
 obj-$(CONFIG_PHY_ROCKCHIP_PCIE)		+= phy-rockchip-pcie.o
drivers/phy/rockchip/phy-rockchip-inno-hdmi.c new file +885 -0

885 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#16 lore raw

PATCH 12/17 video: rockchip: Add rk3328 hdmi support

In reply to Jagan Teki

From: Jagan Teki <[email protected]>

Add Rockchip RK3328 HDMI Out driver.

---
 drivers/video/rockchip/Makefile      |   1 +
 drivers/video/rockchip/rk3328_hdmi.c | 131 +++++++++++++++++++++++++++
 drivers/video/rockchip/rk_hdmi.h     |   3 +
 3 files changed, 135 insertions(+)
 create mode 100644 drivers/video/rockchip/rk3328_hdmi.c
drivers/video/rockchip/Makefile +1 -0
index 8128289cc8..4991303c73 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_ROCKCHIP_RK3399) += rk3399_vop.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_EDP) += rk_edp.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_LVDS) += rk_lvds.o
 obj-hdmi-$(CONFIG_ROCKCHIP_RK3288) += rk3288_hdmi.o
+obj-hdmi-$(CONFIG_ROCKCHIP_RK3328) += rk3328_hdmi.o
 obj-hdmi-$(CONFIG_ROCKCHIP_RK3399) += rk3399_hdmi.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_HDMI) += rk_hdmi.o $(obj-hdmi-y)
 obj-mipi-$(CONFIG_ROCKCHIP_RK3288) += rk3288_mipi.o
drivers/video/rockchip/rk3328_hdmi.c new file +131 -0

131 lines not on this page · raw message

drivers/video/rockchip/rk_hdmi.h +3 -0
index 200dbaea74..dcfba3d3d7 100644
@@ -6,6 +6,8 @@
 #ifndef __RK_HDMI_H__
 #define __RK_HDMI_H__
 
+#include <generic-phy.h>
+
 struct rkhdmi_driverdata {
 	/* configuration */
 	u8 i2c_clk_high;
@@ -19,6 +21,7 @@ struct rkhdmi_driverdata {
 
 struct rk_hdmi_priv {
 	struct dw_hdmi hdmi;
+	struct phy phy;
 	void *grf;
 };
 
Signature · 1 line
2.25.1
author
#17 lore raw

PATCH 13/17 video: rockchip: Add rk3328 vop support

In reply to Jagan Teki

From: Jagan Teki <[email protected]>

Add support for Rockchip RK3328 VOP.

---
 drivers/video/rockchip/Makefile     |  1 +
 drivers/video/rockchip/rk3328_vop.c | 66 +++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)
 create mode 100644 drivers/video/rockchip/rk3328_vop.c
drivers/video/rockchip/Makefile +1 -0
index 4991303c73..f55beceebf 100644
@@ -6,6 +6,7 @@
 ifdef CONFIG_VIDEO_ROCKCHIP
 obj-y += rk_vop.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288_vop.o
+obj-$(CONFIG_ROCKCHIP_RK3328) += rk3328_vop.o
 obj-$(CONFIG_ROCKCHIP_RK3399) += rk3399_vop.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_EDP) += rk_edp.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_LVDS) += rk_lvds.o
drivers/video/rockchip/rk3328_vop.c new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
2.25.1
#18 lore raw

Re: [PATCH 13/17] video: rockchip: Add rk3328 vop support

Hi Jagan,

In  your patch U-boot users must add a new file for each new Rockchip SoC.

With the VOP2 introduction the VOP1 structures and functions are frozen/stabilized.

My proposal would be to use a file simular to Linux rockchip_vop_reg.c and port it to U-boot as is done in the manufacturer tree.

Together with a simple basic rockchip_vop.c to start with.

Not sure if we need a kind of DRM frame work.

Question: What do the U-boot maintainers think of this DRM implementation in use by Rockchip. Is that a route that useful for mainline?

Let me know your ideas.

Johan

Quoted 95 lines · Jagan Teki

From: Jagan Teki <[email protected]>

Add support for Rockchip RK3328 VOP.

---
 drivers/video/rockchip/Makefile     |  1 +
 drivers/video/rockchip/rk3328_vop.c | 66 +++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)
 create mode 100644 drivers/video/rockchip/rk3328_vop.c
drivers/video/rockchip/Makefile +1 -0
index 4991303c73..f55beceebf 100644
@@ -6,6 +6,7 @@
 ifdef CONFIG_VIDEO_ROCKCHIP
 obj-y += rk_vop.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288_vop.o
+obj-$(CONFIG_ROCKCHIP_RK3328) += rk3328_vop.o
 obj-$(CONFIG_ROCKCHIP_RK3399) += rk3399_vop.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_EDP) += rk_edp.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_LVDS) += rk_lvds.o
drivers/video/rockchip/rk3328_vop.c new file +66 -0
new file mode 100644
index 0000000000..2512314e64
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023 Edgeble AI Technologies Pvt. Ltd.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <video.h>
+#include <asm/io.h>
+#include "rk_vop.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static void rk3328_set_pin_polarity(struct udevice *dev,
+				    enum vop_modes mode, u32 polarity)
+{
+	struct rk_vop_priv *priv = dev_get_priv(dev);
+	struct rk3288_vop *regs = priv->regs;
+
+	switch (mode) {
+	case VOP_MODE_HDMI:
+		clrsetbits_le32(&regs->dsp_ctrl1,
+				M_RK3399_DSP_HDMI_POL,
+				V_RK3399_DSP_HDMI_POL(polarity));
+		break;
+	default:
+		debug("%s: unsupported output mode %x\n", __func__, mode);
+	}
+}
+
+static int rk3328_vop_probe(struct udevice *dev)
+{
+	/* Before relocation we don't need to do anything */
+	if (!(gd->flags & GD_FLG_RELOC))
+		return 0;
+
+	return rk_vop_probe(dev);
+}
+
+struct rkvop_driverdata rk3328_driverdata = {
+	.dsp_offset = 0x490,
+	.win_offset = 0xd0,
+	.features = VOP_FEATURE_OUTPUT_10BIT,
+	.set_pin_polarity = rk3328_set_pin_polarity,
+};
+
+static const struct udevice_id rk3328_vop_ids[] = {
+	{
+		.compatible = "rockchip,rk3328-vop",
+		.data = (ulong)&rk3328_driverdata
+	},
+	{ /* sentile */ }
+};
+
+static const struct video_ops rk3328_vop_ops = {
+};
+
+U_BOOT_DRIVER(rk3328_vop) = {
+	.name	= "rk3328_vop",
+	.id	= UCLASS_VIDEO,
+	.of_match = rk3328_vop_ids,
+	.ops	= &rk3328_vop_ops,
+	.bind	= rk_vop_bind,
+	.probe	= rk3328_vop_probe,
+	.priv_auto	= sizeof(struct rk_vop_priv),
+};
author
#19 lore raw

Re: [PATCH 13/17] video: rockchip: Add rk3328 vop support

Please don't top-post.

Quoted 9 lines · Johan Jonker

Hi Jagan,

In your patch U-boot users must add a new file for each new Rockchip SoC.

With the VOP2 introduction the VOP1 structures and functions are frozen/stabilized.

My proposal would be to use a file simular to Linux rockchip_vop_reg.c and port it to U-boot as is done in the manufacturer tree.

Quoted 7 lines

Together with a simple basic rockchip_vop.c to start with.

Not sure if we need a kind of DRM frame work.

Question: What do the U-boot maintainers think of this DRM implementation in use by Rockchip. Is that a route that useful for mainline?

Let me know your ideas.

Yes, I got your point-based rockchip-bsp tree of DRM. Technically it wouldn't required as we have created this structure before and more likely the new RK SoCs like RK3568, RK3588 are working on this tree as well. Why do we need DRM framework as long as this seems suitable?

Jagan.

author
#20 lore raw

PATCH 14/17 ARM: dts: rk3328: Enable VOP for bootph-all

In reply to Jagan Teki

Model: Firefly roc-rk3328-cc
DRAM: 1 GiB (effective 1022 MiB)
Video device 'vop@ff370000' cannot allocate frame buffer memory -ensure the device is set up before relocation Error binding driver 'rockchip_rk3328_vop': -28
Some drivers failed to bind
initcall sequence 000000003ffcd5e8 failed at call 000000000021a5c4 (err=-28)
### ERROR ### Please RESET the board ###

---
 arch/arm/dts/rk3328-u-boot.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/dts/rk3328-u-boot.dtsi +4 -0
index a9f2536de2..5258fec566 100644
@@ -68,3 +68,7 @@
 &spi0 {
 	bootph-all;
 };
+
+&vop {
+	bootph-all;
+};
Signature · 1 line
2.25.1
author
#21 lore raw

PATCH 15/17 rockchip: Enable preconsole for rk3328

In reply to Jagan Teki

Enable and set the start address of pre-console buffer for RK3328.

---
 arch/arm/mach-rockchip/Kconfig | 1 +
 common/Kconfig                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-rockchip/Kconfig +1 -0
index b577a911e7..60f403fe74 100644
@@ -179,6 +179,7 @@ config ROCKCHIP_RK3328
 	select SUPPORT_TPL
 	select TPL
 	select TPL_NEEDS_SEPARATE_STACK if TPL
+	imply PRE_CONSOLE_BUFFER
 	imply ROCKCHIP_COMMON_BOARD
 	imply ROCKCHIP_SDRAM_COMMON
 	imply SPL_ROCKCHIP_COMMON_BOARD
common/Kconfig +1 -1
index 0f54819519..093ebfbd1e 100644
@@ -208,7 +208,7 @@ config PRE_CON_BUF_ADDR
 	default 0x2f000000 if ARCH_SUNXI && MACH_SUN9I
 	default 0x4f000000 if ARCH_SUNXI && !MACH_SUN9I
 	default 0x0f000000 if ROCKCHIP_RK3288
-	default 0x0f200000 if ROCKCHIP_RK3399
+	default 0x0f200000 if ROCKCHIP_RK3399 || ROCKCHIP_RK3328
 	help
 	  This sets the start address of the pre-console buffer. This must
 	  be in available memory and is accessed before relocation and
Signature · 1 line
2.25.1
author
#22 lore raw

PATCH 16/17 configs: evb-rk3328: Enable vidconsole for rk3328

In reply to Jagan Teki

Enable video console for Rockchip RK3328.

---
 include/configs/evb_rk3328.h    | 5 +++++
 include/configs/rk3328_common.h | 1 +
 2 files changed, 6 insertions(+)
include/configs/evb_rk3328.h +5 -0
index d10e5b1d2e..c985080f7b 100644
@@ -6,6 +6,11 @@
 #ifndef __EVB_RK3328_H
 #define __EVB_RK3328_H
 
+#define ROCKCHIP_DEVICE_SETTINGS \
+		"stdin=serial,usbkbd\0" \
+		"stdout=serial,vidconsole\0" \
+		"stderr=serial,vidconsole\0"
+
 #include <configs/rk3328_common.h>
 
 #endif
include/configs/rk3328_common.h +1 -0
index e920ec7e5d..2c40674b22 100644
@@ -26,6 +26,7 @@
 	ENV_MEM_LAYOUT_SETTINGS \
 	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
 	"partitions=" PARTS_DEFAULT \
+	ROCKCHIP_DEVICE_SETTINGS \
 	"boot_targets=" BOOT_TARGETS "\0"
 
 #endif
Signature · 1 line
2.25.1
author
#23 lore raw

PATCH 17/17 configs: Enable HDMI Out for ROC-RK3328-CC

In reply to Jagan Teki

U-Boot 2024.01-rc4-00053-gb9f7cafdd9-dirty (Dec 11 2023 - 13:18:15 +0530)

Model: Firefly roc-rk3328-cc
DRAM:  1 GiB (effective 1022 MiB)
PMIC:  RK8050 (on=0x40, off=0x00)
Core:  236 devices, 26 uclasses, devicetree: separate
MMC:   mmc@ff500000: 1, mmc@ff520000: 0

Loading Environment from MMC... *** Warning - bad CRC, using default environment

tmdsclock = 148500000; chipversion = 1

In:    serial
Out:   vidconsole
Err:   vidconsole
Model: Firefly roc-rk3328-cc
Net:   eth0: ethernet@ff540000
Hit any key to stop autoboot:  0
=> dm tree
 Class     Index  Probed  Driver                Name
-----------------------------------------------------------
 root          0  [ + ]   root_driver           root_driver
 firmware      0  [   ]   psci                  |-- psci
 clk           0  [ + ]   fixed_clock           |-- xin24m
 syscon        0  [ + ]   rockchip_rk3328_grf   |-- syscon@ff100000
 serial        0  [ + ]   ns16550_serial        |-- serial@ff130000
 i2c           0  [ + ]   rockchip_rk3066_i2c   |-- i2c@ff160000
 pmic          0  [ + ]   rockchip_rk805        |   `-- pmic@18
 sysreset      0  [   ]   rk8xx_sysreset        |       |-- rk8xx_sysreset
 regulator     0  [ + ]   rk8xx_buck            |       |-- DCDC_REG1
 regulator     1  [ + ]   rk8xx_buck            |       |-- DCDC_REG2
 regulator     2  [ + ]   rk8xx_buck            |       |-- DCDC_REG3
 regulator     3  [ + ]   rk8xx_buck            |       |-- DCDC_REG4
 regulator     4  [ + ]   rk8xx_ldo             |       |-- LDO_REG1
 regulator     5  [ + ]   rk8xx_ldo             |       |-- LDO_REG2
 regulator     6  [ + ]   rk8xx_ldo             |       `-- LDO_REG3
 video         0  [ + ]   rk3328_vop            |-- vop@ff370000
 vidconsole    0  [ + ]   vidconsole0           |   `-- [email protected]
 display       0  [ + ]   rk3328_hdmi_rockchip  |-- hdmi@ff3c0000
 phy           0  [ + ]   inno_hdmi_phy         |-- phy@ff430000
 clk           1  [ + ]   rockchip_rk3328_cru   |-- clock-controller@ff440000
 sysreset      1  [   ]   rockchip_sysreset     |   |-- sysreset
 reset         0  [ + ]   rockchip_reset        |   `-- reset
---
 configs/roc-cc-rk3328_defconfig | 5 +++++
 1 file changed, 5 insertions(+)
configs/roc-cc-rk3328_defconfig +5 -0
index 4ac3c9403b..4eef9016dc 100644
@@ -79,6 +79,7 @@ CONFIG_PHY_REALTEK=y
 CONFIG_PHY_GIGE=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_GMAC_ROCKCHIP=y
+CONFIG_PHY_ROCKCHIP_INNO_HDMI=y
 CONFIG_PHY_ROCKCHIP_INNO_USB2=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
@@ -114,6 +115,10 @@ CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_VIDEO=y
+CONFIG_DISPLAY=y
+CONFIG_VIDEO_ROCKCHIP=y
+CONFIG_DISPLAY_ROCKCHIP_HDMI=y
 CONFIG_SPL_TINY_MEMSET=y
 CONFIG_TPL_TINY_MEMSET=y
 CONFIG_ERRNO_STR=y
Signature · 1 line
2.25.1
author
#24 lore raw
In reply to Jagan Teki

Hi Heiko/Kerver/Anatoloj,

Quoted 34 lines · Jagan Teki

Unlike RK3399, Sunxi/Meson DW HDMI the new Rockchip SoC Rk3328 would support external vendor PHY with DW HDMI chip.

Support this vendor PHY by adding new platform PHY ops via DW HDMI driver and call the respective generic phy from platform driver code.

This series tested in RK3328 with 1080p (1920x1080) resolution.

Patch 0001/0005: Support Vendor PHY
Patch 0006/0008: VOP extension for win, dsp offsets
Patch 0009/0010: RK3328 VOP, HDMI clocks
Patch 0011:      Rockchip Inno HDMI PHY
Patch 0012:      RK3328 HDMI driver
Patch 0013:      RK3328 VOP driver
Patch 0014/0017: Enable HDMI Out for RK3328

Importent:
One pontential issues is that Linux HDMI out on RK3328 has effected by this patchset as I wouldn't find any relation or clue.

[    0.752016] Loading compiled-in X.509 certificates
[    0.787796] inno_hdmi_phy_rk3328_clk_recalc_rate: parent 24000000
[    0.788391] inno-hdmi-phy ff430000.phy: inno_hdmi_phy_rk3328_clk_recalc_rate rate 148500000 vco 148500000
[    0.798353] rockchip-drm display-subsystem: bound ff370000.vop (ops vop_component_ops)
[    0.799403] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-0v9 not found, using dummy regulator
[    0.800288] rk_iommu ff373f00.iommu: Enable stall request timed out, status: 0x00004b
[    0.801131] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-1v8 not found, using dummy regulator
[    0.802056] rk_iommu ff373f00.iommu: Disable paging request timed out, status: 0x00004b
[    0.803233] dwhdmi-rockchip ff3c0000.hdmi: Detected HDMI TX controller v2.11a with HDCP (inno_dw_hdmi_phy2)
[    0.805355] dwhdmi-rockchip ff3c0000.hdmi: registered DesignWare HDMI I2C bus driver
[    0.808769] rockchip-drm display-subsystem: bound ff3c0000.hdmi (ops dw_hdmi_rockchip_ops)
[    0.810869] [drm] Initialized rockchip 1.0.0 20140818 for display-subsystem on minor 0
Quoted 4 lines

The only way I can use Linux HDMI by disabling IOMMU or support disable-iommu link for RK3328 via DT [1].

[1] https://www.spinics.net/lists/devicetree/msg605124.html

Is anyone aware of this issue? I did post the patches for Linux IOMMU but seems not a proper solution. Any suggestions?

Thanks,
Jagan.

#25 lore raw

Hi Jagan,

Quoted 36 lines · Jagan Teki

Hi Heiko/Kerver/Anatoloj,

Quoted 33 lines · Jagan Teki

Unlike RK3399, Sunxi/Meson DW HDMI the new Rockchip SoC Rk3328 would support external vendor PHY with DW HDMI chip.

Support this vendor PHY by adding new platform PHY ops via DW HDMI driver and call the respective generic phy from platform driver code.

This series tested in RK3328 with 1080p (1920x1080) resolution.

Patch 0001/0005: Support Vendor PHY
Patch 0006/0008: VOP extension for win, dsp offsets
Patch 0009/0010: RK3328 VOP, HDMI clocks
Patch 0011:      Rockchip Inno HDMI PHY
Patch 0012:      RK3328 HDMI driver
Patch 0013:      RK3328 VOP driver
Patch 0014/0017: Enable HDMI Out for RK3328

Importent:
One pontential issues is that Linux HDMI out on RK3328 has effected by this patchset as I wouldn't find any relation or clue.

[    0.752016] Loading compiled-in X.509 certificates
[    0.787796] inno_hdmi_phy_rk3328_clk_recalc_rate: parent 24000000
[    0.788391] inno-hdmi-phy ff430000.phy: inno_hdmi_phy_rk3328_clk_recalc_rate rate 148500000 vco 148500000
[    0.798353] rockchip-drm display-subsystem: bound ff370000.vop (ops vop_component_ops)
[    0.799403] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-0v9 not found, using dummy regulator
[    0.800288] rk_iommu ff373f00.iommu: Enable stall request timed out, status: 0x00004b
[    0.801131] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-1v8 not found, using dummy regulator
[    0.802056] rk_iommu ff373f00.iommu: Disable paging request timed out, status: 0x00004b
[    0.803233] dwhdmi-rockchip ff3c0000.hdmi: Detected HDMI TX controller v2.11a with HDCP (inno_dw_hdmi_phy2)
[    0.805355] dwhdmi-rockchip ff3c0000.hdmi: registered DesignWare HDMI I2C bus driver
[    0.808769] rockchip-drm display-subsystem: bound ff3c0000.hdmi (ops dw_hdmi_rockchip_ops)
[    0.810869] [drm] Initialized rockchip 1.0.0 20140818 for display-subsystem on minor 0
Quoted 6 lines
Quoted 4 lines

The only way I can use Linux HDMI by disabling IOMMU or support disable-iommu link for RK3328 via DT [1].

[1] https://www.spinics.net/lists/devicetree/msg605124.html

Is anyone aware of this issue? I did post the patches for Linux IOMMU but seems not a proper solution. Any suggestions?

I'm not expert in HDMI/VOP, so I can't provide a suitable solution in the kernel,

but here is the reason why we need patch to workaround the issue in the kernel:

- The VOP driver working in U-Boot is non-IOMMU mode, and the VOP access DDR by physical address;

- The VOP driver working in kernel with IOMMU enabled(by default), the VOP access DDR with virtual address(by IOMMU);

- The VOP is keep working in kernel before kernel VOP driver is enabled, and the IOMMU driver will be enabled by

   the Linux PM framework, since the IOMMU is not correctly configured at this point, the VOP will access unknown

    space(the original physical address in U-Boot) convert by IOMMU;

So we need to disable the IOMMU temporary in kernel startup before VOP driver is enabled.

Thanks,

- Kever

Quoted 3 lines

Thanks,
Jagan.

#26 lore raw
Quoted 59 lines · Kever Yang

Hi Jagan,

Quoted 36 lines · Jagan Teki

Hi Heiko/Kerver/Anatoloj,

Quoted 33 lines · Jagan Teki

Unlike RK3399, Sunxi/Meson DW HDMI the new Rockchip SoC Rk3328 would support external vendor PHY with DW HDMI chip.

Support this vendor PHY by adding new platform PHY ops via DW HDMI driver and call the respective generic phy from platform driver code.

This series tested in RK3328 with 1080p (1920x1080) resolution.

Patch 0001/0005: Support Vendor PHY
Patch 0006/0008: VOP extension for win, dsp offsets Patch 0009/0010: RK3328 VOP, HDMI clocks Patch 0011:      Rockchip Inno HDMI PHY Patch 0012:      RK3328 HDMI driver
Patch 0013:      RK3328 VOP driver
Patch 0014/0017: Enable HDMI Out for RK3328

Importent:
One pontential issues is that Linux HDMI out on RK3328 has effected by this patchset as I wouldn't find any relation or clue.

[    0.752016] Loading compiled-in X.509 certificates
[    0.787796] inno_hdmi_phy_rk3328_clk_recalc_rate: parent 24000000
[    0.788391] inno-hdmi-phy ff430000.phy: inno_hdmi_phy_rk3328_clk_recalc_rate rate 148500000 vco 148500000 [    0.798353] rockchip-drm display-subsystem: bound ff370000.vop (ops vop_component_ops)
[    0.799403] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-0v9 not found, using dummy regulator [    0.800288] rk_iommu ff373f00.iommu: Enable stall request timed out, status: 0x00004b
[    0.801131] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-1v8 not found, using dummy regulator [    0.802056] rk_iommu ff373f00.iommu: Disable paging request timed out, status: 0x00004b
[    0.803233] dwhdmi-rockchip ff3c0000.hdmi: Detected HDMI TX controller v2.11a with HDCP (inno_dw_hdmi_phy2) [    0.805355] dwhdmi-rockchip ff3c0000.hdmi: registered DesignWare HDMI I2C bus driver
[    0.808769] rockchip-drm display-subsystem: bound ff3c0000.hdmi (ops dw_hdmi_rockchip_ops) [    0.810869] [drm] Initialized rockchip 1.0.0 20140818 for display-subsystem on minor 0

Quoted 6 lines
Quoted 4 lines

The only way I can use Linux HDMI by disabling IOMMU or support disable-iommu link for RK3328 via DT [1].

[1] https://www.spinics.net/lists/devicetree/msg605124.html

Is anyone aware of this issue? I did post the patches for Linux IOMMU but seems not a proper solution. Any suggestions?

I'm not expert in HDMI/VOP, so I can't provide a suitable solution in the kernel,

but here is the reason why we need patch to workaround the issue in the kernel:

- The VOP driver working in U-Boot is non-IOMMU mode, and the VOP access DDR by physical address;

- The VOP driver working in kernel with IOMMU enabled(by default), the VOP access DDR with virtual address(by IOMMU);

- The VOP is keep working in kernel before kernel VOP driver is enabled, and the IOMMU driver will be enabled by

Quoted 6 lines

   the Linux PM framework, since the IOMMU is not correctly configured
at this point, the VOP will access unknown

    space(the original physical address in U-Boot) convert by IOMMU;

So we need to disable the IOMMU temporary in kernel startup before VOP driver is enabled.

If U-Boot isn't handing off an active framebuffer, then it should be U-Boot's responsibility to stop the VOP before it exits; if on the other hand it is, then it can now use the "iommu-addresses" DT property (see the reserved-memory schema) on the framebuffer region, and we should just need a bit of work in the IOMMU driver to ensure that is respected during the period between the IOMMU initialising and the Linux VOP driver subsequently taking over (i.e. so it won't get stuck on an unexpected page fault as seems to be happening above). The IOMMU aspect of that ought to be fairly straightforward; the trickier part might be the runtime PM aspect to ensure the IOMMU doesn't let itself go idle and actually turn anything off during that period. I also still think that doing the full rk_iommu_disable() upon runtime suspend is wrong, but that's more of a thing which confounds the underlying issue here, rather than being the problem in itself.

Thanks,
Robin.

author
#27 lore raw
Quoted 82 lines · Robin Murphy
Quoted 72 lines · Kever Yang

Hi Jagan,

Quoted 47 lines · Jagan Teki

Hi Heiko/Kerver/Anatoloj,

Quoted 43 lines · Jagan Teki

Unlike RK3399, Sunxi/Meson DW HDMI the new Rockchip SoC Rk3328 would support external vendor PHY with DW HDMI chip.

Support this vendor PHY by adding new platform PHY ops via DW HDMI driver and call the respective generic phy from platform driver code.

This series tested in RK3328 with 1080p (1920x1080) resolution.

Patch 0001/0005: Support Vendor PHY
Patch 0006/0008: VOP extension for win, dsp offsets
Patch 0009/0010: RK3328 VOP, HDMI clocks
Patch 0011:      Rockchip Inno HDMI PHY
Patch 0012:      RK3328 HDMI driver
Patch 0013:      RK3328 VOP driver
Patch 0014/0017: Enable HDMI Out for RK3328

Importent:
One pontential issues is that Linux HDMI out on RK3328 has effected by this patchset as I wouldn't find any relation or clue.

[    0.752016] Loading compiled-in X.509 certificates
[    0.787796] inno_hdmi_phy_rk3328_clk_recalc_rate: parent 24000000
[    0.788391] inno-hdmi-phy ff430000.phy:
inno_hdmi_phy_rk3328_clk_recalc_rate rate 148500000 vco 148500000
[    0.798353] rockchip-drm display-subsystem: bound ff370000.vop
(ops vop_component_ops)
[    0.799403] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-0v9 not
found, using dummy regulator
[    0.800288] rk_iommu ff373f00.iommu: Enable stall request timed
out, status: 0x00004b
[    0.801131] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-1v8 not
found, using dummy regulator
[    0.802056] rk_iommu ff373f00.iommu: Disable paging request timed
out, status: 0x00004b
[    0.803233] dwhdmi-rockchip ff3c0000.hdmi: Detected HDMI TX
controller v2.11a with HDCP (inno_dw_hdmi_phy2)
[    0.805355] dwhdmi-rockchip ff3c0000.hdmi: registered DesignWare
HDMI I2C bus driver
[    0.808769] rockchip-drm display-subsystem: bound ff3c0000.hdmi
(ops dw_hdmi_rockchip_ops)
[    0.810869] [drm] Initialized rockchip 1.0.0 20140818 for

display-subsystem on minor 0

Quoted 6 lines
Quoted 4 lines

The only way I can use Linux HDMI by disabling IOMMU or support disable-iommu link for RK3328 via DT [1].

[1] https://www.spinics.net/lists/devicetree/msg605124.html

Is anyone aware of this issue? I did post the patches for Linux IOMMU but seems not a proper solution. Any suggestions?

I'm not expert in HDMI/VOP, so I can't provide a suitable solution in the kernel,

but here is the reason why we need patch to workaround the issue in the kernel:

- The VOP driver working in U-Boot is non-IOMMU mode, and the VOP access DDR by physical address;

- The VOP driver working in kernel with IOMMU enabled(by default), the VOP access DDR with virtual address(by IOMMU);

- The VOP is keep working in kernel before kernel VOP driver is enabled, and the IOMMU driver will be enabled by

Quoted 7 lines

the Linux PM framework, since the IOMMU is not correctly configured
at this point, the VOP will access unknown

     space(the original physical address in U-Boot) convert by IOMMU;

So we need to disable the IOMMU temporary in kernel startup before VOP driver is enabled.

Quoted 14 lines

If U-Boot isn't handing off an active framebuffer, then it should be U-Boot's responsibility to stop the VOP before it exits; if on the other hand it is, then it can now use the "iommu-addresses" DT property (see the reserved-memory schema) on the framebuffer region, and we should just need a bit of work in the IOMMU driver to ensure that is respected during the period between the IOMMU initialising and the Linux VOP driver subsequently taking over (i.e. so it won't get stuck on an unexpected page fault as seems to be happening above). The IOMMU aspect of that ought to be fairly straightforward; the trickier part might be the runtime PM aspect to ensure the IOMMU doesn't let itself go idle and actually turn anything off during that period. I also still think that doing the full rk_iommu_disable() upon runtime suspend is wrong, but that's more of a thing which confounds the underlying issue here, rather than being the problem in itself.

Thanks for your comments. Okay, keeping the Linux IOMMU issue aside I think whatever change that u-boot makes on VOP has to clear it before handoff to Linux - so clearing the VOP registers during handoff seems working. I only wonder why it happens only on RK3328 (RK3399 and RK3288 seem fine).

I will post the next version with VOP clear during handoff.

Thanks,
Jagan.