Skip to content

Commit 770c4e9

Browse files
mripardpopcornmix
authored andcommitted
drm/vc4: hdmi: Add PHY init and disable function
The HDMI PHY in the BCM2711 HDMI controller is significantly more complicated to setup than in the older BCM283x SoCs. Let's add hooks to enable and disable the PHY. Signed-off-by: Maxime Ripard <maxime@cerno.tech>
1 parent 5bdbf65 commit 770c4e9

4 files changed

Lines changed: 46 additions & 7 deletions

File tree

‎drivers/gpu/drm/vc4/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ vc4-y := \
1313
vc4_kms.o \
1414
vc4_gem.o \
1515
vc4_hdmi.o \
16+
vc4_hdmi_phy.o \
1617
vc4_vec.o \
1718
vc4_hvs.o \
1819
vc4_irq.o \

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,9 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder)
321321

322322
HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, 0);
323323

324-
HDMI_WRITE(HDMI_TX_PHY_RESET_CTL, 0xf << 16);
324+
if (vc4_hdmi->variant->phy_disable)
325+
vc4_hdmi->variant->phy_disable(vc4_hdmi);
326+
325327
HDMI_WRITE(HDMI_VID_CTL,
326328
HDMI_READ(HDMI_VID_CTL) & ~VC4_HD_VID_CTL_ENABLE);
327329

@@ -381,12 +383,8 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)
381383
if (vc4_hdmi->variant->reset)
382384
vc4_hdmi->variant->reset(vc4_hdmi);
383385

384-
/* PHY should be in reset, like
385-
* vc4_hdmi_encoder_disable() does.
386-
*/
387-
HDMI_WRITE(HDMI_TX_PHY_RESET_CTL, 0xf << 16);
388-
389-
HDMI_WRITE(HDMI_TX_PHY_RESET_CTL, 0);
386+
if (vc4_hdmi->variant->phy_init)
387+
vc4_hdmi->variant->phy_init(vc4_hdmi, mode);
390388

391389
if (debug_dump_regs) {
392390
struct drm_printer p = drm_info_printer(&vc4_hdmi->pdev->dev);
@@ -1413,6 +1411,8 @@ static const struct vc4_hdmi_variant bcm2835_variant = {
14131411

14141412
.init_resources = vc4_hdmi_init_resources,
14151413
.reset = vc4_hdmi_reset,
1414+
.phy_init = vc4_hdmi_phy_init,
1415+
.phy_disable = vc4_hdmi_phy_disable,
14161416
};
14171417

14181418
static const struct of_device_id vc4_hdmi_dt_match[] = {

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ to_vc4_hdmi_encoder(struct drm_encoder *encoder)
2121
return container_of(encoder, struct vc4_hdmi_encoder, base.base);
2222
}
2323

24+
struct drm_display_mode;
25+
2426
struct vc4_hdmi;
2527
struct vc4_hdmi_register;
2628

@@ -38,6 +40,13 @@ struct vc4_hdmi_variant {
3840

3941
/* Callback to reset the HDMI block */
4042
void (*reset)(struct vc4_hdmi *vc4_hdmi);
43+
44+
/* Callback to initialize the PHY according to the mode */
45+
void (*phy_init)(struct vc4_hdmi *vc4_hdmi,
46+
struct drm_display_mode *mode);
47+
48+
/* Callback to disable the PHY */
49+
void (*phy_disable)(struct vc4_hdmi *vc4_hdmi);
4150
};
4251

4352
/* HDMI audio information */
@@ -95,4 +104,8 @@ encoder_to_vc4_hdmi(struct drm_encoder *encoder)
95104
return container_of(_encoder, struct vc4_hdmi, encoder);
96105
}
97106

107+
void vc4_hdmi_phy_init(struct vc4_hdmi *vc4_hdmi,
108+
struct drm_display_mode *mode);
109+
void vc4_hdmi_phy_disable(struct vc4_hdmi *vc4_hdmi);
110+
98111
#endif /* _VC4_HDMI_H_ */

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (C) 2015 Broadcom
4+
* Copyright (c) 2014 The Linux Foundation. All rights reserved.
5+
* Copyright (C) 2013 Red Hat
6+
* Author: Rob Clark <robdclark@gmail.com>
7+
*/
8+
9+
#include "vc4_hdmi.h"
10+
#include "vc4_hdmi_regs.h"
11+
12+
void vc4_hdmi_phy_init(struct vc4_hdmi *vc4_hdmi, struct drm_display_mode *mode)
13+
{
14+
/* PHY should be in reset, like
15+
* vc4_hdmi_encoder_disable() does.
16+
*/
17+
18+
HDMI_WRITE(HDMI_TX_PHY_RESET_CTL, 0xf << 16);
19+
HDMI_WRITE(HDMI_TX_PHY_RESET_CTL, 0);
20+
}
21+
22+
void vc4_hdmi_phy_disable(struct vc4_hdmi *vc4_hdmi)
23+
{
24+
HDMI_WRITE(HDMI_TX_PHY_RESET_CTL, 0xf << 16);
25+
}

0 commit comments

Comments
 (0)