diff mbox series

[v2,06/19] video: sunxi: Use DW-HDMI hpd function

Message ID 20210306195437.9740-7-jernej.skrabec@siol.net
State Accepted
Delegated to: Andre Przywara
Headers show
Series video: sunxi: rework DE2 driver | expand

Commit Message

Jernej Škrabec March 6, 2021, 7:54 p.m. UTC
It turns out that there are two ways how hot plug detection can be done.
One is standard way for DW HDMI controller - checking bit 2 in 0x3004
register. Another way is applicable only to Allwinner custom PHY - by
checking bit 19 in register 0x10038. Both method are equally good as far
as we know.

Use standard method in order to reduce amount of custom code.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/video/sunxi/sunxi_dw_hdmi.c | 34 +++++------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)

Comments

Andre Przywara March 7, 2021, 1:30 a.m. UTC | #1
On Sat,  6 Mar 2021 20:54:24 +0100
Jernej Skrabec <jernej.skrabec@siol.net> wrote:

> It turns out that there are two ways how hot plug detection can be done.
> One is standard way for DW HDMI controller - checking bit 2 in 0x3004
> register. Another way is applicable only to Allwinner custom PHY - by
> checking bit 19 in register 0x10038. Both method are equally good as far
> as we know.
> 
> Use standard method in order to reduce amount of custom code.

Thanks for the clarification!
 
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

> ---
>  drivers/video/sunxi/sunxi_dw_hdmi.c | 34 +++++------------------------
>  1 file changed, 6 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/video/sunxi/sunxi_dw_hdmi.c b/drivers/video/sunxi/sunxi_dw_hdmi.c
> index e3811a2ec15f..37e78ff24111 100644
> --- a/drivers/video/sunxi/sunxi_dw_hdmi.c
> +++ b/drivers/video/sunxi/sunxi_dw_hdmi.c
> @@ -114,28 +114,6 @@ static void sunxi_dw_hdmi_phy_init(void)
>  	writel(0x42494E47, &phy->unscramble);
>  }
>  
> -static int sunxi_dw_hdmi_get_plug_in_status(void)
> -{
> -	struct sunxi_hdmi_phy * const phy =
> -		(struct sunxi_hdmi_phy *)(SUNXI_HDMI_BASE + HDMI_PHY_OFFS);
> -
> -	return !!(readl(&phy->status) & (1 << 19));
> -}
> -
> -static int sunxi_dw_hdmi_wait_for_hpd(void)
> -{
> -	ulong start;
> -
> -	start = get_timer(0);
> -	do {
> -		if (sunxi_dw_hdmi_get_plug_in_status())
> -			return 0;
> -		udelay(100);
> -	} while (get_timer(start) < 300);
> -
> -	return -1;
> -}
> -
>  static void sunxi_dw_hdmi_phy_set(uint clock, int phy_div)
>  {
>  	struct sunxi_hdmi_phy * const phy =
> @@ -370,12 +348,6 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
>  
>  	sunxi_dw_hdmi_phy_init();
>  
> -	ret = sunxi_dw_hdmi_wait_for_hpd();
> -	if (ret < 0) {
> -		debug("hdmi can not get hpd signal\n");
> -		return -1;
> -	}
> -
>  	priv->hdmi.ioaddr = SUNXI_HDMI_BASE;
>  	priv->hdmi.i2c_clk_high = 0xd8;
>  	priv->hdmi.i2c_clk_low = 0xfe;
> @@ -383,6 +355,12 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
>  	priv->hdmi.phy_set = sunxi_dw_hdmi_phy_cfg;
>  	priv->mux = uc_plat->source_id;
>  
> +	ret = dw_hdmi_phy_wait_for_hpd(&priv->hdmi);
> +	if (ret < 0) {
> +		debug("hdmi can not get hpd signal\n");
> +		return -1;
> +	}
> +
>  	uclass_get_device_by_phandle(UCLASS_I2C, dev, "ddc-i2c-bus",
>  				     &priv->hdmi.ddc_bus);
>
diff mbox series

Patch

diff --git a/drivers/video/sunxi/sunxi_dw_hdmi.c b/drivers/video/sunxi/sunxi_dw_hdmi.c
index e3811a2ec15f..37e78ff24111 100644
--- a/drivers/video/sunxi/sunxi_dw_hdmi.c
+++ b/drivers/video/sunxi/sunxi_dw_hdmi.c
@@ -114,28 +114,6 @@  static void sunxi_dw_hdmi_phy_init(void)
 	writel(0x42494E47, &phy->unscramble);
 }
 
-static int sunxi_dw_hdmi_get_plug_in_status(void)
-{
-	struct sunxi_hdmi_phy * const phy =
-		(struct sunxi_hdmi_phy *)(SUNXI_HDMI_BASE + HDMI_PHY_OFFS);
-
-	return !!(readl(&phy->status) & (1 << 19));
-}
-
-static int sunxi_dw_hdmi_wait_for_hpd(void)
-{
-	ulong start;
-
-	start = get_timer(0);
-	do {
-		if (sunxi_dw_hdmi_get_plug_in_status())
-			return 0;
-		udelay(100);
-	} while (get_timer(start) < 300);
-
-	return -1;
-}
-
 static void sunxi_dw_hdmi_phy_set(uint clock, int phy_div)
 {
 	struct sunxi_hdmi_phy * const phy =
@@ -370,12 +348,6 @@  static int sunxi_dw_hdmi_probe(struct udevice *dev)
 
 	sunxi_dw_hdmi_phy_init();
 
-	ret = sunxi_dw_hdmi_wait_for_hpd();
-	if (ret < 0) {
-		debug("hdmi can not get hpd signal\n");
-		return -1;
-	}
-
 	priv->hdmi.ioaddr = SUNXI_HDMI_BASE;
 	priv->hdmi.i2c_clk_high = 0xd8;
 	priv->hdmi.i2c_clk_low = 0xfe;
@@ -383,6 +355,12 @@  static int sunxi_dw_hdmi_probe(struct udevice *dev)
 	priv->hdmi.phy_set = sunxi_dw_hdmi_phy_cfg;
 	priv->mux = uc_plat->source_id;
 
+	ret = dw_hdmi_phy_wait_for_hpd(&priv->hdmi);
+	if (ret < 0) {
+		debug("hdmi can not get hpd signal\n");
+		return -1;
+	}
+
 	uclass_get_device_by_phandle(UCLASS_I2C, dev, "ddc-i2c-bus",
 				     &priv->hdmi.ddc_bus);