aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen-Yu Tsai <wens@csie.org>2017-02-23 03:05:37 -0500
committerMaxime Ripard <maxime.ripard@free-electrons.com>2017-03-07 16:18:23 -0500
commit46cce6dac316a707309b374d9b6786b4269e7274 (patch)
tree553800c49e188e27363a770bd44e71e540467dd1
parentb3f266e428db3f08bb57f6edd6be10c4d092c38d (diff)
drm/sun4i: Initialize crtc from tcon bind function
The tcon provides part of the functionality of the crtc, and also provides the device node for the output port of the crtc. To be able to use drm_of_find_possible_crtcs(), all crtc must be initialized before any downstream encoders. The other part of the crtc is the display backend. The Rockchip DRM driver does this by first binding all vops, which is their crtc, and this step also creates the crtc objects. Then all remaining hardware components are bound. With the Allwinner display pipeline, we have multiple components comprising the crtc, and varying depths of the display pipeline. Since components are added with a depth first search of the of_graph, we can initialize the crtc object within the tcon bind function. Since the backend precedes the tcon, and the backends cannot be muxed or switched around, we can be sure that the associated backend is already initialized. This patch also moves the crtc pointer from the main drm_device data to the tcon device data. Besides the crtc callbacks, the crtc structure is only used within the tcon driver to signal vblank events from its interrupt handler. As the crtc and layer bits are now called from the tcon bits, we must move them from the sun4i-drm module to the sun4i-tcon module to avoid circular dependencies between the two modules. This is because sun4i-drm also calls into sun4i-tcon. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
-rw-r--r--drivers/gpu/drm/sun4i/Makefile4
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_drv.c8
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_drv.h1
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_tcon.c10
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_tcon.h3
5 files changed, 13 insertions, 13 deletions
diff --git a/drivers/gpu/drm/sun4i/Makefile b/drivers/gpu/drm/sun4i/Makefile
index d625a82a6e5f..59b757350a1f 100644
--- a/drivers/gpu/drm/sun4i/Makefile
+++ b/drivers/gpu/drm/sun4i/Makefile
@@ -1,11 +1,11 @@
1sun4i-drm-y += sun4i_crtc.o
2sun4i-drm-y += sun4i_drv.o 1sun4i-drm-y += sun4i_drv.o
3sun4i-drm-y += sun4i_framebuffer.o 2sun4i-drm-y += sun4i_framebuffer.o
4sun4i-drm-y += sun4i_layer.o
5 3
6sun4i-tcon-y += sun4i_tcon.o 4sun4i-tcon-y += sun4i_tcon.o
7sun4i-tcon-y += sun4i_rgb.o 5sun4i-tcon-y += sun4i_rgb.o
8sun4i-tcon-y += sun4i_dotclock.o 6sun4i-tcon-y += sun4i_dotclock.o
7sun4i-tcon-y += sun4i_crtc.o
8sun4i-tcon-y += sun4i_layer.o
9 9
10obj-$(CONFIG_DRM_SUN4I) += sun4i-drm.o sun4i-tcon.o 10obj-$(CONFIG_DRM_SUN4I) += sun4i-drm.o sun4i-tcon.o
11obj-$(CONFIG_DRM_SUN4I) += sun4i_backend.o 11obj-$(CONFIG_DRM_SUN4I) += sun4i_backend.o
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 084c158611de..1de15cd1b102 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -20,7 +20,6 @@
20#include <drm/drm_fb_helper.h> 20#include <drm/drm_fb_helper.h>
21#include <drm/drm_of.h> 21#include <drm/drm_of.h>
22 22
23#include "sun4i_crtc.h"
24#include "sun4i_drv.h" 23#include "sun4i_drv.h"
25#include "sun4i_framebuffer.h" 24#include "sun4i_framebuffer.h"
26#include "sun4i_tcon.h" 25#include "sun4i_tcon.h"
@@ -115,13 +114,6 @@ static int sun4i_drv_bind(struct device *dev)
115 goto cleanup_mode_config; 114 goto cleanup_mode_config;
116 } 115 }
117 116
118 /* Create our CRTC */
119 drv->crtc = sun4i_crtc_init(drm);
120 if (IS_ERR(drv->crtc)) {
121 dev_err(drm->dev, "Couldn't create the CRTC\n");
122 ret = PTR_ERR(drv->crtc);
123 goto cleanup_mode_config;
124 }
125 drm->irq_enabled = true; 117 drm->irq_enabled = true;
126 118
127 /* Remove early framebuffers (ie. simplefb) */ 119 /* Remove early framebuffers (ie. simplefb) */
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.h b/drivers/gpu/drm/sun4i/sun4i_drv.h
index e22ee536677e..7a3345b7b6d1 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.h
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.h
@@ -18,7 +18,6 @@
18 18
19struct sun4i_drv { 19struct sun4i_drv {
20 struct sun4i_backend *backend; 20 struct sun4i_backend *backend;
21 struct sun4i_crtc *crtc;
22 struct sun4i_tcon *tcon; 21 struct sun4i_tcon *tcon;
23 22
24 struct drm_plane *primary; 23 struct drm_plane *primary;
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index ea2906f87cb9..3f3eb3f0b209 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -290,8 +290,7 @@ static irqreturn_t sun4i_tcon_handler(int irq, void *private)
290{ 290{
291 struct sun4i_tcon *tcon = private; 291 struct sun4i_tcon *tcon = private;
292 struct drm_device *drm = tcon->drm; 292 struct drm_device *drm = tcon->drm;
293 struct sun4i_drv *drv = drm->dev_private; 293 struct sun4i_crtc *scrtc = tcon->crtc;
294 struct sun4i_crtc *scrtc = drv->crtc;
295 unsigned int status; 294 unsigned int status;
296 295
297 regmap_read(tcon->regs, SUN4I_TCON_GINT0_REG, &status); 296 regmap_read(tcon->regs, SUN4I_TCON_GINT0_REG, &status);
@@ -524,6 +523,13 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master,
524 goto err_free_clocks; 523 goto err_free_clocks;
525 } 524 }
526 525
526 tcon->crtc = sun4i_crtc_init(drm);
527 if (IS_ERR(tcon->crtc)) {
528 dev_err(dev, "Couldn't create our CRTC\n");
529 ret = PTR_ERR(tcon->crtc);
530 goto err_free_clocks;
531 }
532
527 ret = sun4i_rgb_init(drm); 533 ret = sun4i_rgb_init(drm);
528 if (ret < 0) 534 if (ret < 0)
529 goto err_free_clocks; 535 goto err_free_clocks;
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h
index 166064bafe2e..f636343a935d 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.h
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h
@@ -169,6 +169,9 @@ struct sun4i_tcon {
169 169
170 /* Platform adjustments */ 170 /* Platform adjustments */
171 const struct sun4i_tcon_quirks *quirks; 171 const struct sun4i_tcon_quirks *quirks;
172
173 /* Associated crtc */
174 struct sun4i_crtc *crtc;
172}; 175};
173 176
174struct drm_bridge *sun4i_tcon_find_bridge(struct device_node *node); 177struct drm_bridge *sun4i_tcon_find_bridge(struct device_node *node);