1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* drivers/gpu/drm/exynos/exynos7_drm_decon.c
4 * Copyright (C) 2014 Samsung Electronics Co.Ltd
6 * Akshu Agarwal <akshua@gmail.com>
7 * Ajay Kumar <ajaykumar.rs@samsung.com>
10 #include <linux/clk.h>
11 #include <linux/component.h>
12 #include <linux/kernel.h>
14 #include <linux/of_address.h>
15 #include <linux/of_device.h>
16 #include <linux/platform_device.h>
17 #include <linux/pm_runtime.h>
19 #include <video/of_display_timing.h>
20 #include <video/of_videomode.h>
22 #include <drm/drm_fourcc.h>
23 #include <drm/drm_vblank.h>
24 #include <drm/exynos_drm.h>
26 #include "exynos_drm_crtc.h"
27 #include "exynos_drm_drv.h"
28 #include "exynos_drm_fb.h"
29 #include "exynos_drm_plane.h"
30 #include "regs-decon7.h"
33 * DECON stands for Display and Enhancement controller.
36 #define MIN_FB_WIDTH_FOR_16WORD_BURST 128
40 struct decon_context
{
42 struct drm_device
*drm_dev
;
43 struct exynos_drm_crtc
*crtc
;
44 struct exynos_drm_plane planes
[WINDOWS_NR
];
45 struct exynos_drm_plane_config configs
[WINDOWS_NR
];
51 unsigned long irq_flags
;
54 wait_queue_head_t wait_vsync_queue
;
55 atomic_t wait_vsync_event
;
57 struct drm_encoder
*encoder
;
60 static const struct of_device_id decon_driver_dt_match
[] = {
61 {.compatible
= "samsung,exynos7-decon"},
64 MODULE_DEVICE_TABLE(of
, decon_driver_dt_match
);
66 static const uint32_t decon_formats
[] = {
78 static const enum drm_plane_type decon_win_types
[WINDOWS_NR
] = {
79 DRM_PLANE_TYPE_PRIMARY
,
80 DRM_PLANE_TYPE_CURSOR
,
83 static void decon_wait_for_vblank(struct exynos_drm_crtc
*crtc
)
85 struct decon_context
*ctx
= crtc
->ctx
;
90 atomic_set(&ctx
->wait_vsync_event
, 1);
93 * wait for DECON to signal VSYNC interrupt or return after
94 * timeout which is set to 50ms (refresh rate of 20).
96 if (!wait_event_timeout(ctx
->wait_vsync_queue
,
97 !atomic_read(&ctx
->wait_vsync_event
),
99 DRM_DEV_DEBUG_KMS(ctx
->dev
, "vblank wait timed out.\n");
102 static void decon_clear_channels(struct exynos_drm_crtc
*crtc
)
104 struct decon_context
*ctx
= crtc
->ctx
;
105 unsigned int win
, ch_enabled
= 0;
107 /* Check if any channel is enabled. */
108 for (win
= 0; win
< WINDOWS_NR
; win
++) {
109 u32 val
= readl(ctx
->regs
+ WINCON(win
));
111 if (val
& WINCONx_ENWIN
) {
112 val
&= ~WINCONx_ENWIN
;
113 writel(val
, ctx
->regs
+ WINCON(win
));
118 /* Wait for vsync, as disable channel takes effect at next vsync */
120 decon_wait_for_vblank(ctx
->crtc
);
123 static int decon_ctx_initialize(struct decon_context
*ctx
,
124 struct drm_device
*drm_dev
)
126 ctx
->drm_dev
= drm_dev
;
128 decon_clear_channels(ctx
->crtc
);
130 return exynos_drm_register_dma(drm_dev
, ctx
->dev
);
133 static void decon_ctx_remove(struct decon_context
*ctx
)
135 /* detach this sub driver from iommu mapping if supported. */
136 exynos_drm_unregister_dma(ctx
->drm_dev
, ctx
->dev
);
139 static u32
decon_calc_clkdiv(struct decon_context
*ctx
,
140 const struct drm_display_mode
*mode
)
142 unsigned long ideal_clk
= mode
->htotal
* mode
->vtotal
* mode
->vrefresh
;
145 /* Find the clock divider value that gets us closest to ideal_clk */
146 clkdiv
= DIV_ROUND_UP(clk_get_rate(ctx
->vclk
), ideal_clk
);
148 return (clkdiv
< 0x100) ? clkdiv
: 0xff;
151 static void decon_commit(struct exynos_drm_crtc
*crtc
)
153 struct decon_context
*ctx
= crtc
->ctx
;
154 struct drm_display_mode
*mode
= &crtc
->base
.state
->adjusted_mode
;
160 /* nothing to do if we haven't set the mode yet */
161 if (mode
->htotal
== 0 || mode
->vtotal
== 0)
165 int vsync_len
, vbpd
, vfpd
, hsync_len
, hbpd
, hfpd
;
166 /* setup vertical timing values. */
167 vsync_len
= mode
->crtc_vsync_end
- mode
->crtc_vsync_start
;
168 vbpd
= mode
->crtc_vtotal
- mode
->crtc_vsync_end
;
169 vfpd
= mode
->crtc_vsync_start
- mode
->crtc_vdisplay
;
171 val
= VIDTCON0_VBPD(vbpd
- 1) | VIDTCON0_VFPD(vfpd
- 1);
172 writel(val
, ctx
->regs
+ VIDTCON0
);
174 val
= VIDTCON1_VSPW(vsync_len
- 1);
175 writel(val
, ctx
->regs
+ VIDTCON1
);
177 /* setup horizontal timing values. */
178 hsync_len
= mode
->crtc_hsync_end
- mode
->crtc_hsync_start
;
179 hbpd
= mode
->crtc_htotal
- mode
->crtc_hsync_end
;
180 hfpd
= mode
->crtc_hsync_start
- mode
->crtc_hdisplay
;
182 /* setup horizontal timing values. */
183 val
= VIDTCON2_HBPD(hbpd
- 1) | VIDTCON2_HFPD(hfpd
- 1);
184 writel(val
, ctx
->regs
+ VIDTCON2
);
186 val
= VIDTCON3_HSPW(hsync_len
- 1);
187 writel(val
, ctx
->regs
+ VIDTCON3
);
190 /* setup horizontal and vertical display size. */
191 val
= VIDTCON4_LINEVAL(mode
->vdisplay
- 1) |
192 VIDTCON4_HOZVAL(mode
->hdisplay
- 1);
193 writel(val
, ctx
->regs
+ VIDTCON4
);
195 writel(mode
->vdisplay
- 1, ctx
->regs
+ LINECNT_OP_THRESHOLD
);
198 * fields of register with prefix '_F' would be updated
199 * at vsync(same as dma start)
201 val
= VIDCON0_ENVID
| VIDCON0_ENVID_F
;
202 writel(val
, ctx
->regs
+ VIDCON0
);
204 clkdiv
= decon_calc_clkdiv(ctx
, mode
);
206 val
= VCLKCON1_CLKVAL_NUM_VCLK(clkdiv
- 1);
207 writel(val
, ctx
->regs
+ VCLKCON1
);
208 writel(val
, ctx
->regs
+ VCLKCON2
);
211 val
= readl(ctx
->regs
+ DECON_UPDATE
);
212 val
|= DECON_UPDATE_STANDALONE_F
;
213 writel(val
, ctx
->regs
+ DECON_UPDATE
);
216 static int decon_enable_vblank(struct exynos_drm_crtc
*crtc
)
218 struct decon_context
*ctx
= crtc
->ctx
;
224 if (!test_and_set_bit(0, &ctx
->irq_flags
)) {
225 val
= readl(ctx
->regs
+ VIDINTCON0
);
227 val
|= VIDINTCON0_INT_ENABLE
;
230 val
|= VIDINTCON0_INT_FRAME
;
231 val
&= ~VIDINTCON0_FRAMESEL0_MASK
;
232 val
|= VIDINTCON0_FRAMESEL0_VSYNC
;
235 writel(val
, ctx
->regs
+ VIDINTCON0
);
241 static void decon_disable_vblank(struct exynos_drm_crtc
*crtc
)
243 struct decon_context
*ctx
= crtc
->ctx
;
249 if (test_and_clear_bit(0, &ctx
->irq_flags
)) {
250 val
= readl(ctx
->regs
+ VIDINTCON0
);
252 val
&= ~VIDINTCON0_INT_ENABLE
;
254 val
&= ~VIDINTCON0_INT_FRAME
;
256 writel(val
, ctx
->regs
+ VIDINTCON0
);
260 static void decon_win_set_pixfmt(struct decon_context
*ctx
, unsigned int win
,
261 struct drm_framebuffer
*fb
)
266 val
= readl(ctx
->regs
+ WINCON(win
));
267 val
&= ~WINCONx_BPPMODE_MASK
;
269 switch (fb
->format
->format
) {
270 case DRM_FORMAT_RGB565
:
271 val
|= WINCONx_BPPMODE_16BPP_565
;
272 val
|= WINCONx_BURSTLEN_16WORD
;
274 case DRM_FORMAT_XRGB8888
:
275 val
|= WINCONx_BPPMODE_24BPP_xRGB
;
276 val
|= WINCONx_BURSTLEN_16WORD
;
278 case DRM_FORMAT_XBGR8888
:
279 val
|= WINCONx_BPPMODE_24BPP_xBGR
;
280 val
|= WINCONx_BURSTLEN_16WORD
;
282 case DRM_FORMAT_RGBX8888
:
283 val
|= WINCONx_BPPMODE_24BPP_RGBx
;
284 val
|= WINCONx_BURSTLEN_16WORD
;
286 case DRM_FORMAT_BGRX8888
:
287 val
|= WINCONx_BPPMODE_24BPP_BGRx
;
288 val
|= WINCONx_BURSTLEN_16WORD
;
290 case DRM_FORMAT_ARGB8888
:
291 val
|= WINCONx_BPPMODE_32BPP_ARGB
| WINCONx_BLD_PIX
|
293 val
|= WINCONx_BURSTLEN_16WORD
;
295 case DRM_FORMAT_ABGR8888
:
296 val
|= WINCONx_BPPMODE_32BPP_ABGR
| WINCONx_BLD_PIX
|
298 val
|= WINCONx_BURSTLEN_16WORD
;
300 case DRM_FORMAT_RGBA8888
:
301 val
|= WINCONx_BPPMODE_32BPP_RGBA
| WINCONx_BLD_PIX
|
303 val
|= WINCONx_BURSTLEN_16WORD
;
305 case DRM_FORMAT_BGRA8888
:
307 val
|= WINCONx_BPPMODE_32BPP_BGRA
| WINCONx_BLD_PIX
|
309 val
|= WINCONx_BURSTLEN_16WORD
;
313 DRM_DEV_DEBUG_KMS(ctx
->dev
, "cpp = %d\n", fb
->format
->cpp
[0]);
316 * In case of exynos, setting dma-burst to 16Word causes permanent
317 * tearing for very small buffers, e.g. cursor buffer. Burst Mode
318 * switching which is based on plane size is not recommended as
319 * plane size varies a lot towards the end of the screen and rapid
320 * movement causes unstable DMA which results into iommu crash/tear.
323 padding
= (fb
->pitches
[0] / fb
->format
->cpp
[0]) - fb
->width
;
324 if (fb
->width
+ padding
< MIN_FB_WIDTH_FOR_16WORD_BURST
) {
325 val
&= ~WINCONx_BURSTLEN_MASK
;
326 val
|= WINCONx_BURSTLEN_8WORD
;
329 writel(val
, ctx
->regs
+ WINCON(win
));
332 static void decon_win_set_colkey(struct decon_context
*ctx
, unsigned int win
)
334 unsigned int keycon0
= 0, keycon1
= 0;
336 keycon0
= ~(WxKEYCON0_KEYBL_EN
| WxKEYCON0_KEYEN_F
|
337 WxKEYCON0_DIRCON
) | WxKEYCON0_COMPKEY(0);
339 keycon1
= WxKEYCON1_COLVAL(0xffffffff);
341 writel(keycon0
, ctx
->regs
+ WKEYCON0_BASE(win
));
342 writel(keycon1
, ctx
->regs
+ WKEYCON1_BASE(win
));
346 * shadow_protect_win() - disable updating values from shadow registers at vsync
348 * @win: window to protect registers for
349 * @protect: 1 to protect (disable updates)
351 static void decon_shadow_protect_win(struct decon_context
*ctx
,
352 unsigned int win
, bool protect
)
356 bits
= SHADOWCON_WINx_PROTECT(win
);
358 val
= readl(ctx
->regs
+ SHADOWCON
);
363 writel(val
, ctx
->regs
+ SHADOWCON
);
366 static void decon_atomic_begin(struct exynos_drm_crtc
*crtc
)
368 struct decon_context
*ctx
= crtc
->ctx
;
374 for (i
= 0; i
< WINDOWS_NR
; i
++)
375 decon_shadow_protect_win(ctx
, i
, true);
378 static void decon_update_plane(struct exynos_drm_crtc
*crtc
,
379 struct exynos_drm_plane
*plane
)
381 struct exynos_drm_plane_state
*state
=
382 to_exynos_plane_state(plane
->base
.state
);
383 struct decon_context
*ctx
= crtc
->ctx
;
384 struct drm_framebuffer
*fb
= state
->base
.fb
;
386 unsigned long val
, alpha
;
389 unsigned int win
= plane
->index
;
390 unsigned int cpp
= fb
->format
->cpp
[0];
391 unsigned int pitch
= fb
->pitches
[0];
397 * SHADOWCON/PRTCON register is used for enabling timing.
399 * for example, once only width value of a register is set,
400 * if the dma is started then decon hardware could malfunction so
401 * with protect window setting, the register fields with prefix '_F'
402 * wouldn't be updated at vsync also but updated once unprotect window
406 /* buffer start address */
407 val
= (unsigned long)exynos_drm_fb_dma_addr(fb
, 0);
408 writel(val
, ctx
->regs
+ VIDW_BUF_START(win
));
410 padding
= (pitch
/ cpp
) - fb
->width
;
413 writel(fb
->width
+ padding
, ctx
->regs
+ VIDW_WHOLE_X(win
));
414 writel(fb
->height
, ctx
->regs
+ VIDW_WHOLE_Y(win
));
416 /* offset from the start of the buffer to read */
417 writel(state
->src
.x
, ctx
->regs
+ VIDW_OFFSET_X(win
));
418 writel(state
->src
.y
, ctx
->regs
+ VIDW_OFFSET_Y(win
));
420 DRM_DEV_DEBUG_KMS(ctx
->dev
, "start addr = 0x%lx\n",
422 DRM_DEV_DEBUG_KMS(ctx
->dev
, "ovl_width = %d, ovl_height = %d\n",
423 state
->crtc
.w
, state
->crtc
.h
);
425 val
= VIDOSDxA_TOPLEFT_X(state
->crtc
.x
) |
426 VIDOSDxA_TOPLEFT_Y(state
->crtc
.y
);
427 writel(val
, ctx
->regs
+ VIDOSD_A(win
));
429 last_x
= state
->crtc
.x
+ state
->crtc
.w
;
432 last_y
= state
->crtc
.y
+ state
->crtc
.h
;
436 val
= VIDOSDxB_BOTRIGHT_X(last_x
) | VIDOSDxB_BOTRIGHT_Y(last_y
);
438 writel(val
, ctx
->regs
+ VIDOSD_B(win
));
440 DRM_DEV_DEBUG_KMS(ctx
->dev
, "osd pos: tx = %d, ty = %d, bx = %d, by = %d\n",
441 state
->crtc
.x
, state
->crtc
.y
, last_x
, last_y
);
444 alpha
= VIDOSDxC_ALPHA0_R_F(0x0) |
445 VIDOSDxC_ALPHA0_G_F(0x0) |
446 VIDOSDxC_ALPHA0_B_F(0x0);
448 writel(alpha
, ctx
->regs
+ VIDOSD_C(win
));
450 alpha
= VIDOSDxD_ALPHA1_R_F(0xff) |
451 VIDOSDxD_ALPHA1_G_F(0xff) |
452 VIDOSDxD_ALPHA1_B_F(0xff);
454 writel(alpha
, ctx
->regs
+ VIDOSD_D(win
));
456 decon_win_set_pixfmt(ctx
, win
, fb
);
458 /* hardware window 0 doesn't support color key. */
460 decon_win_set_colkey(ctx
, win
);
463 val
= readl(ctx
->regs
+ WINCON(win
));
464 val
|= WINCONx_TRIPLE_BUF_MODE
;
465 val
|= WINCONx_ENWIN
;
466 writel(val
, ctx
->regs
+ WINCON(win
));
468 /* Enable DMA channel and unprotect windows */
469 decon_shadow_protect_win(ctx
, win
, false);
471 val
= readl(ctx
->regs
+ DECON_UPDATE
);
472 val
|= DECON_UPDATE_STANDALONE_F
;
473 writel(val
, ctx
->regs
+ DECON_UPDATE
);
476 static void decon_disable_plane(struct exynos_drm_crtc
*crtc
,
477 struct exynos_drm_plane
*plane
)
479 struct decon_context
*ctx
= crtc
->ctx
;
480 unsigned int win
= plane
->index
;
486 /* protect windows */
487 decon_shadow_protect_win(ctx
, win
, true);
490 val
= readl(ctx
->regs
+ WINCON(win
));
491 val
&= ~WINCONx_ENWIN
;
492 writel(val
, ctx
->regs
+ WINCON(win
));
494 val
= readl(ctx
->regs
+ DECON_UPDATE
);
495 val
|= DECON_UPDATE_STANDALONE_F
;
496 writel(val
, ctx
->regs
+ DECON_UPDATE
);
499 static void decon_atomic_flush(struct exynos_drm_crtc
*crtc
)
501 struct decon_context
*ctx
= crtc
->ctx
;
507 for (i
= 0; i
< WINDOWS_NR
; i
++)
508 decon_shadow_protect_win(ctx
, i
, false);
509 exynos_crtc_handle_event(crtc
);
512 static void decon_init(struct decon_context
*ctx
)
516 writel(VIDCON0_SWRESET
, ctx
->regs
+ VIDCON0
);
518 val
= VIDOUTCON0_DISP_IF_0_ON
;
520 val
|= VIDOUTCON0_RGBIF
;
521 writel(val
, ctx
->regs
+ VIDOUTCON0
);
523 writel(VCLKCON0_CLKVALUP
| VCLKCON0_VCLKFREE
, ctx
->regs
+ VCLKCON0
);
526 writel(VIDCON1_VCLK_HOLD
, ctx
->regs
+ VIDCON1(0));
529 static void decon_atomic_enable(struct exynos_drm_crtc
*crtc
)
531 struct decon_context
*ctx
= crtc
->ctx
;
536 pm_runtime_get_sync(ctx
->dev
);
540 /* if vblank was enabled status, enable it again. */
541 if (test_and_clear_bit(0, &ctx
->irq_flags
))
542 decon_enable_vblank(ctx
->crtc
);
544 decon_commit(ctx
->crtc
);
546 ctx
->suspended
= false;
549 static void decon_atomic_disable(struct exynos_drm_crtc
*crtc
)
551 struct decon_context
*ctx
= crtc
->ctx
;
558 * We need to make sure that all windows are disabled before we
559 * suspend that connector. Otherwise we might try to scan from
560 * a destroyed buffer later.
562 for (i
= 0; i
< WINDOWS_NR
; i
++)
563 decon_disable_plane(crtc
, &ctx
->planes
[i
]);
565 pm_runtime_put_sync(ctx
->dev
);
567 ctx
->suspended
= true;
570 static const struct exynos_drm_crtc_ops decon_crtc_ops
= {
571 .atomic_enable
= decon_atomic_enable
,
572 .atomic_disable
= decon_atomic_disable
,
573 .enable_vblank
= decon_enable_vblank
,
574 .disable_vblank
= decon_disable_vblank
,
575 .atomic_begin
= decon_atomic_begin
,
576 .update_plane
= decon_update_plane
,
577 .disable_plane
= decon_disable_plane
,
578 .atomic_flush
= decon_atomic_flush
,
582 static irqreturn_t
decon_irq_handler(int irq
, void *dev_id
)
584 struct decon_context
*ctx
= (struct decon_context
*)dev_id
;
587 val
= readl(ctx
->regs
+ VIDINTCON1
);
589 clear_bit
= ctx
->i80_if
? VIDINTCON1_INT_I80
: VIDINTCON1_INT_FRAME
;
591 writel(clear_bit
, ctx
->regs
+ VIDINTCON1
);
593 /* check the crtc is detached already from encoder */
598 drm_crtc_handle_vblank(&ctx
->crtc
->base
);
600 /* set wait vsync event to zero and wake up queue. */
601 if (atomic_read(&ctx
->wait_vsync_event
)) {
602 atomic_set(&ctx
->wait_vsync_event
, 0);
603 wake_up(&ctx
->wait_vsync_queue
);
610 static int decon_bind(struct device
*dev
, struct device
*master
, void *data
)
612 struct decon_context
*ctx
= dev_get_drvdata(dev
);
613 struct drm_device
*drm_dev
= data
;
614 struct exynos_drm_plane
*exynos_plane
;
618 ret
= decon_ctx_initialize(ctx
, drm_dev
);
620 DRM_DEV_ERROR(dev
, "decon_ctx_initialize failed.\n");
624 for (i
= 0; i
< WINDOWS_NR
; i
++) {
625 ctx
->configs
[i
].pixel_formats
= decon_formats
;
626 ctx
->configs
[i
].num_pixel_formats
= ARRAY_SIZE(decon_formats
);
627 ctx
->configs
[i
].zpos
= i
;
628 ctx
->configs
[i
].type
= decon_win_types
[i
];
630 ret
= exynos_plane_init(drm_dev
, &ctx
->planes
[i
], i
,
636 exynos_plane
= &ctx
->planes
[DEFAULT_WIN
];
637 ctx
->crtc
= exynos_drm_crtc_create(drm_dev
, &exynos_plane
->base
,
638 EXYNOS_DISPLAY_TYPE_LCD
, &decon_crtc_ops
, ctx
);
639 if (IS_ERR(ctx
->crtc
)) {
640 decon_ctx_remove(ctx
);
641 return PTR_ERR(ctx
->crtc
);
645 exynos_dpi_bind(drm_dev
, ctx
->encoder
);
651 static void decon_unbind(struct device
*dev
, struct device
*master
,
654 struct decon_context
*ctx
= dev_get_drvdata(dev
);
656 decon_atomic_disable(ctx
->crtc
);
659 exynos_dpi_remove(ctx
->encoder
);
661 decon_ctx_remove(ctx
);
664 static const struct component_ops decon_component_ops
= {
666 .unbind
= decon_unbind
,
669 static int decon_probe(struct platform_device
*pdev
)
671 struct device
*dev
= &pdev
->dev
;
672 struct decon_context
*ctx
;
673 struct device_node
*i80_if_timings
;
674 struct resource
*res
;
680 ctx
= devm_kzalloc(dev
, sizeof(*ctx
), GFP_KERNEL
);
685 ctx
->suspended
= true;
687 i80_if_timings
= of_get_child_by_name(dev
->of_node
, "i80-if-timings");
690 of_node_put(i80_if_timings
);
692 ctx
->regs
= of_iomap(dev
->of_node
, 0);
696 ctx
->pclk
= devm_clk_get(dev
, "pclk_decon0");
697 if (IS_ERR(ctx
->pclk
)) {
698 dev_err(dev
, "failed to get bus clock pclk\n");
699 ret
= PTR_ERR(ctx
->pclk
);
703 ctx
->aclk
= devm_clk_get(dev
, "aclk_decon0");
704 if (IS_ERR(ctx
->aclk
)) {
705 dev_err(dev
, "failed to get bus clock aclk\n");
706 ret
= PTR_ERR(ctx
->aclk
);
710 ctx
->eclk
= devm_clk_get(dev
, "decon0_eclk");
711 if (IS_ERR(ctx
->eclk
)) {
712 dev_err(dev
, "failed to get eclock\n");
713 ret
= PTR_ERR(ctx
->eclk
);
717 ctx
->vclk
= devm_clk_get(dev
, "decon0_vclk");
718 if (IS_ERR(ctx
->vclk
)) {
719 dev_err(dev
, "failed to get vclock\n");
720 ret
= PTR_ERR(ctx
->vclk
);
724 res
= platform_get_resource_byname(pdev
, IORESOURCE_IRQ
,
725 ctx
->i80_if
? "lcd_sys" : "vsync");
727 dev_err(dev
, "irq request failed.\n");
732 ret
= devm_request_irq(dev
, res
->start
, decon_irq_handler
,
733 0, "drm_decon", ctx
);
735 dev_err(dev
, "irq request failed.\n");
739 init_waitqueue_head(&ctx
->wait_vsync_queue
);
740 atomic_set(&ctx
->wait_vsync_event
, 0);
742 platform_set_drvdata(pdev
, ctx
);
744 ctx
->encoder
= exynos_dpi_probe(dev
);
745 if (IS_ERR(ctx
->encoder
)) {
746 ret
= PTR_ERR(ctx
->encoder
);
750 pm_runtime_enable(dev
);
752 ret
= component_add(dev
, &decon_component_ops
);
754 goto err_disable_pm_runtime
;
758 err_disable_pm_runtime
:
759 pm_runtime_disable(dev
);
767 static int decon_remove(struct platform_device
*pdev
)
769 struct decon_context
*ctx
= dev_get_drvdata(&pdev
->dev
);
771 pm_runtime_disable(&pdev
->dev
);
775 component_del(&pdev
->dev
, &decon_component_ops
);
781 static int exynos7_decon_suspend(struct device
*dev
)
783 struct decon_context
*ctx
= dev_get_drvdata(dev
);
785 clk_disable_unprepare(ctx
->vclk
);
786 clk_disable_unprepare(ctx
->eclk
);
787 clk_disable_unprepare(ctx
->aclk
);
788 clk_disable_unprepare(ctx
->pclk
);
793 static int exynos7_decon_resume(struct device
*dev
)
795 struct decon_context
*ctx
= dev_get_drvdata(dev
);
798 ret
= clk_prepare_enable(ctx
->pclk
);
800 DRM_DEV_ERROR(dev
, "Failed to prepare_enable the pclk [%d]\n",
805 ret
= clk_prepare_enable(ctx
->aclk
);
807 DRM_DEV_ERROR(dev
, "Failed to prepare_enable the aclk [%d]\n",
812 ret
= clk_prepare_enable(ctx
->eclk
);
814 DRM_DEV_ERROR(dev
, "Failed to prepare_enable the eclk [%d]\n",
819 ret
= clk_prepare_enable(ctx
->vclk
);
821 DRM_DEV_ERROR(dev
, "Failed to prepare_enable the vclk [%d]\n",
830 static const struct dev_pm_ops exynos7_decon_pm_ops
= {
831 SET_RUNTIME_PM_OPS(exynos7_decon_suspend
, exynos7_decon_resume
,
833 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend
,
834 pm_runtime_force_resume
)
837 struct platform_driver decon_driver
= {
838 .probe
= decon_probe
,
839 .remove
= decon_remove
,
841 .name
= "exynos-decon",
842 .pm
= &exynos7_decon_pm_ops
,
843 .of_match_table
= decon_driver_dt_match
,