From nobody Thu Dec 18 08:39:21 2025 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.3]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2856E25A322; Tue, 25 Mar 2025 13:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.3 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742909437; cv=none; b=kmIIz14UArSQOnbXrW75Ov4HTTI5GIBF0Xm58Fsbt0/Zz71TgK6sbyD3kLGcEfa2E62ATReDww6Ha7aDR7uJY+ODjnmP7E7LFrQ87WOW0ODRmdWJnu82IRb3l7tOIS6Tz55bhgXZiz5kQQPZbWM1rbkdUocykgxNYnvDQifE8Ng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742909437; c=relaxed/simple; bh=qRxMs/0Orm9+v2KlI7BI7V6SOQpKNDSjvZHUzjyF4YI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eo5963GinmkVQTS7MHbVY6jji7gm5Z3JJ99YiGA9TZcnHQgYMVZpiUbiTTbKf5CVf3464ll6wtoSlhI6bXHPg9ii88rdW+Xwe4tez4HSSjNa39lulYhnY81/Zd19hJwnSjmTNjQXsj3T6vM9Ok4JX39oEONv7UMUVTp0wiW1tOw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=fu7UU5JI; arc=none smtp.client-ip=117.135.210.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="fu7UU5JI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=Z+Uzc h6EUA5KKSDVbfXUEIaM57kueShEZfjW0O0iCdA=; b=fu7UU5JIFwLPWf3wyRgTx +La/s79dVhcUwOCPv96643Rx533kDnz83TXo+H2ZToo7XQWFiDAiv4x9/6s/vv6L vpkhSdyPiY6ONRTpFn6avAQJNjTCY4+7q//+UiFeXmUXrkwVvybHsn+lE0+jPaBQ znc8T1oZNRrtqs4+CmrDvo= Received: from ProDesk.. (unknown []) by gzsmtp4 (Coremail) with SMTP id PygvCgAnc2bLr+JnWNnrAA--.35530S6; Tue, 25 Mar 2025 21:29:54 +0800 (CST) From: Andy Yan To: heiko@sntech.de Cc: conor+dt@kernel.org, krzk+dt@kernel.org, robh@kernel.org, hjc@rock-chips.com, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Andy Yan Subject: [PATCH v2 4/6] drm/rockchip: inno-hdmi: Fix video timing HSYNC/VSYNC polarity setting for rk3036 Date: Tue, 25 Mar 2025 21:29:38 +0800 Message-ID: <20250325132944.171111-5-andyshrk@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250325132944.171111-1-andyshrk@163.com> References: <20250325132944.171111-1-andyshrk@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: PygvCgAnc2bLr+JnWNnrAA--.35530S6 X-Coremail-Antispam: 1Uf129KBjvJXoWxZr17Gry3Ar18CFW5Xw4xZwb_yoWrJrWfpa y7Ca4UJF43Xa13Jw4xAa93Cr1aga97ta12yry7W3Wa9w12gr9YyF1kZF43uF1rAF93Was7 trW8Ga4UG3W7Zw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jfeOJUUUUU= X-CM-SenderInfo: 5dqg52xkunqiywtou0bp/xtbBkB4bXmfirygTGgAAsA Content-Type: text/plain; charset="utf-8" From: Andy Yan The HSYNC/VSYNC polarity of rk3036 HDMI are controlled by GRF. Without the polarity configuration in GRF, it can be observed from the HDMI protocol analyzer that the H/V front/back timing output by RK3036 HDMI are currently not in line with the specifications. Signed-off-by: Andy Yan --- Changes in v2: - First included in this series drivers/gpu/drm/rockchip/inno_hdmi.c | 36 +++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchi= p/inno_hdmi.c index e891d42dd08a4..db4b4038e51d5 100644 --- a/drivers/gpu/drm/rockchip/inno_hdmi.c +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c @@ -10,10 +10,12 @@ #include #include #include +#include #include #include #include #include +#include =20 #include #include @@ -29,8 +31,19 @@ =20 #include "inno_hdmi.h" =20 +#define HIWORD_UPDATE(val, mask) ((val) | (mask) << 16) + #define INNO_HDMI_MIN_TMDS_CLOCK 25000000U =20 +#define RK3036_GRF_SOC_CON2 0x148 +#define RK3036_HDMI_PHSYNC BIT(4) +#define RK3036_HDMI_PVSYNC BIT(5) + +enum inno_hdmi_dev_type { + RK3036_HDMI, + RK3128_HDMI, +}; + struct inno_hdmi_phy_config { unsigned long pixelclock; u8 pre_emphasis; @@ -38,6 +51,7 @@ struct inno_hdmi_phy_config { }; =20 struct inno_hdmi_variant { + enum inno_hdmi_dev_type dev_type; struct inno_hdmi_phy_config *phy_configs; struct inno_hdmi_phy_config *default_phy_config; }; @@ -58,6 +72,7 @@ struct inno_hdmi { struct clk *pclk; struct clk *refclk; void __iomem *regs; + struct regmap *grf; =20 struct drm_connector connector; struct rockchip_encoder encoder; @@ -374,7 +389,15 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi= *hdmi) static int inno_hdmi_config_video_timing(struct inno_hdmi *hdmi, struct drm_display_mode *mode) { - int value; + int value, psync; + + if (hdmi->variant->dev_type =3D=3D RK3036_HDMI) { + psync =3D mode->flags & DRM_MODE_FLAG_PHSYNC ? RK3036_HDMI_PHSYNC : 0; + value =3D HIWORD_UPDATE(psync, RK3036_HDMI_PHSYNC); + psync =3D mode->flags & DRM_MODE_FLAG_PVSYNC ? RK3036_HDMI_PVSYNC : 0; + value |=3D HIWORD_UPDATE(psync, RK3036_HDMI_PVSYNC); + regmap_write(hdmi->grf, RK3036_GRF_SOC_CON2, value); + } =20 /* Set detail external video timing polarity and interlace mode */ value =3D v_EXTERANL_VIDEO(1); @@ -904,6 +927,15 @@ static int inno_hdmi_bind(struct device *dev, struct d= evice *master, goto err_disable_pclk; } =20 + if (hdmi->variant->dev_type =3D=3D RK3036_HDMI) { + hdmi->grf =3D syscon_regmap_lookup_by_phandle(dev->of_node, "rockchip,gr= f"); + if (IS_ERR(hdmi->grf)) { + ret =3D dev_err_probe(dev, PTR_ERR(hdmi->grf), + "Unable to get rockchip,grf\n"); + goto err_disable_clk; + } + } + irq =3D platform_get_irq(pdev, 0); if (irq < 0) { ret =3D irq; @@ -988,11 +1020,13 @@ static void inno_hdmi_remove(struct platform_device = *pdev) } =20 static const struct inno_hdmi_variant rk3036_inno_hdmi_variant =3D { + .dev_type =3D RK3036_HDMI, .phy_configs =3D rk3036_hdmi_phy_configs, .default_phy_config =3D &rk3036_hdmi_phy_configs[1], }; =20 static const struct inno_hdmi_variant rk3128_inno_hdmi_variant =3D { + .dev_type =3D RK3128_HDMI, .phy_configs =3D rk3128_hdmi_phy_configs, .default_phy_config =3D &rk3128_hdmi_phy_configs[1], }; --=20 2.43.0