Skip to contentSkip to conversation

clk: rockchip: rk3328: use HDMIPHY PLL as a clock parent for VOP_DCLK

PATCH Superseded Vasily Khoruzhick 3 participants 8 messages Jan 14, 2025 – Jan 19, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 clk: rockchip: rk3328: use HDMIPHY PLL as a clock parent for VOP_DCLK

The only video mode that currently works on rk3328 in u-boot is 1080p, because it uses GPLL for VOP_DCLK clock parent.

Linux driver uses HDMIPHY PLL as a clock parent for VOP_DCLK, since using GPLL or CPLL is not feasible due these PLL being used as a clock parent for other devices. It would be cumbersome to recalculate dividers for the rest of the devices, and u-boot doesn't do it anyway. As a result, u-boot is not able to set desired dot clock for most resolutions.

Switch to using HDMIPHY as a clock parent for VOP_DCLK

Tested with 768p, 1080p, 1440p monitors.

Fixes 92edae779f8c ("clk: rockchip: rk3328: Add VOP clk support")
---
 drivers/clk/rockchip/clk_rk3328.c | 76 +++++++------------------------
 1 file changed, 16 insertions(+), 60 deletions(-)
drivers/clk/rockchip/clk_rk3328.c +16 -60
index 7701a9734ee..537af6b3290 100644
@@ -79,6 +79,12 @@ enum {
 	PLL_MODE_SLOW			= 0,
 	PLL_MODE_NORM,
 
+	/* MISC_CON */
+	HDMIPHY_24M_SEL_SHIFT		= 13,
+	HDMIPHY_24M_SEL_MASK		= 1 << HDMIPHY_24M_SEL_SHIFT,
+	HDMIPHY_24M_SEL_PCLK		= 0,
+	HDMIPHY_24M_SEL_24MHZ		= 1,
+
 	/* CLKSEL_CON0 */
 	CLK_CORE_PLL_SEL_APLL		= 0,
 	CLK_CORE_PLL_SEL_GPLL,
@@ -583,41 +589,11 @@ static ulong rk3328_spi_set_clk(struct rk3328_cru *cru, uint hz)
 }
 
 #ifndef CONFIG_XPL_BUILD
-static ulong rk3328_vop_get_clk(struct rk3328_clk_priv *priv, ulong clk_id)
-{
-	struct rk3328_cru *cru = priv->cru;
-	u32 div, con, parent;
-
-	switch (clk_id) {
-	case ACLK_VOP_PRE:
-		con = readl(&cru->clksel_con[39]);
-		div = (con & ACLK_VOP_DIV_CON_MASK) >> ACLK_VOP_DIV_CON_SHIFT;
-		parent = GPLL_HZ;
-		break;
-	case ACLK_VIO_PRE:
-		con = readl(&cru->clksel_con[37]);
-		div = (con & ACLK_VIO_DIV_CON_MASK) >> ACLK_VIO_DIV_CON_SHIFT;
-		parent = GPLL_HZ;
-		break;
-	case DCLK_LCDC:
-		con = readl(&cru->clksel_con[40]);
-		div = (con & DCLK_LCDC_DIV_CON_MASK) >> DCLK_LCDC_DIV_CON_SHIFT;
-		parent = GPLL_HZ;
-		break;
-	default:
-		printf("%s: Unsupported vop get clk#%ld\n", __func__, clk_id);
-		return -ENOENT;
-	}
-
-	return DIV_TO_RATE(parent, div);
-}
-
 static ulong rk3328_vop_set_clk(struct rk3328_clk_priv *priv,
 				ulong clk_id, uint hz)
 {
 	struct rk3328_cru *cru = priv->cru;
 	int src_clk_div;
-	u32 con, parent;
 
 	src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
 	assert(src_clk_div - 1 < 31);
@@ -636,42 +612,25 @@ static ulong rk3328_vop_set_clk(struct rk3328_clk_priv *priv,
 			     (src_clk_div - 1) << ACLK_VIO_DIV_CON_SHIFT);
 		break;
 	case DCLK_LCDC:
-		con = readl(&cru->clksel_con[40]);
-		con = (con & DCLK_LCDC_SEL_MASK) >> DCLK_LCDC_SEL_SHIFT;
-		if (con) {
-			parent = readl(&cru->clksel_con[40]);
-			parent = (parent & DCLK_LCDC_PLL_SEL_MASK) >>
-				 DCLK_LCDC_PLL_SEL_SHIFT;
-			if (parent)
-				src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
-			else
-				src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
-
-			rk_clrsetreg(&cru->clksel_con[40],
-				     DCLK_LCDC_DIV_CON_MASK,
-				     (src_clk_div - 1) <<
-				     DCLK_LCDC_DIV_CON_SHIFT);
-		}
+		/* Set HDMIPHY clock output to pixel clock */
+		rk_clrsetreg(&cru->misc, HDMIPHY_24M_SEL_MASK,
+			     HDMIPHY_24M_SEL_PCLK << HDMIPHY_24M_SEL_SHIFT);
+		/* Set HDMIPHY as a parent of DCLK_LCDC, and set all divisors to 1 */
+		rk_clrsetreg(&cru->clksel_con[40],
+			     DCLK_LCDC_DIV_CON_MASK | DCLK_LCDC_SEL_MASK | CLK_HDMIPHY_DIV_CON_MASK,
+			     (1 - 1) << CLK_HDMIPHY_DIV_CON_SHIFT |
+			     DCLK_LCDC_SEL_HDMIPHY << DCLK_LCDC_SEL_SHIFT |
+			     (1 - 1) << DCLK_LCDC_DIV_CON_SHIFT);
 		break;
 	default:
 		printf("%s: Unable to set vop clk#%ld\n", __func__, clk_id);
 		return -EINVAL;
 	}
 
-	return rk3328_vop_get_clk(priv, clk_id);
+	return hz;
 }
 #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);
@@ -701,9 +660,6 @@ 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;
 	case SCLK_USB3OTG_REF:
 		rate = OSC_HZ;
 		break;
Signature · 1 line
2.47.1
#1 lore raw

PATCH 2/3 video: rockchip: rk3328: filter unsupported modes

While RK3328 is capable of 4K resolution, dw-hdmi driver in u-boot seems to have some issue with 4K. 1440p or lower works fine.

Limit max resolution by 2560x1440x60Hz, by filtering the modes with pixel clock > 297MHz

Fixes f3ea872970d603 ("video: rockchip: Add rk3328 hdmi support")
---
 drivers/video/rockchip/rk3328_hdmi.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/video/rockchip/rk3328_hdmi.c +7 -0
index 763669c09be..d02c58c44c5 100644
@@ -105,9 +105,16 @@ static int rk3328_hdmi_probe(struct udevice *dev)
 	return 0;
 }
 
+static bool rk3328_hdmi_mode_valid(struct udevice *dev,
+				   const struct display_timing *timing)
+{
+	return timing->pixelclock.typ <= 297000000;
+}
+
 static const struct dm_display_ops rk3328_hdmi_ops = {
 	.read_edid = rk_hdmi_read_edid,
 	.enable = rk3328_hdmi_enable,
+	.mode_valid = rk3328_hdmi_mode_valid,
 };
 
 static const struct udevice_id rk3328_hdmi_ids[] = {
Signature · 1 line
2.47.1
#2 lore raw

Re: [PATCH 2/3] video: rockchip: rk3328: filter unsupported modes

Hi Vasily,

Quoted 17 lines · Vasily Khoruzhick

While RK3328 is capable of 4K resolution, dw-hdmi driver in u-boot seems to have some issue with 4K. 1440p or lower works fine.

Limit max resolution by 2560x1440x60Hz, by filtering the modes with pixel clock > 297MHz

Fixes f3ea872970d603 ("video: rockchip: Add rk3328 hdmi support")
---
  drivers/video/rockchip/rk3328_hdmi.c | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/video/rockchip/rk3328_hdmi.c +0 -0
index 763669c09be..d02c58c44c5 100644

drivers/video/rockchip/rk3328_hdmi.c static int rk3328_hdmi_probe(struct udevice *dev) · line 113

Quoted 9 lines
drivers/video/rockchip/rk3328_hdmi.c +6 -0
@@ -105,9 +105,16 @@ static int rk3328_hdmi_probe(struct udevice *dev)
  	return 0;
  }
 
+static bool rk3328_hdmi_mode_valid(struct udevice *dev,
+				   const struct display_timing *timing)
+{
+	return timing->pixelclock.typ <= 297000000;
+}
+

This seems like a hack to me and I would feel better with it being documented as such in the code. Can you simply add a comment there stating that this is a work-around for resolutions above 4K that should be working (that's what I gathered from the commit log, does it work in Linux?) but aren't right now. Maybe also add the formula in the comment?

I also wonder what would happen if we have 120+Hz displays at lower resolutions, they would be filtered out as well. Is that an issue? /me shrugs.

I don't own an RK3328 device though, so...

Cheers,
Quentin

#3 lore raw

Re: [PATCH 2/3] video: rockchip: rk3328: filter unsupported modes

Quoted 2 lines · Quentin Schulz

Hi Vasily,

Hey Quentin,

Quoted 4 lines
Quoted 4 lines
drivers/video/rockchip/rk3328_hdmi.c +4 -0
+static bool rk3328_hdmi_mode_valid(struct udevice *dev,
+                                const struct display_timing *timing)
+{
+     return timing->pixelclock.typ <= 297000000;
Quoted 8 lines

drivers/video/rockchip/rk3328_hdmi.c static int rk3328_hdmi_probe(struct udevice *dev) · line 113

Quoted 2 lines
drivers/video/rockchip/rk3328_hdmi.c +2 -0
+}
+

This seems like a hack to me and I would feel better with it being documented as such in the code. Can you simply add a comment there stating that this is a work-around for resolutions above 4K that should be working (that's what I gathered from the commit log, does it work in Linux?) but aren't right now.

Yeah, I agree it is a hack, and yes, 4K works fine in Linux. I noticed that some other drivers that use dw-hdmi in u-boot also limit max pixel clock at 297MHz, so it might be a known but not documented issue. I'll add a comment about that in v2.

Quoted 1 line

Maybe also add the formula in the comment?

htotal * vtotal * refresh_rate? That would require an explanation of what htotal and vtotal is, and TBH if you know where to get htotal and vtotal from, you know where to look for a pixel clock. I don't think that rk3328_hdmi.c is a proper place for such an explanation.

Quoted 3 lines

I also wonder what would happen if we have 120+Hz displays at lower resolutions, they would be filtered out as well. Is that an issue? /me shrugs.

Yeah, or 4K displays at 30Hz which is exactly 297MHz.

I spent some time debugging this issue, unfortunately with no useful result. This change at least allows my rock64 to show something on my 4K monitor, so it is an improvement.

Regards,
Vasily

#4 lore raw

PATCH 3/3 rockchip: rock64-rk3328_defconfig: enable HDMI output and USB keyboard

In reply to Vasily Khoruzhick

Enable HDMI output and USB keyboard on Rock64 board

---
 configs/rock64-rk3328_defconfig | 10 ++++++++++
 1 file changed, 10 insertions(+)
configs/rock64-rk3328_defconfig +10 -0
index 6d00b52e62f..ae3512625cf 100644
@@ -21,7 +21,9 @@ CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_FIT_SIGNATURE=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_LEGACY_IMAGE_FORMAT=y
+CONFIG_USE_PREBOOT=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3328-rock64.dtb"
+# CONFIG_SYS_DEVICE_NULLDEV is not set
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_MAX_SIZE=0x40000
@@ -72,6 +74,7 @@ CONFIG_DM_ETH_PHY=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
@@ -80,6 +83,8 @@ CONFIG_PMIC_RK8XX=y
 CONFIG_SPL_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_SPL_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_SPL_DM_REGULATOR_GPIO=y
 CONFIG_REGULATOR_RK8XX=y
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_RAM=y
@@ -104,6 +109,11 @@ CONFIG_USB_OHCI_GENERIC=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
+CONFIG_USB_KEYBOARD=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.47.1
#5 lore raw
In reply to Vasily Khoruzhick

Thanks. Very interesting. I'll test it on my Rock64 at the weekend.

вт, 14 янв. 2025 г. в 08:26, Vasily Khoruzhick <[email protected]>:

Quoted 146 lines

The only video mode that currently works on rk3328 in u-boot is 1080p, because it uses GPLL for VOP_DCLK clock parent.

Linux driver uses HDMIPHY PLL as a clock parent for VOP_DCLK, since using GPLL or CPLL is not feasible due these PLL being used as a clock parent for other devices. It would be cumbersome to recalculate dividers for the rest of the devices, and u-boot doesn't do it anyway. As a result, u-boot is not able to set desired dot clock for most resolutions.

Switch to using HDMIPHY as a clock parent for VOP_DCLK

Tested with 768p, 1080p, 1440p monitors.

Fixes 92edae779f8c ("clk: rockchip: rk3328: Add VOP clk support")
---
 drivers/clk/rockchip/clk_rk3328.c | 76 +++++++------------------------
 1 file changed, 16 insertions(+), 60 deletions(-)
drivers/clk/rockchip/clk_rk3328.c +16 -61
index 7701a9734ee..537af6b3290 100644
@@ -79,6 +79,12 @@ enum {
        PLL_MODE_SLOW                   = 0,
        PLL_MODE_NORM,
 
+       /* MISC_CON */
+       HDMIPHY_24M_SEL_SHIFT           = 13,
+       HDMIPHY_24M_SEL_MASK            = 1 << HDMIPHY_24M_SEL_SHIFT,
+       HDMIPHY_24M_SEL_PCLK            = 0,
+       HDMIPHY_24M_SEL_24MHZ           = 1,
+
        /* CLKSEL_CON0 */
        CLK_CORE_PLL_SEL_APLL           = 0,
        CLK_CORE_PLL_SEL_GPLL,
@@ -583,41 +589,11 @@ static ulong rk3328_spi_set_clk(struct rk3328_cru *cru, uint hz)
 }
 
 #ifndef CONFIG_XPL_BUILD
-static ulong rk3328_vop_get_clk(struct rk3328_clk_priv *priv, ulong clk_id)
-{
-       struct rk3328_cru *cru = priv->cru;
-       u32 div, con, parent;
-
-       switch (clk_id) {
-       case ACLK_VOP_PRE:
-               con = readl(&cru->clksel_con[39]);
-               div = (con & ACLK_VOP_DIV_CON_MASK) >> ACLK_VOP_DIV_CON_SHIFT;
-               parent = GPLL_HZ;
-               break;
-       case ACLK_VIO_PRE:
-               con = readl(&cru->clksel_con[37]);
-               div = (con & ACLK_VIO_DIV_CON_MASK) >> ACLK_VIO_DIV_CON_SHIFT;
-               parent = GPLL_HZ;
-               break;
-       case DCLK_LCDC:
-               con = readl(&cru->clksel_con[40]);
-               div = (con & DCLK_LCDC_DIV_CON_MASK) >> DCLK_LCDC_DIV_CON_SHIFT;
-               parent = GPLL_HZ;
-               break;
-       default:
-               printf("%s: Unsupported vop get clk#%ld\n", __func__, clk_id);
-               return -ENOENT;
-       }
-
-       return DIV_TO_RATE(parent, div);
-}
-
 static ulong rk3328_vop_set_clk(struct rk3328_clk_priv *priv,
                                ulong clk_id, uint hz)
 {
        struct rk3328_cru *cru = priv->cru;
        int src_clk_div;
-       u32 con, parent;
 
        src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
        assert(src_clk_div - 1 < 31);
@@ -636,42 +612,25 @@ static ulong rk3328_vop_set_clk(struct rk3328_clk_priv *priv,
                             (src_clk_div - 1) << ACLK_VIO_DIV_CON_SHIFT);
                break;
        case DCLK_LCDC:
-               con = readl(&cru->clksel_con[40]);
-               con = (con & DCLK_LCDC_SEL_MASK) >> DCLK_LCDC_SEL_SHIFT;
-               if (con) {
-                       parent = readl(&cru->clksel_con[40]);
-                       parent = (parent & DCLK_LCDC_PLL_SEL_MASK) >>
-                                DCLK_LCDC_PLL_SEL_SHIFT;
-                       if (parent)
-                               src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
-                       else
-                               src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
-
-                       rk_clrsetreg(&cru->clksel_con[40],
-                                    DCLK_LCDC_DIV_CON_MASK,
-                                    (src_clk_div - 1) <<
-                                    DCLK_LCDC_DIV_CON_SHIFT);
-               }
+               /* Set HDMIPHY clock output to pixel clock */
+               rk_clrsetreg(&cru->misc, HDMIPHY_24M_SEL_MASK,
+                            HDMIPHY_24M_SEL_PCLK << HDMIPHY_24M_SEL_SHIFT);
+               /* Set HDMIPHY as a parent of DCLK_LCDC, and set all divisors to 1 */
+               rk_clrsetreg(&cru->clksel_con[40],
+                            DCLK_LCDC_DIV_CON_MASK | DCLK_LCDC_SEL_MASK | CLK_HDMIPHY_DIV_CON_MASK,
+                            (1 - 1) << CLK_HDMIPHY_DIV_CON_SHIFT |
+                            DCLK_LCDC_SEL_HDMIPHY << DCLK_LCDC_SEL_SHIFT |
+                            (1 - 1) << DCLK_LCDC_DIV_CON_SHIFT);
                break;
        default:
                printf("%s: Unable to set vop clk#%ld\n", __func__, clk_id);
                return -EINVAL;
        }
 
-       return rk3328_vop_get_clk(priv, clk_id);
+       return hz;
 }
 #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);
@@ -701,9 +660,6 @@ 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;
        case SCLK_USB3OTG_REF:
                rate = OSC_HZ;
                break;
--

2.47.1

Signature · 2 lines
With best regards,
Matwey V. Kornilov
Tested-by on v1 1/3
#6 lore raw
In reply to Vasily Khoruzhick

вт, 14 янв. 2025 г. в 08:26, Vasily Khoruzhick <[email protected]>:

Quoted 11 lines

The only video mode that currently works on rk3328 in u-boot is 1080p, because it uses GPLL for VOP_DCLK clock parent.

Linux driver uses HDMIPHY PLL as a clock parent for VOP_DCLK, since using GPLL or CPLL is not feasible due these PLL being used as a clock parent for other devices. It would be cumbersome to recalculate dividers for the rest of the devices, and u-boot doesn't do it anyway. As a result, u-boot is not able to set desired dot clock for most resolutions.

Quoted 6 lines

Switch to using HDMIPHY as a clock parent for VOP_DCLK

Tested with 768p, 1080p, 1440p monitors.

Fixes 92edae779f8c ("clk: rockchip: rk3328: Add VOP clk support")

Both UART-console and HDMI-console works with this patcheset on my Rock64 board.

Quoted 129 lines
---
 drivers/clk/rockchip/clk_rk3328.c | 76 +++++++------------------------
 1 file changed, 16 insertions(+), 60 deletions(-)
drivers/clk/rockchip/clk_rk3328.c +16 -61
index 7701a9734ee..537af6b3290 100644
@@ -79,6 +79,12 @@ enum {
        PLL_MODE_SLOW                   = 0,
        PLL_MODE_NORM,
 
+       /* MISC_CON */
+       HDMIPHY_24M_SEL_SHIFT           = 13,
+       HDMIPHY_24M_SEL_MASK            = 1 << HDMIPHY_24M_SEL_SHIFT,
+       HDMIPHY_24M_SEL_PCLK            = 0,
+       HDMIPHY_24M_SEL_24MHZ           = 1,
+
        /* CLKSEL_CON0 */
        CLK_CORE_PLL_SEL_APLL           = 0,
        CLK_CORE_PLL_SEL_GPLL,
@@ -583,41 +589,11 @@ static ulong rk3328_spi_set_clk(struct rk3328_cru *cru, uint hz)
 }
 
 #ifndef CONFIG_XPL_BUILD
-static ulong rk3328_vop_get_clk(struct rk3328_clk_priv *priv, ulong clk_id)
-{
-       struct rk3328_cru *cru = priv->cru;
-       u32 div, con, parent;
-
-       switch (clk_id) {
-       case ACLK_VOP_PRE:
-               con = readl(&cru->clksel_con[39]);
-               div = (con & ACLK_VOP_DIV_CON_MASK) >> ACLK_VOP_DIV_CON_SHIFT;
-               parent = GPLL_HZ;
-               break;
-       case ACLK_VIO_PRE:
-               con = readl(&cru->clksel_con[37]);
-               div = (con & ACLK_VIO_DIV_CON_MASK) >> ACLK_VIO_DIV_CON_SHIFT;
-               parent = GPLL_HZ;
-               break;
-       case DCLK_LCDC:
-               con = readl(&cru->clksel_con[40]);
-               div = (con & DCLK_LCDC_DIV_CON_MASK) >> DCLK_LCDC_DIV_CON_SHIFT;
-               parent = GPLL_HZ;
-               break;
-       default:
-               printf("%s: Unsupported vop get clk#%ld\n", __func__, clk_id);
-               return -ENOENT;
-       }
-
-       return DIV_TO_RATE(parent, div);
-}
-
 static ulong rk3328_vop_set_clk(struct rk3328_clk_priv *priv,
                                ulong clk_id, uint hz)
 {
        struct rk3328_cru *cru = priv->cru;
        int src_clk_div;
-       u32 con, parent;
 
        src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
        assert(src_clk_div - 1 < 31);
@@ -636,42 +612,25 @@ static ulong rk3328_vop_set_clk(struct rk3328_clk_priv *priv,
                             (src_clk_div - 1) << ACLK_VIO_DIV_CON_SHIFT);
                break;
        case DCLK_LCDC:
-               con = readl(&cru->clksel_con[40]);
-               con = (con & DCLK_LCDC_SEL_MASK) >> DCLK_LCDC_SEL_SHIFT;
-               if (con) {
-                       parent = readl(&cru->clksel_con[40]);
-                       parent = (parent & DCLK_LCDC_PLL_SEL_MASK) >>
-                                DCLK_LCDC_PLL_SEL_SHIFT;
-                       if (parent)
-                               src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
-                       else
-                               src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
-
-                       rk_clrsetreg(&cru->clksel_con[40],
-                                    DCLK_LCDC_DIV_CON_MASK,
-                                    (src_clk_div - 1) <<
-                                    DCLK_LCDC_DIV_CON_SHIFT);
-               }
+               /* Set HDMIPHY clock output to pixel clock */
+               rk_clrsetreg(&cru->misc, HDMIPHY_24M_SEL_MASK,
+                            HDMIPHY_24M_SEL_PCLK << HDMIPHY_24M_SEL_SHIFT);
+               /* Set HDMIPHY as a parent of DCLK_LCDC, and set all divisors to 1 */
+               rk_clrsetreg(&cru->clksel_con[40],
+                            DCLK_LCDC_DIV_CON_MASK | DCLK_LCDC_SEL_MASK | CLK_HDMIPHY_DIV_CON_MASK,
+                            (1 - 1) << CLK_HDMIPHY_DIV_CON_SHIFT |
+                            DCLK_LCDC_SEL_HDMIPHY << DCLK_LCDC_SEL_SHIFT |
+                            (1 - 1) << DCLK_LCDC_DIV_CON_SHIFT);
                break;
        default:
                printf("%s: Unable to set vop clk#%ld\n", __func__, clk_id);
                return -EINVAL;
        }
 
-       return rk3328_vop_get_clk(priv, clk_id);
+       return hz;
 }
 #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);
@@ -701,9 +660,6 @@ 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;
        case SCLK_USB3OTG_REF:
                rate = OSC_HZ;
                break;
--

2.47.1

Signature · 2 lines
With best regards,
Matwey V. Kornilov