Skip to content

Commit a96eb42

Browse files
xubilvrkhuangtao
authored andcommitted
drm/rockchip: dw-mipi-dsi: support read lane-rate from dts
It is convenient for the client to manually adjust the value of lane rate. Change-Id: Ic6d8c4d235eacc8cb7540d172bd69c29c2b277dd Signed-off-by: xubilv <xbl@rock-chips.com>
1 parent d6dfcd0 commit a96eb42

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

drivers/gpu/drm/rockchip/dw-mipi-dsi.c

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,31 +537,50 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
537537
return ret;
538538
}
539539

540-
static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi)
540+
static int rockchip_dsi_calc_bandwidth(struct dw_mipi_dsi *dsi)
541541
{
542-
unsigned int i, pre;
543-
unsigned long mpclk, pllref, tmp;
544-
unsigned int m = 1, n = 1, target_mbps = 1000;
545-
unsigned int max_mbps = dptdin_map[ARRAY_SIZE(dptdin_map) - 1].max_mbps;
546542
int bpp;
543+
unsigned long mpclk, tmp;
544+
unsigned int target_mbps = 1000;
545+
unsigned int value;
546+
struct device_node *np = dsi->dev->of_node;
547+
unsigned int max_mbps = dptdin_map[ARRAY_SIZE(dptdin_map) - 1].max_mbps;
548+
int lanes;
549+
550+
/* optional override of the desired bandwidth */
551+
if (!of_property_read_u32(np, "rockchip,lane-rate", &value))
552+
return value;
547553

548554
bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
549555
if (bpp < 0) {
550556
dev_err(dsi->dev, "failed to get bpp for pixel format %d\n",
551557
dsi->format);
552-
return bpp;
558+
bpp = 24;
553559
}
554560

561+
lanes = dsi->lanes;
562+
555563
mpclk = DIV_ROUND_UP(dsi->mode.clock, MSEC_PER_SEC);
556564
if (mpclk) {
557565
/* take 1 / 0.9, since mbps must big than bandwidth of RGB */
558-
tmp = mpclk * (bpp / dsi->lanes) * 10 / 9;
566+
tmp = mpclk * (bpp / lanes) * 10 / 9;
559567
if (tmp < max_mbps)
560568
target_mbps = tmp;
561569
else
562570
dev_err(dsi->dev, "DPHY clock frequency is out of range\n");
563571
}
564572

573+
return target_mbps;
574+
}
575+
576+
static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi)
577+
{
578+
unsigned int i, pre;
579+
unsigned long pllref, tmp;
580+
unsigned int m = 1, n = 1, target_mbps;
581+
582+
target_mbps = rockchip_dsi_calc_bandwidth(dsi);
583+
565584
pllref = DIV_ROUND_UP(clk_get_rate(dsi->pllref_clk), USEC_PER_SEC);
566585
tmp = pllref;
567586

0 commit comments

Comments
 (0)