Skip to content

drm/vc4: Set a default HSM rate #4547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion drivers/gpu/drm/vc4/vc4_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
# define VC4_HD_M_SW_RST BIT(2)
# define VC4_HD_M_ENABLE BIT(0)

#define HSM_MIN_CLOCK_FREQ 120000000
#define CEC_CLOCK_FREQ 40000
#define HDMI_14_MAX_TMDS_CLK (340 * 1000 * 1000)

Expand Down Expand Up @@ -1192,7 +1193,7 @@ static u32 vc5_hdmi_calc_hsm_clock(struct vc4_hdmi *vc4_hdmi, unsigned long pixe
* pixel clock, but HSM ends up being the limiting factor.
*/

return max_t(unsigned long, 120000000, (pixel_rate / 100) * 101);
return max_t(unsigned long, HSM_MIN_CLOCK_FREQ, (pixel_rate / 100) * 101);
}

static u32 vc4_hdmi_channel_map(struct vc4_hdmi *vc4_hdmi, u32 channel_mask)
Expand Down Expand Up @@ -2317,6 +2318,32 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
vc4_hdmi->disable_4kp60 = true;
}

/*
* If we boot without any cable connected to the HDMI connector,
* the firmware will skip the HSM initialization and leave it
* with a rate of 0, resulting in a bus lockup when we're
* accessing the registers even if it's enabled.
*
* Let's put a sensible default at runtime_resume so that we
* don't end up in this situation.
*
* Strictly speaking we should be using clk_set_min_rate.
* However, the clk-bcm2835 clock driver favors clock rates
* under the expected rate, which in the case where we set the
* minimum clock rate will be rejected by the clock framework.
*
* However, even for the two HDMI controllers found on the
* BCM2711, using clk_set_rate doesn't cause any issue. Indeed,
* the bind callbacks are called in sequence, and before the DRM
* device is registered and therefore a mode is set. As such,
* we're not at risk of having the first controller set a
* different mode and then the second overriding the HSM clock
* frequency in its bind.
*/
ret = clk_set_rate(vc4_hdmi->hsm_clock, HSM_MIN_CLOCK_FREQ);
if (ret)
goto err_put_ddc;

/*
* We need to have the device powered up at this point to call
* our reset hook and for the CEC init.
Expand Down