diff options
Diffstat (limited to 'drivers/gpu/drm/stm')
| -rw-r--r-- | drivers/gpu/drm/stm/drv.c | 41 | ||||
| -rw-r--r-- | drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 14 | ||||
| -rw-r--r-- | drivers/gpu/drm/stm/ltdc.c | 75 | ||||
| -rw-r--r-- | drivers/gpu/drm/stm/ltdc.h | 4 | 
4 files changed, 59 insertions, 75 deletions
| diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c index c857663eafc2..8fe954c27fba 100644 --- a/drivers/gpu/drm/stm/drv.c +++ b/drivers/gpu/drm/stm/drv.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0  /*   * Copyright (C) STMicroelectronics SA 2017   * @@ -5,8 +6,6 @@   *          Yannick Fertre <[email protected]>   *          Fabien Dessenne <[email protected]>   *          Mickael Reulier <[email protected]> - * - * License terms:  GNU General Public License (GPL), version 2   */  #include <linux/component.h> @@ -15,6 +14,7 @@  #include <drm/drm_atomic.h>  #include <drm/drm_atomic_helper.h>  #include <drm/drm_crtc_helper.h> +#include <drm/drm_fb_helper.h>  #include <drm/drm_fb_cma_helper.h>  #include <drm/drm_gem_cma_helper.h>  #include <drm/drm_gem_framebuffer_helper.h> @@ -24,35 +24,19 @@  #define STM_MAX_FB_WIDTH	2048  #define STM_MAX_FB_HEIGHT	2048 /* same as width to handle orientation */ -static void drv_output_poll_changed(struct drm_device *ddev) -{ -	struct ltdc_device *ldev = ddev->dev_private; - -	drm_fbdev_cma_hotplug_event(ldev->fbdev); -} -  static const struct drm_mode_config_funcs drv_mode_config_funcs = {  	.fb_create = drm_gem_fb_create, -	.output_poll_changed = drv_output_poll_changed, +	.output_poll_changed = drm_fb_helper_output_poll_changed,  	.atomic_check = drm_atomic_helper_check,  	.atomic_commit = drm_atomic_helper_commit,  }; -static void drv_lastclose(struct drm_device *ddev) -{ -	struct ltdc_device *ldev = ddev->dev_private; - -	DRM_DEBUG("%s\n", __func__); - -	drm_fbdev_cma_restore_mode(ldev->fbdev); -} -  DEFINE_DRM_GEM_CMA_FOPS(drv_driver_fops);  static struct drm_driver drv_driver = {  	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |  			   DRIVER_ATOMIC, -	.lastclose = drv_lastclose, +	.lastclose = drm_fb_helper_lastclose,  	.name = "stm",  	.desc = "STMicroelectronics SoC DRM",  	.date = "20170330", @@ -79,7 +63,6 @@ static struct drm_driver drv_driver = {  static int drv_load(struct drm_device *ddev)  {  	struct platform_device *pdev = to_platform_device(ddev->dev); -	struct drm_fbdev_cma *fbdev;  	struct ltdc_device *ldev;  	int ret; @@ -112,14 +95,9 @@ static int drv_load(struct drm_device *ddev)  	drm_kms_helper_poll_init(ddev);  	if (ddev->mode_config.num_connector) { -		ldev = ddev->dev_private; -		fbdev = drm_fbdev_cma_init(ddev, 16, -					   ddev->mode_config.num_connector); -		if (IS_ERR(fbdev)) { +		ret = drm_fb_cma_fbdev_init(ddev, 16, 0); +		if (ret)  			DRM_DEBUG("Warning: fails to create fbdev\n"); -			fbdev = NULL; -		} -		ldev->fbdev = fbdev;  	}  	platform_set_drvdata(pdev, ddev); @@ -132,14 +110,9 @@ err:  static void drv_unload(struct drm_device *ddev)  { -	struct ltdc_device *ldev = ddev->dev_private; -  	DRM_DEBUG("%s\n", __func__); -	if (ldev->fbdev) { -		drm_fbdev_cma_fini(ldev->fbdev); -		ldev->fbdev = NULL; -	} +	drm_fb_cma_fbdev_fini(ddev);  	drm_kms_helper_poll_fini(ddev);  	ltdc_unload(ddev);  	drm_mode_config_cleanup(ddev); diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c index e5b6310240fe..fd02506274da 100644 --- a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c +++ b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c @@ -1,10 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0  /*   * Copyright (C) STMicroelectronics SA 2017   *   * Authors: Philippe Cornu <[email protected]>   *          Yannick Fertre <[email protected]> - * - * License terms:  GNU General Public License (GPL), version 2   */  #include <linux/clk.h> @@ -129,7 +128,7 @@ static int dsi_pll_get_params(int clkin_khz, int clkout_khz,  	int fvco_min, fvco_max, delta, best_delta; /* all in khz */  	/* Early checks preventing division by 0 & odd results */ -	if ((clkin_khz <= 0) || (clkout_khz <= 0)) +	if (clkin_khz <= 0 || clkout_khz <= 0)  		return -EINVAL;  	fvco_min = LANE_MIN_KBPS * 2 * ODF_MAX; @@ -155,7 +154,7 @@ static int dsi_pll_get_params(int clkin_khz, int clkout_khz,  		for (o = ODF_MIN; o <= ODF_MAX; o *= 2) {  			n = DIV_ROUND_CLOSEST(i * o * clkout_khz, clkin_khz);  			/* Check ndiv according to vco range */ -			if ((n < n_min) || (n > n_max)) +			if (n < n_min || n > n_max)  				continue;  			/* Check if new delta is better & saves parameters */  			delta = dsi_pll_get_clkout_khz(clkin_khz, i, n, o) - @@ -291,11 +290,6 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)  		return -ENOMEM;  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -	if (!res) { -		DRM_ERROR("Unable to get resource\n"); -		return -ENODEV; -	} -  	dsi->base = devm_ioremap_resource(dev, res);  	if (IS_ERR(dsi->base)) {  		DRM_ERROR("Unable to get dsi registers\n"); @@ -342,7 +336,7 @@ static struct platform_driver dw_mipi_dsi_stm_driver = {  	.remove		= dw_mipi_dsi_stm_remove,  	.driver		= {  		.of_match_table = dw_mipi_dsi_stm_dt_ids, -		.name	= "dw_mipi_dsi-stm", +		.name	= "stm32-display-dsi",  	},  }; diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c index 735c9081202a..6dc5d4ec4e17 100644 --- a/drivers/gpu/drm/stm/ltdc.c +++ b/drivers/gpu/drm/stm/ltdc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0  /*   * Copyright (C) STMicroelectronics SA 2017   * @@ -5,8 +6,6 @@   *          Yannick Fertre <[email protected]>   *          Fabien Dessenne <[email protected]>   *          Mickael Reulier <[email protected]> - * - * License terms:  GNU General Public License (GPL), version 2   */  #include <linux/clk.h> @@ -33,6 +32,8 @@  #define MAX_IRQ 4 +#define MAX_ENDPOINTS 2 +  #define HWVER_10200 0x010200  #define HWVER_10300 0x010300  #define HWVER_20101 0x020101 @@ -556,7 +557,7 @@ static int ltdc_plane_atomic_check(struct drm_plane *plane,  	src_h = state->src_h >> 16;  	/* Reject scaling */ -	if ((src_w != state->crtc_w) || (src_h != state->crtc_h)) { +	if (src_w != state->crtc_w || src_h != state->crtc_h) {  		DRM_ERROR("Scaling is not supported");  		return -EINVAL;  	} @@ -856,18 +857,33 @@ int ltdc_load(struct drm_device *ddev)  	struct ltdc_device *ldev = ddev->dev_private;  	struct device *dev = ddev->dev;  	struct device_node *np = dev->of_node; -	struct drm_bridge *bridge; -	struct drm_panel *panel; +	struct drm_bridge *bridge[MAX_ENDPOINTS] = {NULL}; +	struct drm_panel *panel[MAX_ENDPOINTS] = {NULL};  	struct drm_crtc *crtc;  	struct reset_control *rstc;  	struct resource *res; -	int irq, ret, i; +	int irq, ret, i, endpoint_not_ready = -ENODEV;  	DRM_DEBUG_DRIVER("\n"); -	ret = drm_of_find_panel_or_bridge(np, 0, 0, &panel, &bridge); -	if (ret) -		return ret; +	/* Get endpoints if any */ +	for (i = 0; i < MAX_ENDPOINTS; i++) { +		ret = drm_of_find_panel_or_bridge(np, 0, i, &panel[i], +						  &bridge[i]); + +		/* +		 * If at least one endpoint is ready, continue probing, +		 * else if at least one endpoint is -EPROBE_DEFER and +		 * there is no previous ready endpoints, defer probing. +		 */ +		if (!ret) +			endpoint_not_ready = 0; +		else if (ret == -EPROBE_DEFER && endpoint_not_ready) +			endpoint_not_ready = -EPROBE_DEFER; +	} + +	if (endpoint_not_ready) +		return endpoint_not_ready;  	rstc = devm_reset_control_get_exclusive(dev, NULL); @@ -885,12 +901,6 @@ int ltdc_load(struct drm_device *ddev)  	}  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -	if (!res) { -		DRM_ERROR("Unable to get resource\n"); -		ret = -ENODEV; -		goto err; -	} -  	ldev->regs = devm_ioremap_resource(dev, res);  	if (IS_ERR(ldev->regs)) {  		DRM_ERROR("Unable to get ltdc registers\n"); @@ -928,19 +938,25 @@ int ltdc_load(struct drm_device *ddev)  	DRM_INFO("ltdc hw version 0x%08x - ready\n", ldev->caps.hw_version); -	if (panel) { -		bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DPI); -		if (IS_ERR(bridge)) { -			DRM_ERROR("Failed to create panel-bridge\n"); -			ret = PTR_ERR(bridge); -			goto err; +	/* Add endpoints panels or bridges if any */ +	for (i = 0; i < MAX_ENDPOINTS; i++) { +		if (panel[i]) { +			bridge[i] = drm_panel_bridge_add(panel[i], +							DRM_MODE_CONNECTOR_DPI); +			if (IS_ERR(bridge[i])) { +				DRM_ERROR("panel-bridge endpoint %d\n", i); +				ret = PTR_ERR(bridge[i]); +				goto err; +			}  		} -	} -	ret = ltdc_encoder_init(ddev, bridge); -	if (ret) { -		DRM_ERROR("Failed to init encoder\n"); -		goto err; +		if (bridge[i]) { +			ret = ltdc_encoder_init(ddev, bridge[i]); +			if (ret) { +				DRM_ERROR("init encoder endpoint %d\n", i); +				goto err; +			} +		}  	}  	crtc = devm_kzalloc(dev, sizeof(*crtc), GFP_KERNEL); @@ -968,7 +984,8 @@ int ltdc_load(struct drm_device *ddev)  	return 0;  err: -	drm_panel_bridge_remove(bridge); +	for (i = 0; i < MAX_ENDPOINTS; i++) +		drm_panel_bridge_remove(bridge[i]);  	clk_disable_unprepare(ldev->pixel_clk); @@ -978,10 +995,12 @@ err:  void ltdc_unload(struct drm_device *ddev)  {  	struct ltdc_device *ldev = ddev->dev_private; +	int i;  	DRM_DEBUG_DRIVER("\n"); -	drm_of_panel_bridge_remove(ddev->dev->of_node, 0, 0); +	for (i = 0; i < MAX_ENDPOINTS; i++) +		drm_of_panel_bridge_remove(ddev->dev->of_node, 0, i);  	clk_disable_unprepare(ldev->pixel_clk);  } diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h index ae437557d715..edd1c0a446d1 100644 --- a/drivers/gpu/drm/stm/ltdc.h +++ b/drivers/gpu/drm/stm/ltdc.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */  /*   * Copyright (C) STMicroelectronics SA 2017   * @@ -5,8 +6,6 @@   *          Yannick Fertre <[email protected]>   *          Fabien Dessenne <[email protected]>   *          Mickael Reulier <[email protected]> - * - * License terms:  GNU General Public License (GPL), version 2   */  #ifndef _LTDC_H_ @@ -21,7 +20,6 @@ struct ltdc_caps {  };  struct ltdc_device { -	struct drm_fbdev_cma *fbdev;  	void __iomem *regs;  	struct clk *pixel_clk;	/* lcd pixel clock */  	struct mutex err_lock;	/* protecting error_status */ |