Skip to content

Commit 203f704

Browse files
kFYatekpelwell
authored andcommitted
drm/vc4: Separate VEC compatible variants
The VEC's DAC on BCM2711 is slightly different compared to the one on BCM283x and needs different configuration. In particular, bit 3 (mask 0x8) switches the BCM2711 DAC input to "self-test input data", which makes the output unusable. Separating two compatible variants in devicetrees and the DRM driver was therefore necessary. The configurations used for both variants have been borrowed from Raspberry Pi (model 3B for BCM283x, 4B for BCM2711) firmware defaults. Signed-off-by: Mateusz Kwiatkowski <kfyatek+publicgit@gmail.com>
1 parent faa7e3f commit 203f704

3 files changed

Lines changed: 26 additions & 7 deletions

File tree

‎Documentation/devicetree/bindings/display/brcm,bcm2835-vec.yaml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ maintainers:
1111

1212
properties:
1313
compatible:
14-
const: brcm,bcm2835-vec
14+
enum:
15+
- brcm,bcm2835-vec
16+
- brcm,bcm2711-vec
1517

1618
reg:
1719
maxItems: 1

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@
301301
};
302302

303303
vec: vec@7ec13000 {
304-
compatible = "brcm,bcm2835-vec";
304+
compatible = "brcm,bcm2711-vec";
305305
reg = <0x7ec13000 0x1000>;
306306
clocks = <&clocks BCM2835_CLOCK_VEC>;
307307
interrupts = <2 27>;

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,14 @@
154154
#define VEC_DAC_MISC_DAC_RST_N BIT(0)
155155

156156

157+
struct vc4_vec_variant {
158+
u32 dac_config;
159+
};
160+
157161
/* General VEC hardware state. */
158162
struct vc4_vec {
159163
struct platform_device *pdev;
164+
const struct vc4_vec_variant *variant;
160165

161166
struct drm_encoder *encoder;
162167
struct drm_connector *connector;
@@ -451,10 +456,7 @@ static void vc4_vec_encoder_enable(struct drm_encoder *encoder)
451456
VEC_WRITE(VEC_CONFIG2,
452457
VEC_CONFIG2_UV_DIG_DIS | VEC_CONFIG2_RGB_DIG_DIS);
453458
VEC_WRITE(VEC_CONFIG3, VEC_CONFIG3_HORIZ_LEN_STD);
454-
VEC_WRITE(VEC_DAC_CONFIG,
455-
VEC_DAC_CONFIG_DAC_CTRL(0xc) |
456-
VEC_DAC_CONFIG_DRIVER_CTRL(0xc) |
457-
VEC_DAC_CONFIG_LDO_BIAS_CTRL(0x46));
459+
VEC_WRITE(VEC_DAC_CONFIG, vec->variant->dac_config);
458460

459461
/* Mask all interrupts. */
460462
VEC_WRITE(VEC_MASK0, 0);
@@ -507,8 +509,21 @@ static const struct drm_encoder_helper_funcs vc4_vec_encoder_helper_funcs = {
507509
.atomic_mode_set = vc4_vec_encoder_atomic_mode_set,
508510
};
509511

512+
static const struct vc4_vec_variant bcm2835_vec_variant = {
513+
.dac_config = VEC_DAC_CONFIG_DAC_CTRL(0xc) |
514+
VEC_DAC_CONFIG_DRIVER_CTRL(0xc) |
515+
VEC_DAC_CONFIG_LDO_BIAS_CTRL(0x46)
516+
};
517+
518+
static const struct vc4_vec_variant bcm2711_vec_variant = {
519+
.dac_config = VEC_DAC_CONFIG_DAC_CTRL(0x0) |
520+
VEC_DAC_CONFIG_DRIVER_CTRL(0x80) |
521+
VEC_DAC_CONFIG_LDO_BIAS_CTRL(0x61)
522+
};
523+
510524
static const struct of_device_id vc4_vec_dt_match[] = {
511-
{ .compatible = "brcm,bcm2835-vec", .data = NULL },
525+
{ .compatible = "brcm,bcm2835-vec", .data = &bcm2835_vec_variant },
526+
{ .compatible = "brcm,bcm2711-vec", .data = &bcm2711_vec_variant },
512527
{ /* sentinel */ },
513528
};
514529

@@ -546,6 +561,8 @@ static int vc4_vec_bind(struct device *dev, struct device *master, void *data)
546561
vec->encoder = &vc4_vec_encoder->base.base;
547562

548563
vec->pdev = pdev;
564+
vec->variant = (const struct vc4_vec_variant *)
565+
of_device_get_match_data(dev);
549566
vec->regs = vc4_ioremap_regs(pdev, 0);
550567
if (IS_ERR(vec->regs))
551568
return PTR_ERR(vec->regs);

0 commit comments

Comments
 (0)