xref: /linux/drivers/gpu/drm/exynos/exynos_mixer.c (revision acc8bf040c39499139e6d26e72c642d42ffa5016)
1d8408326SSeung-Woo Kim /*
2d8408326SSeung-Woo Kim  * Copyright (C) 2011 Samsung Electronics Co.Ltd
3d8408326SSeung-Woo Kim  * Authors:
4d8408326SSeung-Woo Kim  * Seung-Woo Kim <sw0312.kim@samsung.com>
5d8408326SSeung-Woo Kim  *	Inki Dae <inki.dae@samsung.com>
6d8408326SSeung-Woo Kim  *	Joonyoung Shim <jy0922.shim@samsung.com>
7d8408326SSeung-Woo Kim  *
8d8408326SSeung-Woo Kim  * Based on drivers/media/video/s5p-tv/mixer_reg.c
9d8408326SSeung-Woo Kim  *
10d8408326SSeung-Woo Kim  * This program is free software; you can redistribute  it and/or modify it
11d8408326SSeung-Woo Kim  * under  the terms of  the GNU General  Public License as published by the
12d8408326SSeung-Woo Kim  * Free Software Foundation;  either version 2 of the  License, or (at your
13d8408326SSeung-Woo Kim  * option) any later version.
14d8408326SSeung-Woo Kim  *
15d8408326SSeung-Woo Kim  */
16d8408326SSeung-Woo Kim 
17760285e7SDavid Howells #include <drm/drmP.h>
18d8408326SSeung-Woo Kim 
19d8408326SSeung-Woo Kim #include "regs-mixer.h"
20d8408326SSeung-Woo Kim #include "regs-vp.h"
21d8408326SSeung-Woo Kim 
22d8408326SSeung-Woo Kim #include <linux/kernel.h>
23d8408326SSeung-Woo Kim #include <linux/spinlock.h>
24d8408326SSeung-Woo Kim #include <linux/wait.h>
25d8408326SSeung-Woo Kim #include <linux/i2c.h>
26d8408326SSeung-Woo Kim #include <linux/platform_device.h>
27d8408326SSeung-Woo Kim #include <linux/interrupt.h>
28d8408326SSeung-Woo Kim #include <linux/irq.h>
29d8408326SSeung-Woo Kim #include <linux/delay.h>
30d8408326SSeung-Woo Kim #include <linux/pm_runtime.h>
31d8408326SSeung-Woo Kim #include <linux/clk.h>
32d8408326SSeung-Woo Kim #include <linux/regulator/consumer.h>
333f1c781dSSachin Kamat #include <linux/of.h>
3448f6155aSMarek Szyprowski #include <linux/of_device.h>
35f37cd5e8SInki Dae #include <linux/component.h>
36d8408326SSeung-Woo Kim 
37d8408326SSeung-Woo Kim #include <drm/exynos_drm.h>
38d8408326SSeung-Woo Kim 
39d8408326SSeung-Woo Kim #include "exynos_drm_drv.h"
40663d8766SRahul Sharma #include "exynos_drm_crtc.h"
410488f50eSMarek Szyprowski #include "exynos_drm_fb.h"
427ee14cdcSGustavo Padovan #include "exynos_drm_plane.h"
431055b39fSInki Dae #include "exynos_drm_iommu.h"
4422b21ae6SJoonyoung Shim 
45f041b257SSean Paul #define MIXER_WIN_NR		3
46fbbb1e1aSMarek Szyprowski #define VP_DEFAULT_WIN		2
47d8408326SSeung-Woo Kim 
482a6e4cd5STobias Jakobi /*
492a6e4cd5STobias Jakobi  * Mixer color space conversion coefficient triplet.
502a6e4cd5STobias Jakobi  * Used for CSC from RGB to YCbCr.
512a6e4cd5STobias Jakobi  * Each coefficient is a 10-bit fixed point number with
522a6e4cd5STobias Jakobi  * sign and no integer part, i.e.
532a6e4cd5STobias Jakobi  * [0:8] = fractional part (representing a value y = x / 2^9)
542a6e4cd5STobias Jakobi  * [9] = sign
552a6e4cd5STobias Jakobi  * Negative values are encoded with two's complement.
562a6e4cd5STobias Jakobi  */
572a6e4cd5STobias Jakobi #define MXR_CSC_C(x) ((int)((x) * 512.0) & 0x3ff)
582a6e4cd5STobias Jakobi #define MXR_CSC_CT(a0, a1, a2) \
592a6e4cd5STobias Jakobi   ((MXR_CSC_C(a0) << 20) | (MXR_CSC_C(a1) << 10) | (MXR_CSC_C(a2) << 0))
602a6e4cd5STobias Jakobi 
612a6e4cd5STobias Jakobi /* YCbCr value, used for mixer background color configuration. */
622a6e4cd5STobias Jakobi #define MXR_YCBCR_VAL(y, cb, cr) (((y) << 16) | ((cb) << 8) | ((cr) << 0))
632a6e4cd5STobias Jakobi 
647a57ca7cSTobias Jakobi /* The pixelformats that are natively supported by the mixer. */
657a57ca7cSTobias Jakobi #define MXR_FORMAT_RGB565	4
667a57ca7cSTobias Jakobi #define MXR_FORMAT_ARGB1555	5
677a57ca7cSTobias Jakobi #define MXR_FORMAT_ARGB4444	6
687a57ca7cSTobias Jakobi #define MXR_FORMAT_ARGB8888	7
697a57ca7cSTobias Jakobi 
701e123441SRahul Sharma enum mixer_version_id {
711e123441SRahul Sharma 	MXR_VER_0_0_0_16,
721e123441SRahul Sharma 	MXR_VER_16_0_33_0,
73def5e095SRahul Sharma 	MXR_VER_128_0_0_184,
741e123441SRahul Sharma };
751e123441SRahul Sharma 
76a44652e8SAndrzej Hajda enum mixer_flag_bits {
77a44652e8SAndrzej Hajda 	MXR_BIT_POWERED,
780df5e4acSAndrzej Hajda 	MXR_BIT_VSYNC,
79adeb6f44STobias Jakobi 	MXR_BIT_INTERLACE,
80adeb6f44STobias Jakobi 	MXR_BIT_VP_ENABLED,
81adeb6f44STobias Jakobi 	MXR_BIT_HAS_SCLK,
82a44652e8SAndrzej Hajda };
83a44652e8SAndrzej Hajda 
84fbbb1e1aSMarek Szyprowski static const uint32_t mixer_formats[] = {
85fbbb1e1aSMarek Szyprowski 	DRM_FORMAT_XRGB4444,
8626a7af3eSTobias Jakobi 	DRM_FORMAT_ARGB4444,
87fbbb1e1aSMarek Szyprowski 	DRM_FORMAT_XRGB1555,
8826a7af3eSTobias Jakobi 	DRM_FORMAT_ARGB1555,
89fbbb1e1aSMarek Szyprowski 	DRM_FORMAT_RGB565,
90fbbb1e1aSMarek Szyprowski 	DRM_FORMAT_XRGB8888,
91fbbb1e1aSMarek Szyprowski 	DRM_FORMAT_ARGB8888,
92fbbb1e1aSMarek Szyprowski };
93fbbb1e1aSMarek Szyprowski 
94fbbb1e1aSMarek Szyprowski static const uint32_t vp_formats[] = {
95fbbb1e1aSMarek Szyprowski 	DRM_FORMAT_NV12,
96fbbb1e1aSMarek Szyprowski 	DRM_FORMAT_NV21,
97fbbb1e1aSMarek Szyprowski };
98fbbb1e1aSMarek Szyprowski 
9922b21ae6SJoonyoung Shim struct mixer_context {
1004551789fSSean Paul 	struct platform_device *pdev;
101cf8fc4f1SJoonyoung Shim 	struct device		*dev;
1021055b39fSInki Dae 	struct drm_device	*drm_dev;
10393bca243SGustavo Padovan 	struct exynos_drm_crtc	*crtc;
1047ee14cdcSGustavo Padovan 	struct exynos_drm_plane	planes[MIXER_WIN_NR];
105a44652e8SAndrzej Hajda 	unsigned long		flags;
10622b21ae6SJoonyoung Shim 
107524c59f1SAndrzej Hajda 	int			irq;
108524c59f1SAndrzej Hajda 	void __iomem		*mixer_regs;
109524c59f1SAndrzej Hajda 	void __iomem		*vp_regs;
110524c59f1SAndrzej Hajda 	spinlock_t		reg_slock;
111524c59f1SAndrzej Hajda 	struct clk		*mixer;
112524c59f1SAndrzej Hajda 	struct clk		*vp;
113524c59f1SAndrzej Hajda 	struct clk		*hdmi;
114524c59f1SAndrzej Hajda 	struct clk		*sclk_mixer;
115524c59f1SAndrzej Hajda 	struct clk		*sclk_hdmi;
116524c59f1SAndrzej Hajda 	struct clk		*mout_mixer;
1171e123441SRahul Sharma 	enum mixer_version_id	mxr_ver;
118*acc8bf04SAndrzej Hajda 	int			scan_value;
1191e123441SRahul Sharma };
1201e123441SRahul Sharma 
1211e123441SRahul Sharma struct mixer_drv_data {
1221e123441SRahul Sharma 	enum mixer_version_id	version;
1231b8e5747SRahul Sharma 	bool					is_vp_enabled;
124ff830c96SMarek Szyprowski 	bool					has_sclk;
12522b21ae6SJoonyoung Shim };
12622b21ae6SJoonyoung Shim 
127fd2d2fc2SMarek Szyprowski static const struct exynos_drm_plane_config plane_configs[MIXER_WIN_NR] = {
128fd2d2fc2SMarek Szyprowski 	{
129fd2d2fc2SMarek Szyprowski 		.zpos = 0,
130fd2d2fc2SMarek Szyprowski 		.type = DRM_PLANE_TYPE_PRIMARY,
131fd2d2fc2SMarek Szyprowski 		.pixel_formats = mixer_formats,
132fd2d2fc2SMarek Szyprowski 		.num_pixel_formats = ARRAY_SIZE(mixer_formats),
133a2cb911eSMarek Szyprowski 		.capabilities = EXYNOS_DRM_PLANE_CAP_DOUBLE |
134a2cb911eSMarek Szyprowski 				EXYNOS_DRM_PLANE_CAP_ZPOS,
135fd2d2fc2SMarek Szyprowski 	}, {
136fd2d2fc2SMarek Szyprowski 		.zpos = 1,
137fd2d2fc2SMarek Szyprowski 		.type = DRM_PLANE_TYPE_CURSOR,
138fd2d2fc2SMarek Szyprowski 		.pixel_formats = mixer_formats,
139fd2d2fc2SMarek Szyprowski 		.num_pixel_formats = ARRAY_SIZE(mixer_formats),
140a2cb911eSMarek Szyprowski 		.capabilities = EXYNOS_DRM_PLANE_CAP_DOUBLE |
141a2cb911eSMarek Szyprowski 				EXYNOS_DRM_PLANE_CAP_ZPOS,
142fd2d2fc2SMarek Szyprowski 	}, {
143fd2d2fc2SMarek Szyprowski 		.zpos = 2,
144fd2d2fc2SMarek Szyprowski 		.type = DRM_PLANE_TYPE_OVERLAY,
145fd2d2fc2SMarek Szyprowski 		.pixel_formats = vp_formats,
146fd2d2fc2SMarek Szyprowski 		.num_pixel_formats = ARRAY_SIZE(vp_formats),
147a2cb911eSMarek Szyprowski 		.capabilities = EXYNOS_DRM_PLANE_CAP_SCALE |
148f40031c2STobias Jakobi 				EXYNOS_DRM_PLANE_CAP_ZPOS |
149f40031c2STobias Jakobi 				EXYNOS_DRM_PLANE_CAP_TILE,
150fd2d2fc2SMarek Szyprowski 	},
151fd2d2fc2SMarek Szyprowski };
152fd2d2fc2SMarek Szyprowski 
153d8408326SSeung-Woo Kim static const u8 filter_y_horiz_tap8[] = {
154d8408326SSeung-Woo Kim 	0,	-1,	-1,	-1,	-1,	-1,	-1,	-1,
155d8408326SSeung-Woo Kim 	-1,	-1,	-1,	-1,	-1,	0,	0,	0,
156d8408326SSeung-Woo Kim 	0,	2,	4,	5,	6,	6,	6,	6,
157d8408326SSeung-Woo Kim 	6,	5,	5,	4,	3,	2,	1,	1,
158d8408326SSeung-Woo Kim 	0,	-6,	-12,	-16,	-18,	-20,	-21,	-20,
159d8408326SSeung-Woo Kim 	-20,	-18,	-16,	-13,	-10,	-8,	-5,	-2,
160d8408326SSeung-Woo Kim 	127,	126,	125,	121,	114,	107,	99,	89,
161d8408326SSeung-Woo Kim 	79,	68,	57,	46,	35,	25,	16,	8,
162d8408326SSeung-Woo Kim };
163d8408326SSeung-Woo Kim 
164d8408326SSeung-Woo Kim static const u8 filter_y_vert_tap4[] = {
165d8408326SSeung-Woo Kim 	0,	-3,	-6,	-8,	-8,	-8,	-8,	-7,
166d8408326SSeung-Woo Kim 	-6,	-5,	-4,	-3,	-2,	-1,	-1,	0,
167d8408326SSeung-Woo Kim 	127,	126,	124,	118,	111,	102,	92,	81,
168d8408326SSeung-Woo Kim 	70,	59,	48,	37,	27,	19,	11,	5,
169d8408326SSeung-Woo Kim 	0,	5,	11,	19,	27,	37,	48,	59,
170d8408326SSeung-Woo Kim 	70,	81,	92,	102,	111,	118,	124,	126,
171d8408326SSeung-Woo Kim 	0,	0,	-1,	-1,	-2,	-3,	-4,	-5,
172d8408326SSeung-Woo Kim 	-6,	-7,	-8,	-8,	-8,	-8,	-6,	-3,
173d8408326SSeung-Woo Kim };
174d8408326SSeung-Woo Kim 
175d8408326SSeung-Woo Kim static const u8 filter_cr_horiz_tap4[] = {
176d8408326SSeung-Woo Kim 	0,	-3,	-6,	-8,	-8,	-8,	-8,	-7,
177d8408326SSeung-Woo Kim 	-6,	-5,	-4,	-3,	-2,	-1,	-1,	0,
178d8408326SSeung-Woo Kim 	127,	126,	124,	118,	111,	102,	92,	81,
179d8408326SSeung-Woo Kim 	70,	59,	48,	37,	27,	19,	11,	5,
180d8408326SSeung-Woo Kim };
181d8408326SSeung-Woo Kim 
182f657a996SMarek Szyprowski static inline bool is_alpha_format(unsigned int pixel_format)
183f657a996SMarek Szyprowski {
184f657a996SMarek Szyprowski 	switch (pixel_format) {
185f657a996SMarek Szyprowski 	case DRM_FORMAT_ARGB8888:
18626a7af3eSTobias Jakobi 	case DRM_FORMAT_ARGB1555:
18726a7af3eSTobias Jakobi 	case DRM_FORMAT_ARGB4444:
188f657a996SMarek Szyprowski 		return true;
189f657a996SMarek Szyprowski 	default:
190f657a996SMarek Szyprowski 		return false;
191f657a996SMarek Szyprowski 	}
192f657a996SMarek Szyprowski }
193f657a996SMarek Szyprowski 
194524c59f1SAndrzej Hajda static inline u32 vp_reg_read(struct mixer_context *ctx, u32 reg_id)
195d8408326SSeung-Woo Kim {
196524c59f1SAndrzej Hajda 	return readl(ctx->vp_regs + reg_id);
197d8408326SSeung-Woo Kim }
198d8408326SSeung-Woo Kim 
199524c59f1SAndrzej Hajda static inline void vp_reg_write(struct mixer_context *ctx, u32 reg_id,
200d8408326SSeung-Woo Kim 				 u32 val)
201d8408326SSeung-Woo Kim {
202524c59f1SAndrzej Hajda 	writel(val, ctx->vp_regs + reg_id);
203d8408326SSeung-Woo Kim }
204d8408326SSeung-Woo Kim 
205524c59f1SAndrzej Hajda static inline void vp_reg_writemask(struct mixer_context *ctx, u32 reg_id,
206d8408326SSeung-Woo Kim 				 u32 val, u32 mask)
207d8408326SSeung-Woo Kim {
208524c59f1SAndrzej Hajda 	u32 old = vp_reg_read(ctx, reg_id);
209d8408326SSeung-Woo Kim 
210d8408326SSeung-Woo Kim 	val = (val & mask) | (old & ~mask);
211524c59f1SAndrzej Hajda 	writel(val, ctx->vp_regs + reg_id);
212d8408326SSeung-Woo Kim }
213d8408326SSeung-Woo Kim 
214524c59f1SAndrzej Hajda static inline u32 mixer_reg_read(struct mixer_context *ctx, u32 reg_id)
215d8408326SSeung-Woo Kim {
216524c59f1SAndrzej Hajda 	return readl(ctx->mixer_regs + reg_id);
217d8408326SSeung-Woo Kim }
218d8408326SSeung-Woo Kim 
219524c59f1SAndrzej Hajda static inline void mixer_reg_write(struct mixer_context *ctx, u32 reg_id,
220d8408326SSeung-Woo Kim 				 u32 val)
221d8408326SSeung-Woo Kim {
222524c59f1SAndrzej Hajda 	writel(val, ctx->mixer_regs + reg_id);
223d8408326SSeung-Woo Kim }
224d8408326SSeung-Woo Kim 
225524c59f1SAndrzej Hajda static inline void mixer_reg_writemask(struct mixer_context *ctx,
226d8408326SSeung-Woo Kim 				 u32 reg_id, u32 val, u32 mask)
227d8408326SSeung-Woo Kim {
228524c59f1SAndrzej Hajda 	u32 old = mixer_reg_read(ctx, reg_id);
229d8408326SSeung-Woo Kim 
230d8408326SSeung-Woo Kim 	val = (val & mask) | (old & ~mask);
231524c59f1SAndrzej Hajda 	writel(val, ctx->mixer_regs + reg_id);
232d8408326SSeung-Woo Kim }
233d8408326SSeung-Woo Kim 
234d8408326SSeung-Woo Kim static void mixer_regs_dump(struct mixer_context *ctx)
235d8408326SSeung-Woo Kim {
236d8408326SSeung-Woo Kim #define DUMPREG(reg_id) \
237d8408326SSeung-Woo Kim do { \
238d8408326SSeung-Woo Kim 	DRM_DEBUG_KMS(#reg_id " = %08x\n", \
239524c59f1SAndrzej Hajda 		(u32)readl(ctx->mixer_regs + reg_id)); \
240d8408326SSeung-Woo Kim } while (0)
241d8408326SSeung-Woo Kim 
242d8408326SSeung-Woo Kim 	DUMPREG(MXR_STATUS);
243d8408326SSeung-Woo Kim 	DUMPREG(MXR_CFG);
244d8408326SSeung-Woo Kim 	DUMPREG(MXR_INT_EN);
245d8408326SSeung-Woo Kim 	DUMPREG(MXR_INT_STATUS);
246d8408326SSeung-Woo Kim 
247d8408326SSeung-Woo Kim 	DUMPREG(MXR_LAYER_CFG);
248d8408326SSeung-Woo Kim 	DUMPREG(MXR_VIDEO_CFG);
249d8408326SSeung-Woo Kim 
250d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC0_CFG);
251d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC0_BASE);
252d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC0_SPAN);
253d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC0_WH);
254d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC0_SXY);
255d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC0_DXY);
256d8408326SSeung-Woo Kim 
257d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC1_CFG);
258d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC1_BASE);
259d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC1_SPAN);
260d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC1_WH);
261d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC1_SXY);
262d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC1_DXY);
263d8408326SSeung-Woo Kim #undef DUMPREG
264d8408326SSeung-Woo Kim }
265d8408326SSeung-Woo Kim 
266d8408326SSeung-Woo Kim static void vp_regs_dump(struct mixer_context *ctx)
267d8408326SSeung-Woo Kim {
268d8408326SSeung-Woo Kim #define DUMPREG(reg_id) \
269d8408326SSeung-Woo Kim do { \
270d8408326SSeung-Woo Kim 	DRM_DEBUG_KMS(#reg_id " = %08x\n", \
271524c59f1SAndrzej Hajda 		(u32) readl(ctx->vp_regs + reg_id)); \
272d8408326SSeung-Woo Kim } while (0)
273d8408326SSeung-Woo Kim 
274d8408326SSeung-Woo Kim 	DUMPREG(VP_ENABLE);
275d8408326SSeung-Woo Kim 	DUMPREG(VP_SRESET);
276d8408326SSeung-Woo Kim 	DUMPREG(VP_SHADOW_UPDATE);
277d8408326SSeung-Woo Kim 	DUMPREG(VP_FIELD_ID);
278d8408326SSeung-Woo Kim 	DUMPREG(VP_MODE);
279d8408326SSeung-Woo Kim 	DUMPREG(VP_IMG_SIZE_Y);
280d8408326SSeung-Woo Kim 	DUMPREG(VP_IMG_SIZE_C);
281d8408326SSeung-Woo Kim 	DUMPREG(VP_PER_RATE_CTRL);
282d8408326SSeung-Woo Kim 	DUMPREG(VP_TOP_Y_PTR);
283d8408326SSeung-Woo Kim 	DUMPREG(VP_BOT_Y_PTR);
284d8408326SSeung-Woo Kim 	DUMPREG(VP_TOP_C_PTR);
285d8408326SSeung-Woo Kim 	DUMPREG(VP_BOT_C_PTR);
286d8408326SSeung-Woo Kim 	DUMPREG(VP_ENDIAN_MODE);
287d8408326SSeung-Woo Kim 	DUMPREG(VP_SRC_H_POSITION);
288d8408326SSeung-Woo Kim 	DUMPREG(VP_SRC_V_POSITION);
289d8408326SSeung-Woo Kim 	DUMPREG(VP_SRC_WIDTH);
290d8408326SSeung-Woo Kim 	DUMPREG(VP_SRC_HEIGHT);
291d8408326SSeung-Woo Kim 	DUMPREG(VP_DST_H_POSITION);
292d8408326SSeung-Woo Kim 	DUMPREG(VP_DST_V_POSITION);
293d8408326SSeung-Woo Kim 	DUMPREG(VP_DST_WIDTH);
294d8408326SSeung-Woo Kim 	DUMPREG(VP_DST_HEIGHT);
295d8408326SSeung-Woo Kim 	DUMPREG(VP_H_RATIO);
296d8408326SSeung-Woo Kim 	DUMPREG(VP_V_RATIO);
297d8408326SSeung-Woo Kim 
298d8408326SSeung-Woo Kim #undef DUMPREG
299d8408326SSeung-Woo Kim }
300d8408326SSeung-Woo Kim 
301524c59f1SAndrzej Hajda static inline void vp_filter_set(struct mixer_context *ctx,
302d8408326SSeung-Woo Kim 		int reg_id, const u8 *data, unsigned int size)
303d8408326SSeung-Woo Kim {
304d8408326SSeung-Woo Kim 	/* assure 4-byte align */
305d8408326SSeung-Woo Kim 	BUG_ON(size & 3);
306d8408326SSeung-Woo Kim 	for (; size; size -= 4, reg_id += 4, data += 4) {
307d8408326SSeung-Woo Kim 		u32 val = (data[0] << 24) |  (data[1] << 16) |
308d8408326SSeung-Woo Kim 			(data[2] << 8) | data[3];
309524c59f1SAndrzej Hajda 		vp_reg_write(ctx, reg_id, val);
310d8408326SSeung-Woo Kim 	}
311d8408326SSeung-Woo Kim }
312d8408326SSeung-Woo Kim 
313524c59f1SAndrzej Hajda static void vp_default_filter(struct mixer_context *ctx)
314d8408326SSeung-Woo Kim {
315524c59f1SAndrzej Hajda 	vp_filter_set(ctx, VP_POLY8_Y0_LL,
316e25e1b66SSachin Kamat 		filter_y_horiz_tap8, sizeof(filter_y_horiz_tap8));
317524c59f1SAndrzej Hajda 	vp_filter_set(ctx, VP_POLY4_Y0_LL,
318e25e1b66SSachin Kamat 		filter_y_vert_tap4, sizeof(filter_y_vert_tap4));
319524c59f1SAndrzej Hajda 	vp_filter_set(ctx, VP_POLY4_C0_LL,
320e25e1b66SSachin Kamat 		filter_cr_horiz_tap4, sizeof(filter_cr_horiz_tap4));
321d8408326SSeung-Woo Kim }
322d8408326SSeung-Woo Kim 
323f657a996SMarek Szyprowski static void mixer_cfg_gfx_blend(struct mixer_context *ctx, unsigned int win,
324f657a996SMarek Szyprowski 				bool alpha)
325f657a996SMarek Szyprowski {
326f657a996SMarek Szyprowski 	u32 val;
327f657a996SMarek Szyprowski 
328f657a996SMarek Szyprowski 	val  = MXR_GRP_CFG_COLOR_KEY_DISABLE; /* no blank key */
329f657a996SMarek Szyprowski 	if (alpha) {
330f657a996SMarek Szyprowski 		/* blending based on pixel alpha */
331f657a996SMarek Szyprowski 		val |= MXR_GRP_CFG_BLEND_PRE_MUL;
332f657a996SMarek Szyprowski 		val |= MXR_GRP_CFG_PIXEL_BLEND_EN;
333f657a996SMarek Szyprowski 	}
334524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_GRAPHIC_CFG(win),
335f657a996SMarek Szyprowski 			    val, MXR_GRP_CFG_MISC_MASK);
336f657a996SMarek Szyprowski }
337f657a996SMarek Szyprowski 
338f657a996SMarek Szyprowski static void mixer_cfg_vp_blend(struct mixer_context *ctx)
339f657a996SMarek Szyprowski {
340f657a996SMarek Szyprowski 	u32 val;
341f657a996SMarek Szyprowski 
342f657a996SMarek Szyprowski 	/*
343f657a996SMarek Szyprowski 	 * No blending at the moment since the NV12/NV21 pixelformats don't
344f657a996SMarek Szyprowski 	 * have an alpha channel. However the mixer supports a global alpha
345f657a996SMarek Szyprowski 	 * value for a layer. Once this functionality is exposed, we can
346f657a996SMarek Szyprowski 	 * support blending of the video layer through this.
347f657a996SMarek Szyprowski 	 */
348f657a996SMarek Szyprowski 	val = 0;
349524c59f1SAndrzej Hajda 	mixer_reg_write(ctx, MXR_VIDEO_CFG, val);
350f657a996SMarek Szyprowski }
351f657a996SMarek Szyprowski 
352d8408326SSeung-Woo Kim static void mixer_vsync_set_update(struct mixer_context *ctx, bool enable)
353d8408326SSeung-Woo Kim {
354d8408326SSeung-Woo Kim 	/* block update on vsync */
355524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_STATUS, enable ?
356d8408326SSeung-Woo Kim 			MXR_STATUS_SYNC_ENABLE : 0, MXR_STATUS_SYNC_ENABLE);
357d8408326SSeung-Woo Kim 
358adeb6f44STobias Jakobi 	if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags))
359524c59f1SAndrzej Hajda 		vp_reg_write(ctx, VP_SHADOW_UPDATE, enable ?
360d8408326SSeung-Woo Kim 			VP_SHADOW_UPDATE_ENABLE : 0);
361d8408326SSeung-Woo Kim }
362d8408326SSeung-Woo Kim 
3633fc40ca9SAndrzej Hajda static void mixer_cfg_scan(struct mixer_context *ctx, int width, int height)
364d8408326SSeung-Woo Kim {
365d8408326SSeung-Woo Kim 	u32 val;
366d8408326SSeung-Woo Kim 
367d8408326SSeung-Woo Kim 	/* choosing between interlace and progressive mode */
368adeb6f44STobias Jakobi 	val = test_bit(MXR_BIT_INTERLACE, &ctx->flags) ?
369adeb6f44STobias Jakobi 		MXR_CFG_SCAN_INTERLACE : MXR_CFG_SCAN_PROGRESSIVE;
370d8408326SSeung-Woo Kim 
371*acc8bf04SAndrzej Hajda 	if (ctx->mxr_ver == MXR_VER_128_0_0_184)
372524c59f1SAndrzej Hajda 		mixer_reg_write(ctx, MXR_RESOLUTION,
3733fc40ca9SAndrzej Hajda 			MXR_MXR_RES_HEIGHT(height) | MXR_MXR_RES_WIDTH(width));
374d8408326SSeung-Woo Kim 	else
375*acc8bf04SAndrzej Hajda 		val |= ctx->scan_value;
376d8408326SSeung-Woo Kim 
377524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_CFG, val, MXR_CFG_SCAN_MASK);
378d8408326SSeung-Woo Kim }
379d8408326SSeung-Woo Kim 
380d8408326SSeung-Woo Kim static void mixer_cfg_rgb_fmt(struct mixer_context *ctx, unsigned int height)
381d8408326SSeung-Woo Kim {
382d8408326SSeung-Woo Kim 	u32 val;
383d8408326SSeung-Woo Kim 
3842a39db01STobias Jakobi 	switch (height) {
3852a39db01STobias Jakobi 	case 480:
3862a39db01STobias Jakobi 	case 576:
387d8408326SSeung-Woo Kim 		val = MXR_CFG_RGB601_0_255;
3882a39db01STobias Jakobi 		break;
3892a39db01STobias Jakobi 	case 720:
3902a39db01STobias Jakobi 	case 1080:
3912a39db01STobias Jakobi 	default:
392d8408326SSeung-Woo Kim 		val = MXR_CFG_RGB709_16_235;
3932a6e4cd5STobias Jakobi 		/* Configure the BT.709 CSC matrix for full range RGB. */
394524c59f1SAndrzej Hajda 		mixer_reg_write(ctx, MXR_CM_COEFF_Y,
3952a6e4cd5STobias Jakobi 			MXR_CSC_CT( 0.184,  0.614,  0.063) |
3962a6e4cd5STobias Jakobi 			MXR_CM_COEFF_RGB_FULL);
397524c59f1SAndrzej Hajda 		mixer_reg_write(ctx, MXR_CM_COEFF_CB,
3982a6e4cd5STobias Jakobi 			MXR_CSC_CT(-0.102, -0.338,  0.440));
399524c59f1SAndrzej Hajda 		mixer_reg_write(ctx, MXR_CM_COEFF_CR,
4002a6e4cd5STobias Jakobi 			MXR_CSC_CT( 0.440, -0.399, -0.040));
4012a39db01STobias Jakobi 		break;
402d8408326SSeung-Woo Kim 	}
403d8408326SSeung-Woo Kim 
404524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_CFG, val, MXR_CFG_RGB_FMT_MASK);
405d8408326SSeung-Woo Kim }
406d8408326SSeung-Woo Kim 
4075b1d5bc6STobias Jakobi static void mixer_cfg_layer(struct mixer_context *ctx, unsigned int win,
408a2cb911eSMarek Szyprowski 			    unsigned int priority, bool enable)
409d8408326SSeung-Woo Kim {
410d8408326SSeung-Woo Kim 	u32 val = enable ? ~0 : 0;
411d8408326SSeung-Woo Kim 
412d8408326SSeung-Woo Kim 	switch (win) {
413d8408326SSeung-Woo Kim 	case 0:
414524c59f1SAndrzej Hajda 		mixer_reg_writemask(ctx, MXR_CFG, val, MXR_CFG_GRP0_ENABLE);
415524c59f1SAndrzej Hajda 		mixer_reg_writemask(ctx, MXR_LAYER_CFG,
416a2cb911eSMarek Szyprowski 				    MXR_LAYER_CFG_GRP0_VAL(priority),
417a2cb911eSMarek Szyprowski 				    MXR_LAYER_CFG_GRP0_MASK);
418d8408326SSeung-Woo Kim 		break;
419d8408326SSeung-Woo Kim 	case 1:
420524c59f1SAndrzej Hajda 		mixer_reg_writemask(ctx, MXR_CFG, val, MXR_CFG_GRP1_ENABLE);
421524c59f1SAndrzej Hajda 		mixer_reg_writemask(ctx, MXR_LAYER_CFG,
422a2cb911eSMarek Szyprowski 				    MXR_LAYER_CFG_GRP1_VAL(priority),
423a2cb911eSMarek Szyprowski 				    MXR_LAYER_CFG_GRP1_MASK);
424adeb6f44STobias Jakobi 
425d8408326SSeung-Woo Kim 		break;
4265e68fef2SMarek Szyprowski 	case VP_DEFAULT_WIN:
427adeb6f44STobias Jakobi 		if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) {
428524c59f1SAndrzej Hajda 			vp_reg_writemask(ctx, VP_ENABLE, val, VP_ENABLE_ON);
429524c59f1SAndrzej Hajda 			mixer_reg_writemask(ctx, MXR_CFG, val,
4301b8e5747SRahul Sharma 				MXR_CFG_VP_ENABLE);
431524c59f1SAndrzej Hajda 			mixer_reg_writemask(ctx, MXR_LAYER_CFG,
432a2cb911eSMarek Szyprowski 					    MXR_LAYER_CFG_VP_VAL(priority),
433a2cb911eSMarek Szyprowski 					    MXR_LAYER_CFG_VP_MASK);
4341b8e5747SRahul Sharma 		}
435d8408326SSeung-Woo Kim 		break;
436d8408326SSeung-Woo Kim 	}
437d8408326SSeung-Woo Kim }
438d8408326SSeung-Woo Kim 
439d8408326SSeung-Woo Kim static void mixer_run(struct mixer_context *ctx)
440d8408326SSeung-Woo Kim {
441524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_STATUS, ~0, MXR_STATUS_REG_RUN);
442d8408326SSeung-Woo Kim }
443d8408326SSeung-Woo Kim 
444381be025SRahul Sharma static void mixer_stop(struct mixer_context *ctx)
445381be025SRahul Sharma {
446381be025SRahul Sharma 	int timeout = 20;
447381be025SRahul Sharma 
448524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_STATUS, 0, MXR_STATUS_REG_RUN);
449381be025SRahul Sharma 
450524c59f1SAndrzej Hajda 	while (!(mixer_reg_read(ctx, MXR_STATUS) & MXR_STATUS_REG_IDLE) &&
451381be025SRahul Sharma 			--timeout)
452381be025SRahul Sharma 		usleep_range(10000, 12000);
453381be025SRahul Sharma }
454381be025SRahul Sharma 
455521d98a3SAndrzej Hajda static void mixer_commit(struct mixer_context *ctx)
456521d98a3SAndrzej Hajda {
457521d98a3SAndrzej Hajda 	struct drm_display_mode *mode = &ctx->crtc->base.state->adjusted_mode;
458521d98a3SAndrzej Hajda 
4593fc40ca9SAndrzej Hajda 	mixer_cfg_scan(ctx, mode->hdisplay, mode->vdisplay);
460521d98a3SAndrzej Hajda 	mixer_cfg_rgb_fmt(ctx, mode->vdisplay);
461521d98a3SAndrzej Hajda 	mixer_run(ctx);
462521d98a3SAndrzej Hajda }
463521d98a3SAndrzej Hajda 
4642eeb2e5eSGustavo Padovan static void vp_video_buffer(struct mixer_context *ctx,
4652eeb2e5eSGustavo Padovan 			    struct exynos_drm_plane *plane)
466d8408326SSeung-Woo Kim {
4670114f404SMarek Szyprowski 	struct exynos_drm_plane_state *state =
4680114f404SMarek Szyprowski 				to_exynos_plane_state(plane->base.state);
4690114f404SMarek Szyprowski 	struct drm_framebuffer *fb = state->base.fb;
470e47726a1SMarek Szyprowski 	unsigned int priority = state->base.normalized_zpos + 1;
471d8408326SSeung-Woo Kim 	unsigned long flags;
472d8408326SSeung-Woo Kim 	dma_addr_t luma_addr[2], chroma_addr[2];
4730f752694STobias Jakobi 	bool is_tiled, is_nv21;
474d8408326SSeung-Woo Kim 	u32 val;
475d8408326SSeung-Woo Kim 
4760f752694STobias Jakobi 	is_nv21 = (fb->format->format == DRM_FORMAT_NV21);
4770f752694STobias Jakobi 	is_tiled = (fb->modifier == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE);
478f40031c2STobias Jakobi 
4790488f50eSMarek Szyprowski 	luma_addr[0] = exynos_drm_fb_dma_addr(fb, 0);
4800488f50eSMarek Szyprowski 	chroma_addr[0] = exynos_drm_fb_dma_addr(fb, 1);
481d8408326SSeung-Woo Kim 
48271469944SAndrzej Hajda 	if (test_bit(MXR_BIT_INTERLACE, &ctx->flags)) {
4830f752694STobias Jakobi 		if (is_tiled) {
484d8408326SSeung-Woo Kim 			luma_addr[1] = luma_addr[0] + 0x40;
485d8408326SSeung-Woo Kim 			chroma_addr[1] = chroma_addr[0] + 0x40;
486d8408326SSeung-Woo Kim 		} else {
4872eeb2e5eSGustavo Padovan 			luma_addr[1] = luma_addr[0] + fb->pitches[0];
4882eeb2e5eSGustavo Padovan 			chroma_addr[1] = chroma_addr[0] + fb->pitches[0];
489d8408326SSeung-Woo Kim 		}
490d8408326SSeung-Woo Kim 	} else {
491d8408326SSeung-Woo Kim 		luma_addr[1] = 0;
492d8408326SSeung-Woo Kim 		chroma_addr[1] = 0;
493d8408326SSeung-Woo Kim 	}
494d8408326SSeung-Woo Kim 
495524c59f1SAndrzej Hajda 	spin_lock_irqsave(&ctx->reg_slock, flags);
496d8408326SSeung-Woo Kim 
497d8408326SSeung-Woo Kim 	/* interlace or progressive scan mode */
498adeb6f44STobias Jakobi 	val = (test_bit(MXR_BIT_INTERLACE, &ctx->flags) ? ~0 : 0);
499524c59f1SAndrzej Hajda 	vp_reg_writemask(ctx, VP_MODE, val, VP_MODE_LINE_SKIP);
500d8408326SSeung-Woo Kim 
501d8408326SSeung-Woo Kim 	/* setup format */
5020f752694STobias Jakobi 	val = (is_nv21 ? VP_MODE_NV21 : VP_MODE_NV12);
5030f752694STobias Jakobi 	val |= (is_tiled ? VP_MODE_MEM_TILED : VP_MODE_MEM_LINEAR);
504524c59f1SAndrzej Hajda 	vp_reg_writemask(ctx, VP_MODE, val, VP_MODE_FMT_MASK);
505d8408326SSeung-Woo Kim 
506d8408326SSeung-Woo Kim 	/* setting size of input image */
507524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_IMG_SIZE_Y, VP_IMG_HSIZE(fb->pitches[0]) |
5082eeb2e5eSGustavo Padovan 		VP_IMG_VSIZE(fb->height));
509dc500cfbSTobias Jakobi 	/* chroma plane for NV12/NV21 is half the height of the luma plane */
510524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_IMG_SIZE_C, VP_IMG_HSIZE(fb->pitches[0]) |
5112eeb2e5eSGustavo Padovan 		VP_IMG_VSIZE(fb->height / 2));
512d8408326SSeung-Woo Kim 
513524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_SRC_WIDTH, state->src.w);
514524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_SRC_HEIGHT, state->src.h);
515524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_SRC_H_POSITION,
5160114f404SMarek Szyprowski 			VP_SRC_H_POSITION_VAL(state->src.x));
517524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_SRC_V_POSITION, state->src.y);
518d8408326SSeung-Woo Kim 
519524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_DST_WIDTH, state->crtc.w);
520524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_DST_H_POSITION, state->crtc.x);
521adeb6f44STobias Jakobi 	if (test_bit(MXR_BIT_INTERLACE, &ctx->flags)) {
522524c59f1SAndrzej Hajda 		vp_reg_write(ctx, VP_DST_HEIGHT, state->crtc.h / 2);
523524c59f1SAndrzej Hajda 		vp_reg_write(ctx, VP_DST_V_POSITION, state->crtc.y / 2);
524d8408326SSeung-Woo Kim 	} else {
525524c59f1SAndrzej Hajda 		vp_reg_write(ctx, VP_DST_HEIGHT, state->crtc.h);
526524c59f1SAndrzej Hajda 		vp_reg_write(ctx, VP_DST_V_POSITION, state->crtc.y);
527d8408326SSeung-Woo Kim 	}
528d8408326SSeung-Woo Kim 
529524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_H_RATIO, state->h_ratio);
530524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_V_RATIO, state->v_ratio);
531d8408326SSeung-Woo Kim 
532524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_ENDIAN_MODE, VP_ENDIAN_MODE_LITTLE);
533d8408326SSeung-Woo Kim 
534d8408326SSeung-Woo Kim 	/* set buffer address to vp */
535524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_TOP_Y_PTR, luma_addr[0]);
536524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_BOT_Y_PTR, luma_addr[1]);
537524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_TOP_C_PTR, chroma_addr[0]);
538524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_BOT_C_PTR, chroma_addr[1]);
539d8408326SSeung-Woo Kim 
540e47726a1SMarek Szyprowski 	mixer_cfg_layer(ctx, plane->index, priority, true);
541f657a996SMarek Szyprowski 	mixer_cfg_vp_blend(ctx);
542d8408326SSeung-Woo Kim 
543524c59f1SAndrzej Hajda 	spin_unlock_irqrestore(&ctx->reg_slock, flags);
544d8408326SSeung-Woo Kim 
545c0734fbaSTobias Jakobi 	mixer_regs_dump(ctx);
546d8408326SSeung-Woo Kim 	vp_regs_dump(ctx);
547d8408326SSeung-Woo Kim }
548d8408326SSeung-Woo Kim 
549aaf8b49eSRahul Sharma static void mixer_layer_update(struct mixer_context *ctx)
550aaf8b49eSRahul Sharma {
551524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_CFG, ~0, MXR_CFG_LAYER_UPDATE);
552aaf8b49eSRahul Sharma }
553aaf8b49eSRahul Sharma 
5542eeb2e5eSGustavo Padovan static void mixer_graph_buffer(struct mixer_context *ctx,
5552eeb2e5eSGustavo Padovan 			       struct exynos_drm_plane *plane)
556d8408326SSeung-Woo Kim {
5570114f404SMarek Szyprowski 	struct exynos_drm_plane_state *state =
5580114f404SMarek Szyprowski 				to_exynos_plane_state(plane->base.state);
5590114f404SMarek Szyprowski 	struct drm_framebuffer *fb = state->base.fb;
560e47726a1SMarek Szyprowski 	unsigned int priority = state->base.normalized_zpos + 1;
561d8408326SSeung-Woo Kim 	unsigned long flags;
56240bdfb0aSMarek Szyprowski 	unsigned int win = plane->index;
5632611015cSTobias Jakobi 	unsigned int x_ratio = 0, y_ratio = 0;
5645dff6905STobias Jakobi 	unsigned int dst_x_offset, dst_y_offset;
565d8408326SSeung-Woo Kim 	dma_addr_t dma_addr;
566d8408326SSeung-Woo Kim 	unsigned int fmt;
567d8408326SSeung-Woo Kim 	u32 val;
568d8408326SSeung-Woo Kim 
569438b74a5SVille Syrjälä 	switch (fb->format->format) {
5707a57ca7cSTobias Jakobi 	case DRM_FORMAT_XRGB4444:
57126a7af3eSTobias Jakobi 	case DRM_FORMAT_ARGB4444:
5727a57ca7cSTobias Jakobi 		fmt = MXR_FORMAT_ARGB4444;
5737a57ca7cSTobias Jakobi 		break;
574d8408326SSeung-Woo Kim 
5757a57ca7cSTobias Jakobi 	case DRM_FORMAT_XRGB1555:
57626a7af3eSTobias Jakobi 	case DRM_FORMAT_ARGB1555:
5777a57ca7cSTobias Jakobi 		fmt = MXR_FORMAT_ARGB1555;
578d8408326SSeung-Woo Kim 		break;
5797a57ca7cSTobias Jakobi 
5807a57ca7cSTobias Jakobi 	case DRM_FORMAT_RGB565:
5817a57ca7cSTobias Jakobi 		fmt = MXR_FORMAT_RGB565;
582d8408326SSeung-Woo Kim 		break;
5837a57ca7cSTobias Jakobi 
5847a57ca7cSTobias Jakobi 	case DRM_FORMAT_XRGB8888:
5857a57ca7cSTobias Jakobi 	case DRM_FORMAT_ARGB8888:
5861e60d62fSTobias Jakobi 	default:
5877a57ca7cSTobias Jakobi 		fmt = MXR_FORMAT_ARGB8888;
5887a57ca7cSTobias Jakobi 		break;
589d8408326SSeung-Woo Kim 	}
590d8408326SSeung-Woo Kim 
591e463b069SMarek Szyprowski 	/* ratio is already checked by common plane code */
592e463b069SMarek Szyprowski 	x_ratio = state->h_ratio == (1 << 15);
593e463b069SMarek Szyprowski 	y_ratio = state->v_ratio == (1 << 15);
594d8408326SSeung-Woo Kim 
5950114f404SMarek Szyprowski 	dst_x_offset = state->crtc.x;
5960114f404SMarek Szyprowski 	dst_y_offset = state->crtc.y;
597d8408326SSeung-Woo Kim 
5985dff6905STobias Jakobi 	/* translate dma address base s.t. the source image offset is zero */
5990488f50eSMarek Szyprowski 	dma_addr = exynos_drm_fb_dma_addr(fb, 0)
600272725c7SVille Syrjälä 		+ (state->src.x * fb->format->cpp[0])
6010114f404SMarek Szyprowski 		+ (state->src.y * fb->pitches[0]);
602d8408326SSeung-Woo Kim 
603524c59f1SAndrzej Hajda 	spin_lock_irqsave(&ctx->reg_slock, flags);
604d8408326SSeung-Woo Kim 
605d8408326SSeung-Woo Kim 	/* setup format */
606524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_GRAPHIC_CFG(win),
607d8408326SSeung-Woo Kim 		MXR_GRP_CFG_FORMAT_VAL(fmt), MXR_GRP_CFG_FORMAT_MASK);
608d8408326SSeung-Woo Kim 
609d8408326SSeung-Woo Kim 	/* setup geometry */
610524c59f1SAndrzej Hajda 	mixer_reg_write(ctx, MXR_GRAPHIC_SPAN(win),
611272725c7SVille Syrjälä 			fb->pitches[0] / fb->format->cpp[0]);
612d8408326SSeung-Woo Kim 
6130114f404SMarek Szyprowski 	val  = MXR_GRP_WH_WIDTH(state->src.w);
6140114f404SMarek Szyprowski 	val |= MXR_GRP_WH_HEIGHT(state->src.h);
615d8408326SSeung-Woo Kim 	val |= MXR_GRP_WH_H_SCALE(x_ratio);
616d8408326SSeung-Woo Kim 	val |= MXR_GRP_WH_V_SCALE(y_ratio);
617524c59f1SAndrzej Hajda 	mixer_reg_write(ctx, MXR_GRAPHIC_WH(win), val);
618d8408326SSeung-Woo Kim 
619d8408326SSeung-Woo Kim 	/* setup offsets in display image */
620d8408326SSeung-Woo Kim 	val  = MXR_GRP_DXY_DX(dst_x_offset);
621d8408326SSeung-Woo Kim 	val |= MXR_GRP_DXY_DY(dst_y_offset);
622524c59f1SAndrzej Hajda 	mixer_reg_write(ctx, MXR_GRAPHIC_DXY(win), val);
623d8408326SSeung-Woo Kim 
624d8408326SSeung-Woo Kim 	/* set buffer address to mixer */
625524c59f1SAndrzej Hajda 	mixer_reg_write(ctx, MXR_GRAPHIC_BASE(win), dma_addr);
626d8408326SSeung-Woo Kim 
627e47726a1SMarek Szyprowski 	mixer_cfg_layer(ctx, win, priority, true);
628438b74a5SVille Syrjälä 	mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->format->format));
629aaf8b49eSRahul Sharma 
630aaf8b49eSRahul Sharma 	/* layer update mandatory for mixer 16.0.33.0 */
631def5e095SRahul Sharma 	if (ctx->mxr_ver == MXR_VER_16_0_33_0 ||
632def5e095SRahul Sharma 		ctx->mxr_ver == MXR_VER_128_0_0_184)
633aaf8b49eSRahul Sharma 		mixer_layer_update(ctx);
634aaf8b49eSRahul Sharma 
635524c59f1SAndrzej Hajda 	spin_unlock_irqrestore(&ctx->reg_slock, flags);
636c0734fbaSTobias Jakobi 
637c0734fbaSTobias Jakobi 	mixer_regs_dump(ctx);
638d8408326SSeung-Woo Kim }
639d8408326SSeung-Woo Kim 
640d8408326SSeung-Woo Kim static void vp_win_reset(struct mixer_context *ctx)
641d8408326SSeung-Woo Kim {
642a696394cSTobias Jakobi 	unsigned int tries = 100;
643d8408326SSeung-Woo Kim 
644524c59f1SAndrzej Hajda 	vp_reg_write(ctx, VP_SRESET, VP_SRESET_PROCESSING);
6458646dcb8SDan Carpenter 	while (--tries) {
646d8408326SSeung-Woo Kim 		/* waiting until VP_SRESET_PROCESSING is 0 */
647524c59f1SAndrzej Hajda 		if (~vp_reg_read(ctx, VP_SRESET) & VP_SRESET_PROCESSING)
648d8408326SSeung-Woo Kim 			break;
64902b3de43STomasz Stanislawski 		mdelay(10);
650d8408326SSeung-Woo Kim 	}
651d8408326SSeung-Woo Kim 	WARN(tries == 0, "failed to reset Video Processor\n");
652d8408326SSeung-Woo Kim }
653d8408326SSeung-Woo Kim 
654cf8fc4f1SJoonyoung Shim static void mixer_win_reset(struct mixer_context *ctx)
655cf8fc4f1SJoonyoung Shim {
656cf8fc4f1SJoonyoung Shim 	unsigned long flags;
657cf8fc4f1SJoonyoung Shim 
658524c59f1SAndrzej Hajda 	spin_lock_irqsave(&ctx->reg_slock, flags);
659cf8fc4f1SJoonyoung Shim 
660524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_CFG, MXR_CFG_DST_HDMI, MXR_CFG_DST_MASK);
661cf8fc4f1SJoonyoung Shim 
662cf8fc4f1SJoonyoung Shim 	/* set output in RGB888 mode */
663524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_CFG, MXR_CFG_OUT_RGB888, MXR_CFG_OUT_MASK);
664cf8fc4f1SJoonyoung Shim 
665cf8fc4f1SJoonyoung Shim 	/* 16 beat burst in DMA */
666524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_STATUS, MXR_STATUS_16_BURST,
667cf8fc4f1SJoonyoung Shim 		MXR_STATUS_BURST_MASK);
668cf8fc4f1SJoonyoung Shim 
669a2cb911eSMarek Szyprowski 	/* reset default layer priority */
670524c59f1SAndrzej Hajda 	mixer_reg_write(ctx, MXR_LAYER_CFG, 0);
671cf8fc4f1SJoonyoung Shim 
6722a6e4cd5STobias Jakobi 	/* set all background colors to RGB (0,0,0) */
673524c59f1SAndrzej Hajda 	mixer_reg_write(ctx, MXR_BG_COLOR0, MXR_YCBCR_VAL(0, 128, 128));
674524c59f1SAndrzej Hajda 	mixer_reg_write(ctx, MXR_BG_COLOR1, MXR_YCBCR_VAL(0, 128, 128));
675524c59f1SAndrzej Hajda 	mixer_reg_write(ctx, MXR_BG_COLOR2, MXR_YCBCR_VAL(0, 128, 128));
676cf8fc4f1SJoonyoung Shim 
677adeb6f44STobias Jakobi 	if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) {
678cf8fc4f1SJoonyoung Shim 		/* configuration of Video Processor Registers */
679cf8fc4f1SJoonyoung Shim 		vp_win_reset(ctx);
680524c59f1SAndrzej Hajda 		vp_default_filter(ctx);
6811b8e5747SRahul Sharma 	}
682cf8fc4f1SJoonyoung Shim 
683cf8fc4f1SJoonyoung Shim 	/* disable all layers */
684524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_CFG, 0, MXR_CFG_GRP0_ENABLE);
685524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_CFG, 0, MXR_CFG_GRP1_ENABLE);
686adeb6f44STobias Jakobi 	if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags))
687524c59f1SAndrzej Hajda 		mixer_reg_writemask(ctx, MXR_CFG, 0, MXR_CFG_VP_ENABLE);
688cf8fc4f1SJoonyoung Shim 
6895dff6905STobias Jakobi 	/* set all source image offsets to zero */
690524c59f1SAndrzej Hajda 	mixer_reg_write(ctx, MXR_GRAPHIC_SXY(0), 0);
691524c59f1SAndrzej Hajda 	mixer_reg_write(ctx, MXR_GRAPHIC_SXY(1), 0);
6925dff6905STobias Jakobi 
693524c59f1SAndrzej Hajda 	spin_unlock_irqrestore(&ctx->reg_slock, flags);
694cf8fc4f1SJoonyoung Shim }
695cf8fc4f1SJoonyoung Shim 
6964551789fSSean Paul static irqreturn_t mixer_irq_handler(int irq, void *arg)
6974551789fSSean Paul {
6984551789fSSean Paul 	struct mixer_context *ctx = arg;
6994551789fSSean Paul 	u32 val, base, shadow;
7004551789fSSean Paul 
701524c59f1SAndrzej Hajda 	spin_lock(&ctx->reg_slock);
7024551789fSSean Paul 
7034551789fSSean Paul 	/* read interrupt status for handling and clearing flags for VSYNC */
704524c59f1SAndrzej Hajda 	val = mixer_reg_read(ctx, MXR_INT_STATUS);
7054551789fSSean Paul 
7064551789fSSean Paul 	/* handling VSYNC */
7074551789fSSean Paul 	if (val & MXR_INT_STATUS_VSYNC) {
70881a464dfSAndrzej Hajda 		/* vsync interrupt use different bit for read and clear */
70981a464dfSAndrzej Hajda 		val |= MXR_INT_CLEAR_VSYNC;
71081a464dfSAndrzej Hajda 		val &= ~MXR_INT_STATUS_VSYNC;
71181a464dfSAndrzej Hajda 
7124551789fSSean Paul 		/* interlace scan need to check shadow register */
713adeb6f44STobias Jakobi 		if (test_bit(MXR_BIT_INTERLACE, &ctx->flags)) {
714524c59f1SAndrzej Hajda 			base = mixer_reg_read(ctx, MXR_GRAPHIC_BASE(0));
715524c59f1SAndrzej Hajda 			shadow = mixer_reg_read(ctx, MXR_GRAPHIC_BASE_S(0));
7164551789fSSean Paul 			if (base != shadow)
7174551789fSSean Paul 				goto out;
7184551789fSSean Paul 
719524c59f1SAndrzej Hajda 			base = mixer_reg_read(ctx, MXR_GRAPHIC_BASE(1));
720524c59f1SAndrzej Hajda 			shadow = mixer_reg_read(ctx, MXR_GRAPHIC_BASE_S(1));
7214551789fSSean Paul 			if (base != shadow)
7224551789fSSean Paul 				goto out;
7234551789fSSean Paul 		}
7244551789fSSean Paul 
725eafd540aSGustavo Padovan 		drm_crtc_handle_vblank(&ctx->crtc->base);
7264551789fSSean Paul 	}
7274551789fSSean Paul 
7284551789fSSean Paul out:
7294551789fSSean Paul 	/* clear interrupts */
730524c59f1SAndrzej Hajda 	mixer_reg_write(ctx, MXR_INT_STATUS, val);
7314551789fSSean Paul 
732524c59f1SAndrzej Hajda 	spin_unlock(&ctx->reg_slock);
7334551789fSSean Paul 
7344551789fSSean Paul 	return IRQ_HANDLED;
7354551789fSSean Paul }
7364551789fSSean Paul 
7374551789fSSean Paul static int mixer_resources_init(struct mixer_context *mixer_ctx)
7384551789fSSean Paul {
7394551789fSSean Paul 	struct device *dev = &mixer_ctx->pdev->dev;
7404551789fSSean Paul 	struct resource *res;
7414551789fSSean Paul 	int ret;
7424551789fSSean Paul 
743524c59f1SAndrzej Hajda 	spin_lock_init(&mixer_ctx->reg_slock);
7444551789fSSean Paul 
745524c59f1SAndrzej Hajda 	mixer_ctx->mixer = devm_clk_get(dev, "mixer");
746524c59f1SAndrzej Hajda 	if (IS_ERR(mixer_ctx->mixer)) {
7474551789fSSean Paul 		dev_err(dev, "failed to get clock 'mixer'\n");
7484551789fSSean Paul 		return -ENODEV;
7494551789fSSean Paul 	}
7504551789fSSean Paul 
751524c59f1SAndrzej Hajda 	mixer_ctx->hdmi = devm_clk_get(dev, "hdmi");
752524c59f1SAndrzej Hajda 	if (IS_ERR(mixer_ctx->hdmi)) {
75304427ec5SMarek Szyprowski 		dev_err(dev, "failed to get clock 'hdmi'\n");
754524c59f1SAndrzej Hajda 		return PTR_ERR(mixer_ctx->hdmi);
75504427ec5SMarek Szyprowski 	}
75604427ec5SMarek Szyprowski 
757524c59f1SAndrzej Hajda 	mixer_ctx->sclk_hdmi = devm_clk_get(dev, "sclk_hdmi");
758524c59f1SAndrzej Hajda 	if (IS_ERR(mixer_ctx->sclk_hdmi)) {
7594551789fSSean Paul 		dev_err(dev, "failed to get clock 'sclk_hdmi'\n");
7604551789fSSean Paul 		return -ENODEV;
7614551789fSSean Paul 	}
7624551789fSSean Paul 	res = platform_get_resource(mixer_ctx->pdev, IORESOURCE_MEM, 0);
7634551789fSSean Paul 	if (res == NULL) {
7644551789fSSean Paul 		dev_err(dev, "get memory resource failed.\n");
7654551789fSSean Paul 		return -ENXIO;
7664551789fSSean Paul 	}
7674551789fSSean Paul 
768524c59f1SAndrzej Hajda 	mixer_ctx->mixer_regs = devm_ioremap(dev, res->start,
7694551789fSSean Paul 							resource_size(res));
770524c59f1SAndrzej Hajda 	if (mixer_ctx->mixer_regs == NULL) {
7714551789fSSean Paul 		dev_err(dev, "register mapping failed.\n");
7724551789fSSean Paul 		return -ENXIO;
7734551789fSSean Paul 	}
7744551789fSSean Paul 
7754551789fSSean Paul 	res = platform_get_resource(mixer_ctx->pdev, IORESOURCE_IRQ, 0);
7764551789fSSean Paul 	if (res == NULL) {
7774551789fSSean Paul 		dev_err(dev, "get interrupt resource failed.\n");
7784551789fSSean Paul 		return -ENXIO;
7794551789fSSean Paul 	}
7804551789fSSean Paul 
7814551789fSSean Paul 	ret = devm_request_irq(dev, res->start, mixer_irq_handler,
7824551789fSSean Paul 						0, "drm_mixer", mixer_ctx);
7834551789fSSean Paul 	if (ret) {
7844551789fSSean Paul 		dev_err(dev, "request interrupt failed.\n");
7854551789fSSean Paul 		return ret;
7864551789fSSean Paul 	}
787524c59f1SAndrzej Hajda 	mixer_ctx->irq = res->start;
7884551789fSSean Paul 
7894551789fSSean Paul 	return 0;
7904551789fSSean Paul }
7914551789fSSean Paul 
7924551789fSSean Paul static int vp_resources_init(struct mixer_context *mixer_ctx)
7934551789fSSean Paul {
7944551789fSSean Paul 	struct device *dev = &mixer_ctx->pdev->dev;
7954551789fSSean Paul 	struct resource *res;
7964551789fSSean Paul 
797524c59f1SAndrzej Hajda 	mixer_ctx->vp = devm_clk_get(dev, "vp");
798524c59f1SAndrzej Hajda 	if (IS_ERR(mixer_ctx->vp)) {
7994551789fSSean Paul 		dev_err(dev, "failed to get clock 'vp'\n");
8004551789fSSean Paul 		return -ENODEV;
8014551789fSSean Paul 	}
802ff830c96SMarek Szyprowski 
803adeb6f44STobias Jakobi 	if (test_bit(MXR_BIT_HAS_SCLK, &mixer_ctx->flags)) {
804524c59f1SAndrzej Hajda 		mixer_ctx->sclk_mixer = devm_clk_get(dev, "sclk_mixer");
805524c59f1SAndrzej Hajda 		if (IS_ERR(mixer_ctx->sclk_mixer)) {
8064551789fSSean Paul 			dev_err(dev, "failed to get clock 'sclk_mixer'\n");
8074551789fSSean Paul 			return -ENODEV;
8084551789fSSean Paul 		}
809524c59f1SAndrzej Hajda 		mixer_ctx->mout_mixer = devm_clk_get(dev, "mout_mixer");
810524c59f1SAndrzej Hajda 		if (IS_ERR(mixer_ctx->mout_mixer)) {
811ff830c96SMarek Szyprowski 			dev_err(dev, "failed to get clock 'mout_mixer'\n");
8124551789fSSean Paul 			return -ENODEV;
8134551789fSSean Paul 		}
8144551789fSSean Paul 
815524c59f1SAndrzej Hajda 		if (mixer_ctx->sclk_hdmi && mixer_ctx->mout_mixer)
816524c59f1SAndrzej Hajda 			clk_set_parent(mixer_ctx->mout_mixer,
817524c59f1SAndrzej Hajda 				       mixer_ctx->sclk_hdmi);
818ff830c96SMarek Szyprowski 	}
8194551789fSSean Paul 
8204551789fSSean Paul 	res = platform_get_resource(mixer_ctx->pdev, IORESOURCE_MEM, 1);
8214551789fSSean Paul 	if (res == NULL) {
8224551789fSSean Paul 		dev_err(dev, "get memory resource failed.\n");
8234551789fSSean Paul 		return -ENXIO;
8244551789fSSean Paul 	}
8254551789fSSean Paul 
826524c59f1SAndrzej Hajda 	mixer_ctx->vp_regs = devm_ioremap(dev, res->start,
8274551789fSSean Paul 							resource_size(res));
828524c59f1SAndrzej Hajda 	if (mixer_ctx->vp_regs == NULL) {
8294551789fSSean Paul 		dev_err(dev, "register mapping failed.\n");
8304551789fSSean Paul 		return -ENXIO;
8314551789fSSean Paul 	}
8324551789fSSean Paul 
8334551789fSSean Paul 	return 0;
8344551789fSSean Paul }
8354551789fSSean Paul 
83693bca243SGustavo Padovan static int mixer_initialize(struct mixer_context *mixer_ctx,
837f37cd5e8SInki Dae 			struct drm_device *drm_dev)
8384551789fSSean Paul {
8394551789fSSean Paul 	int ret;
840f37cd5e8SInki Dae 	struct exynos_drm_private *priv;
841f37cd5e8SInki Dae 	priv = drm_dev->dev_private;
8424551789fSSean Paul 
843eb88e422SGustavo Padovan 	mixer_ctx->drm_dev = drm_dev;
8444551789fSSean Paul 
8454551789fSSean Paul 	/* acquire resources: regs, irqs, clocks */
8464551789fSSean Paul 	ret = mixer_resources_init(mixer_ctx);
8474551789fSSean Paul 	if (ret) {
8484551789fSSean Paul 		DRM_ERROR("mixer_resources_init failed ret=%d\n", ret);
8494551789fSSean Paul 		return ret;
8504551789fSSean Paul 	}
8514551789fSSean Paul 
852adeb6f44STobias Jakobi 	if (test_bit(MXR_BIT_VP_ENABLED, &mixer_ctx->flags)) {
8534551789fSSean Paul 		/* acquire vp resources: regs, irqs, clocks */
8544551789fSSean Paul 		ret = vp_resources_init(mixer_ctx);
8554551789fSSean Paul 		if (ret) {
8564551789fSSean Paul 			DRM_ERROR("vp_resources_init failed ret=%d\n", ret);
8574551789fSSean Paul 			return ret;
8584551789fSSean Paul 		}
8594551789fSSean Paul 	}
8604551789fSSean Paul 
861f44d3d2fSAndrzej Hajda 	return drm_iommu_attach_device(drm_dev, mixer_ctx->dev);
8621055b39fSInki Dae }
8631055b39fSInki Dae 
86493bca243SGustavo Padovan static void mixer_ctx_remove(struct mixer_context *mixer_ctx)
865d8408326SSeung-Woo Kim {
866f041b257SSean Paul 	drm_iommu_detach_device(mixer_ctx->drm_dev, mixer_ctx->dev);
867f041b257SSean Paul }
868f041b257SSean Paul 
86993bca243SGustavo Padovan static int mixer_enable_vblank(struct exynos_drm_crtc *crtc)
870f041b257SSean Paul {
87193bca243SGustavo Padovan 	struct mixer_context *mixer_ctx = crtc->ctx;
872d8408326SSeung-Woo Kim 
8730df5e4acSAndrzej Hajda 	__set_bit(MXR_BIT_VSYNC, &mixer_ctx->flags);
8740df5e4acSAndrzej Hajda 	if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
875f041b257SSean Paul 		return 0;
876d8408326SSeung-Woo Kim 
877d8408326SSeung-Woo Kim 	/* enable vsync interrupt */
878524c59f1SAndrzej Hajda 	mixer_reg_writemask(mixer_ctx, MXR_INT_STATUS, ~0, MXR_INT_CLEAR_VSYNC);
879524c59f1SAndrzej Hajda 	mixer_reg_writemask(mixer_ctx, MXR_INT_EN, ~0, MXR_INT_EN_VSYNC);
880d8408326SSeung-Woo Kim 
881d8408326SSeung-Woo Kim 	return 0;
882d8408326SSeung-Woo Kim }
883d8408326SSeung-Woo Kim 
88493bca243SGustavo Padovan static void mixer_disable_vblank(struct exynos_drm_crtc *crtc)
885d8408326SSeung-Woo Kim {
88693bca243SGustavo Padovan 	struct mixer_context *mixer_ctx = crtc->ctx;
887d8408326SSeung-Woo Kim 
8880df5e4acSAndrzej Hajda 	__clear_bit(MXR_BIT_VSYNC, &mixer_ctx->flags);
8890df5e4acSAndrzej Hajda 
8900df5e4acSAndrzej Hajda 	if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
891947710c6SAndrzej Hajda 		return;
892947710c6SAndrzej Hajda 
893d8408326SSeung-Woo Kim 	/* disable vsync interrupt */
894524c59f1SAndrzej Hajda 	mixer_reg_writemask(mixer_ctx, MXR_INT_STATUS, ~0, MXR_INT_CLEAR_VSYNC);
895524c59f1SAndrzej Hajda 	mixer_reg_writemask(mixer_ctx, MXR_INT_EN, 0, MXR_INT_EN_VSYNC);
896d8408326SSeung-Woo Kim }
897d8408326SSeung-Woo Kim 
8983dbaab16SMarek Szyprowski static void mixer_atomic_begin(struct exynos_drm_crtc *crtc)
8993dbaab16SMarek Szyprowski {
9003dbaab16SMarek Szyprowski 	struct mixer_context *mixer_ctx = crtc->ctx;
9013dbaab16SMarek Szyprowski 
9023dbaab16SMarek Szyprowski 	if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
9033dbaab16SMarek Szyprowski 		return;
9043dbaab16SMarek Szyprowski 
9053dbaab16SMarek Szyprowski 	mixer_vsync_set_update(mixer_ctx, false);
9063dbaab16SMarek Szyprowski }
9073dbaab16SMarek Szyprowski 
9081e1d1393SGustavo Padovan static void mixer_update_plane(struct exynos_drm_crtc *crtc,
9091e1d1393SGustavo Padovan 			       struct exynos_drm_plane *plane)
910d8408326SSeung-Woo Kim {
91193bca243SGustavo Padovan 	struct mixer_context *mixer_ctx = crtc->ctx;
912d8408326SSeung-Woo Kim 
91340bdfb0aSMarek Szyprowski 	DRM_DEBUG_KMS("win: %d\n", plane->index);
914d8408326SSeung-Woo Kim 
915a44652e8SAndrzej Hajda 	if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
916dda9012bSShirish S 		return;
917dda9012bSShirish S 
9185e68fef2SMarek Szyprowski 	if (plane->index == VP_DEFAULT_WIN)
9192eeb2e5eSGustavo Padovan 		vp_video_buffer(mixer_ctx, plane);
920d8408326SSeung-Woo Kim 	else
9212eeb2e5eSGustavo Padovan 		mixer_graph_buffer(mixer_ctx, plane);
922d8408326SSeung-Woo Kim }
923d8408326SSeung-Woo Kim 
9241e1d1393SGustavo Padovan static void mixer_disable_plane(struct exynos_drm_crtc *crtc,
9251e1d1393SGustavo Padovan 				struct exynos_drm_plane *plane)
926d8408326SSeung-Woo Kim {
92793bca243SGustavo Padovan 	struct mixer_context *mixer_ctx = crtc->ctx;
928d8408326SSeung-Woo Kim 	unsigned long flags;
929d8408326SSeung-Woo Kim 
93040bdfb0aSMarek Szyprowski 	DRM_DEBUG_KMS("win: %d\n", plane->index);
931d8408326SSeung-Woo Kim 
932a44652e8SAndrzej Hajda 	if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
933db43fd16SPrathyush K 		return;
934db43fd16SPrathyush K 
935524c59f1SAndrzej Hajda 	spin_lock_irqsave(&mixer_ctx->reg_slock, flags);
936a2cb911eSMarek Szyprowski 	mixer_cfg_layer(mixer_ctx, plane->index, 0, false);
937524c59f1SAndrzej Hajda 	spin_unlock_irqrestore(&mixer_ctx->reg_slock, flags);
9383dbaab16SMarek Szyprowski }
9393dbaab16SMarek Szyprowski 
9403dbaab16SMarek Szyprowski static void mixer_atomic_flush(struct exynos_drm_crtc *crtc)
9413dbaab16SMarek Szyprowski {
9423dbaab16SMarek Szyprowski 	struct mixer_context *mixer_ctx = crtc->ctx;
9433dbaab16SMarek Szyprowski 
9443dbaab16SMarek Szyprowski 	if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
9453dbaab16SMarek Szyprowski 		return;
946d8408326SSeung-Woo Kim 
947d8408326SSeung-Woo Kim 	mixer_vsync_set_update(mixer_ctx, true);
948a392276dSAndrzej Hajda 	exynos_crtc_handle_event(crtc);
949d8408326SSeung-Woo Kim }
950d8408326SSeung-Woo Kim 
9513cecda03SGustavo Padovan static void mixer_enable(struct exynos_drm_crtc *crtc)
952db43fd16SPrathyush K {
9533cecda03SGustavo Padovan 	struct mixer_context *ctx = crtc->ctx;
954db43fd16SPrathyush K 
955a44652e8SAndrzej Hajda 	if (test_bit(MXR_BIT_POWERED, &ctx->flags))
956db43fd16SPrathyush K 		return;
957db43fd16SPrathyush K 
958af65c804SSean Paul 	pm_runtime_get_sync(ctx->dev);
959af65c804SSean Paul 
960a121d179SAndrzej Hajda 	exynos_drm_pipe_clk_enable(crtc, true);
961a121d179SAndrzej Hajda 
9623dbaab16SMarek Szyprowski 	mixer_vsync_set_update(ctx, false);
9633dbaab16SMarek Szyprowski 
964524c59f1SAndrzej Hajda 	mixer_reg_writemask(ctx, MXR_STATUS, ~0, MXR_STATUS_SOFT_RESET);
965d74ed937SRahul Sharma 
9660df5e4acSAndrzej Hajda 	if (test_bit(MXR_BIT_VSYNC, &ctx->flags)) {
967524c59f1SAndrzej Hajda 		mixer_reg_writemask(ctx, MXR_INT_STATUS, ~0,
968524c59f1SAndrzej Hajda 					MXR_INT_CLEAR_VSYNC);
969524c59f1SAndrzej Hajda 		mixer_reg_writemask(ctx, MXR_INT_EN, ~0, MXR_INT_EN_VSYNC);
9700df5e4acSAndrzej Hajda 	}
971db43fd16SPrathyush K 	mixer_win_reset(ctx);
972ccf034a9SGustavo Padovan 
97371469944SAndrzej Hajda 	mixer_commit(ctx);
97471469944SAndrzej Hajda 
9753dbaab16SMarek Szyprowski 	mixer_vsync_set_update(ctx, true);
9763dbaab16SMarek Szyprowski 
977ccf034a9SGustavo Padovan 	set_bit(MXR_BIT_POWERED, &ctx->flags);
978db43fd16SPrathyush K }
979db43fd16SPrathyush K 
9803cecda03SGustavo Padovan static void mixer_disable(struct exynos_drm_crtc *crtc)
981db43fd16SPrathyush K {
9823cecda03SGustavo Padovan 	struct mixer_context *ctx = crtc->ctx;
983c329f667SJoonyoung Shim 	int i;
984db43fd16SPrathyush K 
985a44652e8SAndrzej Hajda 	if (!test_bit(MXR_BIT_POWERED, &ctx->flags))
986b4bfa3c7SRahul Sharma 		return;
987db43fd16SPrathyush K 
988381be025SRahul Sharma 	mixer_stop(ctx);
989c0734fbaSTobias Jakobi 	mixer_regs_dump(ctx);
990c329f667SJoonyoung Shim 
991c329f667SJoonyoung Shim 	for (i = 0; i < MIXER_WIN_NR; i++)
9921e1d1393SGustavo Padovan 		mixer_disable_plane(crtc, &ctx->planes[i]);
993db43fd16SPrathyush K 
994a121d179SAndrzej Hajda 	exynos_drm_pipe_clk_enable(crtc, false);
995a121d179SAndrzej Hajda 
996ccf034a9SGustavo Padovan 	pm_runtime_put(ctx->dev);
997ccf034a9SGustavo Padovan 
998a44652e8SAndrzej Hajda 	clear_bit(MXR_BIT_POWERED, &ctx->flags);
999db43fd16SPrathyush K }
1000db43fd16SPrathyush K 
10016ace38a5SAndrzej Hajda static int mixer_mode_valid(struct exynos_drm_crtc *crtc,
10026ace38a5SAndrzej Hajda 		const struct drm_display_mode *mode)
1003f041b257SSean Paul {
10046ace38a5SAndrzej Hajda 	struct mixer_context *ctx = crtc->ctx;
10056ace38a5SAndrzej Hajda 	u32 w = mode->hdisplay, h = mode->vdisplay;
1006f041b257SSean Paul 
10076ace38a5SAndrzej Hajda 	DRM_DEBUG_KMS("xres=%d, yres=%d, refresh=%d, intl=%d\n", w, h,
10086ace38a5SAndrzej Hajda 		mode->vrefresh, !!(mode->flags & DRM_MODE_FLAG_INTERLACE));
1009f041b257SSean Paul 
10106ace38a5SAndrzej Hajda 	if (ctx->mxr_ver == MXR_VER_128_0_0_184)
10116ace38a5SAndrzej Hajda 		return MODE_OK;
1012f041b257SSean Paul 
1013f041b257SSean Paul 	if ((w >= 464 && w <= 720 && h >= 261 && h <= 576) ||
1014f041b257SSean Paul 	    (w >= 1024 && w <= 1280 && h >= 576 && h <= 720) ||
1015f041b257SSean Paul 	    (w >= 1664 && w <= 1920 && h >= 936 && h <= 1080))
10166ace38a5SAndrzej Hajda 		return MODE_OK;
1017f041b257SSean Paul 
10186ace38a5SAndrzej Hajda 	return MODE_BAD;
1019f041b257SSean Paul }
1020f041b257SSean Paul 
1021*acc8bf04SAndrzej Hajda static bool mixer_mode_fixup(struct exynos_drm_crtc *crtc,
1022*acc8bf04SAndrzej Hajda 		   const struct drm_display_mode *mode,
1023*acc8bf04SAndrzej Hajda 		   struct drm_display_mode *adjusted_mode)
1024*acc8bf04SAndrzej Hajda {
1025*acc8bf04SAndrzej Hajda 	struct mixer_context *ctx = crtc->ctx;
1026*acc8bf04SAndrzej Hajda 	int width = mode->hdisplay, height = mode->vdisplay, i;
1027*acc8bf04SAndrzej Hajda 
1028*acc8bf04SAndrzej Hajda 	struct {
1029*acc8bf04SAndrzej Hajda 		int hdisplay, vdisplay, htotal, vtotal, scan_val;
1030*acc8bf04SAndrzej Hajda 	} static const modes[] = {
1031*acc8bf04SAndrzej Hajda 		{ 720, 480, 858, 525, MXR_CFG_SCAN_NTSC | MXR_CFG_SCAN_SD },
1032*acc8bf04SAndrzej Hajda 		{ 720, 576, 864, 625, MXR_CFG_SCAN_PAL | MXR_CFG_SCAN_SD },
1033*acc8bf04SAndrzej Hajda 		{ 1280, 720, 1650, 750, MXR_CFG_SCAN_HD_720 | MXR_CFG_SCAN_HD },
1034*acc8bf04SAndrzej Hajda 		{ 1920, 1080, 2200, 1125, MXR_CFG_SCAN_HD_1080 |
1035*acc8bf04SAndrzej Hajda 						MXR_CFG_SCAN_HD }
1036*acc8bf04SAndrzej Hajda 	};
1037*acc8bf04SAndrzej Hajda 
1038*acc8bf04SAndrzej Hajda 	if (mode->flags & DRM_MODE_FLAG_INTERLACE)
1039*acc8bf04SAndrzej Hajda 		__set_bit(MXR_BIT_INTERLACE, &ctx->flags);
1040*acc8bf04SAndrzej Hajda 	else
1041*acc8bf04SAndrzej Hajda 		__clear_bit(MXR_BIT_INTERLACE, &ctx->flags);
1042*acc8bf04SAndrzej Hajda 
1043*acc8bf04SAndrzej Hajda 	if (ctx->mxr_ver == MXR_VER_128_0_0_184)
1044*acc8bf04SAndrzej Hajda 		return true;
1045*acc8bf04SAndrzej Hajda 
1046*acc8bf04SAndrzej Hajda 	for (i = 0; i < ARRAY_SIZE(modes); ++i)
1047*acc8bf04SAndrzej Hajda 		if (width <= modes[i].hdisplay && height <= modes[i].vdisplay) {
1048*acc8bf04SAndrzej Hajda 			ctx->scan_value = modes[i].scan_val;
1049*acc8bf04SAndrzej Hajda 			if (width < modes[i].hdisplay ||
1050*acc8bf04SAndrzej Hajda 			    height < modes[i].vdisplay) {
1051*acc8bf04SAndrzej Hajda 				adjusted_mode->hdisplay = modes[i].hdisplay;
1052*acc8bf04SAndrzej Hajda 				adjusted_mode->hsync_start = modes[i].hdisplay;
1053*acc8bf04SAndrzej Hajda 				adjusted_mode->hsync_end = modes[i].htotal;
1054*acc8bf04SAndrzej Hajda 				adjusted_mode->htotal = modes[i].htotal;
1055*acc8bf04SAndrzej Hajda 				adjusted_mode->vdisplay = modes[i].vdisplay;
1056*acc8bf04SAndrzej Hajda 				adjusted_mode->vsync_start = modes[i].vdisplay;
1057*acc8bf04SAndrzej Hajda 				adjusted_mode->vsync_end = modes[i].vtotal;
1058*acc8bf04SAndrzej Hajda 				adjusted_mode->vtotal = modes[i].vtotal;
1059*acc8bf04SAndrzej Hajda 			}
1060*acc8bf04SAndrzej Hajda 
1061*acc8bf04SAndrzej Hajda 			return true;
1062*acc8bf04SAndrzej Hajda 		}
1063*acc8bf04SAndrzej Hajda 
1064*acc8bf04SAndrzej Hajda 	return false;
1065*acc8bf04SAndrzej Hajda }
1066*acc8bf04SAndrzej Hajda 
1067f3aaf762SKrzysztof Kozlowski static const struct exynos_drm_crtc_ops mixer_crtc_ops = {
10683cecda03SGustavo Padovan 	.enable			= mixer_enable,
10693cecda03SGustavo Padovan 	.disable		= mixer_disable,
1070d8408326SSeung-Woo Kim 	.enable_vblank		= mixer_enable_vblank,
1071d8408326SSeung-Woo Kim 	.disable_vblank		= mixer_disable_vblank,
10723dbaab16SMarek Szyprowski 	.atomic_begin		= mixer_atomic_begin,
10739cc7610aSGustavo Padovan 	.update_plane		= mixer_update_plane,
10749cc7610aSGustavo Padovan 	.disable_plane		= mixer_disable_plane,
10753dbaab16SMarek Szyprowski 	.atomic_flush		= mixer_atomic_flush,
10766ace38a5SAndrzej Hajda 	.mode_valid		= mixer_mode_valid,
1077*acc8bf04SAndrzej Hajda 	.mode_fixup		= mixer_mode_fixup,
1078f041b257SSean Paul };
10790ea6822fSRahul Sharma 
10805e6cc1c5SArvind Yadav static const struct mixer_drv_data exynos5420_mxr_drv_data = {
1081def5e095SRahul Sharma 	.version = MXR_VER_128_0_0_184,
1082def5e095SRahul Sharma 	.is_vp_enabled = 0,
1083def5e095SRahul Sharma };
1084def5e095SRahul Sharma 
10855e6cc1c5SArvind Yadav static const struct mixer_drv_data exynos5250_mxr_drv_data = {
1086aaf8b49eSRahul Sharma 	.version = MXR_VER_16_0_33_0,
1087aaf8b49eSRahul Sharma 	.is_vp_enabled = 0,
1088aaf8b49eSRahul Sharma };
1089aaf8b49eSRahul Sharma 
10905e6cc1c5SArvind Yadav static const struct mixer_drv_data exynos4212_mxr_drv_data = {
1091ff830c96SMarek Szyprowski 	.version = MXR_VER_0_0_0_16,
1092ff830c96SMarek Szyprowski 	.is_vp_enabled = 1,
1093ff830c96SMarek Szyprowski };
1094ff830c96SMarek Szyprowski 
10955e6cc1c5SArvind Yadav static const struct mixer_drv_data exynos4210_mxr_drv_data = {
10961e123441SRahul Sharma 	.version = MXR_VER_0_0_0_16,
10971b8e5747SRahul Sharma 	.is_vp_enabled = 1,
1098ff830c96SMarek Szyprowski 	.has_sclk = 1,
10991e123441SRahul Sharma };
11001e123441SRahul Sharma 
11015e6cc1c5SArvind Yadav static const struct of_device_id mixer_match_types[] = {
1102aaf8b49eSRahul Sharma 	{
1103ff830c96SMarek Szyprowski 		.compatible = "samsung,exynos4210-mixer",
1104ff830c96SMarek Szyprowski 		.data	= &exynos4210_mxr_drv_data,
1105ff830c96SMarek Szyprowski 	}, {
1106ff830c96SMarek Szyprowski 		.compatible = "samsung,exynos4212-mixer",
1107ff830c96SMarek Szyprowski 		.data	= &exynos4212_mxr_drv_data,
1108ff830c96SMarek Szyprowski 	}, {
1109aaf8b49eSRahul Sharma 		.compatible = "samsung,exynos5-mixer",
1110cc57caf0SRahul Sharma 		.data	= &exynos5250_mxr_drv_data,
1111cc57caf0SRahul Sharma 	}, {
1112cc57caf0SRahul Sharma 		.compatible = "samsung,exynos5250-mixer",
1113cc57caf0SRahul Sharma 		.data	= &exynos5250_mxr_drv_data,
1114aaf8b49eSRahul Sharma 	}, {
1115def5e095SRahul Sharma 		.compatible = "samsung,exynos5420-mixer",
1116def5e095SRahul Sharma 		.data	= &exynos5420_mxr_drv_data,
1117def5e095SRahul Sharma 	}, {
11181e123441SRahul Sharma 		/* end node */
11191e123441SRahul Sharma 	}
11201e123441SRahul Sharma };
112139b58a39SSjoerd Simons MODULE_DEVICE_TABLE(of, mixer_match_types);
11221e123441SRahul Sharma 
1123f37cd5e8SInki Dae static int mixer_bind(struct device *dev, struct device *manager, void *data)
1124d8408326SSeung-Woo Kim {
11258103ef1bSAndrzej Hajda 	struct mixer_context *ctx = dev_get_drvdata(dev);
1126f37cd5e8SInki Dae 	struct drm_device *drm_dev = data;
11277ee14cdcSGustavo Padovan 	struct exynos_drm_plane *exynos_plane;
1128fd2d2fc2SMarek Szyprowski 	unsigned int i;
11296e2a3b66SGustavo Padovan 	int ret;
1130d8408326SSeung-Woo Kim 
1131e2dc3f72SAlban Browaeys 	ret = mixer_initialize(ctx, drm_dev);
1132e2dc3f72SAlban Browaeys 	if (ret)
1133e2dc3f72SAlban Browaeys 		return ret;
1134e2dc3f72SAlban Browaeys 
1135fd2d2fc2SMarek Szyprowski 	for (i = 0; i < MIXER_WIN_NR; i++) {
1136adeb6f44STobias Jakobi 		if (i == VP_DEFAULT_WIN && !test_bit(MXR_BIT_VP_ENABLED,
1137adeb6f44STobias Jakobi 						     &ctx->flags))
1138ab144201SMarek Szyprowski 			continue;
1139ab144201SMarek Szyprowski 
114040bdfb0aSMarek Szyprowski 		ret = exynos_plane_init(drm_dev, &ctx->planes[i], i,
11412c82607bSAndrzej Hajda 					&plane_configs[i]);
11427ee14cdcSGustavo Padovan 		if (ret)
11437ee14cdcSGustavo Padovan 			return ret;
11447ee14cdcSGustavo Padovan 	}
11457ee14cdcSGustavo Padovan 
11465d3d0995SGustavo Padovan 	exynos_plane = &ctx->planes[DEFAULT_WIN];
11477ee14cdcSGustavo Padovan 	ctx->crtc = exynos_drm_crtc_create(drm_dev, &exynos_plane->base,
1148d644951cSAndrzej Hajda 			EXYNOS_DISPLAY_TYPE_HDMI, &mixer_crtc_ops, ctx);
114993bca243SGustavo Padovan 	if (IS_ERR(ctx->crtc)) {
1150e2dc3f72SAlban Browaeys 		mixer_ctx_remove(ctx);
115193bca243SGustavo Padovan 		ret = PTR_ERR(ctx->crtc);
115293bca243SGustavo Padovan 		goto free_ctx;
11538103ef1bSAndrzej Hajda 	}
11548103ef1bSAndrzej Hajda 
11558103ef1bSAndrzej Hajda 	return 0;
115693bca243SGustavo Padovan 
115793bca243SGustavo Padovan free_ctx:
115893bca243SGustavo Padovan 	devm_kfree(dev, ctx);
115993bca243SGustavo Padovan 	return ret;
11608103ef1bSAndrzej Hajda }
11618103ef1bSAndrzej Hajda 
11628103ef1bSAndrzej Hajda static void mixer_unbind(struct device *dev, struct device *master, void *data)
11638103ef1bSAndrzej Hajda {
11648103ef1bSAndrzej Hajda 	struct mixer_context *ctx = dev_get_drvdata(dev);
11658103ef1bSAndrzej Hajda 
116693bca243SGustavo Padovan 	mixer_ctx_remove(ctx);
11678103ef1bSAndrzej Hajda }
11688103ef1bSAndrzej Hajda 
11698103ef1bSAndrzej Hajda static const struct component_ops mixer_component_ops = {
11708103ef1bSAndrzej Hajda 	.bind	= mixer_bind,
11718103ef1bSAndrzej Hajda 	.unbind	= mixer_unbind,
11728103ef1bSAndrzej Hajda };
11738103ef1bSAndrzej Hajda 
11748103ef1bSAndrzej Hajda static int mixer_probe(struct platform_device *pdev)
11758103ef1bSAndrzej Hajda {
11768103ef1bSAndrzej Hajda 	struct device *dev = &pdev->dev;
117748f6155aSMarek Szyprowski 	const struct mixer_drv_data *drv;
11788103ef1bSAndrzej Hajda 	struct mixer_context *ctx;
11798103ef1bSAndrzej Hajda 	int ret;
1180d8408326SSeung-Woo Kim 
1181f041b257SSean Paul 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
1182f041b257SSean Paul 	if (!ctx) {
1183f041b257SSean Paul 		DRM_ERROR("failed to alloc mixer context.\n");
1184d8408326SSeung-Woo Kim 		return -ENOMEM;
1185f041b257SSean Paul 	}
1186d8408326SSeung-Woo Kim 
118748f6155aSMarek Szyprowski 	drv = of_device_get_match_data(dev);
1188aaf8b49eSRahul Sharma 
11894551789fSSean Paul 	ctx->pdev = pdev;
1190d873ab99SSeung-Woo Kim 	ctx->dev = dev;
11911e123441SRahul Sharma 	ctx->mxr_ver = drv->version;
1192d8408326SSeung-Woo Kim 
1193adeb6f44STobias Jakobi 	if (drv->is_vp_enabled)
1194adeb6f44STobias Jakobi 		__set_bit(MXR_BIT_VP_ENABLED, &ctx->flags);
1195adeb6f44STobias Jakobi 	if (drv->has_sclk)
1196adeb6f44STobias Jakobi 		__set_bit(MXR_BIT_HAS_SCLK, &ctx->flags);
1197adeb6f44STobias Jakobi 
11988103ef1bSAndrzej Hajda 	platform_set_drvdata(pdev, ctx);
1199df5225bcSInki Dae 
1200df5225bcSInki Dae 	ret = component_add(&pdev->dev, &mixer_component_ops);
120186650408SAndrzej Hajda 	if (!ret)
12028103ef1bSAndrzej Hajda 		pm_runtime_enable(dev);
1203df5225bcSInki Dae 
1204df5225bcSInki Dae 	return ret;
1205f37cd5e8SInki Dae }
1206f37cd5e8SInki Dae 
1207d8408326SSeung-Woo Kim static int mixer_remove(struct platform_device *pdev)
1208d8408326SSeung-Woo Kim {
12098103ef1bSAndrzej Hajda 	pm_runtime_disable(&pdev->dev);
12108103ef1bSAndrzej Hajda 
1211df5225bcSInki Dae 	component_del(&pdev->dev, &mixer_component_ops);
1212df5225bcSInki Dae 
1213d8408326SSeung-Woo Kim 	return 0;
1214d8408326SSeung-Woo Kim }
1215d8408326SSeung-Woo Kim 
1216e0fea7e7SArnd Bergmann static int __maybe_unused exynos_mixer_suspend(struct device *dev)
1217ccf034a9SGustavo Padovan {
1218ccf034a9SGustavo Padovan 	struct mixer_context *ctx = dev_get_drvdata(dev);
1219ccf034a9SGustavo Padovan 
1220524c59f1SAndrzej Hajda 	clk_disable_unprepare(ctx->hdmi);
1221524c59f1SAndrzej Hajda 	clk_disable_unprepare(ctx->mixer);
1222adeb6f44STobias Jakobi 	if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) {
1223524c59f1SAndrzej Hajda 		clk_disable_unprepare(ctx->vp);
1224adeb6f44STobias Jakobi 		if (test_bit(MXR_BIT_HAS_SCLK, &ctx->flags))
1225524c59f1SAndrzej Hajda 			clk_disable_unprepare(ctx->sclk_mixer);
1226ccf034a9SGustavo Padovan 	}
1227ccf034a9SGustavo Padovan 
1228ccf034a9SGustavo Padovan 	return 0;
1229ccf034a9SGustavo Padovan }
1230ccf034a9SGustavo Padovan 
1231e0fea7e7SArnd Bergmann static int __maybe_unused exynos_mixer_resume(struct device *dev)
1232ccf034a9SGustavo Padovan {
1233ccf034a9SGustavo Padovan 	struct mixer_context *ctx = dev_get_drvdata(dev);
1234ccf034a9SGustavo Padovan 	int ret;
1235ccf034a9SGustavo Padovan 
1236524c59f1SAndrzej Hajda 	ret = clk_prepare_enable(ctx->mixer);
1237ccf034a9SGustavo Padovan 	if (ret < 0) {
1238ccf034a9SGustavo Padovan 		DRM_ERROR("Failed to prepare_enable the mixer clk [%d]\n", ret);
1239ccf034a9SGustavo Padovan 		return ret;
1240ccf034a9SGustavo Padovan 	}
1241524c59f1SAndrzej Hajda 	ret = clk_prepare_enable(ctx->hdmi);
1242ccf034a9SGustavo Padovan 	if (ret < 0) {
1243ccf034a9SGustavo Padovan 		DRM_ERROR("Failed to prepare_enable the hdmi clk [%d]\n", ret);
1244ccf034a9SGustavo Padovan 		return ret;
1245ccf034a9SGustavo Padovan 	}
1246adeb6f44STobias Jakobi 	if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) {
1247524c59f1SAndrzej Hajda 		ret = clk_prepare_enable(ctx->vp);
1248ccf034a9SGustavo Padovan 		if (ret < 0) {
1249ccf034a9SGustavo Padovan 			DRM_ERROR("Failed to prepare_enable the vp clk [%d]\n",
1250ccf034a9SGustavo Padovan 				  ret);
1251ccf034a9SGustavo Padovan 			return ret;
1252ccf034a9SGustavo Padovan 		}
1253adeb6f44STobias Jakobi 		if (test_bit(MXR_BIT_HAS_SCLK, &ctx->flags)) {
1254524c59f1SAndrzej Hajda 			ret = clk_prepare_enable(ctx->sclk_mixer);
1255ccf034a9SGustavo Padovan 			if (ret < 0) {
1256ccf034a9SGustavo Padovan 				DRM_ERROR("Failed to prepare_enable the " \
1257ccf034a9SGustavo Padovan 					   "sclk_mixer clk [%d]\n",
1258ccf034a9SGustavo Padovan 					  ret);
1259ccf034a9SGustavo Padovan 				return ret;
1260ccf034a9SGustavo Padovan 			}
1261ccf034a9SGustavo Padovan 		}
1262ccf034a9SGustavo Padovan 	}
1263ccf034a9SGustavo Padovan 
1264ccf034a9SGustavo Padovan 	return 0;
1265ccf034a9SGustavo Padovan }
1266ccf034a9SGustavo Padovan 
1267ccf034a9SGustavo Padovan static const struct dev_pm_ops exynos_mixer_pm_ops = {
1268ccf034a9SGustavo Padovan 	SET_RUNTIME_PM_OPS(exynos_mixer_suspend, exynos_mixer_resume, NULL)
1269ccf034a9SGustavo Padovan };
1270ccf034a9SGustavo Padovan 
1271d8408326SSeung-Woo Kim struct platform_driver mixer_driver = {
1272d8408326SSeung-Woo Kim 	.driver = {
1273aaf8b49eSRahul Sharma 		.name = "exynos-mixer",
1274d8408326SSeung-Woo Kim 		.owner = THIS_MODULE,
1275ccf034a9SGustavo Padovan 		.pm = &exynos_mixer_pm_ops,
1276aaf8b49eSRahul Sharma 		.of_match_table = mixer_match_types,
1277d8408326SSeung-Woo Kim 	},
1278d8408326SSeung-Woo Kim 	.probe = mixer_probe,
127956550d94SGreg Kroah-Hartman 	.remove = mixer_remove,
1280d8408326SSeung-Woo Kim };
1281