Skip to content

Commit 4853b9c

Browse files
Yannick FertrePatrice Chotard
authored andcommitted
video: stm32: dsi: fix pll settings
The DSI_WRPCR1 register contains the odf field, set between 0 and 3. It also fixes the channel data rate, which is higher than 20% only with devices that support burst mode. Change-Id: I3fcfe549e9bd6cd12eeaf29325e237172c82b87b Signed-off-by: Yannick Fertre <yannick.fertre@foss.st.com> Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/u-boot/+/449334 ACI: CITOOLS <MDG-smet-aci-reviews@list.st.com> ACI: CIBUILD <MDG-smet-aci-builds@list.st.com> Reviewed-by: Patrice CHOTARD <patrice.chotard@foss.st.com>
1 parent 5afb725 commit 4853b9c

1 file changed

Lines changed: 22 additions & 25 deletions

File tree

drivers/video/stm32/stm32_dsi.c

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,11 @@ static int dsi_get_lane_mbps(void *priv_data, struct display_timing *timings,
337337
/* Compute requested pll out */
338338
bpp = mipi_dsi_pixel_format_to_bpp(format);
339339
pll_out_khz = (timings->pixelclock.typ / 1000) * bpp / lanes;
340+
340341
/* Add 20% to pll out to be higher than pixel bw (burst mode only) */
341-
pll_out_khz = (pll_out_khz * 12) / 10;
342+
if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST)
343+
pll_out_khz = (pll_out_khz * 12) / 10;
344+
342345
if (pll_out_khz > dsi->lane_max_kbps) {
343346
pll_out_khz = dsi->lane_max_kbps;
344347
dev_warn(dev, "Warning max phy mbps is used\n");
@@ -622,25 +625,20 @@ static int dsi_phy_141_init(void *priv_data)
622625

623626
/* find frequency mapping */
624627
for (i = 0; i < ARRAY_SIZE(dppa_map_phy_141); i++) {
625-
if (dsi->lane_mbps < dppa_map_phy_141[i].data_rate) {
626-
i--;
628+
if (dsi->lane_mbps < dppa_map_phy_141[i].data_rate)
627629
break;
628-
}
629630
}
630631

632+
/* ODF: Output division factor */
631633
switch (dppa_map_phy_141[i].odf) {
632634
case(3):
633-
odf = 8;
634-
break;
635+
odf = 8; break;
635636
case(2):
636-
odf = 4;
637-
break;
637+
odf = 4; break;
638638
case(1):
639-
odf = 2;
640-
break;
639+
odf = 2; break;
641640
default:
642-
odf = 1;
643-
break;
641+
odf = 1; break;
644642
}
645643

646644
dsi_phy_141_pll_get_params(dsi, pll_in_khz, pll_out_khz, &idf, &ndiv, &odf);
@@ -661,7 +659,8 @@ static int dsi_phy_141_init(void *priv_data)
661659
val = ((ndiv - 2) << 4) | (idf - 1);
662660
dsi_write(dsi, DSI_WRPCR0, val);
663661

664-
val = ((odf - 1) << 28) | (vco << 24) | (bias << 16) | (int1 << 8) | (gmp << 6) | prop;
662+
val = (dppa_map_phy_141[i].odf << 28) | (vco << 24) | (bias << 16) | (int1 << 8) |
663+
(gmp << 6) | prop;
665664
dsi_write(dsi, DSI_WRPCR1, val);
666665

667666
dsi_write(dsi, DSI_PCTLR, PCTLR_CKEN);
@@ -730,8 +729,11 @@ static int dsi_phy_141_get_lane_mbps(void *priv_data, struct display_timing *tim
730729
/* Compute requested pll out */
731730
bpp = mipi_dsi_pixel_format_to_bpp(format);
732731
pll_out_khz = (timings->pixelclock.typ / 1000) * bpp / (lanes * 2);
732+
733733
/* Add 20% to pll out to be higher than pixel bw (burst mode only) */
734-
pll_out_khz = (pll_out_khz * 12) / 10;
734+
if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST)
735+
pll_out_khz = (pll_out_khz * 12) / 10;
736+
735737
if (pll_out_khz > dsi->lane_max_kbps) {
736738
pll_out_khz = dsi->lane_max_kbps;
737739
dev_warn(dev, "Warning max phy mbps is used\n");
@@ -743,25 +745,20 @@ static int dsi_phy_141_get_lane_mbps(void *priv_data, struct display_timing *tim
743745

744746
/* find frequency mapping */
745747
for (i = 0; i < ARRAY_SIZE(dppa_map_phy_141); i++) {
746-
if (dsi->lane_mbps < dppa_map_phy_141[i].data_rate) {
747-
i--;
748+
if (dsi->lane_mbps < dppa_map_phy_141[i].data_rate)
748749
break;
749-
}
750750
}
751751

752+
/* ODF: Output division factor */
752753
switch (dppa_map_phy_141[i].odf) {
753754
case(3):
754-
odf = 8;
755-
break;
755+
odf = 8; break;
756756
case(2):
757-
odf = 4;
758-
break;
757+
odf = 4; break;
759758
case(1):
760-
odf = 2;
761-
break;
759+
odf = 2; break;
762760
default:
763-
odf = 1;
764-
break;
761+
odf = 1; break;
765762
}
766763

767764
dsi_phy_141_pll_get_params(dsi, pll_in_khz, pll_out_khz, &idf, &ndiv, &odf);

0 commit comments

Comments
 (0)