diff mbox series

drm/stm: dsi: Use dev_ based logging

Message ID 20200925102233.18016-1-yannick.fertre@st.com
State New, archived
Headers show
Series drm/stm: dsi: Use dev_ based logging | expand

Commit Message

Yannick Fertre Sept. 25, 2020, 10:22 a.m. UTC
Standardize on the dev_ based logging and drop the include of drm_print.h.
Remove useless dsi_color_from_mipi function.

Signed-off-by: Yannick Fertre <yannick.fertre@st.com>
---
 drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 87 ++++++++++++++-------------
 1 file changed, 45 insertions(+), 42 deletions(-)

Comments

Joe Perches Sept. 25, 2020, 12:02 p.m. UTC | #1
On Fri, 2020-09-25 at 12:22 +0200, Yannick Fertre wrote:
> Standardize on the dev_ based logging and drop the include of drm_print.h.
> Remove useless dsi_color_from_mipi function.
[]
> diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
[]
> -	DRM_DEBUG_DRIVER("pll_in %ukHz pll_out %ukHz lane_mbps %uMHz\n",
> -			 pll_in_khz, pll_out_khz, *lane_mbps);
> +	dev_dbg(dsi->dev, "pll_in %ukHz pll_out %ukHz lane_mbps %uMHz\n", pll_in_khz, pll_out_khz,
> +		*lane_mbps);

The line wrapping change here is pretty pointless and IMO
makes the code harder to read.
Sam Ravnborg Sept. 25, 2020, 2:51 p.m. UTC | #2
Hi Yannick.

On Fri, Sep 25, 2020 at 12:22:33PM +0200, Yannick Fertre wrote:
> Standardize on the dev_ based logging and drop the include of drm_print.h.
The patchs filas to drop the include mentioned here.

> Remove useless dsi_color_from_mipi function.
IMO the dsi_color_from_mipi() was nice, and inlining the helper
is no gain for readability.

	Sam

> 
> Signed-off-by: Yannick Fertre <yannick.fertre@st.com>
> ---
>  drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 87 ++++++++++++++-------------
>  1 file changed, 45 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
> index 164f79ef6269..93fa8bfd3127 100644
> --- a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
> +++ b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
> @@ -76,6 +76,7 @@ enum dsi_color {
>  
>  struct dw_mipi_dsi_stm {
>  	void __iomem *base;
> +	struct device *dev;
>  	struct clk *pllref_clk;
>  	struct dw_mipi_dsi *dsi;
>  	u32 hw_version;
> @@ -110,23 +111,6 @@ static inline void dsi_update_bits(struct dw_mipi_dsi_stm *dsi, u32 reg,
>  	dsi_write(dsi, reg, (dsi_read(dsi, reg) & ~mask) | val);
>  }
>  
> -static enum dsi_color dsi_color_from_mipi(enum mipi_dsi_pixel_format fmt)
> -{
> -	switch (fmt) {
> -	case MIPI_DSI_FMT_RGB888:
> -		return DSI_RGB888;
> -	case MIPI_DSI_FMT_RGB666:
> -		return DSI_RGB666_CONF2;
> -	case MIPI_DSI_FMT_RGB666_PACKED:
> -		return DSI_RGB666_CONF1;
> -	case MIPI_DSI_FMT_RGB565:
> -		return DSI_RGB565_CONF1;
> -	default:
> -		DRM_DEBUG_DRIVER("MIPI color invalid, so we use rgb888\n");
> -	}
> -	return DSI_RGB888;
> -}
> -
>  static int dsi_pll_get_clkout_khz(int clkin_khz, int idf, int ndiv, int odf)
>  {
>  	int divisor = idf * odf;
> @@ -205,14 +189,14 @@ static int dw_mipi_dsi_phy_init(void *priv_data)
>  	ret = readl_poll_timeout(dsi->base + DSI_WISR, val, val & WISR_RRS,
>  				 SLEEP_US, TIMEOUT_US);
>  	if (ret)
> -		DRM_DEBUG_DRIVER("!TIMEOUT! waiting REGU, let's continue\n");
> +		dev_dbg(dsi->dev, "!TIMEOUT! waiting REGU, let's continue\n");
>  
>  	/* Enable the DSI PLL & wait for its lock */
>  	dsi_set(dsi, DSI_WRPCR, WRPCR_PLLEN);
>  	ret = readl_poll_timeout(dsi->base + DSI_WISR, val, val & WISR_PLLLS,
>  				 SLEEP_US, TIMEOUT_US);
>  	if (ret)
> -		DRM_DEBUG_DRIVER("!TIMEOUT! waiting PLL, let's continue\n");
> +		dev_dbg(dsi->dev, "!TIMEOUT! waiting PLL, let's continue\n");
>  
>  	return 0;
>  }
> @@ -221,7 +205,7 @@ static void dw_mipi_dsi_phy_power_on(void *priv_data)
>  {
>  	struct dw_mipi_dsi_stm *dsi = priv_data;
>  
> -	DRM_DEBUG_DRIVER("\n");
> +	dev_dbg(dsi->dev, "\n");
>  
>  	/* Enable the DSI wrapper */
>  	dsi_set(dsi, DSI_WCR, WCR_DSIEN);
> @@ -231,7 +215,7 @@ static void dw_mipi_dsi_phy_power_off(void *priv_data)
>  {
>  	struct dw_mipi_dsi_stm *dsi = priv_data;
>  
> -	DRM_DEBUG_DRIVER("\n");
> +	dev_dbg(dsi->dev, "\n");
>  
>  	/* Disable the DSI wrapper */
>  	dsi_clear(dsi, DSI_WCR, WCR_DSIEN);
> @@ -244,6 +228,7 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
>  {
>  	struct dw_mipi_dsi_stm *dsi = priv_data;
>  	unsigned int idf, ndiv, odf, pll_in_khz, pll_out_khz;
> +	enum mipi_dsi_pixel_format fmt;
>  	int ret, bpp;
>  	u32 val;
>  
> @@ -267,11 +252,11 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
>  
>  	if (pll_out_khz > dsi->lane_max_kbps) {
>  		pll_out_khz = dsi->lane_max_kbps;
> -		DRM_WARN("Warning max phy mbps is used\n");
> +		dev_warn(dsi->dev, "Warning max phy mbps is used\n");
>  	}
>  	if (pll_out_khz < dsi->lane_min_kbps) {
>  		pll_out_khz = dsi->lane_min_kbps;
> -		DRM_WARN("Warning min phy mbps is used\n");
> +		dev_warn(dsi->dev, "Warning min phy mbps is used\n");
>  	}
>  
>  	/* Compute best pll parameters */
> @@ -281,7 +266,7 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
>  	ret = dsi_pll_get_params(dsi, pll_in_khz, pll_out_khz,
>  				 &idf, &ndiv, &odf);
>  	if (ret)
> -		DRM_WARN("Warning dsi_pll_get_params(): bad params\n");
> +		dev_warn(dsi->dev, "Warning dsi_pll_get_params(): bad params\n");
>  
>  	/* Get the adjusted pll out value */
>  	pll_out_khz = dsi_pll_get_clkout_khz(pll_in_khz, idf, ndiv, odf);
> @@ -297,14 +282,31 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
>  	/* Select video mode by resetting DSIM bit */
>  	dsi_clear(dsi, DSI_WCFGR, WCFGR_DSIM);
>  
> +	switch (format) {
> +	case MIPI_DSI_FMT_RGB888:
> +		fmt = DSI_RGB888;
> +		break;
> +	case MIPI_DSI_FMT_RGB666:
> +		fmt = DSI_RGB666_CONF2;
> +		break;
> +	case MIPI_DSI_FMT_RGB666_PACKED:
> +		fmt = DSI_RGB666_CONF1;
> +		break;
> +	case MIPI_DSI_FMT_RGB565:
> +		fmt = DSI_RGB565_CONF1;
> +		break;
> +	default:
> +		fmt = DSI_RGB888;
> +		dev_err(dsi->dev, "MIPI color invalid, so we use rgb888\n");
> +	}
> +
>  	/* Select the color coding */
> -	dsi_update_bits(dsi, DSI_WCFGR, WCFGR_COLMUX,
> -			dsi_color_from_mipi(format) << 1);
> +	dsi_update_bits(dsi, DSI_WCFGR, WCFGR_COLMUX, fmt << 1);
>  
>  	*lane_mbps = pll_out_khz / 1000;
>  
> -	DRM_DEBUG_DRIVER("pll_in %ukHz pll_out %ukHz lane_mbps %uMHz\n",
> -			 pll_in_khz, pll_out_khz, *lane_mbps);
> +	dev_dbg(dsi->dev, "pll_in %ukHz pll_out %ukHz lane_mbps %uMHz\n", pll_in_khz, pll_out_khz,
> +		*lane_mbps);
>  
>  	return 0;
>  }
> @@ -352,11 +354,13 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>  	if (!dsi)
>  		return -ENOMEM;
>  
> +	dsi->dev = dev;
> +
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	dsi->base = devm_ioremap_resource(dev, res);
>  	if (IS_ERR(dsi->base)) {
>  		ret = PTR_ERR(dsi->base);
> -		DRM_ERROR("Unable to get dsi registers %d\n", ret);
> +		dev_err(dev, "Unable to get dsi registers %d\n", ret);
>  		return ret;
>  	}
>  
> @@ -364,13 +368,13 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>  	if (IS_ERR(dsi->vdd_supply)) {
>  		ret = PTR_ERR(dsi->vdd_supply);
>  		if (ret != -EPROBE_DEFER)
> -			DRM_ERROR("Failed to request regulator: %d\n", ret);
> +			dev_err(dev, "Failed to request regulator: %d\n", ret);
>  		return ret;
>  	}
>  
>  	ret = regulator_enable(dsi->vdd_supply);
>  	if (ret) {
> -		DRM_ERROR("Failed to enable regulator: %d\n", ret);
> +		dev_err(dev, "Failed to enable regulator: %d\n", ret);
>  		return ret;
>  	}
>  
> @@ -378,27 +382,26 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>  	if (IS_ERR(dsi->pllref_clk)) {
>  		ret = PTR_ERR(dsi->pllref_clk);
>  		if (ret != -EPROBE_DEFER)
> -			DRM_ERROR("Unable to get pll reference clock: %d\n",
> -				  ret);
> +			dev_err(dev, "Unable to get pll reference clock: %d\n", ret);
>  		goto err_clk_get;
>  	}
>  
>  	ret = clk_prepare_enable(dsi->pllref_clk);
>  	if (ret) {
> -		DRM_ERROR("Failed to enable pllref_clk: %d\n", ret);
> +		dev_err(dev, "Failed to enable pllref_clk: %d\n", ret);
>  		goto err_clk_get;
>  	}
>  
>  	pclk = devm_clk_get(dev, "pclk");
>  	if (IS_ERR(pclk)) {
>  		ret = PTR_ERR(pclk);
> -		DRM_ERROR("Unable to get peripheral clock: %d\n", ret);
> +		dev_err(dev, "Unable to get peripheral clock: %d\n", ret);
>  		goto err_dsi_probe;
>  	}
>  
>  	ret = clk_prepare_enable(pclk);
>  	if (ret) {
> -		DRM_ERROR("%s: Failed to enable peripheral clk\n", __func__);
> +		dev_err(dev, "%s: Failed to enable peripheral clk\n", __func__);
>  		goto err_dsi_probe;
>  	}
>  
> @@ -407,7 +410,7 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>  
>  	if (dsi->hw_version != HWVER_130 && dsi->hw_version != HWVER_131) {
>  		ret = -ENODEV;
> -		DRM_ERROR("bad dsi hardware version\n");
> +		dev_err(dev, "bad dsi hardware version\n");
>  		goto err_dsi_probe;
>  	}
>  
> @@ -420,7 +423,7 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>  	if (IS_ERR(dsi->dsi)) {
>  		ret = PTR_ERR(dsi->dsi);
>  		if (ret != -EPROBE_DEFER)
> -			DRM_ERROR("Failed to initialize mipi dsi host: %d\n", ret);
> +			dev_err(dev, "Failed to initialize mipi dsi host: %d\n", ret);
>  		goto err_dsi_probe;
>  	}
>  
> @@ -449,7 +452,7 @@ static int __maybe_unused dw_mipi_dsi_stm_suspend(struct device *dev)
>  {
>  	struct dw_mipi_dsi_stm *dsi = dw_mipi_dsi_stm_plat_data.priv_data;
>  
> -	DRM_DEBUG_DRIVER("\n");
> +	dev_dbg(dsi->dev, "\n");
>  
>  	clk_disable_unprepare(dsi->pllref_clk);
>  	regulator_disable(dsi->vdd_supply);
> @@ -462,18 +465,18 @@ static int __maybe_unused dw_mipi_dsi_stm_resume(struct device *dev)
>  	struct dw_mipi_dsi_stm *dsi = dw_mipi_dsi_stm_plat_data.priv_data;
>  	int ret;
>  
> -	DRM_DEBUG_DRIVER("\n");
> +	dev_dbg(dsi->dev, "\n");
>  
>  	ret = regulator_enable(dsi->vdd_supply);
>  	if (ret) {
> -		DRM_ERROR("Failed to enable regulator: %d\n", ret);
> +		dev_err(dev, "Failed to enable regulator: %d\n", ret);
>  		return ret;
>  	}
>  
>  	ret = clk_prepare_enable(dsi->pllref_clk);
>  	if (ret) {
>  		regulator_disable(dsi->vdd_supply);
> -		DRM_ERROR("Failed to enable pllref_clk: %d\n", ret);
> +		dev_err(dev, "Failed to enable pllref_clk: %d\n", ret);
>  		return ret;
>  	}
>  
> -- 
> 2.17.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Yannick Fertre Sept. 28, 2020, 7:36 a.m. UTC | #3
On 9/25/20 2:02 PM, Joe Perches wrote:
> On Fri, 2020-09-25 at 12:22 +0200, Yannick Fertre wrote:
>> Standardize on the dev_ based logging and drop the include of drm_print.h.
>> Remove useless dsi_color_from_mipi function.
> []
>> diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
> []
>> -	DRM_DEBUG_DRIVER("pll_in %ukHz pll_out %ukHz lane_mbps %uMHz\n",
>> -			 pll_in_khz, pll_out_khz, *lane_mbps);
>> +	dev_dbg(dsi->dev, "pll_in %ukHz pll_out %ukHz lane_mbps %uMHz\n", pll_in_khz, pll_out_khz,
>> +		*lane_mbps);
> 
> The line wrapping change here is pretty pointless and IMO
> makes the code harder to read.

Hi,
ok, I will restore the line wrapping.

Best regards

Yannick
Yannick Fertre Sept. 28, 2020, 7:39 a.m. UTC | #4
On 9/25/20 4:51 PM, Sam Ravnborg wrote:
> Hi Yannick.
> 
> On Fri, Sep 25, 2020 at 12:22:33PM +0200, Yannick Fertre wrote:
>> Standardize on the dev_ based logging and drop the include of drm_print.h.
> The patchs filas to drop the include mentioned here.
> 
>> Remove useless dsi_color_from_mipi function.
> IMO the dsi_color_from_mipi() was nice, and inlining the helper
> is no gain for readability.
> 
> 	Sam
> 
Hi,
I will restore the dsi_color_from_mipi() fucntion & introduce a new 
parameter (dev) which is necessary for call of dev_err.
Yannick

>>
>> Signed-off-by: Yannick Fertre <yannick.fertre@st.com>
>> ---
>>   drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 87 ++++++++++++++-------------
>>   1 file changed, 45 insertions(+), 42 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
>> index 164f79ef6269..93fa8bfd3127 100644
>> --- a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
>> +++ b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
>> @@ -76,6 +76,7 @@ enum dsi_color {
>>   
>>   struct dw_mipi_dsi_stm {
>>   	void __iomem *base;
>> +	struct device *dev;
>>   	struct clk *pllref_clk;
>>   	struct dw_mipi_dsi *dsi;
>>   	u32 hw_version;
>> @@ -110,23 +111,6 @@ static inline void dsi_update_bits(struct dw_mipi_dsi_stm *dsi, u32 reg,
>>   	dsi_write(dsi, reg, (dsi_read(dsi, reg) & ~mask) | val);
>>   }
>>   
>> -static enum dsi_color dsi_color_from_mipi(enum mipi_dsi_pixel_format fmt)
>> -{
>> -	switch (fmt) {
>> -	case MIPI_DSI_FMT_RGB888:
>> -		return DSI_RGB888;
>> -	case MIPI_DSI_FMT_RGB666:
>> -		return DSI_RGB666_CONF2;
>> -	case MIPI_DSI_FMT_RGB666_PACKED:
>> -		return DSI_RGB666_CONF1;
>> -	case MIPI_DSI_FMT_RGB565:
>> -		return DSI_RGB565_CONF1;
>> -	default:
>> -		DRM_DEBUG_DRIVER("MIPI color invalid, so we use rgb888\n");
>> -	}
>> -	return DSI_RGB888;
>> -}
>> -
>>   static int dsi_pll_get_clkout_khz(int clkin_khz, int idf, int ndiv, int odf)
>>   {
>>   	int divisor = idf * odf;
>> @@ -205,14 +189,14 @@ static int dw_mipi_dsi_phy_init(void *priv_data)
>>   	ret = readl_poll_timeout(dsi->base + DSI_WISR, val, val & WISR_RRS,
>>   				 SLEEP_US, TIMEOUT_US);
>>   	if (ret)
>> -		DRM_DEBUG_DRIVER("!TIMEOUT! waiting REGU, let's continue\n");
>> +		dev_dbg(dsi->dev, "!TIMEOUT! waiting REGU, let's continue\n");
>>   
>>   	/* Enable the DSI PLL & wait for its lock */
>>   	dsi_set(dsi, DSI_WRPCR, WRPCR_PLLEN);
>>   	ret = readl_poll_timeout(dsi->base + DSI_WISR, val, val & WISR_PLLLS,
>>   				 SLEEP_US, TIMEOUT_US);
>>   	if (ret)
>> -		DRM_DEBUG_DRIVER("!TIMEOUT! waiting PLL, let's continue\n");
>> +		dev_dbg(dsi->dev, "!TIMEOUT! waiting PLL, let's continue\n");
>>   
>>   	return 0;
>>   }
>> @@ -221,7 +205,7 @@ static void dw_mipi_dsi_phy_power_on(void *priv_data)
>>   {
>>   	struct dw_mipi_dsi_stm *dsi = priv_data;
>>   
>> -	DRM_DEBUG_DRIVER("\n");
>> +	dev_dbg(dsi->dev, "\n");
>>   
>>   	/* Enable the DSI wrapper */
>>   	dsi_set(dsi, DSI_WCR, WCR_DSIEN);
>> @@ -231,7 +215,7 @@ static void dw_mipi_dsi_phy_power_off(void *priv_data)
>>   {
>>   	struct dw_mipi_dsi_stm *dsi = priv_data;
>>   
>> -	DRM_DEBUG_DRIVER("\n");
>> +	dev_dbg(dsi->dev, "\n");
>>   
>>   	/* Disable the DSI wrapper */
>>   	dsi_clear(dsi, DSI_WCR, WCR_DSIEN);
>> @@ -244,6 +228,7 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
>>   {
>>   	struct dw_mipi_dsi_stm *dsi = priv_data;
>>   	unsigned int idf, ndiv, odf, pll_in_khz, pll_out_khz;
>> +	enum mipi_dsi_pixel_format fmt;
>>   	int ret, bpp;
>>   	u32 val;
>>   
>> @@ -267,11 +252,11 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
>>   
>>   	if (pll_out_khz > dsi->lane_max_kbps) {
>>   		pll_out_khz = dsi->lane_max_kbps;
>> -		DRM_WARN("Warning max phy mbps is used\n");
>> +		dev_warn(dsi->dev, "Warning max phy mbps is used\n");
>>   	}
>>   	if (pll_out_khz < dsi->lane_min_kbps) {
>>   		pll_out_khz = dsi->lane_min_kbps;
>> -		DRM_WARN("Warning min phy mbps is used\n");
>> +		dev_warn(dsi->dev, "Warning min phy mbps is used\n");
>>   	}
>>   
>>   	/* Compute best pll parameters */
>> @@ -281,7 +266,7 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
>>   	ret = dsi_pll_get_params(dsi, pll_in_khz, pll_out_khz,
>>   				 &idf, &ndiv, &odf);
>>   	if (ret)
>> -		DRM_WARN("Warning dsi_pll_get_params(): bad params\n");
>> +		dev_warn(dsi->dev, "Warning dsi_pll_get_params(): bad params\n");
>>   
>>   	/* Get the adjusted pll out value */
>>   	pll_out_khz = dsi_pll_get_clkout_khz(pll_in_khz, idf, ndiv, odf);
>> @@ -297,14 +282,31 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
>>   	/* Select video mode by resetting DSIM bit */
>>   	dsi_clear(dsi, DSI_WCFGR, WCFGR_DSIM);
>>   
>> +	switch (format) {
>> +	case MIPI_DSI_FMT_RGB888:
>> +		fmt = DSI_RGB888;
>> +		break;
>> +	case MIPI_DSI_FMT_RGB666:
>> +		fmt = DSI_RGB666_CONF2;
>> +		break;
>> +	case MIPI_DSI_FMT_RGB666_PACKED:
>> +		fmt = DSI_RGB666_CONF1;
>> +		break;
>> +	case MIPI_DSI_FMT_RGB565:
>> +		fmt = DSI_RGB565_CONF1;
>> +		break;
>> +	default:
>> +		fmt = DSI_RGB888;
>> +		dev_err(dsi->dev, "MIPI color invalid, so we use rgb888\n");
>> +	}
>> +
>>   	/* Select the color coding */
>> -	dsi_update_bits(dsi, DSI_WCFGR, WCFGR_COLMUX,
>> -			dsi_color_from_mipi(format) << 1);
>> +	dsi_update_bits(dsi, DSI_WCFGR, WCFGR_COLMUX, fmt << 1);
>>   
>>   	*lane_mbps = pll_out_khz / 1000;
>>   
>> -	DRM_DEBUG_DRIVER("pll_in %ukHz pll_out %ukHz lane_mbps %uMHz\n",
>> -			 pll_in_khz, pll_out_khz, *lane_mbps);
>> +	dev_dbg(dsi->dev, "pll_in %ukHz pll_out %ukHz lane_mbps %uMHz\n", pll_in_khz, pll_out_khz,
>> +		*lane_mbps);
>>   
>>   	return 0;
>>   }
>> @@ -352,11 +354,13 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>>   	if (!dsi)
>>   		return -ENOMEM;
>>   
>> +	dsi->dev = dev;
>> +
>>   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>   	dsi->base = devm_ioremap_resource(dev, res);
>>   	if (IS_ERR(dsi->base)) {
>>   		ret = PTR_ERR(dsi->base);
>> -		DRM_ERROR("Unable to get dsi registers %d\n", ret);
>> +		dev_err(dev, "Unable to get dsi registers %d\n", ret);
>>   		return ret;
>>   	}
>>   
>> @@ -364,13 +368,13 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>>   	if (IS_ERR(dsi->vdd_supply)) {
>>   		ret = PTR_ERR(dsi->vdd_supply);
>>   		if (ret != -EPROBE_DEFER)
>> -			DRM_ERROR("Failed to request regulator: %d\n", ret);
>> +			dev_err(dev, "Failed to request regulator: %d\n", ret);
>>   		return ret;
>>   	}
>>   
>>   	ret = regulator_enable(dsi->vdd_supply);
>>   	if (ret) {
>> -		DRM_ERROR("Failed to enable regulator: %d\n", ret);
>> +		dev_err(dev, "Failed to enable regulator: %d\n", ret);
>>   		return ret;
>>   	}
>>   
>> @@ -378,27 +382,26 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>>   	if (IS_ERR(dsi->pllref_clk)) {
>>   		ret = PTR_ERR(dsi->pllref_clk);
>>   		if (ret != -EPROBE_DEFER)
>> -			DRM_ERROR("Unable to get pll reference clock: %d\n",
>> -				  ret);
>> +			dev_err(dev, "Unable to get pll reference clock: %d\n", ret);
>>   		goto err_clk_get;
>>   	}
>>   
>>   	ret = clk_prepare_enable(dsi->pllref_clk);
>>   	if (ret) {
>> -		DRM_ERROR("Failed to enable pllref_clk: %d\n", ret);
>> +		dev_err(dev, "Failed to enable pllref_clk: %d\n", ret);
>>   		goto err_clk_get;
>>   	}
>>   
>>   	pclk = devm_clk_get(dev, "pclk");
>>   	if (IS_ERR(pclk)) {
>>   		ret = PTR_ERR(pclk);
>> -		DRM_ERROR("Unable to get peripheral clock: %d\n", ret);
>> +		dev_err(dev, "Unable to get peripheral clock: %d\n", ret);
>>   		goto err_dsi_probe;
>>   	}
>>   
>>   	ret = clk_prepare_enable(pclk);
>>   	if (ret) {
>> -		DRM_ERROR("%s: Failed to enable peripheral clk\n", __func__);
>> +		dev_err(dev, "%s: Failed to enable peripheral clk\n", __func__);
>>   		goto err_dsi_probe;
>>   	}
>>   
>> @@ -407,7 +410,7 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>>   
>>   	if (dsi->hw_version != HWVER_130 && dsi->hw_version != HWVER_131) {
>>   		ret = -ENODEV;
>> -		DRM_ERROR("bad dsi hardware version\n");
>> +		dev_err(dev, "bad dsi hardware version\n");
>>   		goto err_dsi_probe;
>>   	}
>>   
>> @@ -420,7 +423,7 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>>   	if (IS_ERR(dsi->dsi)) {
>>   		ret = PTR_ERR(dsi->dsi);
>>   		if (ret != -EPROBE_DEFER)
>> -			DRM_ERROR("Failed to initialize mipi dsi host: %d\n", ret);
>> +			dev_err(dev, "Failed to initialize mipi dsi host: %d\n", ret);
>>   		goto err_dsi_probe;
>>   	}
>>   
>> @@ -449,7 +452,7 @@ static int __maybe_unused dw_mipi_dsi_stm_suspend(struct device *dev)
>>   {
>>   	struct dw_mipi_dsi_stm *dsi = dw_mipi_dsi_stm_plat_data.priv_data;
>>   
>> -	DRM_DEBUG_DRIVER("\n");
>> +	dev_dbg(dsi->dev, "\n");
>>   
>>   	clk_disable_unprepare(dsi->pllref_clk);
>>   	regulator_disable(dsi->vdd_supply);
>> @@ -462,18 +465,18 @@ static int __maybe_unused dw_mipi_dsi_stm_resume(struct device *dev)
>>   	struct dw_mipi_dsi_stm *dsi = dw_mipi_dsi_stm_plat_data.priv_data;
>>   	int ret;
>>   
>> -	DRM_DEBUG_DRIVER("\n");
>> +	dev_dbg(dsi->dev, "\n");
>>   
>>   	ret = regulator_enable(dsi->vdd_supply);
>>   	if (ret) {
>> -		DRM_ERROR("Failed to enable regulator: %d\n", ret);
>> +		dev_err(dev, "Failed to enable regulator: %d\n", ret);
>>   		return ret;
>>   	}
>>   
>>   	ret = clk_prepare_enable(dsi->pllref_clk);
>>   	if (ret) {
>>   		regulator_disable(dsi->vdd_supply);
>> -		DRM_ERROR("Failed to enable pllref_clk: %d\n", ret);
>> +		dev_err(dev, "Failed to enable pllref_clk: %d\n", ret);
>>   		return ret;
>>   	}
>>   
>> -- 
>> 2.17.1
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Yannick Fertre Oct. 13, 2020, 7:02 a.m. UTC | #5
Hi Sam,
thanks for the review. I'll send a new patch with the revert of function 
dsi_color_from_mipi.

Best regards

Yannick

On 9/25/20 4:51 PM, Sam Ravnborg wrote:
> Hi Yannick.
> 
> On Fri, Sep 25, 2020 at 12:22:33PM +0200, Yannick Fertre wrote:
>> Standardize on the dev_ based logging and drop the include of drm_print.h.
> The patchs filas to drop the include mentioned here.
> 
>> Remove useless dsi_color_from_mipi function.
> IMO the dsi_color_from_mipi() was nice, and inlining the helper
> is no gain for readability.
> 
> 	Sam
> 
>>
>> Signed-off-by: Yannick Fertre <yannick.fertre@st.com>
>> ---
>>   drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 87 ++++++++++++++-------------
>>   1 file changed, 45 insertions(+), 42 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
>> index 164f79ef6269..93fa8bfd3127 100644
>> --- a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
>> +++ b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
>> @@ -76,6 +76,7 @@ enum dsi_color {
>>   
>>   struct dw_mipi_dsi_stm {
>>   	void __iomem *base;
>> +	struct device *dev;
>>   	struct clk *pllref_clk;
>>   	struct dw_mipi_dsi *dsi;
>>   	u32 hw_version;
>> @@ -110,23 +111,6 @@ static inline void dsi_update_bits(struct dw_mipi_dsi_stm *dsi, u32 reg,
>>   	dsi_write(dsi, reg, (dsi_read(dsi, reg) & ~mask) | val);
>>   }
>>   
>> -static enum dsi_color dsi_color_from_mipi(enum mipi_dsi_pixel_format fmt)
>> -{
>> -	switch (fmt) {
>> -	case MIPI_DSI_FMT_RGB888:
>> -		return DSI_RGB888;
>> -	case MIPI_DSI_FMT_RGB666:
>> -		return DSI_RGB666_CONF2;
>> -	case MIPI_DSI_FMT_RGB666_PACKED:
>> -		return DSI_RGB666_CONF1;
>> -	case MIPI_DSI_FMT_RGB565:
>> -		return DSI_RGB565_CONF1;
>> -	default:
>> -		DRM_DEBUG_DRIVER("MIPI color invalid, so we use rgb888\n");
>> -	}
>> -	return DSI_RGB888;
>> -}
>> -
>>   static int dsi_pll_get_clkout_khz(int clkin_khz, int idf, int ndiv, int odf)
>>   {
>>   	int divisor = idf * odf;
>> @@ -205,14 +189,14 @@ static int dw_mipi_dsi_phy_init(void *priv_data)
>>   	ret = readl_poll_timeout(dsi->base + DSI_WISR, val, val & WISR_RRS,
>>   				 SLEEP_US, TIMEOUT_US);
>>   	if (ret)
>> -		DRM_DEBUG_DRIVER("!TIMEOUT! waiting REGU, let's continue\n");
>> +		dev_dbg(dsi->dev, "!TIMEOUT! waiting REGU, let's continue\n");
>>   
>>   	/* Enable the DSI PLL & wait for its lock */
>>   	dsi_set(dsi, DSI_WRPCR, WRPCR_PLLEN);
>>   	ret = readl_poll_timeout(dsi->base + DSI_WISR, val, val & WISR_PLLLS,
>>   				 SLEEP_US, TIMEOUT_US);
>>   	if (ret)
>> -		DRM_DEBUG_DRIVER("!TIMEOUT! waiting PLL, let's continue\n");
>> +		dev_dbg(dsi->dev, "!TIMEOUT! waiting PLL, let's continue\n");
>>   
>>   	return 0;
>>   }
>> @@ -221,7 +205,7 @@ static void dw_mipi_dsi_phy_power_on(void *priv_data)
>>   {
>>   	struct dw_mipi_dsi_stm *dsi = priv_data;
>>   
>> -	DRM_DEBUG_DRIVER("\n");
>> +	dev_dbg(dsi->dev, "\n");
>>   
>>   	/* Enable the DSI wrapper */
>>   	dsi_set(dsi, DSI_WCR, WCR_DSIEN);
>> @@ -231,7 +215,7 @@ static void dw_mipi_dsi_phy_power_off(void *priv_data)
>>   {
>>   	struct dw_mipi_dsi_stm *dsi = priv_data;
>>   
>> -	DRM_DEBUG_DRIVER("\n");
>> +	dev_dbg(dsi->dev, "\n");
>>   
>>   	/* Disable the DSI wrapper */
>>   	dsi_clear(dsi, DSI_WCR, WCR_DSIEN);
>> @@ -244,6 +228,7 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
>>   {
>>   	struct dw_mipi_dsi_stm *dsi = priv_data;
>>   	unsigned int idf, ndiv, odf, pll_in_khz, pll_out_khz;
>> +	enum mipi_dsi_pixel_format fmt;
>>   	int ret, bpp;
>>   	u32 val;
>>   
>> @@ -267,11 +252,11 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
>>   
>>   	if (pll_out_khz > dsi->lane_max_kbps) {
>>   		pll_out_khz = dsi->lane_max_kbps;
>> -		DRM_WARN("Warning max phy mbps is used\n");
>> +		dev_warn(dsi->dev, "Warning max phy mbps is used\n");
>>   	}
>>   	if (pll_out_khz < dsi->lane_min_kbps) {
>>   		pll_out_khz = dsi->lane_min_kbps;
>> -		DRM_WARN("Warning min phy mbps is used\n");
>> +		dev_warn(dsi->dev, "Warning min phy mbps is used\n");
>>   	}
>>   
>>   	/* Compute best pll parameters */
>> @@ -281,7 +266,7 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
>>   	ret = dsi_pll_get_params(dsi, pll_in_khz, pll_out_khz,
>>   				 &idf, &ndiv, &odf);
>>   	if (ret)
>> -		DRM_WARN("Warning dsi_pll_get_params(): bad params\n");
>> +		dev_warn(dsi->dev, "Warning dsi_pll_get_params(): bad params\n");
>>   
>>   	/* Get the adjusted pll out value */
>>   	pll_out_khz = dsi_pll_get_clkout_khz(pll_in_khz, idf, ndiv, odf);
>> @@ -297,14 +282,31 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
>>   	/* Select video mode by resetting DSIM bit */
>>   	dsi_clear(dsi, DSI_WCFGR, WCFGR_DSIM);
>>   
>> +	switch (format) {
>> +	case MIPI_DSI_FMT_RGB888:
>> +		fmt = DSI_RGB888;
>> +		break;
>> +	case MIPI_DSI_FMT_RGB666:
>> +		fmt = DSI_RGB666_CONF2;
>> +		break;
>> +	case MIPI_DSI_FMT_RGB666_PACKED:
>> +		fmt = DSI_RGB666_CONF1;
>> +		break;
>> +	case MIPI_DSI_FMT_RGB565:
>> +		fmt = DSI_RGB565_CONF1;
>> +		break;
>> +	default:
>> +		fmt = DSI_RGB888;
>> +		dev_err(dsi->dev, "MIPI color invalid, so we use rgb888\n");
>> +	}
>> +
>>   	/* Select the color coding */
>> -	dsi_update_bits(dsi, DSI_WCFGR, WCFGR_COLMUX,
>> -			dsi_color_from_mipi(format) << 1);
>> +	dsi_update_bits(dsi, DSI_WCFGR, WCFGR_COLMUX, fmt << 1);
>>   
>>   	*lane_mbps = pll_out_khz / 1000;
>>   
>> -	DRM_DEBUG_DRIVER("pll_in %ukHz pll_out %ukHz lane_mbps %uMHz\n",
>> -			 pll_in_khz, pll_out_khz, *lane_mbps);
>> +	dev_dbg(dsi->dev, "pll_in %ukHz pll_out %ukHz lane_mbps %uMHz\n", pll_in_khz, pll_out_khz,
>> +		*lane_mbps);
>>   
>>   	return 0;
>>   }
>> @@ -352,11 +354,13 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>>   	if (!dsi)
>>   		return -ENOMEM;
>>   
>> +	dsi->dev = dev;
>> +
>>   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>   	dsi->base = devm_ioremap_resource(dev, res);
>>   	if (IS_ERR(dsi->base)) {
>>   		ret = PTR_ERR(dsi->base);
>> -		DRM_ERROR("Unable to get dsi registers %d\n", ret);
>> +		dev_err(dev, "Unable to get dsi registers %d\n", ret);
>>   		return ret;
>>   	}
>>   
>> @@ -364,13 +368,13 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>>   	if (IS_ERR(dsi->vdd_supply)) {
>>   		ret = PTR_ERR(dsi->vdd_supply);
>>   		if (ret != -EPROBE_DEFER)
>> -			DRM_ERROR("Failed to request regulator: %d\n", ret);
>> +			dev_err(dev, "Failed to request regulator: %d\n", ret);
>>   		return ret;
>>   	}
>>   
>>   	ret = regulator_enable(dsi->vdd_supply);
>>   	if (ret) {
>> -		DRM_ERROR("Failed to enable regulator: %d\n", ret);
>> +		dev_err(dev, "Failed to enable regulator: %d\n", ret);
>>   		return ret;
>>   	}
>>   
>> @@ -378,27 +382,26 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>>   	if (IS_ERR(dsi->pllref_clk)) {
>>   		ret = PTR_ERR(dsi->pllref_clk);
>>   		if (ret != -EPROBE_DEFER)
>> -			DRM_ERROR("Unable to get pll reference clock: %d\n",
>> -				  ret);
>> +			dev_err(dev, "Unable to get pll reference clock: %d\n", ret);
>>   		goto err_clk_get;
>>   	}
>>   
>>   	ret = clk_prepare_enable(dsi->pllref_clk);
>>   	if (ret) {
>> -		DRM_ERROR("Failed to enable pllref_clk: %d\n", ret);
>> +		dev_err(dev, "Failed to enable pllref_clk: %d\n", ret);
>>   		goto err_clk_get;
>>   	}
>>   
>>   	pclk = devm_clk_get(dev, "pclk");
>>   	if (IS_ERR(pclk)) {
>>   		ret = PTR_ERR(pclk);
>> -		DRM_ERROR("Unable to get peripheral clock: %d\n", ret);
>> +		dev_err(dev, "Unable to get peripheral clock: %d\n", ret);
>>   		goto err_dsi_probe;
>>   	}
>>   
>>   	ret = clk_prepare_enable(pclk);
>>   	if (ret) {
>> -		DRM_ERROR("%s: Failed to enable peripheral clk\n", __func__);
>> +		dev_err(dev, "%s: Failed to enable peripheral clk\n", __func__);
>>   		goto err_dsi_probe;
>>   	}
>>   
>> @@ -407,7 +410,7 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>>   
>>   	if (dsi->hw_version != HWVER_130 && dsi->hw_version != HWVER_131) {
>>   		ret = -ENODEV;
>> -		DRM_ERROR("bad dsi hardware version\n");
>> +		dev_err(dev, "bad dsi hardware version\n");
>>   		goto err_dsi_probe;
>>   	}
>>   
>> @@ -420,7 +423,7 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
>>   	if (IS_ERR(dsi->dsi)) {
>>   		ret = PTR_ERR(dsi->dsi);
>>   		if (ret != -EPROBE_DEFER)
>> -			DRM_ERROR("Failed to initialize mipi dsi host: %d\n", ret);
>> +			dev_err(dev, "Failed to initialize mipi dsi host: %d\n", ret);
>>   		goto err_dsi_probe;
>>   	}
>>   
>> @@ -449,7 +452,7 @@ static int __maybe_unused dw_mipi_dsi_stm_suspend(struct device *dev)
>>   {
>>   	struct dw_mipi_dsi_stm *dsi = dw_mipi_dsi_stm_plat_data.priv_data;
>>   
>> -	DRM_DEBUG_DRIVER("\n");
>> +	dev_dbg(dsi->dev, "\n");
>>   
>>   	clk_disable_unprepare(dsi->pllref_clk);
>>   	regulator_disable(dsi->vdd_supply);
>> @@ -462,18 +465,18 @@ static int __maybe_unused dw_mipi_dsi_stm_resume(struct device *dev)
>>   	struct dw_mipi_dsi_stm *dsi = dw_mipi_dsi_stm_plat_data.priv_data;
>>   	int ret;
>>   
>> -	DRM_DEBUG_DRIVER("\n");
>> +	dev_dbg(dsi->dev, "\n");
>>   
>>   	ret = regulator_enable(dsi->vdd_supply);
>>   	if (ret) {
>> -		DRM_ERROR("Failed to enable regulator: %d\n", ret);
>> +		dev_err(dev, "Failed to enable regulator: %d\n", ret);
>>   		return ret;
>>   	}
>>   
>>   	ret = clk_prepare_enable(dsi->pllref_clk);
>>   	if (ret) {
>>   		regulator_disable(dsi->vdd_supply);
>> -		DRM_ERROR("Failed to enable pllref_clk: %d\n", ret);
>> +		dev_err(dev, "Failed to enable pllref_clk: %d\n", ret);
>>   		return ret;
>>   	}
>>   
>> -- 
>> 2.17.1
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
index 164f79ef6269..93fa8bfd3127 100644
--- a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
+++ b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
@@ -76,6 +76,7 @@  enum dsi_color {
 
 struct dw_mipi_dsi_stm {
 	void __iomem *base;
+	struct device *dev;
 	struct clk *pllref_clk;
 	struct dw_mipi_dsi *dsi;
 	u32 hw_version;
@@ -110,23 +111,6 @@  static inline void dsi_update_bits(struct dw_mipi_dsi_stm *dsi, u32 reg,
 	dsi_write(dsi, reg, (dsi_read(dsi, reg) & ~mask) | val);
 }
 
-static enum dsi_color dsi_color_from_mipi(enum mipi_dsi_pixel_format fmt)
-{
-	switch (fmt) {
-	case MIPI_DSI_FMT_RGB888:
-		return DSI_RGB888;
-	case MIPI_DSI_FMT_RGB666:
-		return DSI_RGB666_CONF2;
-	case MIPI_DSI_FMT_RGB666_PACKED:
-		return DSI_RGB666_CONF1;
-	case MIPI_DSI_FMT_RGB565:
-		return DSI_RGB565_CONF1;
-	default:
-		DRM_DEBUG_DRIVER("MIPI color invalid, so we use rgb888\n");
-	}
-	return DSI_RGB888;
-}
-
 static int dsi_pll_get_clkout_khz(int clkin_khz, int idf, int ndiv, int odf)
 {
 	int divisor = idf * odf;
@@ -205,14 +189,14 @@  static int dw_mipi_dsi_phy_init(void *priv_data)
 	ret = readl_poll_timeout(dsi->base + DSI_WISR, val, val & WISR_RRS,
 				 SLEEP_US, TIMEOUT_US);
 	if (ret)
-		DRM_DEBUG_DRIVER("!TIMEOUT! waiting REGU, let's continue\n");
+		dev_dbg(dsi->dev, "!TIMEOUT! waiting REGU, let's continue\n");
 
 	/* Enable the DSI PLL & wait for its lock */
 	dsi_set(dsi, DSI_WRPCR, WRPCR_PLLEN);
 	ret = readl_poll_timeout(dsi->base + DSI_WISR, val, val & WISR_PLLLS,
 				 SLEEP_US, TIMEOUT_US);
 	if (ret)
-		DRM_DEBUG_DRIVER("!TIMEOUT! waiting PLL, let's continue\n");
+		dev_dbg(dsi->dev, "!TIMEOUT! waiting PLL, let's continue\n");
 
 	return 0;
 }
@@ -221,7 +205,7 @@  static void dw_mipi_dsi_phy_power_on(void *priv_data)
 {
 	struct dw_mipi_dsi_stm *dsi = priv_data;
 
-	DRM_DEBUG_DRIVER("\n");
+	dev_dbg(dsi->dev, "\n");
 
 	/* Enable the DSI wrapper */
 	dsi_set(dsi, DSI_WCR, WCR_DSIEN);
@@ -231,7 +215,7 @@  static void dw_mipi_dsi_phy_power_off(void *priv_data)
 {
 	struct dw_mipi_dsi_stm *dsi = priv_data;
 
-	DRM_DEBUG_DRIVER("\n");
+	dev_dbg(dsi->dev, "\n");
 
 	/* Disable the DSI wrapper */
 	dsi_clear(dsi, DSI_WCR, WCR_DSIEN);
@@ -244,6 +228,7 @@  dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
 {
 	struct dw_mipi_dsi_stm *dsi = priv_data;
 	unsigned int idf, ndiv, odf, pll_in_khz, pll_out_khz;
+	enum mipi_dsi_pixel_format fmt;
 	int ret, bpp;
 	u32 val;
 
@@ -267,11 +252,11 @@  dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
 
 	if (pll_out_khz > dsi->lane_max_kbps) {
 		pll_out_khz = dsi->lane_max_kbps;
-		DRM_WARN("Warning max phy mbps is used\n");
+		dev_warn(dsi->dev, "Warning max phy mbps is used\n");
 	}
 	if (pll_out_khz < dsi->lane_min_kbps) {
 		pll_out_khz = dsi->lane_min_kbps;
-		DRM_WARN("Warning min phy mbps is used\n");
+		dev_warn(dsi->dev, "Warning min phy mbps is used\n");
 	}
 
 	/* Compute best pll parameters */
@@ -281,7 +266,7 @@  dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
 	ret = dsi_pll_get_params(dsi, pll_in_khz, pll_out_khz,
 				 &idf, &ndiv, &odf);
 	if (ret)
-		DRM_WARN("Warning dsi_pll_get_params(): bad params\n");
+		dev_warn(dsi->dev, "Warning dsi_pll_get_params(): bad params\n");
 
 	/* Get the adjusted pll out value */
 	pll_out_khz = dsi_pll_get_clkout_khz(pll_in_khz, idf, ndiv, odf);
@@ -297,14 +282,31 @@  dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
 	/* Select video mode by resetting DSIM bit */
 	dsi_clear(dsi, DSI_WCFGR, WCFGR_DSIM);
 
+	switch (format) {
+	case MIPI_DSI_FMT_RGB888:
+		fmt = DSI_RGB888;
+		break;
+	case MIPI_DSI_FMT_RGB666:
+		fmt = DSI_RGB666_CONF2;
+		break;
+	case MIPI_DSI_FMT_RGB666_PACKED:
+		fmt = DSI_RGB666_CONF1;
+		break;
+	case MIPI_DSI_FMT_RGB565:
+		fmt = DSI_RGB565_CONF1;
+		break;
+	default:
+		fmt = DSI_RGB888;
+		dev_err(dsi->dev, "MIPI color invalid, so we use rgb888\n");
+	}
+
 	/* Select the color coding */
-	dsi_update_bits(dsi, DSI_WCFGR, WCFGR_COLMUX,
-			dsi_color_from_mipi(format) << 1);
+	dsi_update_bits(dsi, DSI_WCFGR, WCFGR_COLMUX, fmt << 1);
 
 	*lane_mbps = pll_out_khz / 1000;
 
-	DRM_DEBUG_DRIVER("pll_in %ukHz pll_out %ukHz lane_mbps %uMHz\n",
-			 pll_in_khz, pll_out_khz, *lane_mbps);
+	dev_dbg(dsi->dev, "pll_in %ukHz pll_out %ukHz lane_mbps %uMHz\n", pll_in_khz, pll_out_khz,
+		*lane_mbps);
 
 	return 0;
 }
@@ -352,11 +354,13 @@  static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
 	if (!dsi)
 		return -ENOMEM;
 
+	dsi->dev = dev;
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	dsi->base = devm_ioremap_resource(dev, res);
 	if (IS_ERR(dsi->base)) {
 		ret = PTR_ERR(dsi->base);
-		DRM_ERROR("Unable to get dsi registers %d\n", ret);
+		dev_err(dev, "Unable to get dsi registers %d\n", ret);
 		return ret;
 	}
 
@@ -364,13 +368,13 @@  static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
 	if (IS_ERR(dsi->vdd_supply)) {
 		ret = PTR_ERR(dsi->vdd_supply);
 		if (ret != -EPROBE_DEFER)
-			DRM_ERROR("Failed to request regulator: %d\n", ret);
+			dev_err(dev, "Failed to request regulator: %d\n", ret);
 		return ret;
 	}
 
 	ret = regulator_enable(dsi->vdd_supply);
 	if (ret) {
-		DRM_ERROR("Failed to enable regulator: %d\n", ret);
+		dev_err(dev, "Failed to enable regulator: %d\n", ret);
 		return ret;
 	}
 
@@ -378,27 +382,26 @@  static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
 	if (IS_ERR(dsi->pllref_clk)) {
 		ret = PTR_ERR(dsi->pllref_clk);
 		if (ret != -EPROBE_DEFER)
-			DRM_ERROR("Unable to get pll reference clock: %d\n",
-				  ret);
+			dev_err(dev, "Unable to get pll reference clock: %d\n", ret);
 		goto err_clk_get;
 	}
 
 	ret = clk_prepare_enable(dsi->pllref_clk);
 	if (ret) {
-		DRM_ERROR("Failed to enable pllref_clk: %d\n", ret);
+		dev_err(dev, "Failed to enable pllref_clk: %d\n", ret);
 		goto err_clk_get;
 	}
 
 	pclk = devm_clk_get(dev, "pclk");
 	if (IS_ERR(pclk)) {
 		ret = PTR_ERR(pclk);
-		DRM_ERROR("Unable to get peripheral clock: %d\n", ret);
+		dev_err(dev, "Unable to get peripheral clock: %d\n", ret);
 		goto err_dsi_probe;
 	}
 
 	ret = clk_prepare_enable(pclk);
 	if (ret) {
-		DRM_ERROR("%s: Failed to enable peripheral clk\n", __func__);
+		dev_err(dev, "%s: Failed to enable peripheral clk\n", __func__);
 		goto err_dsi_probe;
 	}
 
@@ -407,7 +410,7 @@  static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
 
 	if (dsi->hw_version != HWVER_130 && dsi->hw_version != HWVER_131) {
 		ret = -ENODEV;
-		DRM_ERROR("bad dsi hardware version\n");
+		dev_err(dev, "bad dsi hardware version\n");
 		goto err_dsi_probe;
 	}
 
@@ -420,7 +423,7 @@  static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
 	if (IS_ERR(dsi->dsi)) {
 		ret = PTR_ERR(dsi->dsi);
 		if (ret != -EPROBE_DEFER)
-			DRM_ERROR("Failed to initialize mipi dsi host: %d\n", ret);
+			dev_err(dev, "Failed to initialize mipi dsi host: %d\n", ret);
 		goto err_dsi_probe;
 	}
 
@@ -449,7 +452,7 @@  static int __maybe_unused dw_mipi_dsi_stm_suspend(struct device *dev)
 {
 	struct dw_mipi_dsi_stm *dsi = dw_mipi_dsi_stm_plat_data.priv_data;
 
-	DRM_DEBUG_DRIVER("\n");
+	dev_dbg(dsi->dev, "\n");
 
 	clk_disable_unprepare(dsi->pllref_clk);
 	regulator_disable(dsi->vdd_supply);
@@ -462,18 +465,18 @@  static int __maybe_unused dw_mipi_dsi_stm_resume(struct device *dev)
 	struct dw_mipi_dsi_stm *dsi = dw_mipi_dsi_stm_plat_data.priv_data;
 	int ret;
 
-	DRM_DEBUG_DRIVER("\n");
+	dev_dbg(dsi->dev, "\n");
 
 	ret = regulator_enable(dsi->vdd_supply);
 	if (ret) {
-		DRM_ERROR("Failed to enable regulator: %d\n", ret);
+		dev_err(dev, "Failed to enable regulator: %d\n", ret);
 		return ret;
 	}
 
 	ret = clk_prepare_enable(dsi->pllref_clk);
 	if (ret) {
 		regulator_disable(dsi->vdd_supply);
-		DRM_ERROR("Failed to enable pllref_clk: %d\n", ret);
+		dev_err(dev, "Failed to enable pllref_clk: %d\n", ret);
 		return ret;
 	}