1 /* drivers/gpu/drm/exynos/exynos7_drm_decon.c
3 * Copyright (C) 2014 Samsung Electronics Co.Ltd
5 * Akshu Agarwal <akshua@gmail.com>
6 * Ajay Kumar <ajaykumar.rs@samsung.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
15 #include <drm/exynos_drm.h>
17 #include <linux/clk.h>
18 #include <linux/component.h>
19 #include <linux/kernel.h>
21 #include <linux/of_address.h>
22 #include <linux/of_device.h>
23 #include <linux/platform_device.h>
24 #include <linux/pm_runtime.h>
26 #include <video/of_display_timing.h>
27 #include <video/of_videomode.h>
29 #include "exynos_drm_crtc.h"
30 #include "exynos_drm_plane.h"
31 #include "exynos_drm_drv.h"
32 #include "exynos_drm_fb.h"
33 #include "exynos_drm_iommu.h"
34 #include "regs-decon7.h"
37 * DECON stands for Display and Enhancement controller.
40 #define MIN_FB_WIDTH_FOR_16WORD_BURST 128
44 struct decon_context
{
46 struct drm_device
*drm_dev
;
47 struct exynos_drm_crtc
*crtc
;
48 struct exynos_drm_plane planes
[WINDOWS_NR
];
49 struct exynos_drm_plane_config configs
[WINDOWS_NR
];
55 unsigned long irq_flags
;
58 wait_queue_head_t wait_vsync_queue
;
59 atomic_t wait_vsync_event
;
61 struct drm_encoder
*encoder
;
64 static const struct of_device_id decon_driver_dt_match
[] = {
65 {.compatible
= "samsung,exynos7-decon"},
68 MODULE_DEVICE_TABLE(of
, decon_driver_dt_match
);
70 static const uint32_t decon_formats
[] = {
82 static const enum drm_plane_type decon_win_types
[WINDOWS_NR
] = {
83 DRM_PLANE_TYPE_PRIMARY
,
84 DRM_PLANE_TYPE_CURSOR
,
87 static void decon_wait_for_vblank(struct exynos_drm_crtc
*crtc
)
89 struct decon_context
*ctx
= crtc
->ctx
;
94 atomic_set(&ctx
->wait_vsync_event
, 1);
97 * wait for DECON to signal VSYNC interrupt or return after
98 * timeout which is set to 50ms (refresh rate of 20).
100 if (!wait_event_timeout(ctx
->wait_vsync_queue
,
101 !atomic_read(&ctx
->wait_vsync_event
),
103 DRM_DEBUG_KMS("vblank wait timed out.\n");
106 static void decon_clear_channels(struct exynos_drm_crtc
*crtc
)
108 struct decon_context
*ctx
= crtc
->ctx
;
109 unsigned int win
, ch_enabled
= 0;
111 DRM_DEBUG_KMS("%s\n", __FILE__
);
113 /* Check if any channel is enabled. */
114 for (win
= 0; win
< WINDOWS_NR
; win
++) {
115 u32 val
= readl(ctx
->regs
+ WINCON(win
));
117 if (val
& WINCONx_ENWIN
) {
118 val
&= ~WINCONx_ENWIN
;
119 writel(val
, ctx
->regs
+ WINCON(win
));
124 /* Wait for vsync, as disable channel takes effect at next vsync */
126 decon_wait_for_vblank(ctx
->crtc
);
129 static int decon_ctx_initialize(struct decon_context
*ctx
,
130 struct drm_device
*drm_dev
)
132 ctx
->drm_dev
= drm_dev
;
134 decon_clear_channels(ctx
->crtc
);
136 return drm_iommu_attach_device(drm_dev
, ctx
->dev
);
139 static void decon_ctx_remove(struct decon_context
*ctx
)
141 /* detach this sub driver from iommu mapping if supported. */
142 drm_iommu_detach_device(ctx
->drm_dev
, ctx
->dev
);
145 static u32
decon_calc_clkdiv(struct decon_context
*ctx
,
146 const struct drm_display_mode
*mode
)
148 unsigned long ideal_clk
= mode
->htotal
* mode
->vtotal
* mode
->vrefresh
;
151 /* Find the clock divider value that gets us closest to ideal_clk */
152 clkdiv
= DIV_ROUND_UP(clk_get_rate(ctx
->vclk
), ideal_clk
);
154 return (clkdiv
< 0x100) ? clkdiv
: 0xff;
157 static void decon_commit(struct exynos_drm_crtc
*crtc
)
159 struct decon_context
*ctx
= crtc
->ctx
;
160 struct drm_display_mode
*mode
= &crtc
->base
.state
->adjusted_mode
;
166 /* nothing to do if we haven't set the mode yet */
167 if (mode
->htotal
== 0 || mode
->vtotal
== 0)
171 int vsync_len
, vbpd
, vfpd
, hsync_len
, hbpd
, hfpd
;
172 /* setup vertical timing values. */
173 vsync_len
= mode
->crtc_vsync_end
- mode
->crtc_vsync_start
;
174 vbpd
= mode
->crtc_vtotal
- mode
->crtc_vsync_end
;
175 vfpd
= mode
->crtc_vsync_start
- mode
->crtc_vdisplay
;
177 val
= VIDTCON0_VBPD(vbpd
- 1) | VIDTCON0_VFPD(vfpd
- 1);
178 writel(val
, ctx
->regs
+ VIDTCON0
);
180 val
= VIDTCON1_VSPW(vsync_len
- 1);
181 writel(val
, ctx
->regs
+ VIDTCON1
);
183 /* setup horizontal timing values. */
184 hsync_len
= mode
->crtc_hsync_end
- mode
->crtc_hsync_start
;
185 hbpd
= mode
->crtc_htotal
- mode
->crtc_hsync_end
;
186 hfpd
= mode
->crtc_hsync_start
- mode
->crtc_hdisplay
;
188 /* setup horizontal timing values. */
189 val
= VIDTCON2_HBPD(hbpd
- 1) | VIDTCON2_HFPD(hfpd
- 1);
190 writel(val
, ctx
->regs
+ VIDTCON2
);
192 val
= VIDTCON3_HSPW(hsync_len
- 1);
193 writel(val
, ctx
->regs
+ VIDTCON3
);
196 /* setup horizontal and vertical display size. */
197 val
= VIDTCON4_LINEVAL(mode
->vdisplay
- 1) |
198 VIDTCON4_HOZVAL(mode
->hdisplay
- 1);
199 writel(val
, ctx
->regs
+ VIDTCON4
);
201 writel(mode
->vdisplay
- 1, ctx
->regs
+ LINECNT_OP_THRESHOLD
);
204 * fields of register with prefix '_F' would be updated
205 * at vsync(same as dma start)
207 val
= VIDCON0_ENVID
| VIDCON0_ENVID_F
;
208 writel(val
, ctx
->regs
+ VIDCON0
);
210 clkdiv
= decon_calc_clkdiv(ctx
, mode
);
212 val
= VCLKCON1_CLKVAL_NUM_VCLK(clkdiv
- 1);
213 writel(val
, ctx
->regs
+ VCLKCON1
);
214 writel(val
, ctx
->regs
+ VCLKCON2
);
217 val
= readl(ctx
->regs
+ DECON_UPDATE
);
218 val
|= DECON_UPDATE_STANDALONE_F
;
219 writel(val
, ctx
->regs
+ DECON_UPDATE
);
222 static int decon_enable_vblank(struct exynos_drm_crtc
*crtc
)
224 struct decon_context
*ctx
= crtc
->ctx
;
230 if (!test_and_set_bit(0, &ctx
->irq_flags
)) {
231 val
= readl(ctx
->regs
+ VIDINTCON0
);
233 val
|= VIDINTCON0_INT_ENABLE
;
236 val
|= VIDINTCON0_INT_FRAME
;
237 val
&= ~VIDINTCON0_FRAMESEL0_MASK
;
238 val
|= VIDINTCON0_FRAMESEL0_VSYNC
;
241 writel(val
, ctx
->regs
+ VIDINTCON0
);
247 static void decon_disable_vblank(struct exynos_drm_crtc
*crtc
)
249 struct decon_context
*ctx
= crtc
->ctx
;
255 if (test_and_clear_bit(0, &ctx
->irq_flags
)) {
256 val
= readl(ctx
->regs
+ VIDINTCON0
);
258 val
&= ~VIDINTCON0_INT_ENABLE
;
260 val
&= ~VIDINTCON0_INT_FRAME
;
262 writel(val
, ctx
->regs
+ VIDINTCON0
);
266 static void decon_win_set_pixfmt(struct decon_context
*ctx
, unsigned int win
,
267 struct drm_framebuffer
*fb
)
272 val
= readl(ctx
->regs
+ WINCON(win
));
273 val
&= ~WINCONx_BPPMODE_MASK
;
275 switch (fb
->format
->format
) {
276 case DRM_FORMAT_RGB565
:
277 val
|= WINCONx_BPPMODE_16BPP_565
;
278 val
|= WINCONx_BURSTLEN_16WORD
;
280 case DRM_FORMAT_XRGB8888
:
281 val
|= WINCONx_BPPMODE_24BPP_xRGB
;
282 val
|= WINCONx_BURSTLEN_16WORD
;
284 case DRM_FORMAT_XBGR8888
:
285 val
|= WINCONx_BPPMODE_24BPP_xBGR
;
286 val
|= WINCONx_BURSTLEN_16WORD
;
288 case DRM_FORMAT_RGBX8888
:
289 val
|= WINCONx_BPPMODE_24BPP_RGBx
;
290 val
|= WINCONx_BURSTLEN_16WORD
;
292 case DRM_FORMAT_BGRX8888
:
293 val
|= WINCONx_BPPMODE_24BPP_BGRx
;
294 val
|= WINCONx_BURSTLEN_16WORD
;
296 case DRM_FORMAT_ARGB8888
:
297 val
|= WINCONx_BPPMODE_32BPP_ARGB
| WINCONx_BLD_PIX
|
299 val
|= WINCONx_BURSTLEN_16WORD
;
301 case DRM_FORMAT_ABGR8888
:
302 val
|= WINCONx_BPPMODE_32BPP_ABGR
| WINCONx_BLD_PIX
|
304 val
|= WINCONx_BURSTLEN_16WORD
;
306 case DRM_FORMAT_RGBA8888
:
307 val
|= WINCONx_BPPMODE_32BPP_RGBA
| WINCONx_BLD_PIX
|
309 val
|= WINCONx_BURSTLEN_16WORD
;
311 case DRM_FORMAT_BGRA8888
:
313 val
|= WINCONx_BPPMODE_32BPP_BGRA
| WINCONx_BLD_PIX
|
315 val
|= WINCONx_BURSTLEN_16WORD
;
319 DRM_DEBUG_KMS("cpp = %d\n", fb
->format
->cpp
[0]);
322 * In case of exynos, setting dma-burst to 16Word causes permanent
323 * tearing for very small buffers, e.g. cursor buffer. Burst Mode
324 * switching which is based on plane size is not recommended as
325 * plane size varies a lot towards the end of the screen and rapid
326 * movement causes unstable DMA which results into iommu crash/tear.
329 padding
= (fb
->pitches
[0] / fb
->format
->cpp
[0]) - fb
->width
;
330 if (fb
->width
+ padding
< MIN_FB_WIDTH_FOR_16WORD_BURST
) {
331 val
&= ~WINCONx_BURSTLEN_MASK
;
332 val
|= WINCONx_BURSTLEN_8WORD
;
335 writel(val
, ctx
->regs
+ WINCON(win
));
338 static void decon_win_set_colkey(struct decon_context
*ctx
, unsigned int win
)
340 unsigned int keycon0
= 0, keycon1
= 0;
342 keycon0
= ~(WxKEYCON0_KEYBL_EN
| WxKEYCON0_KEYEN_F
|
343 WxKEYCON0_DIRCON
) | WxKEYCON0_COMPKEY(0);
345 keycon1
= WxKEYCON1_COLVAL(0xffffffff);
347 writel(keycon0
, ctx
->regs
+ WKEYCON0_BASE(win
));
348 writel(keycon1
, ctx
->regs
+ WKEYCON1_BASE(win
));
352 * shadow_protect_win() - disable updating values from shadow registers at vsync
354 * @win: window to protect registers for
355 * @protect: 1 to protect (disable updates)
357 static void decon_shadow_protect_win(struct decon_context
*ctx
,
358 unsigned int win
, bool protect
)
362 bits
= SHADOWCON_WINx_PROTECT(win
);
364 val
= readl(ctx
->regs
+ SHADOWCON
);
369 writel(val
, ctx
->regs
+ SHADOWCON
);
372 static void decon_atomic_begin(struct exynos_drm_crtc
*crtc
)
374 struct decon_context
*ctx
= crtc
->ctx
;
380 for (i
= 0; i
< WINDOWS_NR
; i
++)
381 decon_shadow_protect_win(ctx
, i
, true);
384 static void decon_update_plane(struct exynos_drm_crtc
*crtc
,
385 struct exynos_drm_plane
*plane
)
387 struct exynos_drm_plane_state
*state
=
388 to_exynos_plane_state(plane
->base
.state
);
389 struct decon_context
*ctx
= crtc
->ctx
;
390 struct drm_framebuffer
*fb
= state
->base
.fb
;
392 unsigned long val
, alpha
;
395 unsigned int win
= plane
->index
;
396 unsigned int cpp
= fb
->format
->cpp
[0];
397 unsigned int pitch
= fb
->pitches
[0];
403 * SHADOWCON/PRTCON register is used for enabling timing.
405 * for example, once only width value of a register is set,
406 * if the dma is started then decon hardware could malfunction so
407 * with protect window setting, the register fields with prefix '_F'
408 * wouldn't be updated at vsync also but updated once unprotect window
412 /* buffer start address */
413 val
= (unsigned long)exynos_drm_fb_dma_addr(fb
, 0);
414 writel(val
, ctx
->regs
+ VIDW_BUF_START(win
));
416 padding
= (pitch
/ cpp
) - fb
->width
;
419 writel(fb
->width
+ padding
, ctx
->regs
+ VIDW_WHOLE_X(win
));
420 writel(fb
->height
, ctx
->regs
+ VIDW_WHOLE_Y(win
));
422 /* offset from the start of the buffer to read */
423 writel(state
->src
.x
, ctx
->regs
+ VIDW_OFFSET_X(win
));
424 writel(state
->src
.y
, ctx
->regs
+ VIDW_OFFSET_Y(win
));
426 DRM_DEBUG_KMS("start addr = 0x%lx\n",
428 DRM_DEBUG_KMS("ovl_width = %d, ovl_height = %d\n",
429 state
->crtc
.w
, state
->crtc
.h
);
431 val
= VIDOSDxA_TOPLEFT_X(state
->crtc
.x
) |
432 VIDOSDxA_TOPLEFT_Y(state
->crtc
.y
);
433 writel(val
, ctx
->regs
+ VIDOSD_A(win
));
435 last_x
= state
->crtc
.x
+ state
->crtc
.w
;
438 last_y
= state
->crtc
.y
+ state
->crtc
.h
;
442 val
= VIDOSDxB_BOTRIGHT_X(last_x
) | VIDOSDxB_BOTRIGHT_Y(last_y
);
444 writel(val
, ctx
->regs
+ VIDOSD_B(win
));
446 DRM_DEBUG_KMS("osd pos: tx = %d, ty = %d, bx = %d, by = %d\n",
447 state
->crtc
.x
, state
->crtc
.y
, last_x
, last_y
);
450 alpha
= VIDOSDxC_ALPHA0_R_F(0x0) |
451 VIDOSDxC_ALPHA0_G_F(0x0) |
452 VIDOSDxC_ALPHA0_B_F(0x0);
454 writel(alpha
, ctx
->regs
+ VIDOSD_C(win
));
456 alpha
= VIDOSDxD_ALPHA1_R_F(0xff) |
457 VIDOSDxD_ALPHA1_G_F(0xff) |
458 VIDOSDxD_ALPHA1_B_F(0xff);
460 writel(alpha
, ctx
->regs
+ VIDOSD_D(win
));
462 decon_win_set_pixfmt(ctx
, win
, fb
);
464 /* hardware window 0 doesn't support color key. */
466 decon_win_set_colkey(ctx
, win
);
469 val
= readl(ctx
->regs
+ WINCON(win
));
470 val
|= WINCONx_TRIPLE_BUF_MODE
;
471 val
|= WINCONx_ENWIN
;
472 writel(val
, ctx
->regs
+ WINCON(win
));
474 /* Enable DMA channel and unprotect windows */
475 decon_shadow_protect_win(ctx
, win
, false);
477 val
= readl(ctx
->regs
+ DECON_UPDATE
);
478 val
|= DECON_UPDATE_STANDALONE_F
;
479 writel(val
, ctx
->regs
+ DECON_UPDATE
);
482 static void decon_disable_plane(struct exynos_drm_crtc
*crtc
,
483 struct exynos_drm_plane
*plane
)
485 struct decon_context
*ctx
= crtc
->ctx
;
486 unsigned int win
= plane
->index
;
492 /* protect windows */
493 decon_shadow_protect_win(ctx
, win
, true);
496 val
= readl(ctx
->regs
+ WINCON(win
));
497 val
&= ~WINCONx_ENWIN
;
498 writel(val
, ctx
->regs
+ WINCON(win
));
500 val
= readl(ctx
->regs
+ DECON_UPDATE
);
501 val
|= DECON_UPDATE_STANDALONE_F
;
502 writel(val
, ctx
->regs
+ DECON_UPDATE
);
505 static void decon_atomic_flush(struct exynos_drm_crtc
*crtc
)
507 struct decon_context
*ctx
= crtc
->ctx
;
513 for (i
= 0; i
< WINDOWS_NR
; i
++)
514 decon_shadow_protect_win(ctx
, i
, false);
515 exynos_crtc_handle_event(crtc
);
518 static void decon_init(struct decon_context
*ctx
)
522 writel(VIDCON0_SWRESET
, ctx
->regs
+ VIDCON0
);
524 val
= VIDOUTCON0_DISP_IF_0_ON
;
526 val
|= VIDOUTCON0_RGBIF
;
527 writel(val
, ctx
->regs
+ VIDOUTCON0
);
529 writel(VCLKCON0_CLKVALUP
| VCLKCON0_VCLKFREE
, ctx
->regs
+ VCLKCON0
);
532 writel(VIDCON1_VCLK_HOLD
, ctx
->regs
+ VIDCON1(0));
535 static void decon_enable(struct exynos_drm_crtc
*crtc
)
537 struct decon_context
*ctx
= crtc
->ctx
;
542 pm_runtime_get_sync(ctx
->dev
);
546 /* if vblank was enabled status, enable it again. */
547 if (test_and_clear_bit(0, &ctx
->irq_flags
))
548 decon_enable_vblank(ctx
->crtc
);
550 decon_commit(ctx
->crtc
);
552 ctx
->suspended
= false;
555 static void decon_disable(struct exynos_drm_crtc
*crtc
)
557 struct decon_context
*ctx
= crtc
->ctx
;
564 * We need to make sure that all windows are disabled before we
565 * suspend that connector. Otherwise we might try to scan from
566 * a destroyed buffer later.
568 for (i
= 0; i
< WINDOWS_NR
; i
++)
569 decon_disable_plane(crtc
, &ctx
->planes
[i
]);
571 pm_runtime_put_sync(ctx
->dev
);
573 ctx
->suspended
= true;
576 static const struct exynos_drm_crtc_ops decon_crtc_ops
= {
577 .enable
= decon_enable
,
578 .disable
= decon_disable
,
579 .enable_vblank
= decon_enable_vblank
,
580 .disable_vblank
= decon_disable_vblank
,
581 .atomic_begin
= decon_atomic_begin
,
582 .update_plane
= decon_update_plane
,
583 .disable_plane
= decon_disable_plane
,
584 .atomic_flush
= decon_atomic_flush
,
588 static irqreturn_t
decon_irq_handler(int irq
, void *dev_id
)
590 struct decon_context
*ctx
= (struct decon_context
*)dev_id
;
593 val
= readl(ctx
->regs
+ VIDINTCON1
);
595 clear_bit
= ctx
->i80_if
? VIDINTCON1_INT_I80
: VIDINTCON1_INT_FRAME
;
597 writel(clear_bit
, ctx
->regs
+ VIDINTCON1
);
599 /* check the crtc is detached already from encoder */
604 drm_crtc_handle_vblank(&ctx
->crtc
->base
);
606 /* set wait vsync event to zero and wake up queue. */
607 if (atomic_read(&ctx
->wait_vsync_event
)) {
608 atomic_set(&ctx
->wait_vsync_event
, 0);
609 wake_up(&ctx
->wait_vsync_queue
);
616 static int decon_bind(struct device
*dev
, struct device
*master
, void *data
)
618 struct decon_context
*ctx
= dev_get_drvdata(dev
);
619 struct drm_device
*drm_dev
= data
;
620 struct exynos_drm_plane
*exynos_plane
;
624 ret
= decon_ctx_initialize(ctx
, drm_dev
);
626 DRM_ERROR("decon_ctx_initialize failed.\n");
630 for (i
= 0; i
< WINDOWS_NR
; i
++) {
631 ctx
->configs
[i
].pixel_formats
= decon_formats
;
632 ctx
->configs
[i
].num_pixel_formats
= ARRAY_SIZE(decon_formats
);
633 ctx
->configs
[i
].zpos
= i
;
634 ctx
->configs
[i
].type
= decon_win_types
[i
];
636 ret
= exynos_plane_init(drm_dev
, &ctx
->planes
[i
], i
,
642 exynos_plane
= &ctx
->planes
[DEFAULT_WIN
];
643 ctx
->crtc
= exynos_drm_crtc_create(drm_dev
, &exynos_plane
->base
,
644 EXYNOS_DISPLAY_TYPE_LCD
, &decon_crtc_ops
, ctx
);
645 if (IS_ERR(ctx
->crtc
)) {
646 decon_ctx_remove(ctx
);
647 return PTR_ERR(ctx
->crtc
);
651 exynos_dpi_bind(drm_dev
, ctx
->encoder
);
657 static void decon_unbind(struct device
*dev
, struct device
*master
,
660 struct decon_context
*ctx
= dev_get_drvdata(dev
);
662 decon_disable(ctx
->crtc
);
665 exynos_dpi_remove(ctx
->encoder
);
667 decon_ctx_remove(ctx
);
670 static const struct component_ops decon_component_ops
= {
672 .unbind
= decon_unbind
,
675 static int decon_probe(struct platform_device
*pdev
)
677 struct device
*dev
= &pdev
->dev
;
678 struct decon_context
*ctx
;
679 struct device_node
*i80_if_timings
;
680 struct resource
*res
;
686 ctx
= devm_kzalloc(dev
, sizeof(*ctx
), GFP_KERNEL
);
691 ctx
->suspended
= true;
693 i80_if_timings
= of_get_child_by_name(dev
->of_node
, "i80-if-timings");
696 of_node_put(i80_if_timings
);
698 ctx
->regs
= of_iomap(dev
->of_node
, 0);
702 ctx
->pclk
= devm_clk_get(dev
, "pclk_decon0");
703 if (IS_ERR(ctx
->pclk
)) {
704 dev_err(dev
, "failed to get bus clock pclk\n");
705 ret
= PTR_ERR(ctx
->pclk
);
709 ctx
->aclk
= devm_clk_get(dev
, "aclk_decon0");
710 if (IS_ERR(ctx
->aclk
)) {
711 dev_err(dev
, "failed to get bus clock aclk\n");
712 ret
= PTR_ERR(ctx
->aclk
);
716 ctx
->eclk
= devm_clk_get(dev
, "decon0_eclk");
717 if (IS_ERR(ctx
->eclk
)) {
718 dev_err(dev
, "failed to get eclock\n");
719 ret
= PTR_ERR(ctx
->eclk
);
723 ctx
->vclk
= devm_clk_get(dev
, "decon0_vclk");
724 if (IS_ERR(ctx
->vclk
)) {
725 dev_err(dev
, "failed to get vclock\n");
726 ret
= PTR_ERR(ctx
->vclk
);
730 res
= platform_get_resource_byname(pdev
, IORESOURCE_IRQ
,
731 ctx
->i80_if
? "lcd_sys" : "vsync");
733 dev_err(dev
, "irq request failed.\n");
738 ret
= devm_request_irq(dev
, res
->start
, decon_irq_handler
,
739 0, "drm_decon", ctx
);
741 dev_err(dev
, "irq request failed.\n");
745 init_waitqueue_head(&ctx
->wait_vsync_queue
);
746 atomic_set(&ctx
->wait_vsync_event
, 0);
748 platform_set_drvdata(pdev
, ctx
);
750 ctx
->encoder
= exynos_dpi_probe(dev
);
751 if (IS_ERR(ctx
->encoder
)) {
752 ret
= PTR_ERR(ctx
->encoder
);
756 pm_runtime_enable(dev
);
758 ret
= component_add(dev
, &decon_component_ops
);
760 goto err_disable_pm_runtime
;
764 err_disable_pm_runtime
:
765 pm_runtime_disable(dev
);
773 static int decon_remove(struct platform_device
*pdev
)
775 struct decon_context
*ctx
= dev_get_drvdata(&pdev
->dev
);
777 pm_runtime_disable(&pdev
->dev
);
781 component_del(&pdev
->dev
, &decon_component_ops
);
787 static int exynos7_decon_suspend(struct device
*dev
)
789 struct decon_context
*ctx
= dev_get_drvdata(dev
);
791 clk_disable_unprepare(ctx
->vclk
);
792 clk_disable_unprepare(ctx
->eclk
);
793 clk_disable_unprepare(ctx
->aclk
);
794 clk_disable_unprepare(ctx
->pclk
);
799 static int exynos7_decon_resume(struct device
*dev
)
801 struct decon_context
*ctx
= dev_get_drvdata(dev
);
804 ret
= clk_prepare_enable(ctx
->pclk
);
806 DRM_ERROR("Failed to prepare_enable the pclk [%d]\n", ret
);
810 ret
= clk_prepare_enable(ctx
->aclk
);
812 DRM_ERROR("Failed to prepare_enable the aclk [%d]\n", ret
);
816 ret
= clk_prepare_enable(ctx
->eclk
);
818 DRM_ERROR("Failed to prepare_enable the eclk [%d]\n", ret
);
822 ret
= clk_prepare_enable(ctx
->vclk
);
824 DRM_ERROR("Failed to prepare_enable the vclk [%d]\n", ret
);
832 static const struct dev_pm_ops exynos7_decon_pm_ops
= {
833 SET_RUNTIME_PM_OPS(exynos7_decon_suspend
, exynos7_decon_resume
,
835 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend
,
836 pm_runtime_force_resume
)
839 struct platform_driver decon_driver
= {
840 .probe
= decon_probe
,
841 .remove
= decon_remove
,
843 .name
= "exynos-decon",
844 .pm
= &exynos7_decon_pm_ops
,
845 .of_match_table
= decon_driver_dt_match
,