1 From 740955399f42caa6406761975656b8aa5b88a39c Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Thu, 25 Nov 2021 14:46:55 +0000
4 Subject: [PATCH] drm/vc4: Move HDMI reset to pm_resume
6 Pi0-3 have power domains attached to the pm_runtime hooks
7 for the HDMI block. Initialisation done in the reset called
8 from bind is therefore lost if all users of the domain are
10 The VEC shares the same lowest level clock/power gating as
11 the HDMI block, so whilst that is enabled the block is never
12 actually powered down, but if it isn't enabled then we lose
15 Reset and initialise the HDMI block from pm_resume.
17 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
19 drivers/gpu/drm/vc4/vc4_hdmi.c | 61 ++++++++++++++++++-----------
20 drivers/gpu/drm/vc4/vc4_hdmi_regs.h | 4 +-
21 2 files changed, 41 insertions(+), 24 deletions(-)
23 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
24 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
25 @@ -2193,7 +2193,6 @@ static int vc4_hdmi_cec_init(struct vc4_
26 struct platform_device *pdev = vc4_hdmi->pdev;
27 struct device *dev = &pdev->dev;
32 if (!of_find_property(dev->of_node, "interrupts", NULL)) {
33 @@ -2213,15 +2212,6 @@ static int vc4_hdmi_cec_init(struct vc4_
34 cec_fill_conn_info_from_drm(&conn_info, &vc4_hdmi->connector);
35 cec_s_conn_info(vc4_hdmi->cec_adap, &conn_info);
37 - spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
38 - value = HDMI_READ(HDMI_CEC_CNTRL_1);
39 - /* Set the logical address to Unregistered */
40 - value |= VC4_HDMI_CEC_ADDR_MASK;
41 - HDMI_WRITE(HDMI_CEC_CNTRL_1, value);
42 - spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
44 - vc4_hdmi_cec_update_clk_div(vc4_hdmi);
46 if (vc4_hdmi->variant->external_irq_controller) {
47 ret = request_threaded_irq(platform_get_irq_byname(pdev, "cec-rx"),
48 vc4_cec_irq_handler_rx_bare,
49 @@ -2284,6 +2274,29 @@ static void vc4_hdmi_cec_exit(struct vc4
51 cec_unregister_adapter(vc4_hdmi->cec_adap);
54 +static int vc4_hdmi_cec_resume(struct vc4_hdmi *vc4_hdmi)
56 + unsigned long flags;
59 + spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
60 + value = HDMI_READ(HDMI_CEC_CNTRL_1);
61 + /* Set the logical address to Unregistered */
62 + value |= VC4_HDMI_CEC_ADDR_MASK;
63 + HDMI_WRITE(HDMI_CEC_CNTRL_1, value);
64 + spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
66 + vc4_hdmi_cec_update_clk_div(vc4_hdmi);
68 + if (!vc4_hdmi->variant->external_irq_controller) {
69 + spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
70 + HDMI_WRITE(HDMI_CEC_CPU_MASK_SET, 0xffffffff);
71 + spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
77 static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
79 @@ -2292,6 +2305,10 @@ static int vc4_hdmi_cec_init(struct vc4_
81 static void vc4_hdmi_cec_exit(struct vc4_hdmi *vc4_hdmi) {};
83 +static void vc4_hdmi_cec_resume(struct vc4_hdmi *vc4_hdmi)
89 static int vc4_hdmi_build_regset(struct vc4_hdmi *vc4_hdmi,
90 @@ -2526,6 +2543,15 @@ static int vc4_hdmi_runtime_resume(struc
94 + if (vc4_hdmi->variant->reset)
95 + vc4_hdmi->variant->reset(vc4_hdmi);
97 + ret = vc4_hdmi_cec_resume(vc4_hdmi);
99 + clk_disable_unprepare(vc4_hdmi->hsm_clock);
106 --- a/drivers/gpu/drm/vc4/vc4_hdmi_regs.h
107 +++ b/drivers/gpu/drm/vc4/vc4_hdmi_regs.h
108 @@ -417,7 +417,7 @@ static inline u32 vc4_hdmi_read(struct v
109 const struct vc4_hdmi_variant *variant = hdmi->variant;
112 - WARN_ON(!pm_runtime_active(&hdmi->pdev->dev));
113 + WARN_ON(pm_runtime_status_suspended(&hdmi->pdev->dev));
115 if (reg >= variant->num_registers) {
116 dev_warn(&hdmi->pdev->dev,
117 @@ -447,7 +447,7 @@ static inline void vc4_hdmi_write(struct
119 lockdep_assert_held(&hdmi->hw_lock);
121 - WARN_ON(!pm_runtime_active(&hdmi->pdev->dev));
122 + WARN_ON(pm_runtime_status_suspended(&hdmi->pdev->dev));
124 if (reg >= variant->num_registers) {
125 dev_warn(&hdmi->pdev->dev,