xref: /linux/drivers/media/platform/samsung/exynos4-is/fimc-is.h (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
1*238c84f7SMauro Carvalho Chehab /* SPDX-License-Identifier: GPL-2.0-only */
2*238c84f7SMauro Carvalho Chehab /*
3*238c84f7SMauro Carvalho Chehab  * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
4*238c84f7SMauro Carvalho Chehab  *
5*238c84f7SMauro Carvalho Chehab  * Copyright (C) 2013 Samsung Electronics Co., Ltd.
6*238c84f7SMauro Carvalho Chehab  *
7*238c84f7SMauro Carvalho Chehab  * Authors: Younghwan Joo <yhwan.joo@samsung.com>
8*238c84f7SMauro Carvalho Chehab  *          Sylwester Nawrocki <s.nawrocki@samsung.com>
9*238c84f7SMauro Carvalho Chehab  */
10*238c84f7SMauro Carvalho Chehab #ifndef FIMC_IS_H_
11*238c84f7SMauro Carvalho Chehab #define FIMC_IS_H_
12*238c84f7SMauro Carvalho Chehab 
13*238c84f7SMauro Carvalho Chehab #include <asm/barrier.h>
14*238c84f7SMauro Carvalho Chehab #include <linux/clk.h>
15*238c84f7SMauro Carvalho Chehab #include <linux/device.h>
16*238c84f7SMauro Carvalho Chehab #include <linux/kernel.h>
17*238c84f7SMauro Carvalho Chehab #include <linux/platform_device.h>
18*238c84f7SMauro Carvalho Chehab #include <linux/sizes.h>
19*238c84f7SMauro Carvalho Chehab #include <linux/spinlock.h>
20*238c84f7SMauro Carvalho Chehab #include <linux/types.h>
21*238c84f7SMauro Carvalho Chehab #include <media/videobuf2-v4l2.h>
22*238c84f7SMauro Carvalho Chehab #include <media/v4l2-ctrls.h>
23*238c84f7SMauro Carvalho Chehab 
24*238c84f7SMauro Carvalho Chehab #include "fimc-isp.h"
25*238c84f7SMauro Carvalho Chehab #include "fimc-is-command.h"
26*238c84f7SMauro Carvalho Chehab #include "fimc-is-sensor.h"
27*238c84f7SMauro Carvalho Chehab #include "fimc-is-param.h"
28*238c84f7SMauro Carvalho Chehab #include "fimc-is-regs.h"
29*238c84f7SMauro Carvalho Chehab 
30*238c84f7SMauro Carvalho Chehab #define FIMC_IS_DRV_NAME		"exynos4-fimc-is"
31*238c84f7SMauro Carvalho Chehab 
32*238c84f7SMauro Carvalho Chehab #define FIMC_IS_FW_FILENAME		"exynos4_fimc_is_fw.bin"
33*238c84f7SMauro Carvalho Chehab #define FIMC_IS_SETFILE_6A3		"exynos4_s5k6a3_setfile.bin"
34*238c84f7SMauro Carvalho Chehab 
35*238c84f7SMauro Carvalho Chehab #define FIMC_IS_FW_LOAD_TIMEOUT		1000 /* ms */
36*238c84f7SMauro Carvalho Chehab #define FIMC_IS_POWER_ON_TIMEOUT	1000 /* us */
37*238c84f7SMauro Carvalho Chehab 
38*238c84f7SMauro Carvalho Chehab #define FIMC_IS_SENSORS_NUM		2
39*238c84f7SMauro Carvalho Chehab 
40*238c84f7SMauro Carvalho Chehab /* Memory definitions */
41*238c84f7SMauro Carvalho Chehab #define FIMC_IS_CPU_MEM_SIZE		(0xa00000)
42*238c84f7SMauro Carvalho Chehab #define FIMC_IS_CPU_BASE_MASK		((1 << 26) - 1)
43*238c84f7SMauro Carvalho Chehab #define FIMC_IS_REGION_SIZE		0x5000
44*238c84f7SMauro Carvalho Chehab 
45*238c84f7SMauro Carvalho Chehab #define FIMC_IS_DEBUG_REGION_OFFSET	0x0084b000
46*238c84f7SMauro Carvalho Chehab #define FIMC_IS_SHARED_REGION_OFFSET	0x008c0000
47*238c84f7SMauro Carvalho Chehab #define FIMC_IS_FW_INFO_LEN		31
48*238c84f7SMauro Carvalho Chehab #define FIMC_IS_FW_VER_LEN		7
49*238c84f7SMauro Carvalho Chehab #define FIMC_IS_FW_DESC_LEN		(FIMC_IS_FW_INFO_LEN + \
50*238c84f7SMauro Carvalho Chehab 					 FIMC_IS_FW_VER_LEN)
51*238c84f7SMauro Carvalho Chehab #define FIMC_IS_SETFILE_INFO_LEN	39
52*238c84f7SMauro Carvalho Chehab 
53*238c84f7SMauro Carvalho Chehab #define FIMC_IS_EXTRA_MEM_SIZE		(FIMC_IS_EXTRA_FW_SIZE + \
54*238c84f7SMauro Carvalho Chehab 					 FIMC_IS_EXTRA_SETFILE_SIZE + 0x1000)
55*238c84f7SMauro Carvalho Chehab #define FIMC_IS_EXTRA_FW_SIZE		0x180000
56*238c84f7SMauro Carvalho Chehab #define FIMC_IS_EXTRA_SETFILE_SIZE	0x4b000
57*238c84f7SMauro Carvalho Chehab 
58*238c84f7SMauro Carvalho Chehab /* TODO: revisit */
59*238c84f7SMauro Carvalho Chehab #define FIMC_IS_FW_ADDR_MASK		((1 << 26) - 1)
60*238c84f7SMauro Carvalho Chehab #define FIMC_IS_FW_SIZE_MAX		(SZ_4M)
61*238c84f7SMauro Carvalho Chehab #define FIMC_IS_FW_SIZE_MIN		(SZ_32K)
62*238c84f7SMauro Carvalho Chehab 
63*238c84f7SMauro Carvalho Chehab #define ATCLK_MCUISP_FREQUENCY		100000000UL
64*238c84f7SMauro Carvalho Chehab #define ACLK_AXI_FREQUENCY		100000000UL
65*238c84f7SMauro Carvalho Chehab 
66*238c84f7SMauro Carvalho Chehab enum {
67*238c84f7SMauro Carvalho Chehab 	ISS_CLK_PPMUISPX,
68*238c84f7SMauro Carvalho Chehab 	ISS_CLK_PPMUISPMX,
69*238c84f7SMauro Carvalho Chehab 	ISS_CLK_LITE0,
70*238c84f7SMauro Carvalho Chehab 	ISS_CLK_LITE1,
71*238c84f7SMauro Carvalho Chehab 	ISS_CLK_MPLL,
72*238c84f7SMauro Carvalho Chehab 	ISS_CLK_ISP,
73*238c84f7SMauro Carvalho Chehab 	ISS_CLK_DRC,
74*238c84f7SMauro Carvalho Chehab 	ISS_CLK_FD,
75*238c84f7SMauro Carvalho Chehab 	ISS_CLK_MCUISP,
76*238c84f7SMauro Carvalho Chehab 	ISS_CLK_GICISP,
77*238c84f7SMauro Carvalho Chehab 	ISS_CLK_PWM_ISP,
78*238c84f7SMauro Carvalho Chehab 	ISS_CLK_MCUCTL_ISP,
79*238c84f7SMauro Carvalho Chehab 	ISS_CLK_UART,
80*238c84f7SMauro Carvalho Chehab 	ISS_GATE_CLKS_MAX,
81*238c84f7SMauro Carvalho Chehab 	ISS_CLK_ISP_DIV0 = ISS_GATE_CLKS_MAX,
82*238c84f7SMauro Carvalho Chehab 	ISS_CLK_ISP_DIV1,
83*238c84f7SMauro Carvalho Chehab 	ISS_CLK_MCUISP_DIV0,
84*238c84f7SMauro Carvalho Chehab 	ISS_CLK_MCUISP_DIV1,
85*238c84f7SMauro Carvalho Chehab 	ISS_CLK_ACLK200,
86*238c84f7SMauro Carvalho Chehab 	ISS_CLK_ACLK200_DIV,
87*238c84f7SMauro Carvalho Chehab 	ISS_CLK_ACLK400MCUISP,
88*238c84f7SMauro Carvalho Chehab 	ISS_CLK_ACLK400MCUISP_DIV,
89*238c84f7SMauro Carvalho Chehab 	ISS_CLKS_MAX
90*238c84f7SMauro Carvalho Chehab };
91*238c84f7SMauro Carvalho Chehab 
92*238c84f7SMauro Carvalho Chehab /* The driver's internal state flags */
93*238c84f7SMauro Carvalho Chehab enum {
94*238c84f7SMauro Carvalho Chehab 	IS_ST_IDLE,
95*238c84f7SMauro Carvalho Chehab 	IS_ST_PWR_ON,
96*238c84f7SMauro Carvalho Chehab 	IS_ST_A5_PWR_ON,
97*238c84f7SMauro Carvalho Chehab 	IS_ST_FW_LOADED,
98*238c84f7SMauro Carvalho Chehab 	IS_ST_OPEN_SENSOR,
99*238c84f7SMauro Carvalho Chehab 	IS_ST_SETFILE_LOADED,
100*238c84f7SMauro Carvalho Chehab 	IS_ST_INIT_DONE,
101*238c84f7SMauro Carvalho Chehab 	IS_ST_STREAM_ON,
102*238c84f7SMauro Carvalho Chehab 	IS_ST_STREAM_OFF,
103*238c84f7SMauro Carvalho Chehab 	IS_ST_CHANGE_MODE,
104*238c84f7SMauro Carvalho Chehab 	IS_ST_BLOCK_CMD_CLEARED,
105*238c84f7SMauro Carvalho Chehab 	IS_ST_SET_ZOOM,
106*238c84f7SMauro Carvalho Chehab 	IS_ST_PWR_SUBIP_ON,
107*238c84f7SMauro Carvalho Chehab 	IS_ST_END,
108*238c84f7SMauro Carvalho Chehab };
109*238c84f7SMauro Carvalho Chehab 
110*238c84f7SMauro Carvalho Chehab enum af_state {
111*238c84f7SMauro Carvalho Chehab 	FIMC_IS_AF_IDLE		= 0,
112*238c84f7SMauro Carvalho Chehab 	FIMC_IS_AF_SETCONFIG	= 1,
113*238c84f7SMauro Carvalho Chehab 	FIMC_IS_AF_RUNNING	= 2,
114*238c84f7SMauro Carvalho Chehab 	FIMC_IS_AF_LOCK		= 3,
115*238c84f7SMauro Carvalho Chehab 	FIMC_IS_AF_ABORT	= 4,
116*238c84f7SMauro Carvalho Chehab 	FIMC_IS_AF_FAILED	= 5,
117*238c84f7SMauro Carvalho Chehab };
118*238c84f7SMauro Carvalho Chehab 
119*238c84f7SMauro Carvalho Chehab enum af_lock_state {
120*238c84f7SMauro Carvalho Chehab 	FIMC_IS_AF_UNLOCKED	= 0,
121*238c84f7SMauro Carvalho Chehab 	FIMC_IS_AF_LOCKED	= 2
122*238c84f7SMauro Carvalho Chehab };
123*238c84f7SMauro Carvalho Chehab 
124*238c84f7SMauro Carvalho Chehab enum ae_lock_state {
125*238c84f7SMauro Carvalho Chehab 	FIMC_IS_AE_UNLOCKED	= 0,
126*238c84f7SMauro Carvalho Chehab 	FIMC_IS_AE_LOCKED	= 1
127*238c84f7SMauro Carvalho Chehab };
128*238c84f7SMauro Carvalho Chehab 
129*238c84f7SMauro Carvalho Chehab enum awb_lock_state {
130*238c84f7SMauro Carvalho Chehab 	FIMC_IS_AWB_UNLOCKED	= 0,
131*238c84f7SMauro Carvalho Chehab 	FIMC_IS_AWB_LOCKED	= 1
132*238c84f7SMauro Carvalho Chehab };
133*238c84f7SMauro Carvalho Chehab 
134*238c84f7SMauro Carvalho Chehab enum {
135*238c84f7SMauro Carvalho Chehab 	IS_METERING_CONFIG_CMD,
136*238c84f7SMauro Carvalho Chehab 	IS_METERING_CONFIG_WIN_POS_X,
137*238c84f7SMauro Carvalho Chehab 	IS_METERING_CONFIG_WIN_POS_Y,
138*238c84f7SMauro Carvalho Chehab 	IS_METERING_CONFIG_WIN_WIDTH,
139*238c84f7SMauro Carvalho Chehab 	IS_METERING_CONFIG_WIN_HEIGHT,
140*238c84f7SMauro Carvalho Chehab 	IS_METERING_CONFIG_MAX
141*238c84f7SMauro Carvalho Chehab };
142*238c84f7SMauro Carvalho Chehab 
143*238c84f7SMauro Carvalho Chehab struct is_setfile {
144*238c84f7SMauro Carvalho Chehab 	const struct firmware *info;
145*238c84f7SMauro Carvalho Chehab 	int state;
146*238c84f7SMauro Carvalho Chehab 	u32 sub_index;
147*238c84f7SMauro Carvalho Chehab 	u32 base;
148*238c84f7SMauro Carvalho Chehab 	size_t size;
149*238c84f7SMauro Carvalho Chehab };
150*238c84f7SMauro Carvalho Chehab 
151*238c84f7SMauro Carvalho Chehab struct is_fd_result_header {
152*238c84f7SMauro Carvalho Chehab 	u32 offset;
153*238c84f7SMauro Carvalho Chehab 	u32 count;
154*238c84f7SMauro Carvalho Chehab 	u32 index;
155*238c84f7SMauro Carvalho Chehab 	u32 curr_index;
156*238c84f7SMauro Carvalho Chehab 	u32 width;
157*238c84f7SMauro Carvalho Chehab 	u32 height;
158*238c84f7SMauro Carvalho Chehab };
159*238c84f7SMauro Carvalho Chehab 
160*238c84f7SMauro Carvalho Chehab struct is_af_info {
161*238c84f7SMauro Carvalho Chehab 	u16 mode;
162*238c84f7SMauro Carvalho Chehab 	u32 af_state;
163*238c84f7SMauro Carvalho Chehab 	u32 af_lock_state;
164*238c84f7SMauro Carvalho Chehab 	u32 ae_lock_state;
165*238c84f7SMauro Carvalho Chehab 	u32 awb_lock_state;
166*238c84f7SMauro Carvalho Chehab 	u16 pos_x;
167*238c84f7SMauro Carvalho Chehab 	u16 pos_y;
168*238c84f7SMauro Carvalho Chehab 	u16 prev_pos_x;
169*238c84f7SMauro Carvalho Chehab 	u16 prev_pos_y;
170*238c84f7SMauro Carvalho Chehab 	u16 use_af;
171*238c84f7SMauro Carvalho Chehab };
172*238c84f7SMauro Carvalho Chehab 
173*238c84f7SMauro Carvalho Chehab struct fimc_is_firmware {
174*238c84f7SMauro Carvalho Chehab 	const struct firmware *f_w;
175*238c84f7SMauro Carvalho Chehab 
176*238c84f7SMauro Carvalho Chehab 	dma_addr_t addr;
177*238c84f7SMauro Carvalho Chehab 	void *vaddr;
178*238c84f7SMauro Carvalho Chehab 	unsigned int size;
179*238c84f7SMauro Carvalho Chehab 
180*238c84f7SMauro Carvalho Chehab 	char info[FIMC_IS_FW_INFO_LEN + 1];
181*238c84f7SMauro Carvalho Chehab 	char version[FIMC_IS_FW_VER_LEN + 1];
182*238c84f7SMauro Carvalho Chehab 	char setfile_info[FIMC_IS_SETFILE_INFO_LEN + 1];
183*238c84f7SMauro Carvalho Chehab 	u8 state;
184*238c84f7SMauro Carvalho Chehab };
185*238c84f7SMauro Carvalho Chehab 
186*238c84f7SMauro Carvalho Chehab struct fimc_is_memory {
187*238c84f7SMauro Carvalho Chehab 	/* DMA base address */
188*238c84f7SMauro Carvalho Chehab 	dma_addr_t addr;
189*238c84f7SMauro Carvalho Chehab 	/* virtual base address */
190*238c84f7SMauro Carvalho Chehab 	void *vaddr;
191*238c84f7SMauro Carvalho Chehab 	/* total length */
192*238c84f7SMauro Carvalho Chehab 	unsigned int size;
193*238c84f7SMauro Carvalho Chehab };
194*238c84f7SMauro Carvalho Chehab 
195*238c84f7SMauro Carvalho Chehab #define FIMC_IS_I2H_MAX_ARGS	12
196*238c84f7SMauro Carvalho Chehab 
197*238c84f7SMauro Carvalho Chehab struct i2h_cmd {
198*238c84f7SMauro Carvalho Chehab 	u32 cmd;
199*238c84f7SMauro Carvalho Chehab 	u32 sensor_id;
200*238c84f7SMauro Carvalho Chehab 	u16 num_args;
201*238c84f7SMauro Carvalho Chehab 	u32 args[FIMC_IS_I2H_MAX_ARGS];
202*238c84f7SMauro Carvalho Chehab };
203*238c84f7SMauro Carvalho Chehab 
204*238c84f7SMauro Carvalho Chehab struct h2i_cmd {
205*238c84f7SMauro Carvalho Chehab 	u16 cmd_type;
206*238c84f7SMauro Carvalho Chehab 	u32 entry_id;
207*238c84f7SMauro Carvalho Chehab };
208*238c84f7SMauro Carvalho Chehab 
209*238c84f7SMauro Carvalho Chehab #define FIMC_IS_DEBUG_MSG	0x3f
210*238c84f7SMauro Carvalho Chehab #define FIMC_IS_DEBUG_LEVEL	3
211*238c84f7SMauro Carvalho Chehab 
212*238c84f7SMauro Carvalho Chehab struct fimc_is_setfile {
213*238c84f7SMauro Carvalho Chehab 	const struct firmware *info;
214*238c84f7SMauro Carvalho Chehab 	unsigned int state;
215*238c84f7SMauro Carvalho Chehab 	unsigned int size;
216*238c84f7SMauro Carvalho Chehab 	u32 sub_index;
217*238c84f7SMauro Carvalho Chehab 	u32 base;
218*238c84f7SMauro Carvalho Chehab };
219*238c84f7SMauro Carvalho Chehab 
220*238c84f7SMauro Carvalho Chehab struct chain_config {
221*238c84f7SMauro Carvalho Chehab 	struct global_param	global;
222*238c84f7SMauro Carvalho Chehab 	struct sensor_param	sensor;
223*238c84f7SMauro Carvalho Chehab 	struct isp_param	isp;
224*238c84f7SMauro Carvalho Chehab 	struct drc_param	drc;
225*238c84f7SMauro Carvalho Chehab 	struct fd_param		fd;
226*238c84f7SMauro Carvalho Chehab 
227*238c84f7SMauro Carvalho Chehab 	unsigned long		p_region_index[2];
228*238c84f7SMauro Carvalho Chehab };
229*238c84f7SMauro Carvalho Chehab 
230*238c84f7SMauro Carvalho Chehab /**
231*238c84f7SMauro Carvalho Chehab  * struct fimc_is - fimc-is data structure
232*238c84f7SMauro Carvalho Chehab  * @pdev: pointer to FIMC-IS platform device
233*238c84f7SMauro Carvalho Chehab  * @v4l2_dev: pointer to the top level v4l2_device
234*238c84f7SMauro Carvalho Chehab  * @fw: data structure describing the FIMC-IS firmware binary
235*238c84f7SMauro Carvalho Chehab  * @memory: memory region assigned for the FIMC-IS (firmware)
236*238c84f7SMauro Carvalho Chehab  * @isp: the ISP block data structure
237*238c84f7SMauro Carvalho Chehab  * @sensor: fimc-is sensor subdevice array
238*238c84f7SMauro Carvalho Chehab  * @setfile: descriptor of the imaging pipeline calibration data
239*238c84f7SMauro Carvalho Chehab  * @ctrl_handler: the v4l2 controls handler
240*238c84f7SMauro Carvalho Chehab  * @lock: mutex serializing video device and the subdev operations
241*238c84f7SMauro Carvalho Chehab  * @slock: spinlock protecting this data structure and the hw registers
242*238c84f7SMauro Carvalho Chehab  * @clocks: FIMC-LITE gate clock
243*238c84f7SMauro Carvalho Chehab  * @regs: MCUCTL mmapped registers region
244*238c84f7SMauro Carvalho Chehab  * @pmu_regs: PMU ISP mmapped registers region
245*238c84f7SMauro Carvalho Chehab  * @irq: FIMC-IS interrupt
246*238c84f7SMauro Carvalho Chehab  * @irq_queue: interrupt handling waitqueue
247*238c84f7SMauro Carvalho Chehab  * @lpm: low power mode flag
248*238c84f7SMauro Carvalho Chehab  * @state: internal driver's state flags
249*238c84f7SMauro Carvalho Chehab  * @sensor_index: image sensor index for the firmware
250*238c84f7SMauro Carvalho Chehab  * @i2h_cmd: FIMC-IS to the host (CPU) mailbox command data structure
251*238c84f7SMauro Carvalho Chehab  * @h2i_cmd: the host (CPU) to FIMC-IS mailbox command data structure
252*238c84f7SMauro Carvalho Chehab  * @fd_header: the face detection result data structure
253*238c84f7SMauro Carvalho Chehab  * @config: shared HW pipeline configuration data
254*238c84f7SMauro Carvalho Chehab  * @config_index: index to the @config entry currently in use
255*238c84f7SMauro Carvalho Chehab  * @is_p_region: pointer to the shared parameter memory region
256*238c84f7SMauro Carvalho Chehab  * @is_dma_p_region: DMA address of the shared parameter memory region
257*238c84f7SMauro Carvalho Chehab  * @is_shared_region: pointer to the IS shared region data structure
258*238c84f7SMauro Carvalho Chehab  * @af: auto focus data
259*238c84f7SMauro Carvalho Chehab  * @debugfs_entry: debugfs entry for the firmware log
260*238c84f7SMauro Carvalho Chehab  */
261*238c84f7SMauro Carvalho Chehab struct fimc_is {
262*238c84f7SMauro Carvalho Chehab 	struct platform_device		*pdev;
263*238c84f7SMauro Carvalho Chehab 	struct v4l2_device		*v4l2_dev;
264*238c84f7SMauro Carvalho Chehab 
265*238c84f7SMauro Carvalho Chehab 	struct fimc_is_firmware		fw;
266*238c84f7SMauro Carvalho Chehab 	struct fimc_is_memory		memory;
267*238c84f7SMauro Carvalho Chehab 
268*238c84f7SMauro Carvalho Chehab 	struct fimc_isp			isp;
269*238c84f7SMauro Carvalho Chehab 	struct fimc_is_sensor		sensor[FIMC_IS_SENSORS_NUM];
270*238c84f7SMauro Carvalho Chehab 	struct fimc_is_setfile		setfile;
271*238c84f7SMauro Carvalho Chehab 
272*238c84f7SMauro Carvalho Chehab 	struct v4l2_ctrl_handler	ctrl_handler;
273*238c84f7SMauro Carvalho Chehab 
274*238c84f7SMauro Carvalho Chehab 	struct mutex			lock;
275*238c84f7SMauro Carvalho Chehab 	spinlock_t			slock;
276*238c84f7SMauro Carvalho Chehab 
277*238c84f7SMauro Carvalho Chehab 	struct clk			*clocks[ISS_CLKS_MAX];
278*238c84f7SMauro Carvalho Chehab 	void __iomem			*regs;
279*238c84f7SMauro Carvalho Chehab 	void __iomem			*pmu_regs;
280*238c84f7SMauro Carvalho Chehab 	int				irq;
281*238c84f7SMauro Carvalho Chehab 	wait_queue_head_t		irq_queue;
282*238c84f7SMauro Carvalho Chehab 	u8				lpm;
283*238c84f7SMauro Carvalho Chehab 
284*238c84f7SMauro Carvalho Chehab 	unsigned long			state;
285*238c84f7SMauro Carvalho Chehab 	unsigned int			sensor_index;
286*238c84f7SMauro Carvalho Chehab 
287*238c84f7SMauro Carvalho Chehab 	struct i2h_cmd			i2h_cmd;
288*238c84f7SMauro Carvalho Chehab 	struct h2i_cmd			h2i_cmd;
289*238c84f7SMauro Carvalho Chehab 	struct is_fd_result_header	fd_header;
290*238c84f7SMauro Carvalho Chehab 
291*238c84f7SMauro Carvalho Chehab 	struct chain_config		config[IS_SC_MAX];
292*238c84f7SMauro Carvalho Chehab 	unsigned			config_index;
293*238c84f7SMauro Carvalho Chehab 
294*238c84f7SMauro Carvalho Chehab 	struct is_region		*is_p_region;
295*238c84f7SMauro Carvalho Chehab 	dma_addr_t			is_dma_p_region;
296*238c84f7SMauro Carvalho Chehab 	struct is_share_region		*is_shared_region;
297*238c84f7SMauro Carvalho Chehab 	struct is_af_info		af;
298*238c84f7SMauro Carvalho Chehab 
299*238c84f7SMauro Carvalho Chehab 	struct dentry			*debugfs_entry;
300*238c84f7SMauro Carvalho Chehab };
301*238c84f7SMauro Carvalho Chehab 
fimc_isp_to_is(struct fimc_isp * isp)302*238c84f7SMauro Carvalho Chehab static inline struct fimc_is *fimc_isp_to_is(struct fimc_isp *isp)
303*238c84f7SMauro Carvalho Chehab {
304*238c84f7SMauro Carvalho Chehab 	return container_of(isp, struct fimc_is, isp);
305*238c84f7SMauro Carvalho Chehab }
306*238c84f7SMauro Carvalho Chehab 
__get_curr_is_config(struct fimc_is * is)307*238c84f7SMauro Carvalho Chehab static inline struct chain_config *__get_curr_is_config(struct fimc_is *is)
308*238c84f7SMauro Carvalho Chehab {
309*238c84f7SMauro Carvalho Chehab 	return &is->config[is->config_index];
310*238c84f7SMauro Carvalho Chehab }
311*238c84f7SMauro Carvalho Chehab 
fimc_is_mem_barrier(void)312*238c84f7SMauro Carvalho Chehab static inline void fimc_is_mem_barrier(void)
313*238c84f7SMauro Carvalho Chehab {
314*238c84f7SMauro Carvalho Chehab 	mb();
315*238c84f7SMauro Carvalho Chehab }
316*238c84f7SMauro Carvalho Chehab 
fimc_is_set_param_bit(struct fimc_is * is,int num)317*238c84f7SMauro Carvalho Chehab static inline void fimc_is_set_param_bit(struct fimc_is *is, int num)
318*238c84f7SMauro Carvalho Chehab {
319*238c84f7SMauro Carvalho Chehab 	struct chain_config *cfg = &is->config[is->config_index];
320*238c84f7SMauro Carvalho Chehab 
321*238c84f7SMauro Carvalho Chehab 	set_bit(num, &cfg->p_region_index[0]);
322*238c84f7SMauro Carvalho Chehab }
323*238c84f7SMauro Carvalho Chehab 
fimc_is_set_param_ctrl_cmd(struct fimc_is * is,int cmd)324*238c84f7SMauro Carvalho Chehab static inline void fimc_is_set_param_ctrl_cmd(struct fimc_is *is, int cmd)
325*238c84f7SMauro Carvalho Chehab {
326*238c84f7SMauro Carvalho Chehab 	is->is_p_region->parameter.isp.control.cmd = cmd;
327*238c84f7SMauro Carvalho Chehab }
328*238c84f7SMauro Carvalho Chehab 
mcuctl_write(u32 v,struct fimc_is * is,unsigned int offset)329*238c84f7SMauro Carvalho Chehab static inline void mcuctl_write(u32 v, struct fimc_is *is, unsigned int offset)
330*238c84f7SMauro Carvalho Chehab {
331*238c84f7SMauro Carvalho Chehab 	writel(v, is->regs + offset);
332*238c84f7SMauro Carvalho Chehab }
333*238c84f7SMauro Carvalho Chehab 
mcuctl_read(struct fimc_is * is,unsigned int offset)334*238c84f7SMauro Carvalho Chehab static inline u32 mcuctl_read(struct fimc_is *is, unsigned int offset)
335*238c84f7SMauro Carvalho Chehab {
336*238c84f7SMauro Carvalho Chehab 	return readl(is->regs + offset);
337*238c84f7SMauro Carvalho Chehab }
338*238c84f7SMauro Carvalho Chehab 
pmuisp_write(u32 v,struct fimc_is * is,unsigned int offset)339*238c84f7SMauro Carvalho Chehab static inline void pmuisp_write(u32 v, struct fimc_is *is, unsigned int offset)
340*238c84f7SMauro Carvalho Chehab {
341*238c84f7SMauro Carvalho Chehab 	writel(v, is->pmu_regs + offset);
342*238c84f7SMauro Carvalho Chehab }
343*238c84f7SMauro Carvalho Chehab 
pmuisp_read(struct fimc_is * is,unsigned int offset)344*238c84f7SMauro Carvalho Chehab static inline u32 pmuisp_read(struct fimc_is *is, unsigned int offset)
345*238c84f7SMauro Carvalho Chehab {
346*238c84f7SMauro Carvalho Chehab 	return readl(is->pmu_regs + offset);
347*238c84f7SMauro Carvalho Chehab }
348*238c84f7SMauro Carvalho Chehab 
349*238c84f7SMauro Carvalho Chehab int fimc_is_wait_event(struct fimc_is *is, unsigned long bit,
350*238c84f7SMauro Carvalho Chehab 		       unsigned int state, unsigned int timeout);
351*238c84f7SMauro Carvalho Chehab int fimc_is_cpu_set_power(struct fimc_is *is, int on);
352*238c84f7SMauro Carvalho Chehab int fimc_is_start_firmware(struct fimc_is *is);
353*238c84f7SMauro Carvalho Chehab int fimc_is_hw_initialize(struct fimc_is *is);
354*238c84f7SMauro Carvalho Chehab void fimc_is_log_dump(const char *level, const void *buf, size_t len);
355*238c84f7SMauro Carvalho Chehab 
356*238c84f7SMauro Carvalho Chehab #endif /* FIMC_IS_H_ */
357