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>
28 #include <video/exynos7_decon.h>
30 #include "exynos_drm_crtc.h"
31 #include "exynos_drm_plane.h"
32 #include "exynos_drm_drv.h"
33 #include "exynos_drm_fb.h"
34 #include "exynos_drm_fbdev.h"
35 #include "exynos_drm_iommu.h"
38 * DECON stands for Display and Enhancement controller.
41 #define MIN_FB_WIDTH_FOR_16WORD_BURST 128
45 struct decon_context
{
47 struct drm_device
*drm_dev
;
48 struct exynos_drm_crtc
*crtc
;
49 struct exynos_drm_plane planes
[WINDOWS_NR
];
50 struct exynos_drm_plane_config configs
[WINDOWS_NR
];
56 unsigned long irq_flags
;
60 wait_queue_head_t wait_vsync_queue
;
61 atomic_t wait_vsync_event
;
63 struct exynos_drm_panel_info panel
;
64 struct drm_encoder
*encoder
;
67 static const struct of_device_id decon_driver_dt_match
[] = {
68 {.compatible
= "samsung,exynos7-decon"},
71 MODULE_DEVICE_TABLE(of
, decon_driver_dt_match
);
73 static const uint32_t decon_formats
[] = {
85 static const enum drm_plane_type decon_win_types
[WINDOWS_NR
] = {
86 DRM_PLANE_TYPE_PRIMARY
,
87 DRM_PLANE_TYPE_CURSOR
,
90 static void decon_wait_for_vblank(struct exynos_drm_crtc
*crtc
)
92 struct decon_context
*ctx
= crtc
->ctx
;
97 atomic_set(&ctx
->wait_vsync_event
, 1);
100 * wait for DECON to signal VSYNC interrupt or return after
101 * timeout which is set to 50ms (refresh rate of 20).
103 if (!wait_event_timeout(ctx
->wait_vsync_queue
,
104 !atomic_read(&ctx
->wait_vsync_event
),
106 DRM_DEBUG_KMS("vblank wait timed out.\n");
109 static void decon_clear_channels(struct exynos_drm_crtc
*crtc
)
111 struct decon_context
*ctx
= crtc
->ctx
;
112 unsigned int win
, ch_enabled
= 0;
114 DRM_DEBUG_KMS("%s\n", __FILE__
);
116 /* Check if any channel is enabled. */
117 for (win
= 0; win
< WINDOWS_NR
; win
++) {
118 u32 val
= readl(ctx
->regs
+ WINCON(win
));
120 if (val
& WINCONx_ENWIN
) {
121 val
&= ~WINCONx_ENWIN
;
122 writel(val
, ctx
->regs
+ WINCON(win
));
127 /* Wait for vsync, as disable channel takes effect at next vsync */
129 decon_wait_for_vblank(ctx
->crtc
);
132 static int decon_ctx_initialize(struct decon_context
*ctx
,
133 struct drm_device
*drm_dev
)
135 struct exynos_drm_private
*priv
= drm_dev
->dev_private
;
138 ctx
->drm_dev
= drm_dev
;
139 ctx
->pipe
= priv
->pipe
++;
141 decon_clear_channels(ctx
->crtc
);
143 ret
= drm_iommu_attach_device(drm_dev
, ctx
->dev
);
150 static void decon_ctx_remove(struct decon_context
*ctx
)
152 /* detach this sub driver from iommu mapping if supported. */
153 drm_iommu_detach_device(ctx
->drm_dev
, ctx
->dev
);
156 static u32
decon_calc_clkdiv(struct decon_context
*ctx
,
157 const struct drm_display_mode
*mode
)
159 unsigned long ideal_clk
= mode
->htotal
* mode
->vtotal
* mode
->vrefresh
;
162 /* Find the clock divider value that gets us closest to ideal_clk */
163 clkdiv
= DIV_ROUND_UP(clk_get_rate(ctx
->vclk
), ideal_clk
);
165 return (clkdiv
< 0x100) ? clkdiv
: 0xff;
168 static void decon_commit(struct exynos_drm_crtc
*crtc
)
170 struct decon_context
*ctx
= crtc
->ctx
;
171 struct drm_display_mode
*mode
= &crtc
->base
.state
->adjusted_mode
;
177 /* nothing to do if we haven't set the mode yet */
178 if (mode
->htotal
== 0 || mode
->vtotal
== 0)
182 int vsync_len
, vbpd
, vfpd
, hsync_len
, hbpd
, hfpd
;
183 /* setup vertical timing values. */
184 vsync_len
= mode
->crtc_vsync_end
- mode
->crtc_vsync_start
;
185 vbpd
= mode
->crtc_vtotal
- mode
->crtc_vsync_end
;
186 vfpd
= mode
->crtc_vsync_start
- mode
->crtc_vdisplay
;
188 val
= VIDTCON0_VBPD(vbpd
- 1) | VIDTCON0_VFPD(vfpd
- 1);
189 writel(val
, ctx
->regs
+ VIDTCON0
);
191 val
= VIDTCON1_VSPW(vsync_len
- 1);
192 writel(val
, ctx
->regs
+ VIDTCON1
);
194 /* setup horizontal timing values. */
195 hsync_len
= mode
->crtc_hsync_end
- mode
->crtc_hsync_start
;
196 hbpd
= mode
->crtc_htotal
- mode
->crtc_hsync_end
;
197 hfpd
= mode
->crtc_hsync_start
- mode
->crtc_hdisplay
;
199 /* setup horizontal timing values. */
200 val
= VIDTCON2_HBPD(hbpd
- 1) | VIDTCON2_HFPD(hfpd
- 1);
201 writel(val
, ctx
->regs
+ VIDTCON2
);
203 val
= VIDTCON3_HSPW(hsync_len
- 1);
204 writel(val
, ctx
->regs
+ VIDTCON3
);
207 /* setup horizontal and vertical display size. */
208 val
= VIDTCON4_LINEVAL(mode
->vdisplay
- 1) |
209 VIDTCON4_HOZVAL(mode
->hdisplay
- 1);
210 writel(val
, ctx
->regs
+ VIDTCON4
);
212 writel(mode
->vdisplay
- 1, ctx
->regs
+ LINECNT_OP_THRESHOLD
);
215 * fields of register with prefix '_F' would be updated
216 * at vsync(same as dma start)
218 val
= VIDCON0_ENVID
| VIDCON0_ENVID_F
;
219 writel(val
, ctx
->regs
+ VIDCON0
);
221 clkdiv
= decon_calc_clkdiv(ctx
, mode
);
223 val
= VCLKCON1_CLKVAL_NUM_VCLK(clkdiv
- 1);
224 writel(val
, ctx
->regs
+ VCLKCON1
);
225 writel(val
, ctx
->regs
+ VCLKCON2
);
228 val
= readl(ctx
->regs
+ DECON_UPDATE
);
229 val
|= DECON_UPDATE_STANDALONE_F
;
230 writel(val
, ctx
->regs
+ DECON_UPDATE
);
233 static int decon_enable_vblank(struct exynos_drm_crtc
*crtc
)
235 struct decon_context
*ctx
= crtc
->ctx
;
241 if (!test_and_set_bit(0, &ctx
->irq_flags
)) {
242 val
= readl(ctx
->regs
+ VIDINTCON0
);
244 val
|= VIDINTCON0_INT_ENABLE
;
247 val
|= VIDINTCON0_INT_FRAME
;
248 val
&= ~VIDINTCON0_FRAMESEL0_MASK
;
249 val
|= VIDINTCON0_FRAMESEL0_VSYNC
;
252 writel(val
, ctx
->regs
+ VIDINTCON0
);
258 static void decon_disable_vblank(struct exynos_drm_crtc
*crtc
)
260 struct decon_context
*ctx
= crtc
->ctx
;
266 if (test_and_clear_bit(0, &ctx
->irq_flags
)) {
267 val
= readl(ctx
->regs
+ VIDINTCON0
);
269 val
&= ~VIDINTCON0_INT_ENABLE
;
271 val
&= ~VIDINTCON0_INT_FRAME
;
273 writel(val
, ctx
->regs
+ VIDINTCON0
);
277 static void decon_win_set_pixfmt(struct decon_context
*ctx
, unsigned int win
,
278 struct drm_framebuffer
*fb
)
283 val
= readl(ctx
->regs
+ WINCON(win
));
284 val
&= ~WINCONx_BPPMODE_MASK
;
286 switch (fb
->pixel_format
) {
287 case DRM_FORMAT_RGB565
:
288 val
|= WINCONx_BPPMODE_16BPP_565
;
289 val
|= WINCONx_BURSTLEN_16WORD
;
291 case DRM_FORMAT_XRGB8888
:
292 val
|= WINCONx_BPPMODE_24BPP_xRGB
;
293 val
|= WINCONx_BURSTLEN_16WORD
;
295 case DRM_FORMAT_XBGR8888
:
296 val
|= WINCONx_BPPMODE_24BPP_xBGR
;
297 val
|= WINCONx_BURSTLEN_16WORD
;
299 case DRM_FORMAT_RGBX8888
:
300 val
|= WINCONx_BPPMODE_24BPP_RGBx
;
301 val
|= WINCONx_BURSTLEN_16WORD
;
303 case DRM_FORMAT_BGRX8888
:
304 val
|= WINCONx_BPPMODE_24BPP_BGRx
;
305 val
|= WINCONx_BURSTLEN_16WORD
;
307 case DRM_FORMAT_ARGB8888
:
308 val
|= WINCONx_BPPMODE_32BPP_ARGB
| WINCONx_BLD_PIX
|
310 val
|= WINCONx_BURSTLEN_16WORD
;
312 case DRM_FORMAT_ABGR8888
:
313 val
|= WINCONx_BPPMODE_32BPP_ABGR
| WINCONx_BLD_PIX
|
315 val
|= WINCONx_BURSTLEN_16WORD
;
317 case DRM_FORMAT_RGBA8888
:
318 val
|= WINCONx_BPPMODE_32BPP_RGBA
| WINCONx_BLD_PIX
|
320 val
|= WINCONx_BURSTLEN_16WORD
;
322 case DRM_FORMAT_BGRA8888
:
323 val
|= WINCONx_BPPMODE_32BPP_BGRA
| WINCONx_BLD_PIX
|
325 val
|= WINCONx_BURSTLEN_16WORD
;
328 DRM_DEBUG_KMS("invalid pixel size so using unpacked 24bpp.\n");
330 val
|= WINCONx_BPPMODE_24BPP_xRGB
;
331 val
|= WINCONx_BURSTLEN_16WORD
;
335 DRM_DEBUG_KMS("bpp = %d\n", fb
->bits_per_pixel
);
338 * In case of exynos, setting dma-burst to 16Word causes permanent
339 * tearing for very small buffers, e.g. cursor buffer. Burst Mode
340 * switching which is based on plane size is not recommended as
341 * plane size varies a lot towards the end of the screen and rapid
342 * movement causes unstable DMA which results into iommu crash/tear.
345 padding
= (fb
->pitches
[0] / (fb
->bits_per_pixel
>> 3)) - fb
->width
;
346 if (fb
->width
+ padding
< MIN_FB_WIDTH_FOR_16WORD_BURST
) {
347 val
&= ~WINCONx_BURSTLEN_MASK
;
348 val
|= WINCONx_BURSTLEN_8WORD
;
351 writel(val
, ctx
->regs
+ WINCON(win
));
354 static void decon_win_set_colkey(struct decon_context
*ctx
, unsigned int win
)
356 unsigned int keycon0
= 0, keycon1
= 0;
358 keycon0
= ~(WxKEYCON0_KEYBL_EN
| WxKEYCON0_KEYEN_F
|
359 WxKEYCON0_DIRCON
) | WxKEYCON0_COMPKEY(0);
361 keycon1
= WxKEYCON1_COLVAL(0xffffffff);
363 writel(keycon0
, ctx
->regs
+ WKEYCON0_BASE(win
));
364 writel(keycon1
, ctx
->regs
+ WKEYCON1_BASE(win
));
368 * shadow_protect_win() - disable updating values from shadow registers at vsync
370 * @win: window to protect registers for
371 * @protect: 1 to protect (disable updates)
373 static void decon_shadow_protect_win(struct decon_context
*ctx
,
374 unsigned int win
, bool protect
)
378 bits
= SHADOWCON_WINx_PROTECT(win
);
380 val
= readl(ctx
->regs
+ SHADOWCON
);
385 writel(val
, ctx
->regs
+ SHADOWCON
);
388 static void decon_atomic_begin(struct exynos_drm_crtc
*crtc
)
390 struct decon_context
*ctx
= crtc
->ctx
;
396 for (i
= 0; i
< WINDOWS_NR
; i
++)
397 decon_shadow_protect_win(ctx
, i
, true);
400 static void decon_update_plane(struct exynos_drm_crtc
*crtc
,
401 struct exynos_drm_plane
*plane
)
403 struct exynos_drm_plane_state
*state
=
404 to_exynos_plane_state(plane
->base
.state
);
405 struct decon_context
*ctx
= crtc
->ctx
;
406 struct drm_framebuffer
*fb
= state
->base
.fb
;
408 unsigned long val
, alpha
;
411 unsigned int win
= plane
->index
;
412 unsigned int bpp
= fb
->bits_per_pixel
>> 3;
413 unsigned int pitch
= fb
->pitches
[0];
419 * SHADOWCON/PRTCON register is used for enabling timing.
421 * for example, once only width value of a register is set,
422 * if the dma is started then decon hardware could malfunction so
423 * with protect window setting, the register fields with prefix '_F'
424 * wouldn't be updated at vsync also but updated once unprotect window
428 /* buffer start address */
429 val
= (unsigned long)exynos_drm_fb_dma_addr(fb
, 0);
430 writel(val
, ctx
->regs
+ VIDW_BUF_START(win
));
432 padding
= (pitch
/ bpp
) - fb
->width
;
435 writel(fb
->width
+ padding
, ctx
->regs
+ VIDW_WHOLE_X(win
));
436 writel(fb
->height
, ctx
->regs
+ VIDW_WHOLE_Y(win
));
438 /* offset from the start of the buffer to read */
439 writel(state
->src
.x
, ctx
->regs
+ VIDW_OFFSET_X(win
));
440 writel(state
->src
.y
, ctx
->regs
+ VIDW_OFFSET_Y(win
));
442 DRM_DEBUG_KMS("start addr = 0x%lx\n",
444 DRM_DEBUG_KMS("ovl_width = %d, ovl_height = %d\n",
445 state
->crtc
.w
, state
->crtc
.h
);
447 val
= VIDOSDxA_TOPLEFT_X(state
->crtc
.x
) |
448 VIDOSDxA_TOPLEFT_Y(state
->crtc
.y
);
449 writel(val
, ctx
->regs
+ VIDOSD_A(win
));
451 last_x
= state
->crtc
.x
+ state
->crtc
.w
;
454 last_y
= state
->crtc
.y
+ state
->crtc
.h
;
458 val
= VIDOSDxB_BOTRIGHT_X(last_x
) | VIDOSDxB_BOTRIGHT_Y(last_y
);
460 writel(val
, ctx
->regs
+ VIDOSD_B(win
));
462 DRM_DEBUG_KMS("osd pos: tx = %d, ty = %d, bx = %d, by = %d\n",
463 state
->crtc
.x
, state
->crtc
.y
, last_x
, last_y
);
466 alpha
= VIDOSDxC_ALPHA0_R_F(0x0) |
467 VIDOSDxC_ALPHA0_G_F(0x0) |
468 VIDOSDxC_ALPHA0_B_F(0x0);
470 writel(alpha
, ctx
->regs
+ VIDOSD_C(win
));
472 alpha
= VIDOSDxD_ALPHA1_R_F(0xff) |
473 VIDOSDxD_ALPHA1_G_F(0xff) |
474 VIDOSDxD_ALPHA1_B_F(0xff);
476 writel(alpha
, ctx
->regs
+ VIDOSD_D(win
));
478 decon_win_set_pixfmt(ctx
, win
, fb
);
480 /* hardware window 0 doesn't support color key. */
482 decon_win_set_colkey(ctx
, win
);
485 val
= readl(ctx
->regs
+ WINCON(win
));
486 val
|= WINCONx_TRIPLE_BUF_MODE
;
487 val
|= WINCONx_ENWIN
;
488 writel(val
, ctx
->regs
+ WINCON(win
));
490 /* Enable DMA channel and unprotect windows */
491 decon_shadow_protect_win(ctx
, win
, false);
493 val
= readl(ctx
->regs
+ DECON_UPDATE
);
494 val
|= DECON_UPDATE_STANDALONE_F
;
495 writel(val
, ctx
->regs
+ DECON_UPDATE
);
498 static void decon_disable_plane(struct exynos_drm_crtc
*crtc
,
499 struct exynos_drm_plane
*plane
)
501 struct decon_context
*ctx
= crtc
->ctx
;
502 unsigned int win
= plane
->index
;
508 /* protect windows */
509 decon_shadow_protect_win(ctx
, win
, true);
512 val
= readl(ctx
->regs
+ WINCON(win
));
513 val
&= ~WINCONx_ENWIN
;
514 writel(val
, ctx
->regs
+ WINCON(win
));
516 val
= readl(ctx
->regs
+ DECON_UPDATE
);
517 val
|= DECON_UPDATE_STANDALONE_F
;
518 writel(val
, ctx
->regs
+ DECON_UPDATE
);
521 static void decon_atomic_flush(struct exynos_drm_crtc
*crtc
)
523 struct decon_context
*ctx
= crtc
->ctx
;
529 for (i
= 0; i
< WINDOWS_NR
; i
++)
530 decon_shadow_protect_win(ctx
, i
, false);
533 static void decon_init(struct decon_context
*ctx
)
537 writel(VIDCON0_SWRESET
, ctx
->regs
+ VIDCON0
);
539 val
= VIDOUTCON0_DISP_IF_0_ON
;
541 val
|= VIDOUTCON0_RGBIF
;
542 writel(val
, ctx
->regs
+ VIDOUTCON0
);
544 writel(VCLKCON0_CLKVALUP
| VCLKCON0_VCLKFREE
, ctx
->regs
+ VCLKCON0
);
547 writel(VIDCON1_VCLK_HOLD
, ctx
->regs
+ VIDCON1(0));
550 static void decon_enable(struct exynos_drm_crtc
*crtc
)
552 struct decon_context
*ctx
= crtc
->ctx
;
557 pm_runtime_get_sync(ctx
->dev
);
561 /* if vblank was enabled status, enable it again. */
562 if (test_and_clear_bit(0, &ctx
->irq_flags
))
563 decon_enable_vblank(ctx
->crtc
);
565 decon_commit(ctx
->crtc
);
567 ctx
->suspended
= false;
570 static void decon_disable(struct exynos_drm_crtc
*crtc
)
572 struct decon_context
*ctx
= crtc
->ctx
;
579 * We need to make sure that all windows are disabled before we
580 * suspend that connector. Otherwise we might try to scan from
581 * a destroyed buffer later.
583 for (i
= 0; i
< WINDOWS_NR
; i
++)
584 decon_disable_plane(crtc
, &ctx
->planes
[i
]);
586 pm_runtime_put_sync(ctx
->dev
);
588 ctx
->suspended
= true;
591 static const struct exynos_drm_crtc_ops decon_crtc_ops
= {
592 .enable
= decon_enable
,
593 .disable
= decon_disable
,
594 .commit
= decon_commit
,
595 .enable_vblank
= decon_enable_vblank
,
596 .disable_vblank
= decon_disable_vblank
,
597 .wait_for_vblank
= decon_wait_for_vblank
,
598 .atomic_begin
= decon_atomic_begin
,
599 .update_plane
= decon_update_plane
,
600 .disable_plane
= decon_disable_plane
,
601 .atomic_flush
= decon_atomic_flush
,
605 static irqreturn_t
decon_irq_handler(int irq
, void *dev_id
)
607 struct decon_context
*ctx
= (struct decon_context
*)dev_id
;
611 val
= readl(ctx
->regs
+ VIDINTCON1
);
613 clear_bit
= ctx
->i80_if
? VIDINTCON1_INT_I80
: VIDINTCON1_INT_FRAME
;
615 writel(clear_bit
, ctx
->regs
+ VIDINTCON1
);
617 /* check the crtc is detached already from encoder */
618 if (ctx
->pipe
< 0 || !ctx
->drm_dev
)
622 drm_crtc_handle_vblank(&ctx
->crtc
->base
);
623 for (win
= 0 ; win
< WINDOWS_NR
; win
++) {
624 struct exynos_drm_plane
*plane
= &ctx
->planes
[win
];
626 if (!plane
->pending_fb
)
629 exynos_drm_crtc_finish_update(ctx
->crtc
, plane
);
632 /* set wait vsync event to zero and wake up queue. */
633 if (atomic_read(&ctx
->wait_vsync_event
)) {
634 atomic_set(&ctx
->wait_vsync_event
, 0);
635 wake_up(&ctx
->wait_vsync_queue
);
642 static int decon_bind(struct device
*dev
, struct device
*master
, void *data
)
644 struct decon_context
*ctx
= dev_get_drvdata(dev
);
645 struct drm_device
*drm_dev
= data
;
646 struct exynos_drm_plane
*exynos_plane
;
650 ret
= decon_ctx_initialize(ctx
, drm_dev
);
652 DRM_ERROR("decon_ctx_initialize failed.\n");
656 for (i
= 0; i
< WINDOWS_NR
; i
++) {
657 ctx
->configs
[i
].pixel_formats
= decon_formats
;
658 ctx
->configs
[i
].num_pixel_formats
= ARRAY_SIZE(decon_formats
);
659 ctx
->configs
[i
].zpos
= i
;
660 ctx
->configs
[i
].type
= decon_win_types
[i
];
662 ret
= exynos_plane_init(drm_dev
, &ctx
->planes
[i
], i
,
663 1 << ctx
->pipe
, &ctx
->configs
[i
]);
668 exynos_plane
= &ctx
->planes
[DEFAULT_WIN
];
669 ctx
->crtc
= exynos_drm_crtc_create(drm_dev
, &exynos_plane
->base
,
670 ctx
->pipe
, EXYNOS_DISPLAY_TYPE_LCD
,
671 &decon_crtc_ops
, ctx
);
672 if (IS_ERR(ctx
->crtc
)) {
673 decon_ctx_remove(ctx
);
674 return PTR_ERR(ctx
->crtc
);
678 exynos_dpi_bind(drm_dev
, ctx
->encoder
);
684 static void decon_unbind(struct device
*dev
, struct device
*master
,
687 struct decon_context
*ctx
= dev_get_drvdata(dev
);
689 decon_disable(ctx
->crtc
);
692 exynos_dpi_remove(ctx
->encoder
);
694 decon_ctx_remove(ctx
);
697 static const struct component_ops decon_component_ops
= {
699 .unbind
= decon_unbind
,
702 static int decon_probe(struct platform_device
*pdev
)
704 struct device
*dev
= &pdev
->dev
;
705 struct decon_context
*ctx
;
706 struct device_node
*i80_if_timings
;
707 struct resource
*res
;
713 ctx
= devm_kzalloc(dev
, sizeof(*ctx
), GFP_KERNEL
);
718 ctx
->suspended
= true;
720 i80_if_timings
= of_get_child_by_name(dev
->of_node
, "i80-if-timings");
723 of_node_put(i80_if_timings
);
725 ctx
->regs
= of_iomap(dev
->of_node
, 0);
729 ctx
->pclk
= devm_clk_get(dev
, "pclk_decon0");
730 if (IS_ERR(ctx
->pclk
)) {
731 dev_err(dev
, "failed to get bus clock pclk\n");
732 ret
= PTR_ERR(ctx
->pclk
);
736 ctx
->aclk
= devm_clk_get(dev
, "aclk_decon0");
737 if (IS_ERR(ctx
->aclk
)) {
738 dev_err(dev
, "failed to get bus clock aclk\n");
739 ret
= PTR_ERR(ctx
->aclk
);
743 ctx
->eclk
= devm_clk_get(dev
, "decon0_eclk");
744 if (IS_ERR(ctx
->eclk
)) {
745 dev_err(dev
, "failed to get eclock\n");
746 ret
= PTR_ERR(ctx
->eclk
);
750 ctx
->vclk
= devm_clk_get(dev
, "decon0_vclk");
751 if (IS_ERR(ctx
->vclk
)) {
752 dev_err(dev
, "failed to get vclock\n");
753 ret
= PTR_ERR(ctx
->vclk
);
757 res
= platform_get_resource_byname(pdev
, IORESOURCE_IRQ
,
758 ctx
->i80_if
? "lcd_sys" : "vsync");
760 dev_err(dev
, "irq request failed.\n");
765 ret
= devm_request_irq(dev
, res
->start
, decon_irq_handler
,
766 0, "drm_decon", ctx
);
768 dev_err(dev
, "irq request failed.\n");
772 init_waitqueue_head(&ctx
->wait_vsync_queue
);
773 atomic_set(&ctx
->wait_vsync_event
, 0);
775 platform_set_drvdata(pdev
, ctx
);
777 ctx
->encoder
= exynos_dpi_probe(dev
);
778 if (IS_ERR(ctx
->encoder
)) {
779 ret
= PTR_ERR(ctx
->encoder
);
783 pm_runtime_enable(dev
);
785 ret
= component_add(dev
, &decon_component_ops
);
787 goto err_disable_pm_runtime
;
791 err_disable_pm_runtime
:
792 pm_runtime_disable(dev
);
800 static int decon_remove(struct platform_device
*pdev
)
802 struct decon_context
*ctx
= dev_get_drvdata(&pdev
->dev
);
804 pm_runtime_disable(&pdev
->dev
);
808 component_del(&pdev
->dev
, &decon_component_ops
);
814 static int exynos7_decon_suspend(struct device
*dev
)
816 struct decon_context
*ctx
= dev_get_drvdata(dev
);
818 clk_disable_unprepare(ctx
->vclk
);
819 clk_disable_unprepare(ctx
->eclk
);
820 clk_disable_unprepare(ctx
->aclk
);
821 clk_disable_unprepare(ctx
->pclk
);
826 static int exynos7_decon_resume(struct device
*dev
)
828 struct decon_context
*ctx
= dev_get_drvdata(dev
);
831 ret
= clk_prepare_enable(ctx
->pclk
);
833 DRM_ERROR("Failed to prepare_enable the pclk [%d]\n", ret
);
837 ret
= clk_prepare_enable(ctx
->aclk
);
839 DRM_ERROR("Failed to prepare_enable the aclk [%d]\n", ret
);
843 ret
= clk_prepare_enable(ctx
->eclk
);
845 DRM_ERROR("Failed to prepare_enable the eclk [%d]\n", ret
);
849 ret
= clk_prepare_enable(ctx
->vclk
);
851 DRM_ERROR("Failed to prepare_enable the vclk [%d]\n", ret
);
859 static const struct dev_pm_ops exynos7_decon_pm_ops
= {
860 SET_RUNTIME_PM_OPS(exynos7_decon_suspend
, exynos7_decon_resume
,
864 struct platform_driver decon_driver
= {
865 .probe
= decon_probe
,
866 .remove
= decon_remove
,
868 .name
= "exynos-decon",
869 .pm
= &exynos7_decon_pm_ops
,
870 .of_match_table
= decon_driver_dt_match
,