Skip to content

Commit 3accb8a

Browse files
6by9popcornmix
authored andcommitted
drm/vc4: Kick the core clock up during a mode change
Experimental commit to kick the core clock up during mode switching. This makes mode switching far more reliable, and mimics what the firmware does. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent 8bf4ba6 commit 3accb8a

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎arch/arm/boot/dts/bcm2711.dtsi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@
306306
};
307307

308308
hvs@7e400000 {
309+
clocks = <&firmware_clocks 4>;
309310
interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>;
310311
};
311312

‎drivers/gpu/drm/vc4/vc4_drv.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ struct vc4_hvs {
326326
void __iomem *regs;
327327
u32 __iomem *dlist;
328328

329+
struct clk *core_clk;
330+
329331
/* Memory manager for CRTCs to allocate space in the display
330332
* list. Units are dwords.
331333
*/

‎drivers/gpu/drm/vc4/vc4_hvs.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* each CRTC.
2020
*/
2121

22+
#include <linux/clk.h>
2223
#include <linux/component.h>
2324
#include <linux/platform_device.h>
2425

@@ -239,6 +240,12 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
239240
hvs->regset.regs = hvs_regs;
240241
hvs->regset.nregs = ARRAY_SIZE(hvs_regs);
241242

243+
hvs->core_clk = devm_clk_get(&pdev->dev, NULL);
244+
if (IS_ERR(hvs->core_clk)) {
245+
dev_err(&pdev->dev, "Couldn't get core clock\n");
246+
return PTR_ERR(hvs->regs);
247+
}
248+
242249
hvs_version = readl(hvs->regs + SCALER_DISPLSTAT) >> 24;
243250
if (hvs_version >= 0x40)
244251
hvs->hvs5 = true;

‎drivers/gpu/drm/vc4/vc4_kms.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <linux/bitfield.h>
1515
#include <linux/bitops.h>
16+
#include <linux/clk.h>
1617

1718
#include <drm/drm_atomic.h>
1819
#include <drm/drm_atomic_helper.h>
@@ -222,6 +223,7 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)
222223
{
223224
struct drm_device *dev = state->dev;
224225
struct vc4_dev *vc4 = to_vc4_dev(dev);
226+
struct vc4_hvs *hvs = vc4->hvs;
225227
struct vc4_crtc *vc4_crtc;
226228
int i;
227229

@@ -237,6 +239,8 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)
237239
vc4_hvs_mask_underrun(dev, vc4_crtc_state->assigned_channel);
238240
}
239241

242+
clk_set_rate(hvs->core_clk, 500000000);
243+
240244
drm_atomic_helper_wait_for_fences(dev, state, false);
241245

242246
drm_atomic_helper_wait_for_dependencies(state);
@@ -262,6 +266,8 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)
262266

263267
drm_atomic_helper_commit_cleanup_done(state);
264268

269+
clk_set_rate(hvs->core_clk, 200000000);
270+
265271
drm_atomic_state_put(state);
266272

267273
up(&vc4->async_modeset);

0 commit comments

Comments
 (0)