xref: /OK3568_Linux_fs/kernel/drivers/media/platform/s3c-camif/camif-regs.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Samsung s3c24xx/s3c64xx SoC CAMIF driver
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
6*4882a593Smuzhiyun  * Copyright (C) 2012 Tomasz Figa <tomasz.figa@gmail.com>
7*4882a593Smuzhiyun */
8*4882a593Smuzhiyun #define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <linux/delay.h>
11*4882a593Smuzhiyun #include "camif-regs.h"
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #define camif_write(_camif, _off, _val)	writel(_val, (_camif)->io_base + (_off))
14*4882a593Smuzhiyun #define camif_read(_camif, _off)	readl((_camif)->io_base + (_off))
15*4882a593Smuzhiyun 
camif_hw_reset(struct camif_dev * camif)16*4882a593Smuzhiyun void camif_hw_reset(struct camif_dev *camif)
17*4882a593Smuzhiyun {
18*4882a593Smuzhiyun 	u32 cfg;
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CISRCFMT);
21*4882a593Smuzhiyun 	cfg |= CISRCFMT_ITU601_8BIT;
22*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CISRCFMT, cfg);
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun 	/* S/W reset */
25*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CIGCTRL);
26*4882a593Smuzhiyun 	cfg |= CIGCTRL_SWRST;
27*4882a593Smuzhiyun 	if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV)
28*4882a593Smuzhiyun 		cfg |= CIGCTRL_IRQ_LEVEL;
29*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CIGCTRL, cfg);
30*4882a593Smuzhiyun 	udelay(10);
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CIGCTRL);
33*4882a593Smuzhiyun 	cfg &= ~CIGCTRL_SWRST;
34*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CIGCTRL, cfg);
35*4882a593Smuzhiyun 	udelay(10);
36*4882a593Smuzhiyun }
37*4882a593Smuzhiyun 
camif_hw_clear_pending_irq(struct camif_vp * vp)38*4882a593Smuzhiyun void camif_hw_clear_pending_irq(struct camif_vp *vp)
39*4882a593Smuzhiyun {
40*4882a593Smuzhiyun 	u32 cfg = camif_read(vp->camif, S3C_CAMIF_REG_CIGCTRL);
41*4882a593Smuzhiyun 	cfg |= CIGCTRL_IRQ_CLR(vp->id);
42*4882a593Smuzhiyun 	camif_write(vp->camif, S3C_CAMIF_REG_CIGCTRL, cfg);
43*4882a593Smuzhiyun }
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun /*
46*4882a593Smuzhiyun  * Sets video test pattern (off, color bar, horizontal or vertical gradient).
47*4882a593Smuzhiyun  * External sensor pixel clock must be active for the test pattern to work.
48*4882a593Smuzhiyun  */
camif_hw_set_test_pattern(struct camif_dev * camif,unsigned int pattern)49*4882a593Smuzhiyun void camif_hw_set_test_pattern(struct camif_dev *camif, unsigned int pattern)
50*4882a593Smuzhiyun {
51*4882a593Smuzhiyun 	u32 cfg = camif_read(camif, S3C_CAMIF_REG_CIGCTRL);
52*4882a593Smuzhiyun 	cfg &= ~CIGCTRL_TESTPATTERN_MASK;
53*4882a593Smuzhiyun 	cfg |= (pattern << 27);
54*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CIGCTRL, cfg);
55*4882a593Smuzhiyun }
56*4882a593Smuzhiyun 
camif_hw_set_effect(struct camif_dev * camif,unsigned int effect,unsigned int cr,unsigned int cb)57*4882a593Smuzhiyun void camif_hw_set_effect(struct camif_dev *camif, unsigned int effect,
58*4882a593Smuzhiyun 			unsigned int cr, unsigned int cb)
59*4882a593Smuzhiyun {
60*4882a593Smuzhiyun 	static const struct v4l2_control colorfx[] = {
61*4882a593Smuzhiyun 		{ V4L2_COLORFX_NONE,		CIIMGEFF_FIN_BYPASS },
62*4882a593Smuzhiyun 		{ V4L2_COLORFX_BW,		CIIMGEFF_FIN_ARBITRARY },
63*4882a593Smuzhiyun 		{ V4L2_COLORFX_SEPIA,		CIIMGEFF_FIN_ARBITRARY },
64*4882a593Smuzhiyun 		{ V4L2_COLORFX_NEGATIVE,	CIIMGEFF_FIN_NEGATIVE },
65*4882a593Smuzhiyun 		{ V4L2_COLORFX_ART_FREEZE,	CIIMGEFF_FIN_ARTFREEZE },
66*4882a593Smuzhiyun 		{ V4L2_COLORFX_EMBOSS,		CIIMGEFF_FIN_EMBOSSING },
67*4882a593Smuzhiyun 		{ V4L2_COLORFX_SILHOUETTE,	CIIMGEFF_FIN_SILHOUETTE },
68*4882a593Smuzhiyun 		{ V4L2_COLORFX_SET_CBCR,	CIIMGEFF_FIN_ARBITRARY },
69*4882a593Smuzhiyun 	};
70*4882a593Smuzhiyun 	unsigned int i, cfg;
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun 	for (i = 0; i < ARRAY_SIZE(colorfx); i++)
73*4882a593Smuzhiyun 		if (colorfx[i].id == effect)
74*4882a593Smuzhiyun 			break;
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun 	if (i == ARRAY_SIZE(colorfx))
77*4882a593Smuzhiyun 		return;
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CIIMGEFF(camif->vp->offset));
80*4882a593Smuzhiyun 	/* Set effect */
81*4882a593Smuzhiyun 	cfg &= ~CIIMGEFF_FIN_MASK;
82*4882a593Smuzhiyun 	cfg |= colorfx[i].value;
83*4882a593Smuzhiyun 	/* Set both paths */
84*4882a593Smuzhiyun 	if (camif->variant->ip_revision >= S3C6400_CAMIF_IP_REV) {
85*4882a593Smuzhiyun 		if (effect == V4L2_COLORFX_NONE)
86*4882a593Smuzhiyun 			cfg &= ~CIIMGEFF_IE_ENABLE_MASK;
87*4882a593Smuzhiyun 		else
88*4882a593Smuzhiyun 			cfg |= CIIMGEFF_IE_ENABLE_MASK;
89*4882a593Smuzhiyun 	}
90*4882a593Smuzhiyun 	cfg &= ~CIIMGEFF_PAT_CBCR_MASK;
91*4882a593Smuzhiyun 	cfg |= cr | (cb << 13);
92*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CIIMGEFF(camif->vp->offset), cfg);
93*4882a593Smuzhiyun }
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun static const u32 src_pixfmt_map[8][2] = {
96*4882a593Smuzhiyun 	{ MEDIA_BUS_FMT_YUYV8_2X8, CISRCFMT_ORDER422_YCBYCR },
97*4882a593Smuzhiyun 	{ MEDIA_BUS_FMT_YVYU8_2X8, CISRCFMT_ORDER422_YCRYCB },
98*4882a593Smuzhiyun 	{ MEDIA_BUS_FMT_UYVY8_2X8, CISRCFMT_ORDER422_CBYCRY },
99*4882a593Smuzhiyun 	{ MEDIA_BUS_FMT_VYUY8_2X8, CISRCFMT_ORDER422_CRYCBY },
100*4882a593Smuzhiyun };
101*4882a593Smuzhiyun 
102*4882a593Smuzhiyun /* Set camera input pixel format and resolution */
camif_hw_set_source_format(struct camif_dev * camif)103*4882a593Smuzhiyun void camif_hw_set_source_format(struct camif_dev *camif)
104*4882a593Smuzhiyun {
105*4882a593Smuzhiyun 	struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
106*4882a593Smuzhiyun 	int i;
107*4882a593Smuzhiyun 	u32 cfg;
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun 	for (i = ARRAY_SIZE(src_pixfmt_map) - 1; i >= 0; i--) {
110*4882a593Smuzhiyun 		if (src_pixfmt_map[i][0] == mf->code)
111*4882a593Smuzhiyun 			break;
112*4882a593Smuzhiyun 	}
113*4882a593Smuzhiyun 	if (i < 0) {
114*4882a593Smuzhiyun 		i = 0;
115*4882a593Smuzhiyun 		dev_err(camif->dev,
116*4882a593Smuzhiyun 			"Unsupported pixel code, falling back to %#08x\n",
117*4882a593Smuzhiyun 			src_pixfmt_map[i][0]);
118*4882a593Smuzhiyun 	}
119*4882a593Smuzhiyun 
120*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CISRCFMT);
121*4882a593Smuzhiyun 	cfg &= ~(CISRCFMT_ORDER422_MASK | CISRCFMT_SIZE_CAM_MASK);
122*4882a593Smuzhiyun 	cfg |= (mf->width << 16) | mf->height;
123*4882a593Smuzhiyun 	cfg |= src_pixfmt_map[i][1];
124*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CISRCFMT, cfg);
125*4882a593Smuzhiyun }
126*4882a593Smuzhiyun 
127*4882a593Smuzhiyun /* Set the camera host input window offsets (cropping) */
camif_hw_set_camera_crop(struct camif_dev * camif)128*4882a593Smuzhiyun void camif_hw_set_camera_crop(struct camif_dev *camif)
129*4882a593Smuzhiyun {
130*4882a593Smuzhiyun 	struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
131*4882a593Smuzhiyun 	struct v4l2_rect *crop = &camif->camif_crop;
132*4882a593Smuzhiyun 	u32 hoff2, voff2;
133*4882a593Smuzhiyun 	u32 cfg;
134*4882a593Smuzhiyun 
135*4882a593Smuzhiyun 	/* Note: s3c244x requirement: left = f_width - rect.width / 2 */
136*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CIWDOFST);
137*4882a593Smuzhiyun 	cfg &= ~(CIWDOFST_OFST_MASK | CIWDOFST_WINOFSEN);
138*4882a593Smuzhiyun 	cfg |= (crop->left << 16) | crop->top;
139*4882a593Smuzhiyun 	if (crop->left != 0 || crop->top != 0)
140*4882a593Smuzhiyun 		cfg |= CIWDOFST_WINOFSEN;
141*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CIWDOFST, cfg);
142*4882a593Smuzhiyun 
143*4882a593Smuzhiyun 	if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV) {
144*4882a593Smuzhiyun 		hoff2 = mf->width - crop->width - crop->left;
145*4882a593Smuzhiyun 		voff2 = mf->height - crop->height - crop->top;
146*4882a593Smuzhiyun 		cfg = (hoff2 << 16) | voff2;
147*4882a593Smuzhiyun 		camif_write(camif, S3C_CAMIF_REG_CIWDOFST2, cfg);
148*4882a593Smuzhiyun 	}
149*4882a593Smuzhiyun }
150*4882a593Smuzhiyun 
camif_hw_clear_fifo_overflow(struct camif_vp * vp)151*4882a593Smuzhiyun void camif_hw_clear_fifo_overflow(struct camif_vp *vp)
152*4882a593Smuzhiyun {
153*4882a593Smuzhiyun 	struct camif_dev *camif = vp->camif;
154*4882a593Smuzhiyun 	u32 cfg;
155*4882a593Smuzhiyun 
156*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CIWDOFST);
157*4882a593Smuzhiyun 	if (vp->id == 0)
158*4882a593Smuzhiyun 		cfg |= (CIWDOFST_CLROVCOFIY | CIWDOFST_CLROVCOFICB |
159*4882a593Smuzhiyun 			CIWDOFST_CLROVCOFICR);
160*4882a593Smuzhiyun 	else
161*4882a593Smuzhiyun 		cfg |= (/* CIWDOFST_CLROVPRFIY | */ CIWDOFST_CLROVPRFICB |
162*4882a593Smuzhiyun 			CIWDOFST_CLROVPRFICR);
163*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CIWDOFST, cfg);
164*4882a593Smuzhiyun }
165*4882a593Smuzhiyun 
166*4882a593Smuzhiyun /* Set video bus signals polarity */
camif_hw_set_camera_bus(struct camif_dev * camif)167*4882a593Smuzhiyun void camif_hw_set_camera_bus(struct camif_dev *camif)
168*4882a593Smuzhiyun {
169*4882a593Smuzhiyun 	unsigned int flags = camif->pdata.sensor.flags;
170*4882a593Smuzhiyun 
171*4882a593Smuzhiyun 	u32 cfg = camif_read(camif, S3C_CAMIF_REG_CIGCTRL);
172*4882a593Smuzhiyun 
173*4882a593Smuzhiyun 	cfg &= ~(CIGCTRL_INVPOLPCLK | CIGCTRL_INVPOLVSYNC |
174*4882a593Smuzhiyun 		 CIGCTRL_INVPOLHREF | CIGCTRL_INVPOLFIELD);
175*4882a593Smuzhiyun 
176*4882a593Smuzhiyun 	if (flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
177*4882a593Smuzhiyun 		cfg |= CIGCTRL_INVPOLPCLK;
178*4882a593Smuzhiyun 
179*4882a593Smuzhiyun 	if (flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
180*4882a593Smuzhiyun 		cfg |= CIGCTRL_INVPOLVSYNC;
181*4882a593Smuzhiyun 	/*
182*4882a593Smuzhiyun 	 * HREF is normally high during frame active data
183*4882a593Smuzhiyun 	 * transmission and low during horizontal synchronization
184*4882a593Smuzhiyun 	 * period. Thus HREF active high means HSYNC active low.
185*4882a593Smuzhiyun 	 */
186*4882a593Smuzhiyun 	if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
187*4882a593Smuzhiyun 		cfg |= CIGCTRL_INVPOLHREF; /* HREF active low */
188*4882a593Smuzhiyun 
189*4882a593Smuzhiyun 	if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV) {
190*4882a593Smuzhiyun 		if (flags & V4L2_MBUS_FIELD_EVEN_LOW)
191*4882a593Smuzhiyun 			cfg |= CIGCTRL_INVPOLFIELD;
192*4882a593Smuzhiyun 		cfg |= CIGCTRL_FIELDMODE;
193*4882a593Smuzhiyun 	}
194*4882a593Smuzhiyun 
195*4882a593Smuzhiyun 	pr_debug("Setting CIGCTRL to: %#x\n", cfg);
196*4882a593Smuzhiyun 
197*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CIGCTRL, cfg);
198*4882a593Smuzhiyun }
199*4882a593Smuzhiyun 
camif_hw_set_output_addr(struct camif_vp * vp,struct camif_addr * paddr,int i)200*4882a593Smuzhiyun void camif_hw_set_output_addr(struct camif_vp *vp,
201*4882a593Smuzhiyun 			      struct camif_addr *paddr, int i)
202*4882a593Smuzhiyun {
203*4882a593Smuzhiyun 	struct camif_dev *camif = vp->camif;
204*4882a593Smuzhiyun 
205*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CIYSA(vp->id, i), paddr->y);
206*4882a593Smuzhiyun 	if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV
207*4882a593Smuzhiyun 		|| vp->id == VP_CODEC) {
208*4882a593Smuzhiyun 		camif_write(camif, S3C_CAMIF_REG_CICBSA(vp->id, i),
209*4882a593Smuzhiyun 								paddr->cb);
210*4882a593Smuzhiyun 		camif_write(camif, S3C_CAMIF_REG_CICRSA(vp->id, i),
211*4882a593Smuzhiyun 								paddr->cr);
212*4882a593Smuzhiyun 	}
213*4882a593Smuzhiyun 
214*4882a593Smuzhiyun 	pr_debug("dst_buf[%d]: %pad, cb: %pad, cr: %pad\n",
215*4882a593Smuzhiyun 		 i, &paddr->y, &paddr->cb, &paddr->cr);
216*4882a593Smuzhiyun }
217*4882a593Smuzhiyun 
camif_hw_set_out_dma_size(struct camif_vp * vp)218*4882a593Smuzhiyun static void camif_hw_set_out_dma_size(struct camif_vp *vp)
219*4882a593Smuzhiyun {
220*4882a593Smuzhiyun 	struct camif_frame *frame = &vp->out_frame;
221*4882a593Smuzhiyun 	u32 cfg;
222*4882a593Smuzhiyun 
223*4882a593Smuzhiyun 	cfg = camif_read(vp->camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset));
224*4882a593Smuzhiyun 	cfg &= ~CITRGFMT_TARGETSIZE_MASK;
225*4882a593Smuzhiyun 	cfg |= (frame->f_width << 16) | frame->f_height;
226*4882a593Smuzhiyun 	camif_write(vp->camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset), cfg);
227*4882a593Smuzhiyun }
228*4882a593Smuzhiyun 
camif_get_dma_burst(u32 width,u32 ybpp,u32 * mburst,u32 * rburst)229*4882a593Smuzhiyun static void camif_get_dma_burst(u32 width, u32 ybpp, u32 *mburst, u32 *rburst)
230*4882a593Smuzhiyun {
231*4882a593Smuzhiyun 	unsigned int nwords = width * ybpp / 4;
232*4882a593Smuzhiyun 	unsigned int div, rem;
233*4882a593Smuzhiyun 
234*4882a593Smuzhiyun 	if (WARN_ON(width < 8 || (width * ybpp) & 7))
235*4882a593Smuzhiyun 		return;
236*4882a593Smuzhiyun 
237*4882a593Smuzhiyun 	for (div = 16; div >= 2; div /= 2) {
238*4882a593Smuzhiyun 		if (nwords < div)
239*4882a593Smuzhiyun 			continue;
240*4882a593Smuzhiyun 
241*4882a593Smuzhiyun 		rem = nwords & (div - 1);
242*4882a593Smuzhiyun 		if (rem == 0) {
243*4882a593Smuzhiyun 			*mburst = div;
244*4882a593Smuzhiyun 			*rburst = div;
245*4882a593Smuzhiyun 			break;
246*4882a593Smuzhiyun 		}
247*4882a593Smuzhiyun 		if (rem == div / 2 || rem == div / 4) {
248*4882a593Smuzhiyun 			*mburst = div;
249*4882a593Smuzhiyun 			*rburst = rem;
250*4882a593Smuzhiyun 			break;
251*4882a593Smuzhiyun 		}
252*4882a593Smuzhiyun 	}
253*4882a593Smuzhiyun }
254*4882a593Smuzhiyun 
camif_hw_set_output_dma(struct camif_vp * vp)255*4882a593Smuzhiyun void camif_hw_set_output_dma(struct camif_vp *vp)
256*4882a593Smuzhiyun {
257*4882a593Smuzhiyun 	struct camif_dev *camif = vp->camif;
258*4882a593Smuzhiyun 	struct camif_frame *frame = &vp->out_frame;
259*4882a593Smuzhiyun 	const struct camif_fmt *fmt = vp->out_fmt;
260*4882a593Smuzhiyun 	unsigned int ymburst = 0, yrburst = 0;
261*4882a593Smuzhiyun 	u32 cfg;
262*4882a593Smuzhiyun 
263*4882a593Smuzhiyun 	camif_hw_set_out_dma_size(vp);
264*4882a593Smuzhiyun 
265*4882a593Smuzhiyun 	if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV) {
266*4882a593Smuzhiyun 		struct camif_dma_offset *offset = &frame->dma_offset;
267*4882a593Smuzhiyun 		/* Set the input dma offsets. */
268*4882a593Smuzhiyun 		cfg = S3C_CISS_OFFS_INITIAL(offset->initial);
269*4882a593Smuzhiyun 		cfg |= S3C_CISS_OFFS_LINE(offset->line);
270*4882a593Smuzhiyun 		camif_write(camif, S3C_CAMIF_REG_CISSY(vp->id), cfg);
271*4882a593Smuzhiyun 		camif_write(camif, S3C_CAMIF_REG_CISSCB(vp->id), cfg);
272*4882a593Smuzhiyun 		camif_write(camif, S3C_CAMIF_REG_CISSCR(vp->id), cfg);
273*4882a593Smuzhiyun 	}
274*4882a593Smuzhiyun 
275*4882a593Smuzhiyun 	/* Configure DMA burst values */
276*4882a593Smuzhiyun 	camif_get_dma_burst(frame->rect.width, fmt->ybpp, &ymburst, &yrburst);
277*4882a593Smuzhiyun 
278*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CICTRL(vp->id, vp->offset));
279*4882a593Smuzhiyun 	cfg &= ~CICTRL_BURST_MASK;
280*4882a593Smuzhiyun 
281*4882a593Smuzhiyun 	cfg |= CICTRL_YBURST1(ymburst) | CICTRL_YBURST2(yrburst);
282*4882a593Smuzhiyun 	cfg |= CICTRL_CBURST1(ymburst / 2) | CICTRL_CBURST2(yrburst / 2);
283*4882a593Smuzhiyun 
284*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CICTRL(vp->id, vp->offset), cfg);
285*4882a593Smuzhiyun 
286*4882a593Smuzhiyun 	pr_debug("ymburst: %u, yrburst: %u\n", ymburst, yrburst);
287*4882a593Smuzhiyun }
288*4882a593Smuzhiyun 
camif_hw_set_input_path(struct camif_vp * vp)289*4882a593Smuzhiyun void camif_hw_set_input_path(struct camif_vp *vp)
290*4882a593Smuzhiyun {
291*4882a593Smuzhiyun 	u32 cfg = camif_read(vp->camif, S3C_CAMIF_REG_MSCTRL(vp->id));
292*4882a593Smuzhiyun 	cfg &= ~MSCTRL_SEL_DMA_CAM;
293*4882a593Smuzhiyun 	camif_write(vp->camif, S3C_CAMIF_REG_MSCTRL(vp->id), cfg);
294*4882a593Smuzhiyun }
295*4882a593Smuzhiyun 
camif_hw_set_target_format(struct camif_vp * vp)296*4882a593Smuzhiyun void camif_hw_set_target_format(struct camif_vp *vp)
297*4882a593Smuzhiyun {
298*4882a593Smuzhiyun 	struct camif_dev *camif = vp->camif;
299*4882a593Smuzhiyun 	struct camif_frame *frame = &vp->out_frame;
300*4882a593Smuzhiyun 	u32 cfg;
301*4882a593Smuzhiyun 
302*4882a593Smuzhiyun 	pr_debug("fw: %d, fh: %d color: %d\n", frame->f_width,
303*4882a593Smuzhiyun 		 frame->f_height, vp->out_fmt->color);
304*4882a593Smuzhiyun 
305*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset));
306*4882a593Smuzhiyun 	cfg &= ~CITRGFMT_TARGETSIZE_MASK;
307*4882a593Smuzhiyun 
308*4882a593Smuzhiyun 	if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV) {
309*4882a593Smuzhiyun 		/* We currently support only YCbCr 4:2:2 at the camera input */
310*4882a593Smuzhiyun 		cfg |= CITRGFMT_IN422;
311*4882a593Smuzhiyun 		cfg &= ~CITRGFMT_OUT422;
312*4882a593Smuzhiyun 		if (vp->out_fmt->color == IMG_FMT_YCBCR422P)
313*4882a593Smuzhiyun 			cfg |= CITRGFMT_OUT422;
314*4882a593Smuzhiyun 	} else {
315*4882a593Smuzhiyun 		cfg &= ~CITRGFMT_OUTFORMAT_MASK;
316*4882a593Smuzhiyun 		switch (vp->out_fmt->color) {
317*4882a593Smuzhiyun 		case IMG_FMT_RGB565...IMG_FMT_XRGB8888:
318*4882a593Smuzhiyun 			cfg |= CITRGFMT_OUTFORMAT_RGB;
319*4882a593Smuzhiyun 			break;
320*4882a593Smuzhiyun 		case IMG_FMT_YCBCR420...IMG_FMT_YCRCB420:
321*4882a593Smuzhiyun 			cfg |= CITRGFMT_OUTFORMAT_YCBCR420;
322*4882a593Smuzhiyun 			break;
323*4882a593Smuzhiyun 		case IMG_FMT_YCBCR422P:
324*4882a593Smuzhiyun 			cfg |= CITRGFMT_OUTFORMAT_YCBCR422;
325*4882a593Smuzhiyun 			break;
326*4882a593Smuzhiyun 		case IMG_FMT_YCBYCR422...IMG_FMT_CRYCBY422:
327*4882a593Smuzhiyun 			cfg |= CITRGFMT_OUTFORMAT_YCBCR422I;
328*4882a593Smuzhiyun 			break;
329*4882a593Smuzhiyun 		}
330*4882a593Smuzhiyun 	}
331*4882a593Smuzhiyun 
332*4882a593Smuzhiyun 	/* Rotation is only supported by s3c64xx */
333*4882a593Smuzhiyun 	if (vp->rotation == 90 || vp->rotation == 270)
334*4882a593Smuzhiyun 		cfg |= (frame->f_height << 16) | frame->f_width;
335*4882a593Smuzhiyun 	else
336*4882a593Smuzhiyun 		cfg |= (frame->f_width << 16) | frame->f_height;
337*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset), cfg);
338*4882a593Smuzhiyun 
339*4882a593Smuzhiyun 	/* Target area, output pixel width * height */
340*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CITAREA(vp->id, vp->offset));
341*4882a593Smuzhiyun 	cfg &= ~CITAREA_MASK;
342*4882a593Smuzhiyun 	cfg |= (frame->f_width * frame->f_height);
343*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CITAREA(vp->id, vp->offset), cfg);
344*4882a593Smuzhiyun }
345*4882a593Smuzhiyun 
camif_hw_set_flip(struct camif_vp * vp)346*4882a593Smuzhiyun void camif_hw_set_flip(struct camif_vp *vp)
347*4882a593Smuzhiyun {
348*4882a593Smuzhiyun 	u32 cfg = camif_read(vp->camif,
349*4882a593Smuzhiyun 				S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset));
350*4882a593Smuzhiyun 
351*4882a593Smuzhiyun 	cfg &= ~CITRGFMT_FLIP_MASK;
352*4882a593Smuzhiyun 
353*4882a593Smuzhiyun 	if (vp->hflip)
354*4882a593Smuzhiyun 		cfg |= CITRGFMT_FLIP_Y_MIRROR;
355*4882a593Smuzhiyun 	if (vp->vflip)
356*4882a593Smuzhiyun 		cfg |= CITRGFMT_FLIP_X_MIRROR;
357*4882a593Smuzhiyun 
358*4882a593Smuzhiyun 	camif_write(vp->camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset), cfg);
359*4882a593Smuzhiyun }
360*4882a593Smuzhiyun 
camif_hw_set_prescaler(struct camif_vp * vp)361*4882a593Smuzhiyun static void camif_hw_set_prescaler(struct camif_vp *vp)
362*4882a593Smuzhiyun {
363*4882a593Smuzhiyun 	struct camif_dev *camif = vp->camif;
364*4882a593Smuzhiyun 	struct camif_scaler *sc = &vp->scaler;
365*4882a593Smuzhiyun 	u32 cfg, shfactor, addr;
366*4882a593Smuzhiyun 
367*4882a593Smuzhiyun 	addr = S3C_CAMIF_REG_CISCPRERATIO(vp->id, vp->offset);
368*4882a593Smuzhiyun 
369*4882a593Smuzhiyun 	shfactor = 10 - (sc->h_shift + sc->v_shift);
370*4882a593Smuzhiyun 	cfg = shfactor << 28;
371*4882a593Smuzhiyun 
372*4882a593Smuzhiyun 	cfg |= (sc->pre_h_ratio << 16) | sc->pre_v_ratio;
373*4882a593Smuzhiyun 	camif_write(camif, addr, cfg);
374*4882a593Smuzhiyun 
375*4882a593Smuzhiyun 	cfg = (sc->pre_dst_width << 16) | sc->pre_dst_height;
376*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CISCPREDST(vp->id, vp->offset), cfg);
377*4882a593Smuzhiyun }
378*4882a593Smuzhiyun 
camif_s3c244x_hw_set_scaler(struct camif_vp * vp)379*4882a593Smuzhiyun static void camif_s3c244x_hw_set_scaler(struct camif_vp *vp)
380*4882a593Smuzhiyun {
381*4882a593Smuzhiyun 	struct camif_dev *camif = vp->camif;
382*4882a593Smuzhiyun 	struct camif_scaler *scaler = &vp->scaler;
383*4882a593Smuzhiyun 	unsigned int color = vp->out_fmt->color;
384*4882a593Smuzhiyun 	u32 cfg;
385*4882a593Smuzhiyun 
386*4882a593Smuzhiyun 	camif_hw_set_prescaler(vp);
387*4882a593Smuzhiyun 
388*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset));
389*4882a593Smuzhiyun 
390*4882a593Smuzhiyun 	cfg &= ~(CISCCTRL_SCALEUP_MASK | CISCCTRL_SCALERBYPASS |
391*4882a593Smuzhiyun 		 CISCCTRL_MAIN_RATIO_MASK | CIPRSCCTRL_RGB_FORMAT_24BIT);
392*4882a593Smuzhiyun 
393*4882a593Smuzhiyun 	if (scaler->enable) {
394*4882a593Smuzhiyun 		if (scaler->scaleup_h) {
395*4882a593Smuzhiyun 			if (vp->id == VP_CODEC)
396*4882a593Smuzhiyun 				cfg |= CISCCTRL_SCALEUP_H;
397*4882a593Smuzhiyun 			else
398*4882a593Smuzhiyun 				cfg |= CIPRSCCTRL_SCALEUP_H;
399*4882a593Smuzhiyun 		}
400*4882a593Smuzhiyun 		if (scaler->scaleup_v) {
401*4882a593Smuzhiyun 			if (vp->id == VP_CODEC)
402*4882a593Smuzhiyun 				cfg |= CISCCTRL_SCALEUP_V;
403*4882a593Smuzhiyun 			else
404*4882a593Smuzhiyun 				cfg |= CIPRSCCTRL_SCALEUP_V;
405*4882a593Smuzhiyun 		}
406*4882a593Smuzhiyun 	} else {
407*4882a593Smuzhiyun 		if (vp->id == VP_CODEC)
408*4882a593Smuzhiyun 			cfg |= CISCCTRL_SCALERBYPASS;
409*4882a593Smuzhiyun 	}
410*4882a593Smuzhiyun 
411*4882a593Smuzhiyun 	cfg |= ((scaler->main_h_ratio & 0x1ff) << 16);
412*4882a593Smuzhiyun 	cfg |= scaler->main_v_ratio & 0x1ff;
413*4882a593Smuzhiyun 
414*4882a593Smuzhiyun 	if (vp->id == VP_PREVIEW) {
415*4882a593Smuzhiyun 		if (color == IMG_FMT_XRGB8888)
416*4882a593Smuzhiyun 			cfg |= CIPRSCCTRL_RGB_FORMAT_24BIT;
417*4882a593Smuzhiyun 		cfg |= CIPRSCCTRL_SAMPLE;
418*4882a593Smuzhiyun 	}
419*4882a593Smuzhiyun 
420*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset), cfg);
421*4882a593Smuzhiyun 
422*4882a593Smuzhiyun 	pr_debug("main: h_ratio: %#x, v_ratio: %#x",
423*4882a593Smuzhiyun 		 scaler->main_h_ratio, scaler->main_v_ratio);
424*4882a593Smuzhiyun }
425*4882a593Smuzhiyun 
camif_s3c64xx_hw_set_scaler(struct camif_vp * vp)426*4882a593Smuzhiyun static void camif_s3c64xx_hw_set_scaler(struct camif_vp *vp)
427*4882a593Smuzhiyun {
428*4882a593Smuzhiyun 	struct camif_dev *camif = vp->camif;
429*4882a593Smuzhiyun 	struct camif_scaler *scaler = &vp->scaler;
430*4882a593Smuzhiyun 	unsigned int color = vp->out_fmt->color;
431*4882a593Smuzhiyun 	u32 cfg;
432*4882a593Smuzhiyun 
433*4882a593Smuzhiyun 	camif_hw_set_prescaler(vp);
434*4882a593Smuzhiyun 
435*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset));
436*4882a593Smuzhiyun 
437*4882a593Smuzhiyun 	cfg &= ~(CISCCTRL_CSCR2Y_WIDE | CISCCTRL_CSCY2R_WIDE
438*4882a593Smuzhiyun 		| CISCCTRL_SCALEUP_H | CISCCTRL_SCALEUP_V
439*4882a593Smuzhiyun 		| CISCCTRL_SCALERBYPASS | CISCCTRL_ONE2ONE
440*4882a593Smuzhiyun 		| CISCCTRL_INRGB_FMT_MASK | CISCCTRL_OUTRGB_FMT_MASK
441*4882a593Smuzhiyun 		| CISCCTRL_INTERLACE | CISCCTRL_EXTRGB_EXTENSION
442*4882a593Smuzhiyun 		| CISCCTRL_MAIN_RATIO_MASK);
443*4882a593Smuzhiyun 
444*4882a593Smuzhiyun 	cfg |= (CISCCTRL_CSCR2Y_WIDE | CISCCTRL_CSCY2R_WIDE);
445*4882a593Smuzhiyun 
446*4882a593Smuzhiyun 	if (!scaler->enable) {
447*4882a593Smuzhiyun 		cfg |= CISCCTRL_SCALERBYPASS;
448*4882a593Smuzhiyun 	} else {
449*4882a593Smuzhiyun 		if (scaler->scaleup_h)
450*4882a593Smuzhiyun 			cfg |= CISCCTRL_SCALEUP_H;
451*4882a593Smuzhiyun 		if (scaler->scaleup_v)
452*4882a593Smuzhiyun 			cfg |= CISCCTRL_SCALEUP_V;
453*4882a593Smuzhiyun 		if (scaler->copy)
454*4882a593Smuzhiyun 			cfg |= CISCCTRL_ONE2ONE;
455*4882a593Smuzhiyun 	}
456*4882a593Smuzhiyun 
457*4882a593Smuzhiyun 	switch (color) {
458*4882a593Smuzhiyun 	case IMG_FMT_RGB666:
459*4882a593Smuzhiyun 		cfg |= CISCCTRL_OUTRGB_FMT_RGB666;
460*4882a593Smuzhiyun 		break;
461*4882a593Smuzhiyun 	case IMG_FMT_XRGB8888:
462*4882a593Smuzhiyun 		cfg |= CISCCTRL_OUTRGB_FMT_RGB888;
463*4882a593Smuzhiyun 		break;
464*4882a593Smuzhiyun 	}
465*4882a593Smuzhiyun 
466*4882a593Smuzhiyun 	cfg |= (scaler->main_h_ratio & 0x1ff) << 16;
467*4882a593Smuzhiyun 	cfg |= scaler->main_v_ratio & 0x1ff;
468*4882a593Smuzhiyun 
469*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset), cfg);
470*4882a593Smuzhiyun 
471*4882a593Smuzhiyun 	pr_debug("main: h_ratio: %#x, v_ratio: %#x",
472*4882a593Smuzhiyun 		 scaler->main_h_ratio, scaler->main_v_ratio);
473*4882a593Smuzhiyun }
474*4882a593Smuzhiyun 
camif_hw_set_scaler(struct camif_vp * vp)475*4882a593Smuzhiyun void camif_hw_set_scaler(struct camif_vp *vp)
476*4882a593Smuzhiyun {
477*4882a593Smuzhiyun 	unsigned int ip_rev = vp->camif->variant->ip_revision;
478*4882a593Smuzhiyun 
479*4882a593Smuzhiyun 	if (ip_rev == S3C244X_CAMIF_IP_REV)
480*4882a593Smuzhiyun 		camif_s3c244x_hw_set_scaler(vp);
481*4882a593Smuzhiyun 	else
482*4882a593Smuzhiyun 		camif_s3c64xx_hw_set_scaler(vp);
483*4882a593Smuzhiyun }
484*4882a593Smuzhiyun 
camif_hw_enable_scaler(struct camif_vp * vp,bool on)485*4882a593Smuzhiyun void camif_hw_enable_scaler(struct camif_vp *vp, bool on)
486*4882a593Smuzhiyun {
487*4882a593Smuzhiyun 	u32 addr = S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset);
488*4882a593Smuzhiyun 	u32 cfg;
489*4882a593Smuzhiyun 
490*4882a593Smuzhiyun 	cfg = camif_read(vp->camif, addr);
491*4882a593Smuzhiyun 	if (on)
492*4882a593Smuzhiyun 		cfg |= CISCCTRL_SCALERSTART;
493*4882a593Smuzhiyun 	else
494*4882a593Smuzhiyun 		cfg &= ~CISCCTRL_SCALERSTART;
495*4882a593Smuzhiyun 	camif_write(vp->camif, addr, cfg);
496*4882a593Smuzhiyun }
497*4882a593Smuzhiyun 
camif_hw_set_lastirq(struct camif_vp * vp,int enable)498*4882a593Smuzhiyun void camif_hw_set_lastirq(struct camif_vp *vp, int enable)
499*4882a593Smuzhiyun {
500*4882a593Smuzhiyun 	u32 addr = S3C_CAMIF_REG_CICTRL(vp->id, vp->offset);
501*4882a593Smuzhiyun 	u32 cfg;
502*4882a593Smuzhiyun 
503*4882a593Smuzhiyun 	cfg = camif_read(vp->camif, addr);
504*4882a593Smuzhiyun 	if (enable)
505*4882a593Smuzhiyun 		cfg |= CICTRL_LASTIRQ_ENABLE;
506*4882a593Smuzhiyun 	else
507*4882a593Smuzhiyun 		cfg &= ~CICTRL_LASTIRQ_ENABLE;
508*4882a593Smuzhiyun 	camif_write(vp->camif, addr, cfg);
509*4882a593Smuzhiyun }
510*4882a593Smuzhiyun 
camif_hw_enable_capture(struct camif_vp * vp)511*4882a593Smuzhiyun void camif_hw_enable_capture(struct camif_vp *vp)
512*4882a593Smuzhiyun {
513*4882a593Smuzhiyun 	struct camif_dev *camif = vp->camif;
514*4882a593Smuzhiyun 	u32 cfg;
515*4882a593Smuzhiyun 
516*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CIIMGCPT(vp->offset));
517*4882a593Smuzhiyun 	camif->stream_count++;
518*4882a593Smuzhiyun 
519*4882a593Smuzhiyun 	if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV)
520*4882a593Smuzhiyun 		cfg |= CIIMGCPT_CPT_FREN_ENABLE(vp->id);
521*4882a593Smuzhiyun 
522*4882a593Smuzhiyun 	if (vp->scaler.enable)
523*4882a593Smuzhiyun 		cfg |= CIIMGCPT_IMGCPTEN_SC(vp->id);
524*4882a593Smuzhiyun 
525*4882a593Smuzhiyun 	if (camif->stream_count == 1)
526*4882a593Smuzhiyun 		cfg |= CIIMGCPT_IMGCPTEN;
527*4882a593Smuzhiyun 
528*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CIIMGCPT(vp->offset), cfg);
529*4882a593Smuzhiyun 
530*4882a593Smuzhiyun 	pr_debug("CIIMGCPT: %#x, camif->stream_count: %d\n",
531*4882a593Smuzhiyun 		 cfg, camif->stream_count);
532*4882a593Smuzhiyun }
533*4882a593Smuzhiyun 
camif_hw_disable_capture(struct camif_vp * vp)534*4882a593Smuzhiyun void camif_hw_disable_capture(struct camif_vp *vp)
535*4882a593Smuzhiyun {
536*4882a593Smuzhiyun 	struct camif_dev *camif = vp->camif;
537*4882a593Smuzhiyun 	u32 cfg;
538*4882a593Smuzhiyun 
539*4882a593Smuzhiyun 	cfg = camif_read(camif, S3C_CAMIF_REG_CIIMGCPT(vp->offset));
540*4882a593Smuzhiyun 	cfg &= ~CIIMGCPT_IMGCPTEN_SC(vp->id);
541*4882a593Smuzhiyun 
542*4882a593Smuzhiyun 	if (WARN_ON(--(camif->stream_count) < 0))
543*4882a593Smuzhiyun 		camif->stream_count = 0;
544*4882a593Smuzhiyun 
545*4882a593Smuzhiyun 	if (camif->stream_count == 0)
546*4882a593Smuzhiyun 		cfg &= ~CIIMGCPT_IMGCPTEN;
547*4882a593Smuzhiyun 
548*4882a593Smuzhiyun 	pr_debug("CIIMGCPT: %#x, camif->stream_count: %d\n",
549*4882a593Smuzhiyun 		 cfg, camif->stream_count);
550*4882a593Smuzhiyun 
551*4882a593Smuzhiyun 	camif_write(camif, S3C_CAMIF_REG_CIIMGCPT(vp->offset), cfg);
552*4882a593Smuzhiyun }
553*4882a593Smuzhiyun 
camif_hw_dump_regs(struct camif_dev * camif,const char * label)554*4882a593Smuzhiyun void camif_hw_dump_regs(struct camif_dev *camif, const char *label)
555*4882a593Smuzhiyun {
556*4882a593Smuzhiyun 	static const struct {
557*4882a593Smuzhiyun 		u32 offset;
558*4882a593Smuzhiyun 		const char * const name;
559*4882a593Smuzhiyun 	} registers[] = {
560*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CISRCFMT,		"CISRCFMT" },
561*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CIWDOFST,		"CIWDOFST" },
562*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CIGCTRL,		"CIGCTRL" },
563*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CIWDOFST2,		"CIWDOFST2" },
564*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CIYSA(0, 0),		"CICOYSA0" },
565*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CICBSA(0, 0),		"CICOCBSA0" },
566*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CICRSA(0, 0),		"CICOCRSA0" },
567*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CIYSA(0, 1),		"CICOYSA1" },
568*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CICBSA(0, 1),		"CICOCBSA1" },
569*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CICRSA(0, 1),		"CICOCRSA1" },
570*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CIYSA(0, 2),		"CICOYSA2" },
571*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CICBSA(0, 2),		"CICOCBSA2" },
572*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CICRSA(0, 2),		"CICOCRSA2" },
573*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CIYSA(0, 3),		"CICOYSA3" },
574*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CICBSA(0, 3),		"CICOCBSA3" },
575*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CICRSA(0, 3),		"CICOCRSA3" },
576*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CIYSA(1, 0),		"CIPRYSA0" },
577*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CIYSA(1, 1),		"CIPRYSA1" },
578*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CIYSA(1, 2),		"CIPRYSA2" },
579*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CIYSA(1, 3),		"CIPRYSA3" },
580*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CITRGFMT(0, 0),		"CICOTRGFMT" },
581*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CITRGFMT(1, 0),		"CIPRTRGFMT" },
582*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CICTRL(0, 0),		"CICOCTRL" },
583*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CICTRL(1, 0),		"CIPRCTRL" },
584*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CISCPREDST(0, 0),	"CICOSCPREDST" },
585*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CISCPREDST(1, 0),	"CIPRSCPREDST" },
586*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CISCPRERATIO(0, 0),	"CICOSCPRERATIO" },
587*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CISCPRERATIO(1, 0),	"CIPRSCPRERATIO" },
588*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CISCCTRL(0, 0),		"CICOSCCTRL" },
589*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CISCCTRL(1, 0),		"CIPRSCCTRL" },
590*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CITAREA(0, 0),		"CICOTAREA" },
591*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CITAREA(1, 0),		"CIPRTAREA" },
592*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CISTATUS(0, 0),		"CICOSTATUS" },
593*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CISTATUS(1, 0),		"CIPRSTATUS" },
594*4882a593Smuzhiyun 		{ S3C_CAMIF_REG_CIIMGCPT(0),		"CIIMGCPT" },
595*4882a593Smuzhiyun 	};
596*4882a593Smuzhiyun 	u32 i;
597*4882a593Smuzhiyun 
598*4882a593Smuzhiyun 	pr_info("--- %s ---\n", label);
599*4882a593Smuzhiyun 	for (i = 0; i < ARRAY_SIZE(registers); i++) {
600*4882a593Smuzhiyun 		u32 cfg = readl(camif->io_base + registers[i].offset);
601*4882a593Smuzhiyun 		dev_info(camif->dev, "%s:\t0x%08x\n", registers[i].name, cfg);
602*4882a593Smuzhiyun 	}
603*4882a593Smuzhiyun }
604