From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90CF860A263D for ; Tue, 1 Dec 2026 20:14:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=JWT+5Amr; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VsRIbfFL DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References: Message-Id:MIME-Version:Subject:Date:From:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=wx5r1KMtdhrXwNyFlnSGPEPxhhvozRceqdnGU4+PBQA=; b=JWT+5Amr5DvxqpmR46zcLfVdmF tnTyD/CCj2jbKA8bNWZO6MQNqi3GH6UbuKGsATDbo/Pac7EQZcwL7J4vVCeGLqrKGcal3OX76T2gh GhbIs35vc4LinGI891v7ehHJvYmSmtpkSn1UPxbJs4nvnhSrRcwRGbinDFejcsI/MhMpkTNqz/eEO nhiuOS2r04LQ24baZhl7q5pF/Z/3oS2OFsMEIsVU12FX1zapWHNlFNm2FxlmrjNa1ZqrGzdcJH+ux Ryy6yCvlw6i5RsVOW5+ArKSZu12tVULp+oqI57L1tmhkA+QYS/9UW7+DxaSIyjs7bAZPlZ5vWHcRh /hYh2Tvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYUEm-00000009K43-0Own; Tue, 01 Dec 2026 20:14:04 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYUEk-00000009K0q-1uZT; Tue, 01 Dec 2026 20:14:02 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 3585E40FE4; Tue, 1 Dec 2026 20:14:02 +0000 (UTC) Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796156041; b=TnLpFKW9C8iXpi5jIb01JcumcmABq2NnUjQBmg49QqLrekDrq8aHta0WrA394nBeihUb Uatu7PQwkFbk/dsTmOQKFGJZqDWwqXE9PXjMAy4TWeRggDozidaqxLohWzYpJnD7ncjV4 4vucc2CtiEuRlXUnUYoqqmRr7yaRbrDvocybXFkHt5ahK87Af1aSS43dLmK2FQnVMbmuL TIHiHSPlVGqmtKRgOoze0eRmQbk6o1OEhPKlYtH3/766BJbqQzuv2Bt/JaD4olYn+8WDD FahCyqVUjYLXAOJd8GqC+GLuT4tCHfbDYzIehS7SIfdseGVqmk+K2rSC/qtui+7J71w== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796156041; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=Jmj0DPDDKFvXFOMRCT0aoTFsmt441k003J2Ocrs54uk=; b=WWbgvk45No0jtAh76PHDluac+QILscM/KfVSJPwR8WSPX48/7XcfvllEHuk1ojWdfKR1 1F6Ne1OuiDzuQZHLvsy407bJXOGszTFco1GqX+5XI3BRjajrrsAyA/+LJ/VmFEASb88CA ja1geD2jP6zQNcrXXVvqPiHMnnQ6hlS+7BY0BgkzU61i6IGR+RM9bv5tcPcbAPV42K6rA dfvJdiRG7ky8gy9Wt9Cg0obAxZENx1FDarR5b/Gt9l8C1dgSo36DfLGCuFn/EL3ENVBxH R2PwYlzXn3WGs+MNuQRznfAz4BKDby4FLsIgvKO7zJ8GDPdkqF1aACxKIK2cujCHZMw== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 7D0F01F000C1; Tue, 1 Dec 2026 20:13:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796156041; bh=Jmj0DPDDKFvXFOMRCT0aoTFsmt441k003J2Ocrs54uk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=VsRIbfFLlkT7QNjzSQgBO2r2mwpT9aQs1fQPvGT6XokRUwfxPafeq1lc4dXaQO+qQ 0UvFbTp7V4p+Gg30/S2BwHOkVoe6ISpK9bv4Hs82uZi/bGRcyMS+VsUcHWxknP3LWE AsO1xEfk5EeEtG4/DNIeTADu7qCDIWOg3anosaCWwpOmv3wPiDrHoJKFd5qVV3OZyJ hXTtVfliMXKGK7t8l1exILeYnjGgDQdwcY64JtI2bWaOx5YgYnqkcqCsgxjNGN6jFR D1M4yBn6WJo20JqB+Zc4mTxVdUl0yknK8nR17Z77dfEzGSNTc7JqbW//HX8B725JLB anNo2JlQk3PGQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 93C544F08B; Tue, 1 Dec 2026 20:13:42 +0000 (UTC) From: Ronald Claveau via B4 Relay Date: Tue, 01 Dec 2026 21:12:57 +0100 Subject: [PATCH v6 09/13] drm/meson: dw-hdmi: Use the generic PHY framework for the HDMI TX PHY X-Archived-By: MIME-Version: 1.0 Message-Id: <20261201-meson-drm-create-hdmitx-phy-v6-9-5ccdf57a6cf5@aliel.fr> References: <20261201-meson-drm-create-hdmitx-phy-v6-0-5ccdf57a6cf5@aliel.fr> In-Reply-To: <20261201-meson-drm-create-hdmitx-phy-v6-0-5ccdf57a6cf5@aliel.fr> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Vinod Koul , Manivannan Sadhasivam , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Ulf Hansson Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, dri-devel@lists.freedesktop.org, Ronald Claveau , linux-pm@vger.kernel.org X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=16768; i=linux-kernel-dev@aliel.fr; h=from:subject:message-id; bh=2uq/x64YJkkdmSERtY1nWqdjFxoVwi4xfGmLD2wNkPM=; b=owGbwMvMwCWm1SvKXP3cUInxtFoSQza/VoZC7XdOG9He8C9pgTefxXx9Okvm1fIvAXr6c57vY PqesMS+o5SFQYyLQVZMkaV/ruWJd5ePnvm6Rz0FZg4rE8gQBi5OAZjI+khGhmsrS803TnzayH6Z XcPg+OcV/m5FH6M3d8wSuyl88O4D9wkM/xPyvrZfe6/1KK1c+uHpxXf2aHL1HUwX3rdg05pERc9 cNSYA X-Developer-Key: i=linux-kernel-dev@aliel.fr; a=openpgp; fpr=DFD863F61375BF917F0012173953305EF1D0EC3E X-Endpoint-Received: by B4 Relay for linux-kernel-dev@aliel.fr/default with auth_id=744 X-Original-From: Ronald Claveau X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: linux-kernel-dev@aliel.fr Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Ronald Claveau The HDMI TX PHY registers (HHI_HDMI_PHY_CNTL0..5) were programmed directly from this driver, with per-SoC tables selected by compatible string. A dedicated PHY driver now exists, so use it through the generic PHY API instead: - phy_init() replaces the initial CNTL0/CNTL1 programming, - phy_configure() replaces meson_hdmi_phy_setup_mode(), the TMDS character rate being derived from the (possibly 4:2:0 halved) pixel clock, with 8 bpc as before, - phy_power_on() replaces the three successive PHY resets, - phy_power_off() replaces the fallback to the initial state in dw_hdmi_phy_disable(). The "hdmi" PHY is looked up through the "phys" property of the HDMI TX node. Device trees that do not provide it keep working: in that case the PHY is created by this driver through meson_hdmi_phy_create_legacy(), using a per-SoC identifier replacing the former cntl0_init/cntl1_init fields, and a warning is printed. This fallback is deprecated and will be removed once all device trees have been converted. meson_dw_hdmi_init() can now fail, so propagate its return value from probe and resume. Select PHY_MESON_HDMI_TX in Kconfig since the driver now depends on it, including for the legacy path. Add a device link with hdmi-tx as consumer and vpu as supplier to get the correct order on suspend/resume. Move the atomic suspend/resume to the .prepare/.complete callbacks. This guarantees: suspend: power_off (prepare) -> phy_exit (suspend) resume : venc_init (resume) -> phy_init (resume) -> power_on (complete) The constraints are: - phy_exit() must come after phy_power_off(), which is done by the atomic disable in drm_mode_config_helper_suspend(). - phy_init() must come after meson_venc_init(), which writes 0 to HHI_HDMI_PHY_CNTL0 and would otherwise clobber the value programmed by phy_init() (bandgap on G12A). - phy_power_on() must come after phy_init(), otherwise the PHY core warns that it was called before phy_init. Signed-off-by: Ronald Claveau --- drivers/gpu/drm/meson/Kconfig | 1 + drivers/gpu/drm/meson/meson_drv.c | 16 ++- drivers/gpu/drm/meson/meson_dw_hdmi.c | 192 +++++++++++++--------------------- 3 files changed, 89 insertions(+), 120 deletions(-) diff --git a/drivers/gpu/drm/meson/Kconfig b/drivers/gpu/drm/meson/Kconfig index 6645665f6038..a91cf851314a 100644 --- a/drivers/gpu/drm/meson/Kconfig +++ b/drivers/gpu/drm/meson/Kconfig @@ -20,6 +20,7 @@ config DRM_MESON_DW_HDMI depends on PM default y if DRM_MESON select DRM_DW_HDMI + select PHY_MESON_HDMI_TX imply DRM_DW_HDMI_I2S_AUDIO config DRM_MESON_DW_MIPI_DSI diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c index 38bf2811d068..5343323f404a 100644 --- a/drivers/gpu/drm/meson/meson_drv.c +++ b/drivers/gpu/drm/meson/meson_drv.c @@ -422,7 +422,7 @@ static const struct component_master_ops meson_drv_master_ops = { .unbind = meson_drv_unbind, }; -static int __maybe_unused meson_drv_pm_suspend(struct device *dev) +static int meson_drv_pm_prepare(struct device *dev) { struct meson_drm *priv = dev_get_drvdata(dev); @@ -432,6 +432,14 @@ static int __maybe_unused meson_drv_pm_suspend(struct device *dev) return drm_mode_config_helper_suspend(priv->drm); } +static void meson_drv_pm_complete(struct device *dev) +{ + struct meson_drm *priv = dev_get_drvdata(dev); + + if (priv) + drm_mode_config_helper_resume(priv->drm); +} + static int __maybe_unused meson_drv_pm_resume(struct device *dev) { struct meson_drm *priv = dev_get_drvdata(dev); @@ -446,7 +454,7 @@ static int __maybe_unused meson_drv_pm_resume(struct device *dev) if (priv->afbcd.ops) priv->afbcd.ops->init(priv); - return drm_mode_config_helper_resume(priv->drm); + return 0; } static void meson_drv_shutdown(struct platform_device *pdev) @@ -553,7 +561,9 @@ static const struct of_device_id dt_match[] = { MODULE_DEVICE_TABLE(of, dt_match); static const struct dev_pm_ops meson_drv_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(meson_drv_pm_suspend, meson_drv_pm_resume) + .prepare = meson_drv_pm_prepare, + .complete = meson_drv_pm_complete, + SET_SYSTEM_SLEEP_PM_OPS(NULL, meson_drv_pm_resume) }; static struct platform_driver meson_drm_platform_driver = { diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index 20a821936b3a..ec21d13775b7 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include #include @@ -102,16 +104,6 @@ #define HDMITX_DWC_DATA_REG 0x14 #define HDMITX_DWC_CTRL_REG 0x18 -/* HHI Registers */ -#define HHI_HDMI_PHY_CNTL0 0x3a0 /* 0xe8 */ -#define HHI_HDMI_PHY_CNTL1 0x3a4 /* 0xe9 */ -#define PHY_CNTL1_INIT 0x03900000 -#define PHY_INVERT BIT(17) -#define HHI_HDMI_PHY_CNTL2 0x3a8 /* 0xea */ -#define HHI_HDMI_PHY_CNTL3 0x3ac /* 0xeb */ -#define HHI_HDMI_PHY_CNTL4 0x3b0 /* 0xec */ -#define HHI_HDMI_PHY_CNTL5 0x3b4 /* 0xed */ - static DEFINE_SPINLOCK(reg_lock); enum meson_venc_source { @@ -131,8 +123,7 @@ struct meson_dw_hdmi_data { unsigned int addr); void (*dwc_write)(struct meson_dw_hdmi *dw_hdmi, unsigned int addr, unsigned int data); - u32 cntl0_init; - u32 cntl1_init; + enum meson_hdmi_phy_soc phy_soc; /* legacy PHY only */ }; struct meson_dw_hdmi { @@ -147,6 +138,8 @@ struct meson_dw_hdmi { u32 irq_stat; struct dw_hdmi *hdmi; struct drm_bridge *bridge; + struct phy *phy; + bool legacy_phy; }; static inline int dw_hdmi_is_compatible(struct meson_dw_hdmi *dw_hdmi, @@ -273,87 +266,6 @@ static inline void dw_hdmi_g12a_dwc_write(struct meson_dw_hdmi *dw_hdmi, /* Bridge */ -/* Setup PHY bandwidth modes */ -static void meson_hdmi_phy_setup_mode(struct meson_dw_hdmi *dw_hdmi, - const struct drm_display_mode *mode, - bool mode_is_420) -{ - struct meson_drm *priv = dw_hdmi->priv; - unsigned int pixel_clock = mode->clock; - - /* For 420, pixel clock is half unlike venc clock */ - if (mode_is_420) pixel_clock /= 2; - - if (dw_hdmi_is_compatible(dw_hdmi, "amlogic,meson-gxl-dw-hdmi") || - dw_hdmi_is_compatible(dw_hdmi, "amlogic,meson-gxm-dw-hdmi")) { - if (pixel_clock >= 371250) { - /* 5.94Gbps, 3.7125Gbps */ - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0x333d3282); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL3, 0x2136315b); - } else if (pixel_clock >= 297000) { - /* 2.97Gbps */ - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0x33303382); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL3, 0x2036315b); - } else if (pixel_clock >= 148500) { - /* 1.485Gbps */ - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0x33303362); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL3, 0x2016315b); - } else { - /* 742.5Mbps, and below */ - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0x33604142); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL3, 0x0016315b); - } - } else if (dw_hdmi_is_compatible(dw_hdmi, - "amlogic,meson-gxbb-dw-hdmi")) { - if (pixel_clock >= 371250) { - /* 5.94Gbps, 3.7125Gbps */ - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0x33353245); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL3, 0x2100115b); - } else if (pixel_clock >= 297000) { - /* 2.97Gbps */ - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0x33634283); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL3, 0xb000115b); - } else { - /* 1.485Gbps, and below */ - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0x33632122); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL3, 0x2000115b); - } - } else if (dw_hdmi_is_compatible(dw_hdmi, - "amlogic,meson-g12a-dw-hdmi")) { - if (pixel_clock >= 371250) { - /* 5.94Gbps, 3.7125Gbps */ - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0x37eb65c4); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL3, 0x2ab0ff3b); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL5, 0x0000080b); - } else if (pixel_clock >= 297000) { - /* 2.97Gbps */ - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0x33eb6262); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL3, 0x2ab0ff3b); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL5, 0x00000003); - } else { - /* 1.485Gbps, and below */ - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0x33eb4242); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL3, 0x2ab0ff3b); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL5, 0x00000003); - } - } -} - -static inline void meson_dw_hdmi_phy_reset(struct meson_dw_hdmi *dw_hdmi) -{ - struct meson_drm *priv = dw_hdmi->priv; - - /* Enable and software reset */ - regmap_update_bits(priv->hhi, HHI_HDMI_PHY_CNTL1, 0xf, 0xf); - - mdelay(2); - - /* Enable and unreset */ - regmap_update_bits(priv->hhi, HHI_HDMI_PHY_CNTL1, 0xf, 0xe); - - mdelay(2); -} - static int dw_hdmi_phy_init(struct dw_hdmi *hdmi, void *data, const struct drm_display_info *display, const struct drm_display_mode *mode) @@ -364,6 +276,9 @@ static int dw_hdmi_phy_init(struct dw_hdmi *hdmi, void *data, unsigned int wr_clk = readl_relaxed(priv->io_base + _REG(VPU_HDMI_SETTING)); bool mode_is_420 = false; + unsigned int pixel_clock = mode->clock; + union phy_configure_opts opts = {}; + int ret; DRM_DEBUG_DRIVER("\"%s\" div%d\n", mode->name, mode->clock > 340000 ? 40 : 10); @@ -392,19 +307,22 @@ static int dw_hdmi_phy_init(struct dw_hdmi *hdmi, void *data, dw_hdmi->data->top_write(dw_hdmi, HDMITX_TOP_TMDS_CLK_PTTN_CNTL, 0x2); /* Setup PHY parameters */ - meson_hdmi_phy_setup_mode(dw_hdmi, mode, mode_is_420); - - /* Disable clock, fifo, fifo_wr */ - regmap_update_bits(priv->hhi, HHI_HDMI_PHY_CNTL1, 0xf, 0); + if (mode_is_420) + pixel_clock /= 2; + opts.hdmi.tmds_char_rate = (u64)pixel_clock * 1000; + opts.hdmi.bpc = 8; + ret = phy_configure(dw_hdmi->phy, &opts); + if (ret) + return ret; dw_hdmi_set_high_tmds_clock_ratio(hdmi, display); msleep(100); /* Reset PHY 3 times in a row */ - meson_dw_hdmi_phy_reset(dw_hdmi); - meson_dw_hdmi_phy_reset(dw_hdmi); - meson_dw_hdmi_phy_reset(dw_hdmi); + ret = phy_power_on(dw_hdmi->phy); + if (ret) + return ret; /* Temporary Disable VENC video stream */ if (priv->venc.hdmi_use_enci) @@ -443,13 +361,11 @@ static void dw_hdmi_phy_disable(struct dw_hdmi *hdmi, void *data) { struct meson_dw_hdmi *dw_hdmi = (struct meson_dw_hdmi *)data; - struct meson_drm *priv = dw_hdmi->priv; DRM_DEBUG_DRIVER("\n"); /* Fallback to init mode */ - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL1, dw_hdmi->data->cntl1_init); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, dw_hdmi->data->cntl0_init); + phy_power_off(dw_hdmi->phy); } static enum drm_connector_status dw_hdmi_read_hpd(struct dw_hdmi *hdmi, @@ -572,8 +488,7 @@ static const struct meson_dw_hdmi_data meson_dw_hdmi_gxbb_data = { .top_write = dw_hdmi_top_write, .dwc_read = dw_hdmi_dwc_read, .dwc_write = dw_hdmi_dwc_write, - .cntl0_init = 0x0, - .cntl1_init = PHY_CNTL1_INIT | PHY_INVERT, + .phy_soc = MESON_HDMI_PHY_GXBB, }; static const struct meson_dw_hdmi_data meson_dw_hdmi_gxl_data = { @@ -581,8 +496,7 @@ static const struct meson_dw_hdmi_data meson_dw_hdmi_gxl_data = { .top_write = dw_hdmi_top_write, .dwc_read = dw_hdmi_dwc_read, .dwc_write = dw_hdmi_dwc_write, - .cntl0_init = 0x0, - .cntl1_init = PHY_CNTL1_INIT, + .phy_soc = MESON_HDMI_PHY_GXL, }; static const struct meson_dw_hdmi_data meson_dw_hdmi_g12a_data = { @@ -590,13 +504,13 @@ static const struct meson_dw_hdmi_data meson_dw_hdmi_g12a_data = { .top_write = dw_hdmi_g12a_top_write, .dwc_read = dw_hdmi_g12a_dwc_read, .dwc_write = dw_hdmi_g12a_dwc_write, - .cntl0_init = 0x000b4242, /* Bandgap */ - .cntl1_init = PHY_CNTL1_INIT, + .phy_soc = MESON_HDMI_PHY_G12A, }; -static void meson_dw_hdmi_init(struct meson_dw_hdmi *meson_dw_hdmi) +static int meson_dw_hdmi_init(struct meson_dw_hdmi *meson_dw_hdmi) { struct meson_drm *priv = meson_dw_hdmi->priv; + int ret; /* Reset HDMITX APB & TX & PHY */ reset_control_reset(meson_dw_hdmi->hdmitx_apb); @@ -624,8 +538,9 @@ static void meson_dw_hdmi_init(struct meson_dw_hdmi *meson_dw_hdmi) meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_BIST_CNTL, BIT(12)); /* Setup PHY */ - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL1, meson_dw_hdmi->data->cntl1_init); - regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, meson_dw_hdmi->data->cntl0_init); + ret = phy_init(meson_dw_hdmi->phy); + if (ret) + return ret; /* Enable HDMI-TX Interrupt */ meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_INTR_STAT_CLR, @@ -634,6 +549,7 @@ static void meson_dw_hdmi_init(struct meson_dw_hdmi *meson_dw_hdmi) meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_INTR_MASKN, HDMITX_TOP_INTR_CORE); + return 0; } static void meson_disable_clk(void *data) @@ -664,10 +580,11 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master, { struct platform_device *pdev = to_platform_device(dev); const struct meson_dw_hdmi_data *match; + struct dw_hdmi_plat_data *dw_plat_data; struct meson_dw_hdmi *meson_dw_hdmi; + struct device_link *link; struct drm_device *drm = data; struct meson_drm *priv = drm->dev_private; - struct dw_hdmi_plat_data *dw_plat_data; int irq; int ret; @@ -746,7 +663,26 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master, return ret; } - meson_dw_hdmi_init(meson_dw_hdmi); + meson_dw_hdmi->phy = devm_phy_optional_get(dev, NULL); + if (IS_ERR(meson_dw_hdmi->phy)) + return dev_err_probe(dev, PTR_ERR(meson_dw_hdmi->phy), + "failed to get HDMI PHY\n"); + + if (!meson_dw_hdmi->phy) { + /* DEPRECATED: DT without "phys" */ + dev_warn(dev, "missing \"phys\", using legacy HDMI PHY\n"); + meson_dw_hdmi->phy = meson_hdmi_phy_create_legacy(dev, priv->hhi, + meson_dw_hdmi->data->phy_soc); + if (IS_ERR(meson_dw_hdmi->phy)) + return dev_err_probe(dev, PTR_ERR(meson_dw_hdmi->phy), + "failed to create legacy HDMI PHY\n"); + + meson_dw_hdmi->legacy_phy = true; + } + + ret = meson_dw_hdmi_init(meson_dw_hdmi); + if (ret) + return ret; /* Bridge / Connector */ @@ -767,14 +703,25 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master, platform_set_drvdata(pdev, meson_dw_hdmi); meson_dw_hdmi->hdmi = dw_hdmi_probe(pdev, &meson_dw_hdmi->dw_plat_data); - if (IS_ERR(meson_dw_hdmi->hdmi)) - return PTR_ERR(meson_dw_hdmi->hdmi); + if (IS_ERR(meson_dw_hdmi->hdmi)) { + ret = PTR_ERR(meson_dw_hdmi->hdmi); + goto err_hdmi_probe; + } meson_dw_hdmi->bridge = of_drm_find_and_get_bridge(pdev->dev.of_node); + link = device_link_add(dev, master, DL_FLAG_STATELESS); + if (!link) + dev_warn(dev, "failed to link DRM master (supplier) to HDMI (consumer)\n"); + DRM_DEBUG_DRIVER("HDMI controller initialized\n"); return 0; + +err_hdmi_probe: + phy_exit(meson_dw_hdmi->phy); + + return ret; } static void meson_dw_hdmi_unbind(struct device *dev, struct device *master, @@ -784,8 +731,14 @@ static void meson_dw_hdmi_unbind(struct device *dev, struct device *master, struct platform_device *pdev = to_platform_device(dev); int irq = platform_get_irq(pdev, 0); + device_link_remove(dev, master); /* (consumer, supplier) */ + devm_free_irq(dev, irq, meson_dw_hdmi); dw_hdmi_unbind(meson_dw_hdmi->hdmi); + + phy_exit(meson_dw_hdmi->phy); + if (meson_dw_hdmi->legacy_phy) + devm_phy_destroy(dev, meson_dw_hdmi->phy); drm_bridge_put(meson_dw_hdmi->bridge); } @@ -801,6 +754,8 @@ static int __maybe_unused meson_dw_hdmi_pm_suspend(struct device *dev) if (!meson_dw_hdmi) return 0; + phy_exit(meson_dw_hdmi->phy); + /* Reset TOP */ meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_SW_RESET, 0); @@ -811,11 +766,14 @@ static int __maybe_unused meson_dw_hdmi_pm_suspend(struct device *dev) static int __maybe_unused meson_dw_hdmi_pm_resume(struct device *dev) { struct meson_dw_hdmi *meson_dw_hdmi = dev_get_drvdata(dev); + int ret; if (!meson_dw_hdmi) return 0; - meson_dw_hdmi_init(meson_dw_hdmi); + ret = meson_dw_hdmi_init(meson_dw_hdmi); + if (ret) + return ret; dw_hdmi_resume(meson_dw_hdmi->hdmi); -- 2.56.1 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic