18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Samsung s3c24xx/s3c64xx SoC CAMIF driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
68c2ecf20Sopenharmony_ci * Copyright (C) 2012 Tomasz Figa <tomasz.figa@gmail.com>
78c2ecf20Sopenharmony_ci*/
88c2ecf20Sopenharmony_ci#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/delay.h>
118c2ecf20Sopenharmony_ci#include "camif-regs.h"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define camif_write(_camif, _off, _val)	writel(_val, (_camif)->io_base + (_off))
148c2ecf20Sopenharmony_ci#define camif_read(_camif, _off)	readl((_camif)->io_base + (_off))
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_civoid camif_hw_reset(struct camif_dev *camif)
178c2ecf20Sopenharmony_ci{
188c2ecf20Sopenharmony_ci	u32 cfg;
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CISRCFMT);
218c2ecf20Sopenharmony_ci	cfg |= CISRCFMT_ITU601_8BIT;
228c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CISRCFMT, cfg);
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci	/* S/W reset */
258c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CIGCTRL);
268c2ecf20Sopenharmony_ci	cfg |= CIGCTRL_SWRST;
278c2ecf20Sopenharmony_ci	if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV)
288c2ecf20Sopenharmony_ci		cfg |= CIGCTRL_IRQ_LEVEL;
298c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CIGCTRL, cfg);
308c2ecf20Sopenharmony_ci	udelay(10);
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CIGCTRL);
338c2ecf20Sopenharmony_ci	cfg &= ~CIGCTRL_SWRST;
348c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CIGCTRL, cfg);
358c2ecf20Sopenharmony_ci	udelay(10);
368c2ecf20Sopenharmony_ci}
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_civoid camif_hw_clear_pending_irq(struct camif_vp *vp)
398c2ecf20Sopenharmony_ci{
408c2ecf20Sopenharmony_ci	u32 cfg = camif_read(vp->camif, S3C_CAMIF_REG_CIGCTRL);
418c2ecf20Sopenharmony_ci	cfg |= CIGCTRL_IRQ_CLR(vp->id);
428c2ecf20Sopenharmony_ci	camif_write(vp->camif, S3C_CAMIF_REG_CIGCTRL, cfg);
438c2ecf20Sopenharmony_ci}
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/*
468c2ecf20Sopenharmony_ci * Sets video test pattern (off, color bar, horizontal or vertical gradient).
478c2ecf20Sopenharmony_ci * External sensor pixel clock must be active for the test pattern to work.
488c2ecf20Sopenharmony_ci */
498c2ecf20Sopenharmony_civoid camif_hw_set_test_pattern(struct camif_dev *camif, unsigned int pattern)
508c2ecf20Sopenharmony_ci{
518c2ecf20Sopenharmony_ci	u32 cfg = camif_read(camif, S3C_CAMIF_REG_CIGCTRL);
528c2ecf20Sopenharmony_ci	cfg &= ~CIGCTRL_TESTPATTERN_MASK;
538c2ecf20Sopenharmony_ci	cfg |= (pattern << 27);
548c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CIGCTRL, cfg);
558c2ecf20Sopenharmony_ci}
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_civoid camif_hw_set_effect(struct camif_dev *camif, unsigned int effect,
588c2ecf20Sopenharmony_ci			unsigned int cr, unsigned int cb)
598c2ecf20Sopenharmony_ci{
608c2ecf20Sopenharmony_ci	static const struct v4l2_control colorfx[] = {
618c2ecf20Sopenharmony_ci		{ V4L2_COLORFX_NONE,		CIIMGEFF_FIN_BYPASS },
628c2ecf20Sopenharmony_ci		{ V4L2_COLORFX_BW,		CIIMGEFF_FIN_ARBITRARY },
638c2ecf20Sopenharmony_ci		{ V4L2_COLORFX_SEPIA,		CIIMGEFF_FIN_ARBITRARY },
648c2ecf20Sopenharmony_ci		{ V4L2_COLORFX_NEGATIVE,	CIIMGEFF_FIN_NEGATIVE },
658c2ecf20Sopenharmony_ci		{ V4L2_COLORFX_ART_FREEZE,	CIIMGEFF_FIN_ARTFREEZE },
668c2ecf20Sopenharmony_ci		{ V4L2_COLORFX_EMBOSS,		CIIMGEFF_FIN_EMBOSSING },
678c2ecf20Sopenharmony_ci		{ V4L2_COLORFX_SILHOUETTE,	CIIMGEFF_FIN_SILHOUETTE },
688c2ecf20Sopenharmony_ci		{ V4L2_COLORFX_SET_CBCR,	CIIMGEFF_FIN_ARBITRARY },
698c2ecf20Sopenharmony_ci	};
708c2ecf20Sopenharmony_ci	unsigned int i, cfg;
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(colorfx); i++)
738c2ecf20Sopenharmony_ci		if (colorfx[i].id == effect)
748c2ecf20Sopenharmony_ci			break;
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	if (i == ARRAY_SIZE(colorfx))
778c2ecf20Sopenharmony_ci		return;
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CIIMGEFF(camif->vp->offset));
808c2ecf20Sopenharmony_ci	/* Set effect */
818c2ecf20Sopenharmony_ci	cfg &= ~CIIMGEFF_FIN_MASK;
828c2ecf20Sopenharmony_ci	cfg |= colorfx[i].value;
838c2ecf20Sopenharmony_ci	/* Set both paths */
848c2ecf20Sopenharmony_ci	if (camif->variant->ip_revision >= S3C6400_CAMIF_IP_REV) {
858c2ecf20Sopenharmony_ci		if (effect == V4L2_COLORFX_NONE)
868c2ecf20Sopenharmony_ci			cfg &= ~CIIMGEFF_IE_ENABLE_MASK;
878c2ecf20Sopenharmony_ci		else
888c2ecf20Sopenharmony_ci			cfg |= CIIMGEFF_IE_ENABLE_MASK;
898c2ecf20Sopenharmony_ci	}
908c2ecf20Sopenharmony_ci	cfg &= ~CIIMGEFF_PAT_CBCR_MASK;
918c2ecf20Sopenharmony_ci	cfg |= cr | (cb << 13);
928c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CIIMGEFF(camif->vp->offset), cfg);
938c2ecf20Sopenharmony_ci}
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_cistatic const u32 src_pixfmt_map[8][2] = {
968c2ecf20Sopenharmony_ci	{ MEDIA_BUS_FMT_YUYV8_2X8, CISRCFMT_ORDER422_YCBYCR },
978c2ecf20Sopenharmony_ci	{ MEDIA_BUS_FMT_YVYU8_2X8, CISRCFMT_ORDER422_YCRYCB },
988c2ecf20Sopenharmony_ci	{ MEDIA_BUS_FMT_UYVY8_2X8, CISRCFMT_ORDER422_CBYCRY },
998c2ecf20Sopenharmony_ci	{ MEDIA_BUS_FMT_VYUY8_2X8, CISRCFMT_ORDER422_CRYCBY },
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci/* Set camera input pixel format and resolution */
1038c2ecf20Sopenharmony_civoid camif_hw_set_source_format(struct camif_dev *camif)
1048c2ecf20Sopenharmony_ci{
1058c2ecf20Sopenharmony_ci	struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
1068c2ecf20Sopenharmony_ci	int i;
1078c2ecf20Sopenharmony_ci	u32 cfg;
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci	for (i = ARRAY_SIZE(src_pixfmt_map) - 1; i >= 0; i--) {
1108c2ecf20Sopenharmony_ci		if (src_pixfmt_map[i][0] == mf->code)
1118c2ecf20Sopenharmony_ci			break;
1128c2ecf20Sopenharmony_ci	}
1138c2ecf20Sopenharmony_ci	if (i < 0) {
1148c2ecf20Sopenharmony_ci		i = 0;
1158c2ecf20Sopenharmony_ci		dev_err(camif->dev,
1168c2ecf20Sopenharmony_ci			"Unsupported pixel code, falling back to %#08x\n",
1178c2ecf20Sopenharmony_ci			src_pixfmt_map[i][0]);
1188c2ecf20Sopenharmony_ci	}
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CISRCFMT);
1218c2ecf20Sopenharmony_ci	cfg &= ~(CISRCFMT_ORDER422_MASK | CISRCFMT_SIZE_CAM_MASK);
1228c2ecf20Sopenharmony_ci	cfg |= (mf->width << 16) | mf->height;
1238c2ecf20Sopenharmony_ci	cfg |= src_pixfmt_map[i][1];
1248c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CISRCFMT, cfg);
1258c2ecf20Sopenharmony_ci}
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci/* Set the camera host input window offsets (cropping) */
1288c2ecf20Sopenharmony_civoid camif_hw_set_camera_crop(struct camif_dev *camif)
1298c2ecf20Sopenharmony_ci{
1308c2ecf20Sopenharmony_ci	struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
1318c2ecf20Sopenharmony_ci	struct v4l2_rect *crop = &camif->camif_crop;
1328c2ecf20Sopenharmony_ci	u32 hoff2, voff2;
1338c2ecf20Sopenharmony_ci	u32 cfg;
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci	/* Note: s3c244x requirement: left = f_width - rect.width / 2 */
1368c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CIWDOFST);
1378c2ecf20Sopenharmony_ci	cfg &= ~(CIWDOFST_OFST_MASK | CIWDOFST_WINOFSEN);
1388c2ecf20Sopenharmony_ci	cfg |= (crop->left << 16) | crop->top;
1398c2ecf20Sopenharmony_ci	if (crop->left != 0 || crop->top != 0)
1408c2ecf20Sopenharmony_ci		cfg |= CIWDOFST_WINOFSEN;
1418c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CIWDOFST, cfg);
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci	if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV) {
1448c2ecf20Sopenharmony_ci		hoff2 = mf->width - crop->width - crop->left;
1458c2ecf20Sopenharmony_ci		voff2 = mf->height - crop->height - crop->top;
1468c2ecf20Sopenharmony_ci		cfg = (hoff2 << 16) | voff2;
1478c2ecf20Sopenharmony_ci		camif_write(camif, S3C_CAMIF_REG_CIWDOFST2, cfg);
1488c2ecf20Sopenharmony_ci	}
1498c2ecf20Sopenharmony_ci}
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_civoid camif_hw_clear_fifo_overflow(struct camif_vp *vp)
1528c2ecf20Sopenharmony_ci{
1538c2ecf20Sopenharmony_ci	struct camif_dev *camif = vp->camif;
1548c2ecf20Sopenharmony_ci	u32 cfg;
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CIWDOFST);
1578c2ecf20Sopenharmony_ci	if (vp->id == 0)
1588c2ecf20Sopenharmony_ci		cfg |= (CIWDOFST_CLROVCOFIY | CIWDOFST_CLROVCOFICB |
1598c2ecf20Sopenharmony_ci			CIWDOFST_CLROVCOFICR);
1608c2ecf20Sopenharmony_ci	else
1618c2ecf20Sopenharmony_ci		cfg |= (/* CIWDOFST_CLROVPRFIY | */ CIWDOFST_CLROVPRFICB |
1628c2ecf20Sopenharmony_ci			CIWDOFST_CLROVPRFICR);
1638c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CIWDOFST, cfg);
1648c2ecf20Sopenharmony_ci}
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci/* Set video bus signals polarity */
1678c2ecf20Sopenharmony_civoid camif_hw_set_camera_bus(struct camif_dev *camif)
1688c2ecf20Sopenharmony_ci{
1698c2ecf20Sopenharmony_ci	unsigned int flags = camif->pdata.sensor.flags;
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci	u32 cfg = camif_read(camif, S3C_CAMIF_REG_CIGCTRL);
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci	cfg &= ~(CIGCTRL_INVPOLPCLK | CIGCTRL_INVPOLVSYNC |
1748c2ecf20Sopenharmony_ci		 CIGCTRL_INVPOLHREF | CIGCTRL_INVPOLFIELD);
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci	if (flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
1778c2ecf20Sopenharmony_ci		cfg |= CIGCTRL_INVPOLPCLK;
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci	if (flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
1808c2ecf20Sopenharmony_ci		cfg |= CIGCTRL_INVPOLVSYNC;
1818c2ecf20Sopenharmony_ci	/*
1828c2ecf20Sopenharmony_ci	 * HREF is normally high during frame active data
1838c2ecf20Sopenharmony_ci	 * transmission and low during horizontal synchronization
1848c2ecf20Sopenharmony_ci	 * period. Thus HREF active high means HSYNC active low.
1858c2ecf20Sopenharmony_ci	 */
1868c2ecf20Sopenharmony_ci	if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
1878c2ecf20Sopenharmony_ci		cfg |= CIGCTRL_INVPOLHREF; /* HREF active low */
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci	if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV) {
1908c2ecf20Sopenharmony_ci		if (flags & V4L2_MBUS_FIELD_EVEN_LOW)
1918c2ecf20Sopenharmony_ci			cfg |= CIGCTRL_INVPOLFIELD;
1928c2ecf20Sopenharmony_ci		cfg |= CIGCTRL_FIELDMODE;
1938c2ecf20Sopenharmony_ci	}
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci	pr_debug("Setting CIGCTRL to: %#x\n", cfg);
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CIGCTRL, cfg);
1988c2ecf20Sopenharmony_ci}
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_civoid camif_hw_set_output_addr(struct camif_vp *vp,
2018c2ecf20Sopenharmony_ci			      struct camif_addr *paddr, int i)
2028c2ecf20Sopenharmony_ci{
2038c2ecf20Sopenharmony_ci	struct camif_dev *camif = vp->camif;
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CIYSA(vp->id, i), paddr->y);
2068c2ecf20Sopenharmony_ci	if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV
2078c2ecf20Sopenharmony_ci		|| vp->id == VP_CODEC) {
2088c2ecf20Sopenharmony_ci		camif_write(camif, S3C_CAMIF_REG_CICBSA(vp->id, i),
2098c2ecf20Sopenharmony_ci								paddr->cb);
2108c2ecf20Sopenharmony_ci		camif_write(camif, S3C_CAMIF_REG_CICRSA(vp->id, i),
2118c2ecf20Sopenharmony_ci								paddr->cr);
2128c2ecf20Sopenharmony_ci	}
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci	pr_debug("dst_buf[%d]: %pad, cb: %pad, cr: %pad\n",
2158c2ecf20Sopenharmony_ci		 i, &paddr->y, &paddr->cb, &paddr->cr);
2168c2ecf20Sopenharmony_ci}
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_cistatic void camif_hw_set_out_dma_size(struct camif_vp *vp)
2198c2ecf20Sopenharmony_ci{
2208c2ecf20Sopenharmony_ci	struct camif_frame *frame = &vp->out_frame;
2218c2ecf20Sopenharmony_ci	u32 cfg;
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci	cfg = camif_read(vp->camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset));
2248c2ecf20Sopenharmony_ci	cfg &= ~CITRGFMT_TARGETSIZE_MASK;
2258c2ecf20Sopenharmony_ci	cfg |= (frame->f_width << 16) | frame->f_height;
2268c2ecf20Sopenharmony_ci	camif_write(vp->camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset), cfg);
2278c2ecf20Sopenharmony_ci}
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_cistatic void camif_get_dma_burst(u32 width, u32 ybpp, u32 *mburst, u32 *rburst)
2308c2ecf20Sopenharmony_ci{
2318c2ecf20Sopenharmony_ci	unsigned int nwords = width * ybpp / 4;
2328c2ecf20Sopenharmony_ci	unsigned int div, rem;
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci	if (WARN_ON(width < 8 || (width * ybpp) & 7))
2358c2ecf20Sopenharmony_ci		return;
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci	for (div = 16; div >= 2; div /= 2) {
2388c2ecf20Sopenharmony_ci		if (nwords < div)
2398c2ecf20Sopenharmony_ci			continue;
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci		rem = nwords & (div - 1);
2428c2ecf20Sopenharmony_ci		if (rem == 0) {
2438c2ecf20Sopenharmony_ci			*mburst = div;
2448c2ecf20Sopenharmony_ci			*rburst = div;
2458c2ecf20Sopenharmony_ci			break;
2468c2ecf20Sopenharmony_ci		}
2478c2ecf20Sopenharmony_ci		if (rem == div / 2 || rem == div / 4) {
2488c2ecf20Sopenharmony_ci			*mburst = div;
2498c2ecf20Sopenharmony_ci			*rburst = rem;
2508c2ecf20Sopenharmony_ci			break;
2518c2ecf20Sopenharmony_ci		}
2528c2ecf20Sopenharmony_ci	}
2538c2ecf20Sopenharmony_ci}
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_civoid camif_hw_set_output_dma(struct camif_vp *vp)
2568c2ecf20Sopenharmony_ci{
2578c2ecf20Sopenharmony_ci	struct camif_dev *camif = vp->camif;
2588c2ecf20Sopenharmony_ci	struct camif_frame *frame = &vp->out_frame;
2598c2ecf20Sopenharmony_ci	const struct camif_fmt *fmt = vp->out_fmt;
2608c2ecf20Sopenharmony_ci	unsigned int ymburst = 0, yrburst = 0;
2618c2ecf20Sopenharmony_ci	u32 cfg;
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci	camif_hw_set_out_dma_size(vp);
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci	if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV) {
2668c2ecf20Sopenharmony_ci		struct camif_dma_offset *offset = &frame->dma_offset;
2678c2ecf20Sopenharmony_ci		/* Set the input dma offsets. */
2688c2ecf20Sopenharmony_ci		cfg = S3C_CISS_OFFS_INITIAL(offset->initial);
2698c2ecf20Sopenharmony_ci		cfg |= S3C_CISS_OFFS_LINE(offset->line);
2708c2ecf20Sopenharmony_ci		camif_write(camif, S3C_CAMIF_REG_CISSY(vp->id), cfg);
2718c2ecf20Sopenharmony_ci		camif_write(camif, S3C_CAMIF_REG_CISSCB(vp->id), cfg);
2728c2ecf20Sopenharmony_ci		camif_write(camif, S3C_CAMIF_REG_CISSCR(vp->id), cfg);
2738c2ecf20Sopenharmony_ci	}
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci	/* Configure DMA burst values */
2768c2ecf20Sopenharmony_ci	camif_get_dma_burst(frame->rect.width, fmt->ybpp, &ymburst, &yrburst);
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CICTRL(vp->id, vp->offset));
2798c2ecf20Sopenharmony_ci	cfg &= ~CICTRL_BURST_MASK;
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci	cfg |= CICTRL_YBURST1(ymburst) | CICTRL_YBURST2(yrburst);
2828c2ecf20Sopenharmony_ci	cfg |= CICTRL_CBURST1(ymburst / 2) | CICTRL_CBURST2(yrburst / 2);
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CICTRL(vp->id, vp->offset), cfg);
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci	pr_debug("ymburst: %u, yrburst: %u\n", ymburst, yrburst);
2878c2ecf20Sopenharmony_ci}
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_civoid camif_hw_set_input_path(struct camif_vp *vp)
2908c2ecf20Sopenharmony_ci{
2918c2ecf20Sopenharmony_ci	u32 cfg = camif_read(vp->camif, S3C_CAMIF_REG_MSCTRL(vp->id));
2928c2ecf20Sopenharmony_ci	cfg &= ~MSCTRL_SEL_DMA_CAM;
2938c2ecf20Sopenharmony_ci	camif_write(vp->camif, S3C_CAMIF_REG_MSCTRL(vp->id), cfg);
2948c2ecf20Sopenharmony_ci}
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_civoid camif_hw_set_target_format(struct camif_vp *vp)
2978c2ecf20Sopenharmony_ci{
2988c2ecf20Sopenharmony_ci	struct camif_dev *camif = vp->camif;
2998c2ecf20Sopenharmony_ci	struct camif_frame *frame = &vp->out_frame;
3008c2ecf20Sopenharmony_ci	u32 cfg;
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci	pr_debug("fw: %d, fh: %d color: %d\n", frame->f_width,
3038c2ecf20Sopenharmony_ci		 frame->f_height, vp->out_fmt->color);
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset));
3068c2ecf20Sopenharmony_ci	cfg &= ~CITRGFMT_TARGETSIZE_MASK;
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci	if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV) {
3098c2ecf20Sopenharmony_ci		/* We currently support only YCbCr 4:2:2 at the camera input */
3108c2ecf20Sopenharmony_ci		cfg |= CITRGFMT_IN422;
3118c2ecf20Sopenharmony_ci		cfg &= ~CITRGFMT_OUT422;
3128c2ecf20Sopenharmony_ci		if (vp->out_fmt->color == IMG_FMT_YCBCR422P)
3138c2ecf20Sopenharmony_ci			cfg |= CITRGFMT_OUT422;
3148c2ecf20Sopenharmony_ci	} else {
3158c2ecf20Sopenharmony_ci		cfg &= ~CITRGFMT_OUTFORMAT_MASK;
3168c2ecf20Sopenharmony_ci		switch (vp->out_fmt->color) {
3178c2ecf20Sopenharmony_ci		case IMG_FMT_RGB565...IMG_FMT_XRGB8888:
3188c2ecf20Sopenharmony_ci			cfg |= CITRGFMT_OUTFORMAT_RGB;
3198c2ecf20Sopenharmony_ci			break;
3208c2ecf20Sopenharmony_ci		case IMG_FMT_YCBCR420...IMG_FMT_YCRCB420:
3218c2ecf20Sopenharmony_ci			cfg |= CITRGFMT_OUTFORMAT_YCBCR420;
3228c2ecf20Sopenharmony_ci			break;
3238c2ecf20Sopenharmony_ci		case IMG_FMT_YCBCR422P:
3248c2ecf20Sopenharmony_ci			cfg |= CITRGFMT_OUTFORMAT_YCBCR422;
3258c2ecf20Sopenharmony_ci			break;
3268c2ecf20Sopenharmony_ci		case IMG_FMT_YCBYCR422...IMG_FMT_CRYCBY422:
3278c2ecf20Sopenharmony_ci			cfg |= CITRGFMT_OUTFORMAT_YCBCR422I;
3288c2ecf20Sopenharmony_ci			break;
3298c2ecf20Sopenharmony_ci		}
3308c2ecf20Sopenharmony_ci	}
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_ci	/* Rotation is only supported by s3c64xx */
3338c2ecf20Sopenharmony_ci	if (vp->rotation == 90 || vp->rotation == 270)
3348c2ecf20Sopenharmony_ci		cfg |= (frame->f_height << 16) | frame->f_width;
3358c2ecf20Sopenharmony_ci	else
3368c2ecf20Sopenharmony_ci		cfg |= (frame->f_width << 16) | frame->f_height;
3378c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset), cfg);
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci	/* Target area, output pixel width * height */
3408c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CITAREA(vp->id, vp->offset));
3418c2ecf20Sopenharmony_ci	cfg &= ~CITAREA_MASK;
3428c2ecf20Sopenharmony_ci	cfg |= (frame->f_width * frame->f_height);
3438c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CITAREA(vp->id, vp->offset), cfg);
3448c2ecf20Sopenharmony_ci}
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_civoid camif_hw_set_flip(struct camif_vp *vp)
3478c2ecf20Sopenharmony_ci{
3488c2ecf20Sopenharmony_ci	u32 cfg = camif_read(vp->camif,
3498c2ecf20Sopenharmony_ci				S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset));
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci	cfg &= ~CITRGFMT_FLIP_MASK;
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci	if (vp->hflip)
3548c2ecf20Sopenharmony_ci		cfg |= CITRGFMT_FLIP_Y_MIRROR;
3558c2ecf20Sopenharmony_ci	if (vp->vflip)
3568c2ecf20Sopenharmony_ci		cfg |= CITRGFMT_FLIP_X_MIRROR;
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci	camif_write(vp->camif, S3C_CAMIF_REG_CITRGFMT(vp->id, vp->offset), cfg);
3598c2ecf20Sopenharmony_ci}
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_cistatic void camif_hw_set_prescaler(struct camif_vp *vp)
3628c2ecf20Sopenharmony_ci{
3638c2ecf20Sopenharmony_ci	struct camif_dev *camif = vp->camif;
3648c2ecf20Sopenharmony_ci	struct camif_scaler *sc = &vp->scaler;
3658c2ecf20Sopenharmony_ci	u32 cfg, shfactor, addr;
3668c2ecf20Sopenharmony_ci
3678c2ecf20Sopenharmony_ci	addr = S3C_CAMIF_REG_CISCPRERATIO(vp->id, vp->offset);
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ci	shfactor = 10 - (sc->h_shift + sc->v_shift);
3708c2ecf20Sopenharmony_ci	cfg = shfactor << 28;
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	cfg |= (sc->pre_h_ratio << 16) | sc->pre_v_ratio;
3738c2ecf20Sopenharmony_ci	camif_write(camif, addr, cfg);
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ci	cfg = (sc->pre_dst_width << 16) | sc->pre_dst_height;
3768c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CISCPREDST(vp->id, vp->offset), cfg);
3778c2ecf20Sopenharmony_ci}
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_cistatic void camif_s3c244x_hw_set_scaler(struct camif_vp *vp)
3808c2ecf20Sopenharmony_ci{
3818c2ecf20Sopenharmony_ci	struct camif_dev *camif = vp->camif;
3828c2ecf20Sopenharmony_ci	struct camif_scaler *scaler = &vp->scaler;
3838c2ecf20Sopenharmony_ci	unsigned int color = vp->out_fmt->color;
3848c2ecf20Sopenharmony_ci	u32 cfg;
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci	camif_hw_set_prescaler(vp);
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset));
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci	cfg &= ~(CISCCTRL_SCALEUP_MASK | CISCCTRL_SCALERBYPASS |
3918c2ecf20Sopenharmony_ci		 CISCCTRL_MAIN_RATIO_MASK | CIPRSCCTRL_RGB_FORMAT_24BIT);
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci	if (scaler->enable) {
3948c2ecf20Sopenharmony_ci		if (scaler->scaleup_h) {
3958c2ecf20Sopenharmony_ci			if (vp->id == VP_CODEC)
3968c2ecf20Sopenharmony_ci				cfg |= CISCCTRL_SCALEUP_H;
3978c2ecf20Sopenharmony_ci			else
3988c2ecf20Sopenharmony_ci				cfg |= CIPRSCCTRL_SCALEUP_H;
3998c2ecf20Sopenharmony_ci		}
4008c2ecf20Sopenharmony_ci		if (scaler->scaleup_v) {
4018c2ecf20Sopenharmony_ci			if (vp->id == VP_CODEC)
4028c2ecf20Sopenharmony_ci				cfg |= CISCCTRL_SCALEUP_V;
4038c2ecf20Sopenharmony_ci			else
4048c2ecf20Sopenharmony_ci				cfg |= CIPRSCCTRL_SCALEUP_V;
4058c2ecf20Sopenharmony_ci		}
4068c2ecf20Sopenharmony_ci	} else {
4078c2ecf20Sopenharmony_ci		if (vp->id == VP_CODEC)
4088c2ecf20Sopenharmony_ci			cfg |= CISCCTRL_SCALERBYPASS;
4098c2ecf20Sopenharmony_ci	}
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_ci	cfg |= ((scaler->main_h_ratio & 0x1ff) << 16);
4128c2ecf20Sopenharmony_ci	cfg |= scaler->main_v_ratio & 0x1ff;
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci	if (vp->id == VP_PREVIEW) {
4158c2ecf20Sopenharmony_ci		if (color == IMG_FMT_XRGB8888)
4168c2ecf20Sopenharmony_ci			cfg |= CIPRSCCTRL_RGB_FORMAT_24BIT;
4178c2ecf20Sopenharmony_ci		cfg |= CIPRSCCTRL_SAMPLE;
4188c2ecf20Sopenharmony_ci	}
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset), cfg);
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci	pr_debug("main: h_ratio: %#x, v_ratio: %#x",
4238c2ecf20Sopenharmony_ci		 scaler->main_h_ratio, scaler->main_v_ratio);
4248c2ecf20Sopenharmony_ci}
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_cistatic void camif_s3c64xx_hw_set_scaler(struct camif_vp *vp)
4278c2ecf20Sopenharmony_ci{
4288c2ecf20Sopenharmony_ci	struct camif_dev *camif = vp->camif;
4298c2ecf20Sopenharmony_ci	struct camif_scaler *scaler = &vp->scaler;
4308c2ecf20Sopenharmony_ci	unsigned int color = vp->out_fmt->color;
4318c2ecf20Sopenharmony_ci	u32 cfg;
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ci	camif_hw_set_prescaler(vp);
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset));
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci	cfg &= ~(CISCCTRL_CSCR2Y_WIDE | CISCCTRL_CSCY2R_WIDE
4388c2ecf20Sopenharmony_ci		| CISCCTRL_SCALEUP_H | CISCCTRL_SCALEUP_V
4398c2ecf20Sopenharmony_ci		| CISCCTRL_SCALERBYPASS | CISCCTRL_ONE2ONE
4408c2ecf20Sopenharmony_ci		| CISCCTRL_INRGB_FMT_MASK | CISCCTRL_OUTRGB_FMT_MASK
4418c2ecf20Sopenharmony_ci		| CISCCTRL_INTERLACE | CISCCTRL_EXTRGB_EXTENSION
4428c2ecf20Sopenharmony_ci		| CISCCTRL_MAIN_RATIO_MASK);
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_ci	cfg |= (CISCCTRL_CSCR2Y_WIDE | CISCCTRL_CSCY2R_WIDE);
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci	if (!scaler->enable) {
4478c2ecf20Sopenharmony_ci		cfg |= CISCCTRL_SCALERBYPASS;
4488c2ecf20Sopenharmony_ci	} else {
4498c2ecf20Sopenharmony_ci		if (scaler->scaleup_h)
4508c2ecf20Sopenharmony_ci			cfg |= CISCCTRL_SCALEUP_H;
4518c2ecf20Sopenharmony_ci		if (scaler->scaleup_v)
4528c2ecf20Sopenharmony_ci			cfg |= CISCCTRL_SCALEUP_V;
4538c2ecf20Sopenharmony_ci		if (scaler->copy)
4548c2ecf20Sopenharmony_ci			cfg |= CISCCTRL_ONE2ONE;
4558c2ecf20Sopenharmony_ci	}
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_ci	switch (color) {
4588c2ecf20Sopenharmony_ci	case IMG_FMT_RGB666:
4598c2ecf20Sopenharmony_ci		cfg |= CISCCTRL_OUTRGB_FMT_RGB666;
4608c2ecf20Sopenharmony_ci		break;
4618c2ecf20Sopenharmony_ci	case IMG_FMT_XRGB8888:
4628c2ecf20Sopenharmony_ci		cfg |= CISCCTRL_OUTRGB_FMT_RGB888;
4638c2ecf20Sopenharmony_ci		break;
4648c2ecf20Sopenharmony_ci	}
4658c2ecf20Sopenharmony_ci
4668c2ecf20Sopenharmony_ci	cfg |= (scaler->main_h_ratio & 0x1ff) << 16;
4678c2ecf20Sopenharmony_ci	cfg |= scaler->main_v_ratio & 0x1ff;
4688c2ecf20Sopenharmony_ci
4698c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset), cfg);
4708c2ecf20Sopenharmony_ci
4718c2ecf20Sopenharmony_ci	pr_debug("main: h_ratio: %#x, v_ratio: %#x",
4728c2ecf20Sopenharmony_ci		 scaler->main_h_ratio, scaler->main_v_ratio);
4738c2ecf20Sopenharmony_ci}
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_civoid camif_hw_set_scaler(struct camif_vp *vp)
4768c2ecf20Sopenharmony_ci{
4778c2ecf20Sopenharmony_ci	unsigned int ip_rev = vp->camif->variant->ip_revision;
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_ci	if (ip_rev == S3C244X_CAMIF_IP_REV)
4808c2ecf20Sopenharmony_ci		camif_s3c244x_hw_set_scaler(vp);
4818c2ecf20Sopenharmony_ci	else
4828c2ecf20Sopenharmony_ci		camif_s3c64xx_hw_set_scaler(vp);
4838c2ecf20Sopenharmony_ci}
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_civoid camif_hw_enable_scaler(struct camif_vp *vp, bool on)
4868c2ecf20Sopenharmony_ci{
4878c2ecf20Sopenharmony_ci	u32 addr = S3C_CAMIF_REG_CISCCTRL(vp->id, vp->offset);
4888c2ecf20Sopenharmony_ci	u32 cfg;
4898c2ecf20Sopenharmony_ci
4908c2ecf20Sopenharmony_ci	cfg = camif_read(vp->camif, addr);
4918c2ecf20Sopenharmony_ci	if (on)
4928c2ecf20Sopenharmony_ci		cfg |= CISCCTRL_SCALERSTART;
4938c2ecf20Sopenharmony_ci	else
4948c2ecf20Sopenharmony_ci		cfg &= ~CISCCTRL_SCALERSTART;
4958c2ecf20Sopenharmony_ci	camif_write(vp->camif, addr, cfg);
4968c2ecf20Sopenharmony_ci}
4978c2ecf20Sopenharmony_ci
4988c2ecf20Sopenharmony_civoid camif_hw_set_lastirq(struct camif_vp *vp, int enable)
4998c2ecf20Sopenharmony_ci{
5008c2ecf20Sopenharmony_ci	u32 addr = S3C_CAMIF_REG_CICTRL(vp->id, vp->offset);
5018c2ecf20Sopenharmony_ci	u32 cfg;
5028c2ecf20Sopenharmony_ci
5038c2ecf20Sopenharmony_ci	cfg = camif_read(vp->camif, addr);
5048c2ecf20Sopenharmony_ci	if (enable)
5058c2ecf20Sopenharmony_ci		cfg |= CICTRL_LASTIRQ_ENABLE;
5068c2ecf20Sopenharmony_ci	else
5078c2ecf20Sopenharmony_ci		cfg &= ~CICTRL_LASTIRQ_ENABLE;
5088c2ecf20Sopenharmony_ci	camif_write(vp->camif, addr, cfg);
5098c2ecf20Sopenharmony_ci}
5108c2ecf20Sopenharmony_ci
5118c2ecf20Sopenharmony_civoid camif_hw_enable_capture(struct camif_vp *vp)
5128c2ecf20Sopenharmony_ci{
5138c2ecf20Sopenharmony_ci	struct camif_dev *camif = vp->camif;
5148c2ecf20Sopenharmony_ci	u32 cfg;
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CIIMGCPT(vp->offset));
5178c2ecf20Sopenharmony_ci	camif->stream_count++;
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci	if (camif->variant->ip_revision == S3C6410_CAMIF_IP_REV)
5208c2ecf20Sopenharmony_ci		cfg |= CIIMGCPT_CPT_FREN_ENABLE(vp->id);
5218c2ecf20Sopenharmony_ci
5228c2ecf20Sopenharmony_ci	if (vp->scaler.enable)
5238c2ecf20Sopenharmony_ci		cfg |= CIIMGCPT_IMGCPTEN_SC(vp->id);
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci	if (camif->stream_count == 1)
5268c2ecf20Sopenharmony_ci		cfg |= CIIMGCPT_IMGCPTEN;
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CIIMGCPT(vp->offset), cfg);
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_ci	pr_debug("CIIMGCPT: %#x, camif->stream_count: %d\n",
5318c2ecf20Sopenharmony_ci		 cfg, camif->stream_count);
5328c2ecf20Sopenharmony_ci}
5338c2ecf20Sopenharmony_ci
5348c2ecf20Sopenharmony_civoid camif_hw_disable_capture(struct camif_vp *vp)
5358c2ecf20Sopenharmony_ci{
5368c2ecf20Sopenharmony_ci	struct camif_dev *camif = vp->camif;
5378c2ecf20Sopenharmony_ci	u32 cfg;
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_ci	cfg = camif_read(camif, S3C_CAMIF_REG_CIIMGCPT(vp->offset));
5408c2ecf20Sopenharmony_ci	cfg &= ~CIIMGCPT_IMGCPTEN_SC(vp->id);
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_ci	if (WARN_ON(--(camif->stream_count) < 0))
5438c2ecf20Sopenharmony_ci		camif->stream_count = 0;
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci	if (camif->stream_count == 0)
5468c2ecf20Sopenharmony_ci		cfg &= ~CIIMGCPT_IMGCPTEN;
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_ci	pr_debug("CIIMGCPT: %#x, camif->stream_count: %d\n",
5498c2ecf20Sopenharmony_ci		 cfg, camif->stream_count);
5508c2ecf20Sopenharmony_ci
5518c2ecf20Sopenharmony_ci	camif_write(camif, S3C_CAMIF_REG_CIIMGCPT(vp->offset), cfg);
5528c2ecf20Sopenharmony_ci}
5538c2ecf20Sopenharmony_ci
5548c2ecf20Sopenharmony_civoid camif_hw_dump_regs(struct camif_dev *camif, const char *label)
5558c2ecf20Sopenharmony_ci{
5568c2ecf20Sopenharmony_ci	static const struct {
5578c2ecf20Sopenharmony_ci		u32 offset;
5588c2ecf20Sopenharmony_ci		const char * const name;
5598c2ecf20Sopenharmony_ci	} registers[] = {
5608c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CISRCFMT,		"CISRCFMT" },
5618c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CIWDOFST,		"CIWDOFST" },
5628c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CIGCTRL,		"CIGCTRL" },
5638c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CIWDOFST2,		"CIWDOFST2" },
5648c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CIYSA(0, 0),		"CICOYSA0" },
5658c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CICBSA(0, 0),		"CICOCBSA0" },
5668c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CICRSA(0, 0),		"CICOCRSA0" },
5678c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CIYSA(0, 1),		"CICOYSA1" },
5688c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CICBSA(0, 1),		"CICOCBSA1" },
5698c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CICRSA(0, 1),		"CICOCRSA1" },
5708c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CIYSA(0, 2),		"CICOYSA2" },
5718c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CICBSA(0, 2),		"CICOCBSA2" },
5728c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CICRSA(0, 2),		"CICOCRSA2" },
5738c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CIYSA(0, 3),		"CICOYSA3" },
5748c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CICBSA(0, 3),		"CICOCBSA3" },
5758c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CICRSA(0, 3),		"CICOCRSA3" },
5768c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CIYSA(1, 0),		"CIPRYSA0" },
5778c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CIYSA(1, 1),		"CIPRYSA1" },
5788c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CIYSA(1, 2),		"CIPRYSA2" },
5798c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CIYSA(1, 3),		"CIPRYSA3" },
5808c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CITRGFMT(0, 0),		"CICOTRGFMT" },
5818c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CITRGFMT(1, 0),		"CIPRTRGFMT" },
5828c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CICTRL(0, 0),		"CICOCTRL" },
5838c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CICTRL(1, 0),		"CIPRCTRL" },
5848c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CISCPREDST(0, 0),	"CICOSCPREDST" },
5858c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CISCPREDST(1, 0),	"CIPRSCPREDST" },
5868c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CISCPRERATIO(0, 0),	"CICOSCPRERATIO" },
5878c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CISCPRERATIO(1, 0),	"CIPRSCPRERATIO" },
5888c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CISCCTRL(0, 0),		"CICOSCCTRL" },
5898c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CISCCTRL(1, 0),		"CIPRSCCTRL" },
5908c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CITAREA(0, 0),		"CICOTAREA" },
5918c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CITAREA(1, 0),		"CIPRTAREA" },
5928c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CISTATUS(0, 0),		"CICOSTATUS" },
5938c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CISTATUS(1, 0),		"CIPRSTATUS" },
5948c2ecf20Sopenharmony_ci		{ S3C_CAMIF_REG_CIIMGCPT(0),		"CIIMGCPT" },
5958c2ecf20Sopenharmony_ci	};
5968c2ecf20Sopenharmony_ci	u32 i;
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_ci	pr_info("--- %s ---\n", label);
5998c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(registers); i++) {
6008c2ecf20Sopenharmony_ci		u32 cfg = readl(camif->io_base + registers[i].offset);
6018c2ecf20Sopenharmony_ci		dev_info(camif->dev, "%s:\t0x%08x\n", registers[i].name, cfg);
6028c2ecf20Sopenharmony_ci	}
6038c2ecf20Sopenharmony_ci}
604