diff options
author | Hung-Te Lin <hungte@chromium.org> | 2019-08-08 06:28:43 +0800 |
---|---|---|
committer | Julius Werner <jwerner@chromium.org> | 2019-08-13 02:37:18 +0000 |
commit | 302dddf0f48acce1c00ae04606b0bf56c7da3f9d (patch) | |
tree | fb96c4bdf5e7ef7724763a49af01d1513d07e95a /src/soc/mediatek/common | |
parent | 61e346624a2c8b7e3de5313f2f4bfa2d4359e660 (diff) | |
download | coreboot-302dddf0f48acce1c00ae04606b0bf56c7da3f9d.tar.xz |
soc/mediatek: dsi: Refactor MIPI TX configuration
The only platform-specific difference in mtk_dsi_phy_clk_setting is how
to configure MIPI TX because those registers (and logic) are quite
different across different SOCs.
The calculation of data rate is actually the same so we should isolate
it and move to common, and rename mtk_dsi_phy_clk_setting to a better
name as mtk_dsi_configure_mipi_tx.
BUG=b:80501386,b:117254947
TEST=make -j # board = oak and boots
Change-Id: I894dc2c4c053267debf5a58313b2bb489bcf5f3a
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34784
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/soc/mediatek/common')
-rw-r--r-- | src/soc/mediatek/common/dsi.c | 31 | ||||
-rw-r--r-- | src/soc/mediatek/common/include/soc/dsi_common.h | 4 |
2 files changed, 30 insertions, 5 deletions
diff --git a/src/soc/mediatek/common/dsi.c b/src/soc/mediatek/common/dsi.c index 92a645682e..12d536b497 100644 --- a/src/soc/mediatek/common/dsi.c +++ b/src/soc/mediatek/common/dsi.c @@ -37,6 +37,33 @@ static unsigned int mtk_dsi_get_bits_per_pixel(u32 format) return 24; } +static int mtk_dsi_get_data_rate(u32 bits_per_pixel, u32 lanes, + const struct edid *edid) +{ + /* data_rate = pixel_clock * bits_per_pixel * mipi_ratio / lanes + * Note pixel_clock comes in kHz and returned data_rate is in Mbps. + * mipi_ratio is the clk coefficient to balance the pixel clk in MIPI + * for older platforms which do not have complete implementation in HFP. + * Newer platforms should just set that to 1.0 (100 / 100). + */ + int data_rate = (u64)edid->mode.pixel_clock * bits_per_pixel * + MTK_DSI_MIPI_RATIO_NUMERATOR / + (1000 * lanes * MTK_DSI_MIPI_RATIO_DENOMINATOR); + printk(BIOS_INFO, "DSI data_rate: %d Mbps\n", data_rate); + + if (data_rate < MTK_DSI_DATA_RATE_MIN_MHZ) { + printk(BIOS_ERR, "data rate (%dMbps) must be >=%dMbps. " + "Please check the pixel clock (%u), bits per pixel(%u), " + "mipi_ratio (%d%%) and number of lanes (%d)\n", + data_rate, MTK_DSI_DATA_RATE_MIN_MHZ, + edid->mode.pixel_clock, bits_per_pixel, + (100 * MTK_DSI_MIPI_RATIO_NUMERATOR / + MTK_DSI_MIPI_RATIO_DENOMINATOR), lanes); + return -1; + } + return data_rate; +} + static void mtk_dsi_phy_timconfig(u32 data_rate) { u32 timcon0, timcon1, timcon2, timcon3; @@ -186,11 +213,11 @@ int mtk_dsi_init(u32 mode_flags, u32 format, u32 lanes, const struct edid *edid) int data_rate; u32 bits_per_pixel = mtk_dsi_get_bits_per_pixel(format); - data_rate = mtk_dsi_phy_clk_setting(bits_per_pixel, lanes, edid); - + data_rate = mtk_dsi_get_data_rate(bits_per_pixel, lanes, edid); if (data_rate < 0) return -1; + mtk_dsi_configure_mipi_tx(data_rate, lanes); mtk_dsi_reset(); mtk_dsi_phy_timconfig(data_rate); mtk_dsi_rxtx_control(mode_flags, lanes); diff --git a/src/soc/mediatek/common/include/soc/dsi_common.h b/src/soc/mediatek/common/include/soc/dsi_common.h index 7a48d53507..7241097380 100644 --- a/src/soc/mediatek/common/include/soc/dsi_common.h +++ b/src/soc/mediatek/common/include/soc/dsi_common.h @@ -302,9 +302,7 @@ enum { /* Functions that each SOC should provide. */ void mtk_dsi_reset(void); -/* mtk_dsi_phy_clk_setting should return the data rate in Mbps. */ -int mtk_dsi_phy_clk_setting(u32 bits_per_pixel, u32 lanes, - const struct edid *edid); +void mtk_dsi_configure_mipi_tx(int data_rate, u32 lanes); /* Public API provided in common/dsi.c */ int mtk_dsi_init(u32 mode_flags, u32 format, u32 lanes, |