xref: /openbmc/linux/drivers/media/platform/samsung/exynos4-is/fimc-reg.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1*238c84f7SMauro Carvalho Chehab /* SPDX-License-Identifier: GPL-2.0-only */
2*238c84f7SMauro Carvalho Chehab /*
3*238c84f7SMauro Carvalho Chehab  * Samsung camera host interface (FIMC) registers definition
4*238c84f7SMauro Carvalho Chehab  *
5*238c84f7SMauro Carvalho Chehab  * Copyright (C) 2010 - 2012 Samsung Electronics Co., Ltd.
6*238c84f7SMauro Carvalho Chehab  */
7*238c84f7SMauro Carvalho Chehab 
8*238c84f7SMauro Carvalho Chehab #ifndef FIMC_REG_H_
9*238c84f7SMauro Carvalho Chehab #define FIMC_REG_H_
10*238c84f7SMauro Carvalho Chehab 
11*238c84f7SMauro Carvalho Chehab #include <linux/bitops.h>
12*238c84f7SMauro Carvalho Chehab 
13*238c84f7SMauro Carvalho Chehab #include "fimc-core.h"
14*238c84f7SMauro Carvalho Chehab 
15*238c84f7SMauro Carvalho Chehab /* Input source format */
16*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISRCFMT			0x00
17*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISRCFMT_ITU601_8BIT		BIT(31)
18*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISRCFMT_ITU601_16BIT		BIT(29)
19*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISRCFMT_ORDER422_YCBYCR	(0 << 14)
20*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISRCFMT_ORDER422_YCRYCB	(1 << 14)
21*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISRCFMT_ORDER422_CBYCRY	(2 << 14)
22*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISRCFMT_ORDER422_CRYCBY	(3 << 14)
23*238c84f7SMauro Carvalho Chehab 
24*238c84f7SMauro Carvalho Chehab /* Window offset */
25*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIWDOFST			0x04
26*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIWDOFST_OFF_EN		BIT(31)
27*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIWDOFST_CLROVFIY		BIT(30)
28*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIWDOFST_CLROVRLB		BIT(29)
29*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIWDOFST_HOROFF_MASK		(0x7ff << 16)
30*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIWDOFST_CLROVFICB		BIT(15)
31*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIWDOFST_CLROVFICR		BIT(14)
32*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIWDOFST_VEROFF_MASK		(0xfff << 0)
33*238c84f7SMauro Carvalho Chehab 
34*238c84f7SMauro Carvalho Chehab /* Global control */
35*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL			0x08
36*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_SWRST			BIT(31)
37*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_CAMRST_A		BIT(30)
38*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_SELCAM_ITU_A		BIT(29)
39*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_TESTPAT_NORMAL		(0 << 27)
40*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_TESTPAT_COLOR_BAR	(1 << 27)
41*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_TESTPAT_HOR_INC	(2 << 27)
42*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_TESTPAT_VER_INC	(3 << 27)
43*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_TESTPAT_MASK		(3 << 27)
44*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_TESTPAT_SHIFT		27
45*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_INVPOLPCLK		BIT(26)
46*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_INVPOLVSYNC		BIT(25)
47*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_INVPOLHREF		BIT(24)
48*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_IRQ_OVFEN		BIT(22)
49*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_HREF_MASK		BIT(21)
50*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_IRQ_LEVEL		BIT(20)
51*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_IRQ_CLR		BIT(19)
52*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_IRQ_ENABLE		BIT(16)
53*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_SHDW_DISABLE		BIT(12)
54*238c84f7SMauro Carvalho Chehab /* 0 - selects Writeback A (LCD), 1 - selects Writeback B (LCD/ISP) */
55*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_SELWB_A		BIT(10)
56*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_CAM_JPEG		BIT(8)
57*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_SELCAM_MIPI_A		BIT(7)
58*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_CAMIF_SELWB		BIT(6)
59*238c84f7SMauro Carvalho Chehab /* 0 - ITU601; 1 - ITU709 */
60*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_CSC_ITU601_709		BIT(5)
61*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_INVPOLHSYNC		BIT(4)
62*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_SELCAM_MIPI		BIT(3)
63*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_INVPOLFIELD		BIT(1)
64*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIGCTRL_INTERLACE		BIT(0)
65*238c84f7SMauro Carvalho Chehab 
66*238c84f7SMauro Carvalho Chehab /* Window offset 2 */
67*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIWDOFST2			0x14
68*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIWDOFST2_HOROFF_MASK		(0xfff << 16)
69*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIWDOFST2_VEROFF_MASK		(0xfff << 0)
70*238c84f7SMauro Carvalho Chehab 
71*238c84f7SMauro Carvalho Chehab /* Output DMA Y/Cb/Cr plane start addresses */
72*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOYSA(n)			(0x18 + (n) * 4)
73*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCBSA(n)			(0x28 + (n) * 4)
74*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCRSA(n)			(0x38 + (n) * 4)
75*238c84f7SMauro Carvalho Chehab 
76*238c84f7SMauro Carvalho Chehab /* Target image format */
77*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT			0x48
78*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_INROT90		BIT(31)
79*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_YCBCR420		(0 << 29)
80*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_YCBCR422		(1 << 29)
81*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_YCBCR422_1P		(2 << 29)
82*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_RGB			(3 << 29)
83*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_FMT_MASK		(3 << 29)
84*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_HSIZE_MASK		(0xfff << 16)
85*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_FLIP_SHIFT		14
86*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_FLIP_NORMAL		(0 << 14)
87*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_FLIP_X_MIRROR		(1 << 14)
88*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_FLIP_Y_MIRROR		(2 << 14)
89*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_FLIP_180		(3 << 14)
90*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_FLIP_MASK		(3 << 14)
91*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_OUTROT90		BIT(13)
92*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITRGFMT_VSIZE_MASK		(0xfff << 0)
93*238c84f7SMauro Carvalho Chehab 
94*238c84f7SMauro Carvalho Chehab /* Output DMA control */
95*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL			0x4c
96*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_ORDER422_MASK		(3 << 0)
97*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_ORDER422_YCBYCR	(0 << 0)
98*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_ORDER422_YCRYCB	(1 << 0)
99*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_ORDER422_CBYCRY	(2 << 0)
100*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_ORDER422_CRYCBY	(3 << 0)
101*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_LASTIRQ_ENABLE		BIT(2)
102*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_YCBCR_3PLANE		(0 << 3)
103*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_YCBCR_2PLANE		(1 << 3)
104*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_YCBCR_PLANE_MASK	(1 << 3)
105*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_ALPHA_OUT_MASK		(0xff << 4)
106*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_RGB16FMT_MASK		(3 << 16)
107*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_RGB565			(0 << 16)
108*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_ARGB1555		(1 << 16)
109*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_ARGB4444		(2 << 16)
110*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_ORDER2P_SHIFT		24
111*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_ORDER2P_MASK		(3 << 24)
112*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCTRL_ORDER422_2P_LSB_CRCB	(0 << 24)
113*238c84f7SMauro Carvalho Chehab 
114*238c84f7SMauro Carvalho Chehab /* Pre-scaler control 1 */
115*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCPRERATIO			0x50
116*238c84f7SMauro Carvalho Chehab 
117*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCPREDST			0x54
118*238c84f7SMauro Carvalho Chehab 
119*238c84f7SMauro Carvalho Chehab /* Main scaler control */
120*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL			0x58
121*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_SCALERBYPASS		BIT(31)
122*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_SCALEUP_H		BIT(30)
123*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_SCALEUP_V		BIT(29)
124*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_CSCR2Y_WIDE		BIT(28)
125*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_CSCY2R_WIDE		BIT(27)
126*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_LCDPATHEN_FIFO	BIT(26)
127*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_INTERLACE		BIT(25)
128*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_SCALERSTART		BIT(15)
129*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_INRGB_FMT_RGB565	(0 << 13)
130*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_INRGB_FMT_RGB666	(1 << 13)
131*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_INRGB_FMT_RGB888	(2 << 13)
132*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_INRGB_FMT_MASK	(3 << 13)
133*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_OUTRGB_FMT_RGB565	(0 << 11)
134*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_OUTRGB_FMT_RGB666	(1 << 11)
135*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_OUTRGB_FMT_RGB888	(2 << 11)
136*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_OUTRGB_FMT_MASK	(3 << 11)
137*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_RGB_EXT		BIT(10)
138*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_ONE2ONE		BIT(9)
139*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_MHRATIO(x)		((x) << 16)
140*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_MVRATIO(x)		((x) << 0)
141*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_MHRATIO_MASK		(0x1ff << 16)
142*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_MVRATIO_MASK		(0x1ff << 0)
143*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_MHRATIO_EXT(x)	(((x) >> 6) << 16)
144*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISCCTRL_MVRATIO_EXT(x)	(((x) >> 6) << 0)
145*238c84f7SMauro Carvalho Chehab 
146*238c84f7SMauro Carvalho Chehab /* Target area */
147*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITAREA			0x5c
148*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CITAREA_MASK			0x0fffffff
149*238c84f7SMauro Carvalho Chehab 
150*238c84f7SMauro Carvalho Chehab /* General status */
151*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS			0x64
152*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_OVFIY			BIT(31)
153*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_OVFICB		BIT(30)
154*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_OVFICR		BIT(29)
155*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_VSYNC			BIT(28)
156*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_FRAMECNT_MASK		(3 << 26)
157*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_FRAMECNT_SHIFT	26
158*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_WINOFF_EN		BIT(25)
159*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_IMGCPT_EN		BIT(22)
160*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_IMGCPT_SCEN		BIT(21)
161*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_VSYNC_A		BIT(20)
162*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_VSYNC_B		BIT(19)
163*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_OVRLB			BIT(18)
164*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_FRAME_END		BIT(17)
165*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_LASTCAPT_END		BIT(16)
166*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_VVALID_A		BIT(15)
167*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS_VVALID_B		BIT(14)
168*238c84f7SMauro Carvalho Chehab 
169*238c84f7SMauro Carvalho Chehab /* Indexes to the last and the currently processed buffer. */
170*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CISTATUS2			0x68
171*238c84f7SMauro Carvalho Chehab 
172*238c84f7SMauro Carvalho Chehab /* Image capture control */
173*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGCPT			0xc0
174*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGCPT_IMGCPTEN		BIT(31)
175*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGCPT_IMGCPTEN_SC		BIT(30)
176*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGCPT_CPT_FREN_ENABLE	BIT(25)
177*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGCPT_CPT_FRMOD_CNT		BIT(18)
178*238c84f7SMauro Carvalho Chehab 
179*238c84f7SMauro Carvalho Chehab /* Frame capture sequence */
180*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CICPTSEQ			0xc4
181*238c84f7SMauro Carvalho Chehab 
182*238c84f7SMauro Carvalho Chehab /* Image effect */
183*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGEFF			0xd0
184*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGEFF_IE_ENABLE		BIT(30)
185*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGEFF_IE_SC_BEFORE		(0 << 29)
186*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGEFF_IE_SC_AFTER		(1 << 29)
187*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGEFF_FIN_BYPASS		(0 << 26)
188*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGEFF_FIN_ARBITRARY		(1 << 26)
189*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGEFF_FIN_NEGATIVE		(2 << 26)
190*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGEFF_FIN_ARTFREEZE		(3 << 26)
191*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGEFF_FIN_EMBOSSING		(4 << 26)
192*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGEFF_FIN_SILHOUETTE	(5 << 26)
193*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGEFF_FIN_MASK		(7 << 26)
194*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIMGEFF_PAT_CBCR_MASK		((0xff << 13) | 0xff)
195*238c84f7SMauro Carvalho Chehab 
196*238c84f7SMauro Carvalho Chehab /* Input DMA Y/Cb/Cr plane start address 0/1 */
197*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIYSA(n)			(0xd4 + (n) * 0x70)
198*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIICBSA(n)			(0xd8 + (n) * 0x70)
199*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIICRSA(n)			(0xdc + (n) * 0x70)
200*238c84f7SMauro Carvalho Chehab 
201*238c84f7SMauro Carvalho Chehab /* Real input DMA image size */
202*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIREAL_ISIZE			0xf8
203*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIREAL_ISIZE_AUTOLOAD_EN	BIT(31)
204*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIREAL_ISIZE_ADDR_CH_DIS	BIT(30)
205*238c84f7SMauro Carvalho Chehab 
206*238c84f7SMauro Carvalho Chehab /* Input DMA control */
207*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL				0xfc
208*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_IN_BURST_COUNT_MASK	(0xf << 24)
209*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_2P_IN_ORDER_MASK	(3 << 16)
210*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_2P_IN_ORDER_SHIFT	16
211*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_C_INT_IN_3PLANE		(0 << 15)
212*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_C_INT_IN_2PLANE		(1 << 15)
213*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_C_INT_IN_MASK		(1 << 15)
214*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_FLIP_SHIFT		13
215*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_FLIP_MASK		(3 << 13)
216*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_FLIP_NORMAL		(0 << 13)
217*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_FLIP_X_MIRROR		(1 << 13)
218*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_FLIP_Y_MIRROR		(2 << 13)
219*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_FLIP_180		(3 << 13)
220*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_FIFO_CTRL_FULL		BIT(12)
221*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_ORDER422_SHIFT		4
222*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_ORDER422_CRYCBY		(0 << 4)
223*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_ORDER422_YCRYCB		(1 << 4)
224*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_ORDER422_CBYCRY		(2 << 4)
225*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_ORDER422_YCBYCR		(3 << 4)
226*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_ORDER422_MASK		(3 << 4)
227*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_INPUT_EXTCAM		(0 << 3)
228*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_INPUT_MEMORY		BIT(3)
229*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_INPUT_MASK		BIT(3)
230*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_INFORMAT_YCBCR420	(0 << 1)
231*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_INFORMAT_YCBCR422	(1 << 1)
232*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_INFORMAT_YCBCR422_1P	(2 << 1)
233*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_INFORMAT_RGB		(3 << 1)
234*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_INFORMAT_MASK		(3 << 1)
235*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_ENVID			BIT(0)
236*238c84f7SMauro Carvalho Chehab #define FIMC_REG_MSCTRL_IN_BURST_COUNT(x)	((x) << 24)
237*238c84f7SMauro Carvalho Chehab 
238*238c84f7SMauro Carvalho Chehab /* Output DMA Y/Cb/Cr offset */
239*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOYOFF			0x168
240*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCBOFF			0x16c
241*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIOCROFF			0x170
242*238c84f7SMauro Carvalho Chehab 
243*238c84f7SMauro Carvalho Chehab /* Input DMA Y/Cb/Cr offset */
244*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIIYOFF			0x174
245*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIICBOFF			0x178
246*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIICROFF			0x17c
247*238c84f7SMauro Carvalho Chehab 
248*238c84f7SMauro Carvalho Chehab /* Input DMA original image size */
249*238c84f7SMauro Carvalho Chehab #define FIMC_REG_ORGISIZE			0x180
250*238c84f7SMauro Carvalho Chehab 
251*238c84f7SMauro Carvalho Chehab /* Output DMA original image size */
252*238c84f7SMauro Carvalho Chehab #define FIMC_REG_ORGOSIZE			0x184
253*238c84f7SMauro Carvalho Chehab 
254*238c84f7SMauro Carvalho Chehab /* Real output DMA image size (extension register) */
255*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIEXTEN			0x188
256*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIEXTEN_MHRATIO_EXT(x)		(((x) & 0x3f) << 10)
257*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIEXTEN_MVRATIO_EXT(x)		((x) & 0x3f)
258*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIEXTEN_MHRATIO_EXT_MASK	(0x3f << 10)
259*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIEXTEN_MVRATIO_EXT_MASK	0x3f
260*238c84f7SMauro Carvalho Chehab 
261*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIDMAPARAM			0x18c
262*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIDMAPARAM_R_LINEAR		(0 << 29)
263*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIDMAPARAM_R_64X32		(3 << 29)
264*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIDMAPARAM_W_LINEAR		(0 << 13)
265*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIDMAPARAM_W_64X32		(3 << 13)
266*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIDMAPARAM_TILE_MASK		((3 << 29) | (3 << 13))
267*238c84f7SMauro Carvalho Chehab 
268*238c84f7SMauro Carvalho Chehab /* MIPI CSI image format */
269*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CSIIMGFMT			0x194
270*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CSIIMGFMT_YCBCR422_8BIT	0x1e
271*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CSIIMGFMT_RAW8			0x2a
272*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CSIIMGFMT_RAW10		0x2b
273*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CSIIMGFMT_RAW12		0x2c
274*238c84f7SMauro Carvalho Chehab /* User defined formats. x = 0...16. */
275*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CSIIMGFMT_USER(x)		(0x30 + x - 1)
276*238c84f7SMauro Carvalho Chehab 
277*238c84f7SMauro Carvalho Chehab /* Output frame buffer sequence mask */
278*238c84f7SMauro Carvalho Chehab #define FIMC_REG_CIFCNTSEQ			0x1fc
279*238c84f7SMauro Carvalho Chehab 
280*238c84f7SMauro Carvalho Chehab /* SYSREG ISP Writeback register address offsets */
281*238c84f7SMauro Carvalho Chehab #define SYSREG_ISPBLK				0x020c
282*238c84f7SMauro Carvalho Chehab #define SYSREG_ISPBLK_FIFORST_CAM_BLK		BIT(7)
283*238c84f7SMauro Carvalho Chehab 
284*238c84f7SMauro Carvalho Chehab #define SYSREG_CAMBLK				0x0218
285*238c84f7SMauro Carvalho Chehab #define SYSREG_CAMBLK_FIFORST_ISP		BIT(15)
286*238c84f7SMauro Carvalho Chehab #define SYSREG_CAMBLK_ISPWB_FULL_EN		(7 << 20)
287*238c84f7SMauro Carvalho Chehab 
288*238c84f7SMauro Carvalho Chehab /*
289*238c84f7SMauro Carvalho Chehab  * Function declarations
290*238c84f7SMauro Carvalho Chehab  */
291*238c84f7SMauro Carvalho Chehab void fimc_hw_reset(struct fimc_dev *fimc);
292*238c84f7SMauro Carvalho Chehab void fimc_hw_set_rotation(struct fimc_ctx *ctx);
293*238c84f7SMauro Carvalho Chehab void fimc_hw_set_target_format(struct fimc_ctx *ctx);
294*238c84f7SMauro Carvalho Chehab void fimc_hw_set_out_dma(struct fimc_ctx *ctx);
295*238c84f7SMauro Carvalho Chehab void fimc_hw_en_lastirq(struct fimc_dev *fimc, int enable);
296*238c84f7SMauro Carvalho Chehab void fimc_hw_en_irq(struct fimc_dev *fimc, int enable);
297*238c84f7SMauro Carvalho Chehab void fimc_hw_set_prescaler(struct fimc_ctx *ctx);
298*238c84f7SMauro Carvalho Chehab void fimc_hw_set_mainscaler(struct fimc_ctx *ctx);
299*238c84f7SMauro Carvalho Chehab void fimc_hw_enable_capture(struct fimc_ctx *ctx);
300*238c84f7SMauro Carvalho Chehab void fimc_hw_set_effect(struct fimc_ctx *ctx);
301*238c84f7SMauro Carvalho Chehab void fimc_hw_set_rgb_alpha(struct fimc_ctx *ctx);
302*238c84f7SMauro Carvalho Chehab void fimc_hw_set_in_dma(struct fimc_ctx *ctx);
303*238c84f7SMauro Carvalho Chehab void fimc_hw_set_input_path(struct fimc_ctx *ctx);
304*238c84f7SMauro Carvalho Chehab void fimc_hw_set_output_path(struct fimc_ctx *ctx);
305*238c84f7SMauro Carvalho Chehab void fimc_hw_set_input_addr(struct fimc_dev *fimc, struct fimc_addr *addr);
306*238c84f7SMauro Carvalho Chehab void fimc_hw_set_output_addr(struct fimc_dev *fimc, struct fimc_addr *addr,
307*238c84f7SMauro Carvalho Chehab 			     int index);
308*238c84f7SMauro Carvalho Chehab int fimc_hw_set_camera_source(struct fimc_dev *fimc,
309*238c84f7SMauro Carvalho Chehab 			      struct fimc_source_info *cam);
310*238c84f7SMauro Carvalho Chehab void fimc_hw_set_camera_offset(struct fimc_dev *fimc, struct fimc_frame *f);
311*238c84f7SMauro Carvalho Chehab int fimc_hw_set_camera_polarity(struct fimc_dev *fimc,
312*238c84f7SMauro Carvalho Chehab 				struct fimc_source_info *cam);
313*238c84f7SMauro Carvalho Chehab int fimc_hw_set_camera_type(struct fimc_dev *fimc,
314*238c84f7SMauro Carvalho Chehab 			    struct fimc_source_info *cam);
315*238c84f7SMauro Carvalho Chehab void fimc_hw_clear_irq(struct fimc_dev *dev);
316*238c84f7SMauro Carvalho Chehab void fimc_hw_enable_scaler(struct fimc_dev *dev, bool on);
317*238c84f7SMauro Carvalho Chehab void fimc_hw_activate_input_dma(struct fimc_dev *dev, bool on);
318*238c84f7SMauro Carvalho Chehab void fimc_hw_disable_capture(struct fimc_dev *dev);
319*238c84f7SMauro Carvalho Chehab s32 fimc_hw_get_frame_index(struct fimc_dev *dev);
320*238c84f7SMauro Carvalho Chehab s32 fimc_hw_get_prev_frame_index(struct fimc_dev *dev);
321*238c84f7SMauro Carvalho Chehab int fimc_hw_camblk_cfg_writeback(struct fimc_dev *fimc);
322*238c84f7SMauro Carvalho Chehab void fimc_activate_capture(struct fimc_ctx *ctx);
323*238c84f7SMauro Carvalho Chehab void fimc_deactivate_capture(struct fimc_dev *fimc);
324*238c84f7SMauro Carvalho Chehab 
325*238c84f7SMauro Carvalho Chehab /**
326*238c84f7SMauro Carvalho Chehab  * fimc_hw_set_dma_seq - configure output DMA buffer sequence
327*238c84f7SMauro Carvalho Chehab  * @dev: fimc device
328*238c84f7SMauro Carvalho Chehab  * @mask: bitmask for the DMA output buffer registers, set to 0 to skip buffer
329*238c84f7SMauro Carvalho Chehab  * This function masks output DMA ring buffers, it allows to select which of
330*238c84f7SMauro Carvalho Chehab  * the 32 available output buffer address registers will be used by the DMA
331*238c84f7SMauro Carvalho Chehab  * engine.
332*238c84f7SMauro Carvalho Chehab  */
fimc_hw_set_dma_seq(struct fimc_dev * dev,u32 mask)333*238c84f7SMauro Carvalho Chehab static inline void fimc_hw_set_dma_seq(struct fimc_dev *dev, u32 mask)
334*238c84f7SMauro Carvalho Chehab {
335*238c84f7SMauro Carvalho Chehab 	writel(mask, dev->regs + FIMC_REG_CIFCNTSEQ);
336*238c84f7SMauro Carvalho Chehab }
337*238c84f7SMauro Carvalho Chehab 
338*238c84f7SMauro Carvalho Chehab #endif /* FIMC_REG_H_ */
339