From: Ronald Claveau <[email protected]>

meson_dw_hdmi_init() programs two HHI registers by hand: the HDMI clock
mux/divider/gate (HHI_HDMI_CLK_CNTL) and the HDMITX memory power-down
bits (HHI_MEM_PD_REG0). Both are already covered by resources described
in the DT:

 - the HDMI clock is selected and rated through assigned-clocks
   (CLKID_HDMI_SEL parented to xtal, CLKID_HDMI at 24 MHz), and gated
   through the "isfr" clock, which the driver already enables at bind
   time;
 - the memory power-down bits are handled by the VPU power domain
   referenced by "power-domains".

Remove the open-coded register writes. Take an explicit runtime PM
reference in probe and release it on removal, so that the domain is
guaranteed to be on for the lifetime of the device.

Signed-off-by: Ronald Claveau <[email protected]>
---
 drivers/gpu/drm/meson/meson_dw_hdmi.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c 
b/drivers/gpu/drm/meson/meson_dw_hdmi.c
index eb33c70f29c3..20a821936b3a 100644
--- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
@@ -12,6 +12,7 @@
 #include <linux/of.h>
 #include <linux/of_graph.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
 #include <linux/reset.h>
 
@@ -102,8 +103,6 @@
 #define HDMITX_DWC_CTRL_REG    0x18
 
 /* HHI Registers */
-#define HHI_MEM_PD_REG0                0x100 /* 0x40 */
-#define HHI_HDMI_CLK_CNTL      0x1cc /* 0x73 */
 #define HHI_HDMI_PHY_CNTL0     0x3a0 /* 0xe8 */
 #define HHI_HDMI_PHY_CNTL1     0x3a4 /* 0xe9 */
 #define  PHY_CNTL1_INIT                0x03900000
@@ -599,12 +598,6 @@ static void meson_dw_hdmi_init(struct meson_dw_hdmi 
*meson_dw_hdmi)
 {
        struct meson_drm *priv = meson_dw_hdmi->priv;
 
-       /* Enable clocks */
-       regmap_update_bits(priv->hhi, HHI_HDMI_CLK_CNTL, 0xffff, 0x100);
-
-       /* Bring HDMITX MEM output of power down */
-       regmap_update_bits(priv->hhi, HHI_MEM_PD_REG0, 0xff << 8, 0);
-
        /* Reset HDMITX APB & TX & PHY */
        reset_control_reset(meson_dw_hdmi->hdmitx_apb);
        reset_control_reset(meson_dw_hdmi->hdmitx_ctrl);
@@ -829,9 +822,29 @@ static int __maybe_unused meson_dw_hdmi_pm_resume(struct 
device *dev)
        return 0;
 }
 
+static void meson_dw_hdmi_pm_put(void *dev)
+{
+       pm_runtime_put_sync(dev);
+}
+
 static int meson_dw_hdmi_probe(struct platform_device *pdev)
 {
-       return component_add(&pdev->dev, &meson_dw_hdmi_ops);
+       struct device *dev = &pdev->dev;
+       int ret;
+
+       ret = devm_pm_runtime_enable(dev);
+       if (ret)
+               return ret;
+
+       ret = pm_runtime_resume_and_get(dev);
+       if (ret)
+               return dev_err_probe(dev, ret, "Failed to power on HDMI TX\n");
+
+       ret = devm_add_action_or_reset(dev, meson_dw_hdmi_pm_put, dev);
+       if (ret)
+               return ret;
+
+       return component_add(dev, &meson_dw_hdmi_ops);
 }
 
 static void meson_dw_hdmi_remove(struct platform_device *pdev)

-- 
2.43.0


Reply via email to