1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2015, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  */
14 
15 #ifndef __IBUF_CTRL_GLOBAL_H_INCLUDED__
16 #define __IBUF_CTRL_GLOBAL_H_INCLUDED__
17 
18 #include <type_support.h>
19 
20 #include <ibuf_cntrl_defs.h>	/* _IBUF_CNTRL_RECALC_WORDS_STATUS,
21 				 * _IBUF_CNTRL_ARBITERS_STATUS,
22 				 * _IBUF_CNTRL_PROC_REG_ALIGN,
23 				 * etc.
24 				 */
25 
26 /* Definition of contents of main controller state register is lacking
27  * in ibuf_cntrl_defs.h, so define these here:
28  */
29 #define _IBUF_CNTRL_MAIN_CNTRL_FSM_MASK			0xf
30 #define _IBUF_CNTRL_MAIN_CNTRL_FSM_NEXT_COMMAND_CHECK	0x9
31 #define _IBUF_CNTRL_MAIN_CNTRL_MEM_INP_BUF_ALLOC	BIT(8)
32 #define _IBUF_CNTRL_DMA_SYNC_WAIT_FOR_SYNC		1
33 #define _IBUF_CNTRL_DMA_SYNC_FSM_WAIT_FOR_ACK		(0x3 << 1)
34 
35 typedef struct ib_buffer_s	ib_buffer_t;
36 struct	ib_buffer_s {
37 	u32	start_addr;	/* start address of the buffer in the
38 					 * "input-buffer hardware block"
39 					 */
40 
41 	u32	stride;		/* stride per buffer line (in bytes) */
42 	u32	lines;		/* lines in the buffer */
43 };
44 
45 typedef struct ibuf_ctrl_cfg_s ibuf_ctrl_cfg_t;
46 struct ibuf_ctrl_cfg_s {
47 	bool online;
48 
49 	struct {
50 		/* DMA configuration */
51 		u32 channel;
52 		u32 cmd; /* must be _DMA_V2_MOVE_A2B_NO_SYNC_CHK_COMMAND */
53 
54 		/* DMA reconfiguration */
55 		u32 shift_returned_items;
56 		u32 elems_per_word_in_ibuf;
57 		u32 elems_per_word_in_dest;
58 	} dma_cfg;
59 
60 	ib_buffer_t ib_buffer;
61 
62 	struct {
63 		u32 stride;
64 		u32 start_addr;
65 		u32 lines;
66 	} dest_buf_cfg;
67 
68 	u32 items_per_store;
69 	u32 stores_per_frame;
70 
71 	struct {
72 		u32 sync_cmd;	/* must be _STREAM2MMIO_CMD_TOKEN_SYNC_FRAME */
73 		u32 store_cmd;	/* must be _STREAM2MMIO_CMD_TOKEN_STORE_PACKETS */
74 	} stream2mmio_cfg;
75 };
76 
77 extern const u32 N_IBUF_CTRL_PROCS[N_IBUF_CTRL_ID];
78 
79 #endif /* __IBUF_CTRL_GLOBAL_H_INCLUDED__ */
80