Skip to content

Commit 542acfe

Browse files
mripardbebarino
authored andcommitted
clk: bcm: rpi: Set a default minimum rate
The M2MC clock provides the state machine clock for both HDMI controllers. However, if no HDMI monitor is plugged in at boot, its clock rate will be left at 0 by the firmware and will make any register access end up in a CPU stall, even though the clock was enabled. We had some code in the HDMI controller to deal with this before, but it makes more sense to have it in the clock driver. Move it there. Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 12c90f3 commit 542acfe

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/clk/bcm/clk-raspberrypi.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ struct raspberrypi_clk_data {
7676
struct raspberrypi_clk_variant {
7777
bool export;
7878
char *clkdev;
79+
unsigned long min_rate;
7980
};
8081

8182
static struct raspberrypi_clk_variant
@@ -89,6 +90,18 @@ raspberrypi_clk_variants[RPI_FIRMWARE_NUM_CLK_ID] = {
8990
},
9091
[RPI_FIRMWARE_M2MC_CLK_ID] = {
9192
.export = true,
93+
94+
/*
95+
* If we boot without any cable connected to any of the
96+
* HDMI connector, the firmware will skip the HSM
97+
* initialization and leave it with a rate of 0,
98+
* resulting in a bus lockup when we're accessing the
99+
* registers even if it's enabled.
100+
*
101+
* Let's put a sensible default so that we don't end up
102+
* in this situation.
103+
*/
104+
.min_rate = 120000000,
92105
},
93106
[RPI_FIRMWARE_V3D_CLK_ID] = {
94107
.export = true,
@@ -267,6 +280,19 @@ static struct clk_hw *raspberrypi_clk_register(struct raspberrypi_clk *rpi,
267280
}
268281
}
269282

283+
if (variant->min_rate) {
284+
unsigned long rate;
285+
286+
clk_hw_set_rate_range(&data->hw, variant->min_rate, max_rate);
287+
288+
rate = raspberrypi_fw_get_rate(&data->hw, 0);
289+
if (rate < variant->min_rate) {
290+
ret = raspberrypi_fw_set_rate(&data->hw, variant->min_rate, 0);
291+
if (ret)
292+
return ERR_PTR(ret);
293+
}
294+
}
295+
270296
return &data->hw;
271297
}
272298

0 commit comments

Comments
 (0)